const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PostcardManager-6m0AWMVD.js","assets/usePostcardZones-CUk6lEz3.js","assets/DirectMail-YxgdM4xP.js","assets/EmailCampaignComposer-D7O3zh4Q.js","assets/EditorModeSelector-Cliz3uIS.js","assets/SharedCampaignTemplates-DFvpYHux.js","assets/TemplateEditorDialog-BZF2bgWG.js","assets/AgentTemplates-DAciBLrC.js"])))=>i.map(i=>d[i]); var fmt=Object.defineProperty;var pTe=t=>{throw TypeError(t)};var xmt=(t,s,r)=>s in t?fmt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var Mn=(t,s,r)=>xmt(t,typeof s!="symbol"?s+"":s,r),wfe=(t,s,r)=>s.has(t)||pTe("Cannot "+r);var is=(t,s,r)=>(wfe(t,s,"read from private field"),r?r.call(t):s.get(t)),Xa=(t,s,r)=>s.has(t)?pTe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),Yn=(t,s,r,n)=>(wfe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Qi=(t,s,r)=>(wfe(t,s,"access private method"),r);var y7=(t,s,r,n)=>({set _(a){Yn(t,s,a,r)},get _(){return is(t,s,n)}});function gmt(t,s){for(var r=0;rn[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function r(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(a){if(a.ep)return;a.ep=!0;const o=r(a);fetch(a.href,o)}})();const ymt="modulepreload",vmt=function(t){return"/"+t},fTe={},Al=function(s,r,n){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),i=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=Promise.allSettled(r.map(c=>{if(c=vmt(c),c in fTe)return;fTe[c]=!0;const u=c.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":ymt,u||(f.as="script"),f.crossOrigin="",f.href=c,i&&f.setAttribute("nonce",i),document.head.appendChild(f),u)return new Promise((g,b)=>{f.addEventListener("load",g),f.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return a.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return s().catch(o)})};var Gv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Po(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function v9e(t){if(t.__esModule)return t;var s=t.default;if(typeof s=="function"){var r=function n(){return this instanceof n?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};r.prototype=s.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var a=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:function(){return t[n]}})}),r}var b9e={exports:{}},ade={},_9e={exports:{}},go={};/** * @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 mO=Symbol.for("react.element"),bmt=Symbol.for("react.portal"),_mt=Symbol.for("react.fragment"),wmt=Symbol.for("react.strict_mode"),jmt=Symbol.for("react.profiler"),Nmt=Symbol.for("react.provider"),kmt=Symbol.for("react.context"),Smt=Symbol.for("react.forward_ref"),Cmt=Symbol.for("react.suspense"),Mmt=Symbol.for("react.memo"),Tmt=Symbol.for("react.lazy"),xTe=Symbol.iterator;function Amt(t){return t===null||typeof t!="object"?null:(t=xTe&&t[xTe]||t["@@iterator"],typeof t=="function"?t:null)}var w9e={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j9e=Object.assign,N9e={};function DA(t,s,r){this.props=t,this.context=s,this.refs=N9e,this.updater=r||w9e}DA.prototype.isReactComponent={};DA.prototype.setState=function(t,s){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,s,"setState")};DA.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function k9e(){}k9e.prototype=DA.prototype;function xwe(t,s,r){this.props=t,this.context=s,this.refs=N9e,this.updater=r||w9e}var gwe=xwe.prototype=new k9e;gwe.constructor=xwe;j9e(gwe,DA.prototype);gwe.isPureReactComponent=!0;var gTe=Array.isArray,S9e=Object.prototype.hasOwnProperty,ywe={current:null},C9e={key:!0,ref:!0,__self:!0,__source:!0};function M9e(t,s,r){var n,a={},o=null,l=null;if(s!=null)for(n in s.ref!==void 0&&(l=s.ref),s.key!==void 0&&(o=""+s.key),s)S9e.call(s,n)&&!C9e.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,pe=ce[ue];if(0>>1;ue<_e;){var $e=2*(ue+1)-1,Ae=ce[$e],Ie=$e+1,Ce=ce[Ie];if(0>a(Ae,ye))Iea(Ce,Ae)?(ce[ue]=Ce,ce[Ie]=ye,ue=Ie):(ce[ue]=Ae,ce[$e]=ye,ue=$e);else if(Iea(Ce,ye))ce[ue]=Ce,ce[Ie]=ye,ue=Ie;else break e}}return ge}function a(ce,ge){var ye=ce.sortIndex-ge.sortIndex;return ye!==0?ye:ce.id-ge.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();t.unstable_now=function(){return l.now()-i}}var c=[],u=[],p=1,f=null,g=3,b=!1,_=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function M(ce){for(var ge=r(u);ge!==null;){if(ge.callback===null)n(u);else if(ge.startTime<=ce)n(u),ge.sortIndex=ge.expirationTime,s(c,ge);else break;ge=r(u)}}function L(ce){if(j=!1,M(ce),!_)if(r(c)!==null)_=!0,re(I);else{var ge=r(u);ge!==null&&oe(L,ge.startTime-ce)}}function I(ce,ge){_=!1,j&&(j=!1,N(U),U=-1),b=!0;var ye=g;try{for(M(ge),f=r(c);f!==null&&(!(f.expirationTime>ge)||ce&&!Y());){var ue=f.callback;if(typeof ue=="function"){f.callback=null,g=f.priorityLevel;var pe=ue(f.expirationTime<=ge);ge=t.unstable_now(),typeof pe=="function"?f.callback=pe:f===r(c)&&n(c),M(ge)}else n(c);f=r(c)}if(f!==null)var _e=!0;else{var $e=r(u);$e!==null&&oe(L,$e.startTime-ge),_e=!1}return _e}finally{f=null,g=ye,b=!1}}var O=!1,q=null,U=-1,B=5,V=-1;function Y(){return!(t.unstable_now()-Vce||125ue?(ce.sortIndex=ye,s(u,ce),r(c)===null&&ce===r(u)&&(j?(N(U),U=-1):j=!0,oe(L,ye-ue))):(ce.sortIndex=pe,s(c,ce),_||b||(_=!0,re(I))),ce},t.unstable_shouldYield=Y,t.unstable_wrapCallback=function(ce){var ge=g;return function(){var ye=g;g=ge;try{return ce.apply(this,arguments)}finally{g=ye}}}})(I9e);P9e.exports=I9e;var $mt=P9e.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 qmt=k,Cf=$mt;function Qr(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zye=Object.prototype.hasOwnProperty,Umt=/^[: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]*$/,vTe={},bTe={};function Vmt(t){return zye.call(bTe,t)?!0:zye.call(vTe,t)?!1:Umt.test(t)?bTe[t]=!0:(vTe[t]=!0,!1)}function Hmt(t,s,r,n){if(r!==null&&r.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function Wmt(t,s,r,n){if(s===null||typeof s>"u"||Hmt(t,s,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function Hm(t,s,r,n,a,o,l){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=n,this.attributeNamespace=a,this.mustUseProperty=r,this.propertyName=t,this.type=s,this.sanitizeURL=o,this.removeEmptyString=l}var Ph={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ph[t]=new Hm(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];Ph[s]=new Hm(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ph[t]=new Hm(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ph[t]=new Hm(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ph[t]=new Hm(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Ph[t]=new Hm(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Ph[t]=new Hm(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Ph[t]=new Hm(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Ph[t]=new Hm(t,5,!1,t.toLowerCase(),null,!1,!1)});var _we=/[\-:]([a-z])/g;function wwe(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var s=t.replace(_we,wwe);Ph[s]=new Hm(s,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(_we,wwe);Ph[s]=new Hm(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(_we,wwe);Ph[s]=new Hm(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Ph[t]=new Hm(t,1,!1,t.toLowerCase(),null,!1,!1)});Ph.xlinkHref=new Hm("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Ph[t]=new Hm(t,1,!1,t.toLowerCase(),null,!0,!0)});function jwe(t,s,r,n){var a=Ph.hasOwnProperty(s)?Ph[s]:null;(a!==null?a.type!==0:n||!(2i||a[l]!==o[i]){var c=` `+a[l].replace(" at new "," at ");return t.displayName&&c.includes("")&&(c=c.replace("",t.displayName)),c}while(1<=l&&0<=i);break}}}finally{kfe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?fI(t):""}function Gmt(t){switch(t.tag){case 5:return fI(t.type);case 16:return fI("Lazy");case 13:return fI("Suspense");case 19:return fI("SuspenseList");case 0:case 2:case 15:return t=Sfe(t.type,!1),t;case 11:return t=Sfe(t.type.render,!1),t;case 1:return t=Sfe(t.type,!0),t;default:return""}}function Uye(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Z5:return"Fragment";case K5:return"Portal";case Bye:return"Profiler";case Nwe:return"StrictMode";case $ye:return"Suspense";case qye:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case O9e:return(t.displayName||"Context")+".Consumer";case D9e:return(t._context.displayName||"Context")+".Provider";case kwe:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Swe:return s=t.displayName||null,s!==null?s:Uye(t.type)||"Memo";case Hb:s=t._payload,t=t._init;try{return Uye(t(s))}catch{}}return null}function Kmt(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Uye(s);case 8:return s===Nwe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function iw(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function F9e(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Zmt(t){var s=F9e(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),n=""+t[s];if(!t.hasOwnProperty(s)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var a=r.get,o=r.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return a.call(this)},set:function(l){n=""+l,o.call(this,l)}}),Object.defineProperty(t,s,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(l){n=""+l},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function _7(t){t._valueTracker||(t._valueTracker=Zmt(t))}function z9e(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=F9e(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function Rie(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Vye(t,s){var r=s.checked;return nd({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function wTe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=iw(s.value!=null?s.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function B9e(t,s){s=s.checked,s!=null&&jwe(t,"checked",s,!1)}function Hye(t,s){B9e(t,s);var r=iw(s.value),n=s.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?Wye(t,s.type,r):s.hasOwnProperty("defaultValue")&&Wye(t,s.type,iw(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function jTe(t,s,r){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var n=s.type;if(!(n!=="submit"&&n!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,r||s===t.value||(t.value=s),t.defaultValue=s}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function Wye(t,s,r){(s!=="number"||Rie(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var xI=Array.isArray;function vM(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=w7.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function S8(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var DI={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},Ymt=["Webkit","ms","Moz","O"];Object.keys(DI).forEach(function(t){Ymt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),DI[s]=DI[t]})});function V9e(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||DI.hasOwnProperty(t)&&DI[t]?(""+s).trim():s+"px"}function H9e(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=V9e(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var Xmt=nd({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 Zye(t,s){if(s){if(Xmt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Qr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Qr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Qr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Qr(62))}}function Yye(t,s){if(t.indexOf("-")===-1)return typeof s.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Xye=null;function Cwe(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Qye=null,bM=null,_M=null;function STe(t){if(t=xO(t)){if(typeof Qye!="function")throw Error(Qr(280));var s=t.stateNode;s&&(s=dde(s),Qye(t.stateNode,t.type,s))}}function W9e(t){bM?_M?_M.push(t):_M=[t]:bM=t}function G9e(){if(bM){var t=bM,s=_M;if(_M=bM=null,STe(t),s)for(t=0;t>>=0,t===0?32:31-(lpt(t)/cpt|0)|0}var j7=64,N7=4194304;function gI(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function $ie(t,s){var r=t.pendingLanes;if(r===0)return 0;var n=0,a=t.suspendedLanes,o=t.pingedLanes,l=r&268435455;if(l!==0){var i=l&~a;i!==0?n=gI(i):(o&=l,o!==0&&(n=gI(o)))}else l=r&~a,l!==0?n=gI(l):o!==0&&(n=gI(o));if(n===0)return 0;if(s!==0&&s!==n&&!(s&a)&&(a=n&-n,o=s&-s,a>=o||a===16&&(o&4194240)!==0))return s;if(n&4&&(n|=r&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=n;0r;r++)s.push(t);return s}function pO(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Zg(s),t[s]=r}function mpt(t,s){var r=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0=RI),DTe=" ",OTe=!1;function mBe(t,s){switch(t){case"keyup":return $pt.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function pBe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Y5=!1;function Upt(t,s){switch(t){case"compositionend":return pBe(s);case"keypress":return s.which!==32?null:(OTe=!0,DTe);case"textInput":return t=s.data,t===DTe&&OTe?null:t;default:return null}}function Vpt(t,s){if(Y5)return t==="compositionend"||!Dwe&&mBe(t,s)?(t=uBe(),d9=Pwe=b_=null,Y5=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:r,offset:s-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=BTe(r)}}function yBe(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?yBe(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function vBe(){for(var t=window,s=Rie();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=Rie(t.document)}return s}function Owe(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function Jpt(t){var s=vBe(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&yBe(r.ownerDocument.documentElement,r)){if(n!==null&&Owe(r)){if(s=n.start,t=n.end,t===void 0&&(t=s),"selectionStart"in r)r.selectionStart=s,r.selectionEnd=Math.min(t,r.value.length);else if(t=(s=r.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var a=r.textContent.length,o=Math.min(n.start,a);n=n.end===void 0?o:Math.min(n.end,a),!t.extend&&o>n&&(a=n,n=o,o=a),a=$Te(r,o);var l=$Te(r,n);a&&l&&(t.rangeCount!==1||t.anchorNode!==a.node||t.anchorOffset!==a.offset||t.focusNode!==l.node||t.focusOffset!==l.offset)&&(s=s.createRange(),s.setStart(a.node,a.offset),t.removeAllRanges(),o>n?(t.addRange(s),t.extend(l.node,l.offset)):(s.setEnd(l.node,l.offset),t.addRange(s)))}}for(s=[],t=r;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,X5=null,n0e=null,zI=null,a0e=!1;function qTe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;a0e||X5==null||X5!==Rie(n)||(n=X5,"selectionStart"in n&&Owe(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}),zI&&P8(zI,n)||(zI=n,n=Vie(n0e,"onSelect"),0eM||(t.current=u0e[eM],u0e[eM]=null,eM--)}function Yl(t,s){eM++,u0e[eM]=t.current,t.current=s}var ow={},Yh=jw(ow),wp=jw(!1),PS=ow;function kT(t,s){var r=t.type.contextTypes;if(!r)return ow;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===s)return n.__reactInternalMemoizedMaskedChildContext;var a={},o;for(o in r)a[o]=s[o];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=a),a}function jp(t){return t=t.childContextTypes,t!=null}function Wie(){jc(wp),jc(Yh)}function ZTe(t,s,r){if(Yh.current!==ow)throw Error(Qr(168));Yl(Yh,s),Yl(wp,r)}function MBe(t,s,r){var n=t.stateNode;if(s=s.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var a in n)if(!(a in s))throw Error(Qr(108,Kmt(t)||"Unknown",a));return nd({},r,n)}function Gie(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||ow,PS=Yh.current,Yl(Yh,t),Yl(wp,wp.current),!0}function YTe(t,s,r){var n=t.stateNode;if(!n)throw Error(Qr(169));r?(t=MBe(t,s,PS),n.__reactInternalMemoizedMergedChildContext=t,jc(wp),jc(Yh),Yl(Yh,t)):jc(wp),Yl(wp,r)}var Ov=null,ude=!1,Bfe=!1;function TBe(t){Ov===null?Ov=[t]:Ov.push(t)}function uft(t){ude=!0,TBe(t)}function Nw(){if(!Bfe&&Ov!==null){Bfe=!0;var t=0,s=vl;try{var r=Ov;for(vl=1;t>=l,a-=l,Kv=1<<32-Zg(s)+a|r<U?(B=q,q=null):B=q.sibling;var V=g(N,q,M[U],L);if(V===null){q===null&&(q=B);break}t&&q&&V.alternate===null&&s(N,q),S=o(V,S,U),O===null?I=V:O.sibling=V,O=V,q=B}if(U===M.length)return r(N,q),zc&&H2(N,U),I;if(q===null){for(;UU?(B=q,q=null):B=q.sibling;var Y=g(N,q,V.value,L);if(Y===null){q===null&&(q=B);break}t&&q&&Y.alternate===null&&s(N,q),S=o(Y,S,U),O===null?I=Y:O.sibling=Y,O=Y,q=B}if(V.done)return r(N,q),zc&&H2(N,U),I;if(q===null){for(;!V.done;U++,V=M.next())V=f(N,V.value,L),V!==null&&(S=o(V,S,U),O===null?I=V:O.sibling=V,O=V);return zc&&H2(N,U),I}for(q=n(N,q);!V.done;U++,V=M.next())V=b(q,N,U,V.value,L),V!==null&&(t&&V.alternate!==null&&q.delete(V.key===null?U:V.key),S=o(V,S,U),O===null?I=V:O.sibling=V,O=V);return t&&q.forEach(function(Q){return s(N,Q)}),zc&&H2(N,U),I}function w(N,S,M,L){if(typeof M=="object"&&M!==null&&M.type===Z5&&M.key===null&&(M=M.props.children),typeof M=="object"&&M!==null){switch(M.$$typeof){case b7:e:{for(var I=M.key,O=S;O!==null;){if(O.key===I){if(I=M.type,I===Z5){if(O.tag===7){r(N,O.sibling),S=a(O,M.props.children),S.return=N,N=S;break e}}else if(O.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===Hb&&JTe(I)===O.type){r(N,O.sibling),S=a(O,M.props),S.ref=DP(N,O,M),S.return=N,N=S;break e}r(N,O);break}else s(N,O);O=O.sibling}M.type===Z5?(S=H4(M.props.children,N.mode,L,M.key),S.return=N,N=S):(L=y9(M.type,M.key,M.props,null,N.mode,L),L.ref=DP(N,S,M),L.return=N,N=L)}return l(N);case K5:e:{for(O=M.key;S!==null;){if(S.key===O)if(S.tag===4&&S.stateNode.containerInfo===M.containerInfo&&S.stateNode.implementation===M.implementation){r(N,S.sibling),S=a(S,M.children||[]),S.return=N,N=S;break e}else{r(N,S);break}else s(N,S);S=S.sibling}S=Kfe(M,N.mode,L),S.return=N,N=S}return l(N);case Hb:return O=M._init,w(N,S,O(M._payload),L)}if(xI(M))return _(N,S,M,L);if(AP(M))return j(N,S,M,L);E7(N,M)}return typeof M=="string"&&M!==""||typeof M=="number"?(M=""+M,S!==null&&S.tag===6?(r(N,S.sibling),S=a(S,M),S.return=N,N=S):(r(N,S),S=Gfe(M,N.mode,L),S.return=N,N=S),l(N)):r(N,S)}return w}var CT=IBe(!0),LBe=IBe(!1),Yie=jw(null),Xie=null,rM=null,Bwe=null;function $we(){Bwe=rM=Xie=null}function qwe(t){var s=Yie.current;jc(Yie),t._currentValue=s}function p0e(t,s,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,n!==null&&(n.childLanes|=s)):n!==null&&(n.childLanes&s)!==s&&(n.childLanes|=s),t===r)break;t=t.return}}function jM(t,s){Xie=t,Bwe=rM=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(gp=!0),t.firstContext=null)}function Ix(t){var s=t._currentValue;if(Bwe!==t)if(t={context:t,memoizedValue:s,next:null},rM===null){if(Xie===null)throw Error(Qr(308));rM=t,Xie.dependencies={lanes:0,firstContext:t}}else rM=rM.next=t;return s}var f4=null;function Uwe(t){f4===null?f4=[t]:f4.push(t)}function DBe(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,Uwe(s)):(r.next=a.next,a.next=r),s.interleaved=r,k1(t,n)}function k1(t,s){t.lanes|=s;var r=t.alternate;for(r!==null&&(r.lanes|=s),r=t,t=t.return;t!==null;)t.childLanes|=s,r=t.alternate,r!==null&&(r.childLanes|=s),r=t,t=t.return;return r.tag===3?r.stateNode:null}var Wb=!1;function Vwe(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function OBe(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function t1(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function I_(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,zo&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,k1(t,r)}return a=n.interleaved,a===null?(s.next=s,Uwe(n)):(s.next=a.next,a.next=s),n.interleaved=s,k1(t,r)}function h9(t,s,r){if(s=s.updateQueue,s!==null&&(s=s.shared,(r&4194240)!==0)){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,Twe(t,r)}}function eAe(t,s){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var a=null,o=null;if(r=r.firstBaseUpdate,r!==null){do{var l={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};o===null?a=o=l:o=o.next=l,r=r.next}while(r!==null);o===null?a=o=s:o=o.next=s}else a=o=s;r={baseState:n.baseState,firstBaseUpdate:a,lastBaseUpdate:o,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=s:t.next=s,r.lastBaseUpdate=s}function Qie(t,s,r,n){var a=t.updateQueue;Wb=!1;var o=a.firstBaseUpdate,l=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var c=i,u=c.next;c.next=null,l===null?o=u:l.next=u,l=c;var p=t.alternate;p!==null&&(p=p.updateQueue,i=p.lastBaseUpdate,i!==l&&(i===null?p.firstBaseUpdate=u:i.next=u,p.lastBaseUpdate=c))}if(o!==null){var f=a.baseState;l=0,p=u=c=null,i=o;do{var g=i.lane,b=i.eventTime;if((n&g)===g){p!==null&&(p=p.next={eventTime:b,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var _=t,j=i;switch(g=s,b=r,j.tag){case 1:if(_=j.payload,typeof _=="function"){f=_.call(b,f,g);break e}f=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=j.payload,g=typeof _=="function"?_.call(b,f,g):_,g==null)break e;f=nd({},f,g);break e;case 2:Wb=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,g=a.effects,g===null?a.effects=[i]:g.push(i))}else b={eventTime:b,lane:g,tag:i.tag,payload:i.payload,callback:i.callback,next:null},p===null?(u=p=b,c=f):p=p.next=b,l|=g;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;g=i,i=g.next,g.next=null,a.lastBaseUpdate=g,a.shared.pending=null}}while(!0);if(p===null&&(c=f),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=p,s=a.shared.interleaved,s!==null){a=s;do l|=a.lane,a=a.next;while(a!==s)}else o===null&&(a.shared.lanes=0);DS|=l,t.lanes=l,t.memoizedState=f}}function tAe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=qfe.transition;qfe.transition={};try{t(!1),s()}finally{vl=r,qfe.transition=n}}function JBe(){return Lx().memoizedState}function fft(t,s,r){var n=D_(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},e$e(t))t$e(s,r);else if(r=DBe(t,s,r,n),r!==null){var a=Pm();Yg(r,t,n,a),s$e(r,s,n)}}function xft(t,s,r){var n=D_(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(e$e(t))t$e(s,a);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=s.lastRenderedReducer,o!==null))try{var l=s.lastRenderedState,i=o(l,r);if(a.hasEagerState=!0,a.eagerState=i,ay(i,l)){var c=s.interleaved;c===null?(a.next=a,Uwe(s)):(a.next=c.next,c.next=a),s.interleaved=a;return}}catch{}finally{}r=DBe(t,s,a,n),r!==null&&(a=Pm(),Yg(r,t,n,a),s$e(r,s,n))}}function e$e(t){var s=t.alternate;return t===sd||s!==null&&s===sd}function t$e(t,s){BI=eoe=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function s$e(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,Twe(t,r)}}var toe={readContext:Ix,useCallback:Rh,useContext:Rh,useEffect:Rh,useImperativeHandle:Rh,useInsertionEffect:Rh,useLayoutEffect:Rh,useMemo:Rh,useReducer:Rh,useRef:Rh,useState:Rh,useDebugValue:Rh,useDeferredValue:Rh,useTransition:Rh,useMutableSource:Rh,useSyncExternalStore:Rh,useId:Rh,unstable_isNewReconciler:!1},gft={readContext:Ix,useCallback:function(t,s){return Hy().memoizedState=[t,s===void 0?null:s],t},useContext:Ix,useEffect:rAe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,p9(4194308,4,KBe.bind(null,s,t),r)},useLayoutEffect:function(t,s){return p9(4194308,4,t,s)},useInsertionEffect:function(t,s){return p9(4,2,t,s)},useMemo:function(t,s){var r=Hy();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Hy();return s=r!==void 0?r(s):s,n.memoizedState=n.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},n.queue=t,t=t.dispatch=fft.bind(null,sd,t),[n.memoizedState,t]},useRef:function(t){var s=Hy();return t={current:t},s.memoizedState=t},useState:sAe,useDebugValue:Qwe,useDeferredValue:function(t){return Hy().memoizedState=t},useTransition:function(){var t=sAe(!1),s=t[0];return t=pft.bind(null,t[1]),Hy().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=sd,a=Hy();if(zc){if(r===void 0)throw Error(Qr(407));r=r()}else{if(r=s(),Qu===null)throw Error(Qr(349));LS&30||BBe(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,rAe(qBe.bind(null,n,o,t),[t]),n.flags|=2048,B8(9,$Be.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Hy(),s=Qu.identifierPrefix;if(zc){var r=Zv,n=Kv;r=(n&~(1<<32-Zg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=F8++,0<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=l.createElement(r,{is:n.is}):(t=l.createElement(r),r==="select"&&(l=t,n.multiple?l.multiple=!0:n.size&&(l.size=n.size))):t=l.createElementNS(t,r),t[s0]=s,t[D8]=n,h$e(t,s,!1,!1),s.stateNode=t;e:{switch(l=Yye(r,n),r){case"dialog":pc("cancel",t),pc("close",t),a=n;break;case"iframe":case"object":case"embed":pc("load",t),a=n;break;case"video":case"audio":for(a=0;aAT&&(s.flags|=128,n=!0,OP(o,!1),s.lanes=4194304)}else{if(!n)if(t=Jie(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),OP(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!zc)return Fh(s),null}else 2*Id()-o.renderingStartTime>AT&&r!==1073741824&&(s.flags|=128,n=!0,OP(o,!1),s.lanes=4194304);o.isBackwards?(l.sibling=s.child,s.child=l):(r=o.last,r!==null?r.sibling=l:s.child=l,o.last=l)}return o.tail!==null?(s=o.tail,o.rendering=s,o.tail=s.sibling,o.renderingStartTime=Id(),s.sibling=null,r=Qc.current,Yl(Qc,n?r&1|2:r&1),s):(Fh(s),null);case 22:case 23:return n2e(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?tf&1073741824&&(Fh(s),s.subtreeFlags&6&&(s.flags|=8192)):Fh(s),null;case 24:return null;case 25:return null}throw Error(Qr(156,s.tag))}function kft(t,s){switch(Fwe(s),s.tag){case 1:return jp(s.type)&&Wie(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return MT(),jc(wp),jc(Yh),Gwe(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return Wwe(s),null;case 13:if(jc(Qc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Qr(340));ST()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return jc(Qc),null;case 4:return MT(),null;case 10:return qwe(s.type._context),null;case 22:case 23:return n2e(),null;case 24:return null;default:return null}}var I7=!1,Uh=!1,Sft=typeof WeakSet=="function"?WeakSet:Set,na=null;function nM(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){pd(t,s,n)}else r.current=null}function j0e(t,s,r){try{r()}catch(n){pd(t,s,n)}}var pAe=!1;function Cft(t,s){if(i0e=qie,t=vBe(),Owe(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var a=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var l=0,i=-1,c=-1,u=0,p=0,f=t,g=null;t:for(;;){for(var b;f!==r||a!==0&&f.nodeType!==3||(i=l+a),f!==o||n!==0&&f.nodeType!==3||(c=l+n),f.nodeType===3&&(l+=f.nodeValue.length),(b=f.firstChild)!==null;)g=f,f=b;for(;;){if(f===t)break t;if(g===r&&++u===a&&(i=l),g===o&&++p===n&&(c=l),(b=f.nextSibling)!==null)break;f=g,g=f.parentNode}f=b}r=i===-1||c===-1?null:{start:i,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(o0e={focusedElem:t,selectionRange:r},qie=!1,na=s;na!==null;)if(s=na,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,na=t;else for(;na!==null;){s=na;try{var _=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var j=_.memoizedProps,w=_.memoizedState,N=s.stateNode,S=N.getSnapshotBeforeUpdate(s.elementType===s.type?j:Pg(s.type,j),w);N.__reactInternalSnapshotBeforeUpdate=S}break;case 3:var M=s.stateNode.containerInfo;M.nodeType===1?M.textContent="":M.nodeType===9&&M.documentElement&&M.removeChild(M.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Qr(163))}}catch(L){pd(s,s.return,L)}if(t=s.sibling,t!==null){t.return=s.return,na=t;break}na=s.return}return _=pAe,pAe=!1,_}function $I(t,s,r){var n=s.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var a=n=n.next;do{if((a.tag&t)===t){var o=a.destroy;a.destroy=void 0,o!==void 0&&j0e(s,r,o)}a=a.next}while(a!==n)}}function pde(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==s)}}function N0e(t){var s=t.ref;if(s!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof s=="function"?s(t):s.current=t}}function f$e(t){var s=t.alternate;s!==null&&(t.alternate=null,f$e(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[s0],delete s[D8],delete s[d0e],delete s[cft],delete s[dft])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function x$e(t){return t.tag===5||t.tag===3||t.tag===4}function fAe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||x$e(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function k0e(t,s,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,s?r.nodeType===8?r.parentNode.insertBefore(t,s):r.insertBefore(t,s):(r.nodeType===8?(s=r.parentNode,s.insertBefore(t,r)):(s=r,s.appendChild(t)),r=r._reactRootContainer,r!=null||s.onclick!==null||(s.onclick=Hie));else if(n!==4&&(t=t.child,t!==null))for(k0e(t,s,r),t=t.sibling;t!==null;)k0e(t,s,r),t=t.sibling}function S0e(t,s,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,s?r.insertBefore(t,s):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(S0e(t,s,r),t=t.sibling;t!==null;)S0e(t,s,r),t=t.sibling}var gh=null,Og=!1;function Tb(t,s,r){for(r=r.child;r!==null;)g$e(t,s,r),r=r.sibling}function g$e(t,s,r){if(u0&&typeof u0.onCommitFiberUnmount=="function")try{u0.onCommitFiberUnmount(ide,r)}catch{}switch(r.tag){case 5:Uh||nM(r,s);case 6:var n=gh,a=Og;gh=null,Tb(t,s,r),gh=n,Og=a,gh!==null&&(Og?(t=gh,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):gh.removeChild(r.stateNode));break;case 18:gh!==null&&(Og?(t=gh,r=r.stateNode,t.nodeType===8?zfe(t.parentNode,r):t.nodeType===1&&zfe(t,r),A8(t)):zfe(gh,r.stateNode));break;case 4:n=gh,a=Og,gh=r.stateNode.containerInfo,Og=!0,Tb(t,s,r),gh=n,Og=a;break;case 0:case 11:case 14:case 15:if(!Uh&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){a=n=n.next;do{var o=a,l=o.destroy;o=o.tag,l!==void 0&&(o&2||o&4)&&j0e(r,s,l),a=a.next}while(a!==n)}Tb(t,s,r);break;case 1:if(!Uh&&(nM(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){pd(r,s,i)}Tb(t,s,r);break;case 21:Tb(t,s,r);break;case 22:r.mode&1?(Uh=(n=Uh)||r.memoizedState!==null,Tb(t,s,r),Uh=n):Tb(t,s,r);break;default:Tb(t,s,r)}}function xAe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new Sft),s.forEach(function(n){var a=Oft.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function jg(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=Id()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Tft(n/1960))-n,10t?16:t,__===null)var n=!1;else{if(t=__,__=null,noe=0,zo&6)throw Error(Qr(331));var a=zo;for(zo|=4,na=t.current;na!==null;){var o=na,l=o.child;if(na.flags&16){var i=o.deletions;if(i!==null){for(var c=0;cId()-s2e?V4(t,0):t2e|=r),Np(t,s)}function k$e(t,s){s===0&&(t.mode&1?(s=N7,N7<<=1,!(N7&130023424)&&(N7=4194304)):s=1);var r=Pm();t=k1(t,s),t!==null&&(pO(t,s,r),Np(t,r))}function Dft(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),k$e(t,r)}function Oft(t,s){var r=0;switch(t.tag){case 13:var n=t.stateNode,a=t.memoizedState;a!==null&&(r=a.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(Qr(314))}n!==null&&n.delete(s),k$e(t,r)}var S$e;S$e=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||wp.current)gp=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return gp=!1,jft(t,s,r);gp=!!(t.flags&131072)}else gp=!1,zc&&s.flags&1048576&&ABe(s,Zie,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;f9(t,s),t=s.pendingProps;var a=kT(s,Yh.current);jM(s,r),a=Zwe(null,s,n,t,a,r);var o=Ywe();return s.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,jp(n)?(o=!0,Gie(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Vwe(s),a.updater=mde,s.stateNode=a,a._reactInternals=s,x0e(s,n,t,r),s=v0e(null,s,n,!0,o,r)):(s.tag=0,zc&&o&&Rwe(s),bm(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(f9(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=Fft(n),t=Pg(n,t),a){case 0:s=y0e(null,s,n,t,r);break e;case 1:s=uAe(null,s,n,t,r);break e;case 11:s=cAe(null,s,n,t,r);break e;case 14:s=dAe(null,s,n,Pg(n.type,t),r);break e}throw Error(Qr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Pg(n,a),y0e(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Pg(n,a),uAe(t,s,n,a,r);case 3:e:{if(c$e(s),t===null)throw Error(Qr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,OBe(t,s),Qie(s,n,null,r);var l=s.memoizedState;if(n=l.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},s.updateQueue.baseState=o,s.memoizedState=o,s.flags&256){a=TT(Error(Qr(423)),s),s=hAe(t,s,n,r,a);break e}else if(n!==a){a=TT(Error(Qr(424)),s),s=hAe(t,s,n,r,a);break e}else for(hf=P_(s.stateNode.containerInfo.firstChild),pf=s,zc=!0,$g=null,r=LBe(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(ST(),n===a){s=S1(t,s,r);break e}bm(t,s,n,r)}s=s.child}return s;case 5:return RBe(s),t===null&&m0e(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,l0e(n,a)?l=null:o!==null&&l0e(n,o)&&(s.flags|=32),l$e(t,s),bm(t,s,l,r),s.child;case 6:return t===null&&m0e(s),null;case 13:return d$e(t,s,r);case 4:return Hwe(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=CT(s,null,n,r):bm(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Pg(n,a),cAe(t,s,n,a,r);case 7:return bm(t,s,s.pendingProps,r),s.child;case 8:return bm(t,s,s.pendingProps.children,r),s.child;case 12:return bm(t,s,s.pendingProps.children,r),s.child;case 10:e:{if(n=s.type._context,a=s.pendingProps,o=s.memoizedProps,l=a.value,Yl(Yie,n._currentValue),n._currentValue=l,o!==null)if(ay(o.value,l)){if(o.children===a.children&&!wp.current){s=S1(t,s,r);break e}}else for(o=s.child,o!==null&&(o.return=s);o!==null;){var i=o.dependencies;if(i!==null){l=o.child;for(var c=i.firstContext;c!==null;){if(c.context===n){if(o.tag===1){c=t1(-1,r&-r),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}o.lanes|=r,c=o.alternate,c!==null&&(c.lanes|=r),p0e(o.return,r,s),i.lanes|=r;break}c=c.next}}else if(o.tag===10)l=o.type===s.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(Qr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),p0e(l,r,s),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===s){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}bm(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,jM(s,r),a=Ix(a),n=n(a),s.flags|=1,bm(t,s,n,r),s.child;case 14:return n=s.type,a=Pg(n,s.pendingProps),a=Pg(n.type,a),dAe(t,s,n,a,r);case 15:return i$e(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Pg(n,a),f9(t,s),s.tag=1,jp(n)?(t=!0,Gie(s)):t=!1,jM(s,r),r$e(s,n,a),x0e(s,n,a,r),v0e(null,s,n,!0,t,r);case 19:return u$e(t,s,r);case 22:return o$e(t,s,r)}throw Error(Qr(156,s.tag))};function C$e(t,s){return eBe(t,s)}function Rft(t,s,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bx(t,s,r,n){return new Rft(t,s,r,n)}function i2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Fft(t){if(typeof t=="function")return i2e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===kwe)return 11;if(t===Swe)return 14}return 2}function O_(t,s){var r=t.alternate;return r===null?(r=bx(t.tag,s,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=s,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,s=t.dependencies,r.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function y9(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")i2e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case Z5:return H4(r.children,a,o,s);case Nwe:l=8,a|=8;break;case Bye:return t=bx(12,r,s,a|2),t.elementType=Bye,t.lanes=o,t;case $ye:return t=bx(13,r,s,a),t.elementType=$ye,t.lanes=o,t;case qye:return t=bx(19,r,s,a),t.elementType=qye,t.lanes=o,t;case R9e:return xde(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case D9e:l=10;break e;case O9e:l=9;break e;case kwe:l=11;break e;case Swe:l=14;break e;case Hb:l=16,n=null;break e}throw Error(Qr(130,t==null?t:typeof t,""))}return s=bx(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function H4(t,s,r,n){return t=bx(7,t,n,s),t.lanes=r,t}function xde(t,s,r,n){return t=bx(22,t,n,s),t.elementType=R9e,t.lanes=r,t.stateNode={isHidden:!1},t}function Gfe(t,s,r){return t=bx(6,t,null,s),t.lanes=r,t}function Kfe(t,s,r){return s=bx(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function zft(t,s,r,n,a){this.tag=s,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mfe(0),this.expirationTimes=Mfe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mfe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function o2e(t,s,r,n,a,o,l,i,c){return t=new zft(t,s,r,i,c),s===1?(s=1,o===!0&&(s|=8)):s=0,o=bx(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},Vwe(o),t}function Bft(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(E$e)}catch(t){console.error(t)}}E$e(),E9e.exports=Pf;var yp=E9e.exports;const u2e=Po(yp);var P$e,NAe=yp;P$e=NAe.createRoot,NAe.hydrateRoot;const Hft=1,Wft=1e6;let Zfe=0;function Gft(){return Zfe=(Zfe+1)%Number.MAX_SAFE_INTEGER,Zfe.toString()}const Yfe=new Map,kAe=t=>{if(Yfe.has(t))return;const s=setTimeout(()=>{Yfe.delete(t),VI({type:"REMOVE_TOAST",toastId:t})},Wft);Yfe.set(t,s)},Kft=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,Hft)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(r=>r.id===s.toast.id?{...r,...s.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=s;return r?kAe(r):t.toasts.forEach(n=>{kAe(n.id)}),{...t,toasts:t.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return s.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(r=>r.id!==s.toastId)}}},v9=[];let b9={toasts:[]};function VI(t){b9=Kft(b9,t),v9.forEach(s=>{s(b9)})}function wn({...t}){const s=Gft(),r=a=>VI({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>VI({type:"DISMISS_TOAST",toastId:s});return VI({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Ua(){const[t,s]=k.useState(b9);return k.useEffect(()=>(v9.push(s),()=>{const r=v9.indexOf(s);r>-1&&v9.splice(r,1)}),[t]),{...t,toast:wn,dismiss:r=>VI({type:"DISMISS_TOAST",toastId:r})}}function Ir(t,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(t==null||t(a),r===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}function SAe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function C1(...t){return s=>{let r=!1;const n=t.map(a=>{const o=SAe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,c=k.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:c,children:l})};n.displayName=t+"Provider";function a(o){const l=k.useContext(r);if(l)return l;if(s!==void 0)return s;throw new Error(`\`${o}\` must be used within \`${t}\``)}return[n,a]}function ad(t,s=[]){let r=[];function n(o,l){const i=k.createContext(l),c=r.length;r=[...r,l];const u=f=>{var N;const{scope:g,children:b,..._}=f,j=((N=g==null?void 0:g[t])==null?void 0:N[c])||i,w=k.useMemo(()=>_,Object.values(_));return e.jsx(j.Provider,{value:w,children:b})};u.displayName=o+"Provider";function p(f,g){var j;const b=((j=g==null?void 0:g[t])==null?void 0:j[c])||i,_=k.useContext(b);if(_)return _;if(l!==void 0)return l;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[u,p]}const a=()=>{const o=r.map(l=>k.createContext(l));return function(i){const c=(i==null?void 0:i[t])||o;return k.useMemo(()=>({[`__scope${t}`]:{...i,[t]:c}}),[i,c])}};return a.scopeName=t,[n,Yft(a,...s)]}function Yft(...t){const s=t[0];if(t.length===1)return s;const r=()=>{const n=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const l=n.reduce((i,{useScope:c,scopeName:u})=>{const f=c(o)[`__scope${u}`];return{...i,...f}},{});return k.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function lw(t){const s=Xft(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),c=i.find(Qft);if(c){const u=c.props.children,p=i.map(f=>f===c?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var h2e=lw("Slot");function Xft(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=ext(a),i=Jft(o,a.props);return a.type!==k.Fragment&&(i.ref=n?C1(n,l):l),k.cloneElement(a,i)}return k.Children.count(a)>1?k.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var I$e=Symbol("radix.slottable");function L$e(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=I$e,s}function Qft(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===I$e}function Jft(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const c=o(...i);return a(...i),c}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function ext(t){var n,a;let s=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function yO(t){const s=t+"CollectionProvider",[r,n]=ad(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=j=>{const{scope:w,children:N}=j,S=ht.useRef(null),M=ht.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:M,collectionRef:S,children:N})};l.displayName=s;const i=t+"CollectionSlot",c=lw(i),u=ht.forwardRef((j,w)=>{const{scope:N,children:S}=j,M=o(i,N),L=qa(w,M.collectionRef);return e.jsx(c,{ref:L,children:S})});u.displayName=i;const p=t+"CollectionItemSlot",f="data-radix-collection-item",g=lw(p),b=ht.forwardRef((j,w)=>{const{scope:N,children:S,...M}=j,L=ht.useRef(null),I=qa(w,L),O=o(p,N);return ht.useEffect(()=>(O.itemMap.set(L,{ref:L,...M}),()=>void O.itemMap.delete(L))),e.jsx(g,{[f]:"",ref:I,children:S})});b.displayName=p;function _(j){const w=o(t+"CollectionConsumer",j);return ht.useCallback(()=>{const S=w.collectionRef.current;if(!S)return[];const M=Array.from(S.querySelectorAll(`[${f}]`));return Array.from(w.itemMap.values()).sort((O,q)=>M.indexOf(O.ref.current)-M.indexOf(q.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:l,Slot:u,ItemSlot:b},_,n]}var txt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],nn=txt.reduce((t,s)=>{const r=lw(`Primitive.${s}`),n=k.forwardRef((a,o)=>{const{asChild:l,...i}=a,c=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(c,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{});function m2e(t,s){t&&yp.flushSync(()=>t.dispatchEvent(s))}function vd(t){const s=k.useRef(t);return k.useEffect(()=>{s.current=t}),k.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function sxt(t,s=globalThis==null?void 0:globalThis.document){const r=vd(t);k.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return s.addEventListener("keydown",n,{capture:!0}),()=>s.removeEventListener("keydown",n,{capture:!0})},[r,s])}var rxt="DismissableLayer",E0e="dismissableLayer.update",nxt="dismissableLayer.pointerDownOutside",axt="dismissableLayer.focusOutside",CAe,D$e=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),kw=k.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...c}=t,u=k.useContext(D$e),[p,f]=k.useState(null),g=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=k.useState({}),_=qa(s,q=>f(q)),j=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(w),S=p?j.indexOf(p):-1,M=u.layersWithOutsidePointerEventsDisabled.size>0,L=S>=N,I=oxt(q=>{const U=q.target,B=[...u.branches].some(V=>V.contains(U));!L||B||(a==null||a(q),l==null||l(q),q.defaultPrevented||i==null||i())},g),O=lxt(q=>{const U=q.target;[...u.branches].some(V=>V.contains(U))||(o==null||o(q),l==null||l(q),q.defaultPrevented||i==null||i())},g);return sxt(q=>{S===u.layers.size-1&&(n==null||n(q),!q.defaultPrevented&&i&&(q.preventDefault(),i()))},g),k.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(CAe=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),MAe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=CAe)}},[p,g,r,u]),k.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),MAe())},[p,u]),k.useEffect(()=>{const q=()=>b({});return document.addEventListener(E0e,q),()=>document.removeEventListener(E0e,q)},[]),e.jsx(nn.div,{...c,ref:_,style:{pointerEvents:M?L?"auto":"none":void 0,...t.style},onFocusCapture:Ir(t.onFocusCapture,O.onFocusCapture),onBlurCapture:Ir(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Ir(t.onPointerDownCapture,I.onPointerDownCapture)})});kw.displayName=rxt;var ixt="DismissableLayerBranch",O$e=k.forwardRef((t,s)=>{const r=k.useContext(D$e),n=k.useRef(null),a=qa(s,n);return k.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(nn.div,{...t,ref:a})});O$e.displayName=ixt;function oxt(t,s=globalThis==null?void 0:globalThis.document){const r=vd(t),n=k.useRef(!1),a=k.useRef(()=>{});return k.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let c=function(){R$e(nxt,r,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=c,s.addEventListener("click",a.current,{once:!0})):c()}else s.removeEventListener("click",a.current);n.current=!1},l=window.setTimeout(()=>{s.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(l),s.removeEventListener("pointerdown",o),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function lxt(t,s=globalThis==null?void 0:globalThis.document){const r=vd(t),n=k.useRef(!1);return k.useEffect(()=>{const a=o=>{o.target&&!n.current&&R$e(axt,r,{originalEvent:o},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function MAe(){const t=new CustomEvent(E0e);document.dispatchEvent(t)}function R$e(t,s,r,{discrete:n}){const a=r.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});s&&a.addEventListener(t,s,{once:!0}),n?m2e(a,o):a.dispatchEvent(o)}var cxt=kw,dxt=O$e,jd=globalThis!=null&&globalThis.document?k.useLayoutEffect:()=>{},uxt="Portal",FA=k.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=k.useState(!1);jd(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?u2e.createPortal(e.jsx(nn.div,{...n,ref:s}),l):null});FA.displayName=uxt;function hxt(t,s){return k.useReducer((r,n)=>s[r][n]??r,t)}var zd=t=>{const{present:s,children:r}=t,n=mxt(s),a=typeof r=="function"?r({present:n.isPresent}):k.Children.only(r),o=qa(n.ref,pxt(a));return typeof r=="function"||n.isPresent?k.cloneElement(a,{ref:o}):null};zd.displayName="Presence";function mxt(t){const[s,r]=k.useState(),n=k.useRef(null),a=k.useRef(t),o=k.useRef("none"),l=t?"mounted":"unmounted",[i,c]=hxt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const u=O7(n.current);o.current=i==="mounted"?u:"none"},[i]),jd(()=>{const u=n.current,p=a.current;if(p!==t){const g=o.current,b=O7(u);t?c("MOUNT"):b==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(p&&g!==b?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,c]),jd(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=b=>{const j=O7(n.current).includes(b.animationName);if(b.target===s&&j&&(c("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},g=b=>{b.target===s&&(o.current=O7(n.current))};return s.addEventListener("animationstart",g),s.addEventListener("animationcancel",f),s.addEventListener("animationend",f),()=>{p.clearTimeout(u),s.removeEventListener("animationstart",g),s.removeEventListener("animationcancel",f),s.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:k.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function O7(t){return(t==null?void 0:t.animationName)||"none"}function pxt(t){var n,a;let s=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var fxt=bwe[" useInsertionEffect ".trim().toString()]||jd;function ah({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=xxt({defaultProp:s,onChange:r}),i=t!==void 0,c=i?t:a;{const p=k.useRef(t!==void 0);k.useEffect(()=>{const f=p.current;f!==i&&console.warn(`${n} is changing from ${f?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=i},[i,n])}const u=k.useCallback(p=>{var f;if(i){const g=gxt(p)?p(t):p;g!==t&&((f=l.current)==null||f.call(l,g))}else o(p)},[i,t,o,l]);return[c,u]}function xxt({defaultProp:t,onChange:s}){const[r,n]=k.useState(t),a=k.useRef(r),o=k.useRef(s);return fxt(()=>{o.current=s},[s]),k.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function gxt(t){return typeof t=="function"}var F$e=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"}),yxt="VisuallyHidden",_de=k.forwardRef((t,s)=>e.jsx(nn.span,{...t,ref:s,style:{...F$e,...t.style}}));_de.displayName=yxt;var vxt=_de,p2e="ToastProvider",[f2e,bxt,_xt]=yO("Toast"),[z$e]=ad("Toast",[_xt]),[wxt,wde]=z$e(p2e),B$e=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,c]=k.useState(null),[u,p]=k.useState(0),f=k.useRef(!1),g=k.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${p2e}\`. Expected non-empty \`string\`.`),e.jsx(f2e.Provider,{scope:s,children:e.jsx(wxt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:c,onToastAdd:k.useCallback(()=>p(b=>b+1),[]),onToastRemove:k.useCallback(()=>p(b=>b-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:g,children:l})})};B$e.displayName=p2e;var $$e="ToastViewport",jxt=["F8"],P0e="toast.viewportPause",I0e="toast.viewportResume",q$e=k.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=jxt,label:a="Notifications ({hotkey})",...o}=t,l=wde($$e,r),i=bxt(r),c=k.useRef(null),u=k.useRef(null),p=k.useRef(null),f=k.useRef(null),g=qa(s,f,l.onViewportChange),b=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=l.toastCount>0;k.useEffect(()=>{const w=N=>{var M;n.length!==0&&n.every(L=>N[L]||N.code===L)&&((M=f.current)==null||M.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),k.useEffect(()=>{const w=c.current,N=f.current;if(_&&w&&N){const S=()=>{if(!l.isClosePausedRef.current){const O=new CustomEvent(P0e);N.dispatchEvent(O),l.isClosePausedRef.current=!0}},M=()=>{if(l.isClosePausedRef.current){const O=new CustomEvent(I0e);N.dispatchEvent(O),l.isClosePausedRef.current=!1}},L=O=>{!w.contains(O.relatedTarget)&&M()},I=()=>{w.contains(document.activeElement)||M()};return w.addEventListener("focusin",S),w.addEventListener("focusout",L),w.addEventListener("pointermove",S),w.addEventListener("pointerleave",I),window.addEventListener("blur",S),window.addEventListener("focus",M),()=>{w.removeEventListener("focusin",S),w.removeEventListener("focusout",L),w.removeEventListener("pointermove",S),w.removeEventListener("pointerleave",I),window.removeEventListener("blur",S),window.removeEventListener("focus",M)}}},[_,l.isClosePausedRef]);const j=k.useCallback(({tabbingDirection:w})=>{const S=i().map(M=>{const L=M.ref.current,I=[L,...Oxt(L)];return w==="forwards"?I:I.reverse()});return(w==="forwards"?S.reverse():S).flat()},[i]);return k.useEffect(()=>{const w=f.current;if(w){const N=S=>{var I,O,q;const M=S.altKey||S.ctrlKey||S.metaKey;if(S.key==="Tab"&&!M){const U=document.activeElement,B=S.shiftKey;if(S.target===w&&B){(I=u.current)==null||I.focus();return}const Q=j({tabbingDirection:B?"backwards":"forwards"}),ee=Q.findIndex(X=>X===U);Xfe(Q.slice(ee+1))?S.preventDefault():B?(O=u.current)==null||O.focus():(q=p.current)==null||q.focus()}};return w.addEventListener("keydown",N),()=>w.removeEventListener("keydown",N)}},[i,j]),e.jsxs(dxt,{ref:c,role:"region","aria-label":a.replace("{hotkey}",b),tabIndex:-1,style:{pointerEvents:_?void 0:"none"},children:[_&&e.jsx(L0e,{ref:u,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"forwards"});Xfe(w)}}),e.jsx(f2e.Slot,{scope:r,children:e.jsx(nn.ol,{tabIndex:-1,...o,ref:g})}),_&&e.jsx(L0e,{ref:p,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"backwards"});Xfe(w)}})]})});q$e.displayName=$$e;var U$e="ToastFocusProxy",L0e=k.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=wde(U$e,r);return e.jsx(_de,{"aria-hidden":!0,tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:l=>{var u;const i=l.relatedTarget;!((u=o.viewport)!=null&&u.contains(i))&&n()}})});L0e.displayName=U$e;var vO="Toast",Nxt="toast.swipeStart",kxt="toast.swipeMove",Sxt="toast.swipeCancel",Cxt="toast.swipeEnd",V$e=k.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,c]=ah({prop:n,defaultProp:a??!0,onChange:o,caller:vO});return e.jsx(zd,{present:r||i,children:e.jsx(Axt,{open:i,...l,ref:s,onClose:()=>c(!1),onPause:vd(t.onPause),onResume:vd(t.onResume),onSwipeStart:Ir(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ir(t.onSwipeMove,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:Ir(t.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Ir(t.onSwipeEnd,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});V$e.displayName=vO;var[Mxt,Txt]=z$e(vO,{onClose(){}}),Axt=k.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:c,onResume:u,onSwipeStart:p,onSwipeMove:f,onSwipeCancel:g,onSwipeEnd:b,..._}=t,j=wde(vO,r),[w,N]=k.useState(null),S=qa(s,X=>N(X)),M=k.useRef(null),L=k.useRef(null),I=a||j.duration,O=k.useRef(0),q=k.useRef(I),U=k.useRef(0),{onToastAdd:B,onToastRemove:V}=j,Y=vd(()=>{var ie;(w==null?void 0:w.contains(document.activeElement))&&((ie=j.viewport)==null||ie.focus()),l()}),Q=k.useCallback(X=>{!X||X===1/0||(window.clearTimeout(U.current),O.current=new Date().getTime(),U.current=window.setTimeout(Y,X))},[Y]);k.useEffect(()=>{const X=j.viewport;if(X){const ie=()=>{Q(q.current),u==null||u()},re=()=>{const oe=new Date().getTime()-O.current;q.current=q.current-oe,window.clearTimeout(U.current),c==null||c()};return X.addEventListener(P0e,re),X.addEventListener(I0e,ie),()=>{X.removeEventListener(P0e,re),X.removeEventListener(I0e,ie)}}},[j.viewport,I,c,u,Q]),k.useEffect(()=>{o&&!j.isClosePausedRef.current&&Q(I)},[o,I,j.isClosePausedRef,Q]),k.useEffect(()=>(B(),()=>V()),[B,V]);const ee=k.useMemo(()=>w?X$e(w):null,[w]);return j.viewport?e.jsxs(e.Fragment,{children:[ee&&e.jsx(Ext,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:ee}),e.jsx(Mxt,{scope:r,onClose:Y,children:yp.createPortal(e.jsx(f2e.ItemSlot,{scope:r,children:e.jsx(cxt,{asChild:!0,onEscapeKeyDown:Ir(i,()=>{j.isFocusedToastEscapeKeyDownRef.current||Y(),j.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(nn.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":j.swipeDirection,..._,ref:S,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Ir(t.onKeyDown,X=>{X.key==="Escape"&&(i==null||i(X.nativeEvent),X.nativeEvent.defaultPrevented||(j.isFocusedToastEscapeKeyDownRef.current=!0,Y()))}),onPointerDown:Ir(t.onPointerDown,X=>{X.button===0&&(M.current={x:X.clientX,y:X.clientY})}),onPointerMove:Ir(t.onPointerMove,X=>{if(!M.current)return;const ie=X.clientX-M.current.x,re=X.clientY-M.current.y,oe=!!L.current,ce=["left","right"].includes(j.swipeDirection),ge=["left","up"].includes(j.swipeDirection)?Math.min:Math.max,ye=ce?ge(0,ie):0,ue=ce?0:ge(0,re),pe=X.pointerType==="touch"?10:2,_e={x:ye,y:ue},$e={originalEvent:X,delta:_e};oe?(L.current=_e,R7(kxt,f,$e,{discrete:!1})):TAe(_e,j.swipeDirection,pe)?(L.current=_e,R7(Nxt,p,$e,{discrete:!1}),X.target.setPointerCapture(X.pointerId)):(Math.abs(ie)>pe||Math.abs(re)>pe)&&(M.current=null)}),onPointerUp:Ir(t.onPointerUp,X=>{const ie=L.current,re=X.target;if(re.hasPointerCapture(X.pointerId)&&re.releasePointerCapture(X.pointerId),L.current=null,M.current=null,ie){const oe=X.currentTarget,ce={originalEvent:X,delta:ie};TAe(ie,j.swipeDirection,j.swipeThreshold)?R7(Cxt,b,ce,{discrete:!0}):R7(Sxt,g,ce,{discrete:!0}),oe.addEventListener("click",ge=>ge.preventDefault(),{once:!0})}})})})}),j.viewport)})]}):null}),Ext=t=>{const{__scopeToast:s,children:r,...n}=t,a=wde(vO,s),[o,l]=k.useState(!1),[i,c]=k.useState(!1);return Lxt(()=>l(!0)),k.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(FA,{asChild:!0,children:e.jsx(_de,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},Pxt="ToastTitle",H$e=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(nn.div,{...n,ref:s})});H$e.displayName=Pxt;var Ixt="ToastDescription",W$e=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(nn.div,{...n,ref:s})});W$e.displayName=Ixt;var G$e="ToastAction",K$e=k.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(Y$e,{altText:r,asChild:!0,children:e.jsx(x2e,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${G$e}\`. Expected non-empty \`string\`.`),null)});K$e.displayName=G$e;var Z$e="ToastClose",x2e=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=Txt(Z$e,r);return e.jsx(Y$e,{asChild:!0,children:e.jsx(nn.button,{type:"button",...n,ref:s,onClick:Ir(t.onClick,a.onClose)})})});x2e.displayName=Z$e;var Y$e=k.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(nn.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function X$e(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Dxt(n)){const a=n.ariaHidden||n.hidden||n.style.display==="none",o=n.dataset.radixToastAnnounceExclude==="";if(!a)if(o){const l=n.dataset.radixToastAnnounceAlt;l&&s.push(l)}else s.push(...X$e(n))}}),s}function R7(t,s,r,{discrete:n}){const a=r.originalEvent.currentTarget,o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r});s&&a.addEventListener(t,s,{once:!0}),n?m2e(a,o):a.dispatchEvent(o)}var TAe=(t,s,r=0)=>{const n=Math.abs(t.x),a=Math.abs(t.y),o=n>a;return s==="left"||s==="right"?o&&n>r:!o&&a>r};function Lxt(t=()=>{}){const s=vd(t);jd(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Dxt(t){return t.nodeType===t.ELEMENT_NODE}function Oxt(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function Xfe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Rxt=B$e,Q$e=q$e,J$e=V$e,eqe=H$e,tqe=W$e,sqe=K$e,rqe=x2e;function nqe(t){var s,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(s=0;stypeof t=="boolean"?`${t}`:t===0?"0":t,EAe=Vi,pC=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return EAe(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:o}=s,l=Object.keys(a).map(u=>{const p=r==null?void 0:r[u],f=o==null?void 0:o[u];if(p===null)return null;const g=AAe(p)||AAe(f);return a[u][g]}),i=r&&Object.entries(r).reduce((u,p)=>{let[f,g]=p;return g===void 0||(u[f]=g),u},{}),c=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,p)=>{let{class:f,className:g,...b}=p;return Object.entries(b).every(_=>{let[j,w]=_;return Array.isArray(w)?w.includes({...o,...i}[j]):{...o,...i}[j]===w})?[...u,f,g]:u},[]);return EAe(t,l,c,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fxt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),aqe=(...t)=>t.filter((s,r,n)=>!!s&&s.trim()!==""&&n.indexOf(s)===r).join(" ").trim();/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var zxt={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 iqe=k.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},c)=>k.createElement("svg",{ref:c,...zxt,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:aqe("lucide",a),...i},[...l.map(([u,p])=>k.createElement(u,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z=(t,s)=>{const r=k.forwardRef(({className:n,...a},o)=>k.createElement(iqe,{ref:o,iconNode:s,className:aqe(`lucide-${Fxt(t)}`,n),...a}));return r.displayName=`${t}`,r};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _9=Z("AArrowDown",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 7v9",key:"pknjwm"}],["path",{d:"m14 12 4 4 4-4",key:"buelq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w9=Z("AArrowUp",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 16V7",key:"ty0viw"}],["path",{d:"m14 11 4-4 4 4",key:"1pu57t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j9=Z("ALargeSmall",[["path",{d:"M21 14h-5",key:"1vh23k"}],["path",{d:"M16 16v-3.5a2.5 2.5 0 0 1 5 0V16",key:"1wh10o"}],["path",{d:"M4.5 13h6",key:"dfilno"}],["path",{d:"m3 16 4.5-9 4.5 9",key:"2dxa0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N9=Z("Accessibility",[["circle",{cx:"16",cy:"4",r:"1",key:"1grugj"}],["path",{d:"m18 19 1-7-6 1",key:"r0i19z"}],["path",{d:"m5 8 3-3 5.5 3-2.36 3.5",key:"9ptxx2"}],["path",{d:"M4.24 14.5a5 5 0 0 0 6.88 6",key:"10kmtu"}],["path",{d:"M13.76 17.5a5 5 0 0 0-6.88-6",key:"2qq6rc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kh=Z("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k9=Z("AirVent",[["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12",key:"1bo8pg"}],["path",{d:"M6.6 15.6A2 2 0 1 0 10 17v-5",key:"t9h90c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S9=Z("Airplay",[["path",{d:"M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1",key:"ns4c3b"}],["path",{d:"m12 15 5 6H7Z",key:"14qnn2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G2=Z("AlarmClockCheck",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K2=Z("AlarmClockMinus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C9=Z("AlarmClockOff",[["path",{d:"M6.87 6.87a8 8 0 1 0 11.26 11.26",key:"3on8tj"}],["path",{d:"M19.9 14.25a8 8 0 0 0-9.15-9.15",key:"15ghsc"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.26 18.67 4 21",key:"yzmioq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M4 4 2 6",key:"1ycko6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z2=Z("AlarmClockPlus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M9=Z("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T9=Z("AlarmSmoke",[["path",{d:"M11 21c0-2.5 2-2.5 2-5",key:"1sicvv"}],["path",{d:"M16 21c0-2.5 2-2.5 2-5",key:"1o3eny"}],["path",{d:"m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8",key:"1bvca4"}],["path",{d:"M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z",key:"x3qr1j"}],["path",{d:"M6 21c0-2.5 2-2.5 2-5",key:"i3w1gp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A9=Z("Album",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["polyline",{points:"11 3 11 11 14 8 17 11 17 3",key:"1wcwz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E9=Z("AlignCenterHorizontal",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P9=Z("AlignCenterVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W4=Z("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I9=Z("AlignEndHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L9=Z("AlignEndVertical",[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D9=Z("AlignHorizontalDistributeCenter",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O9=Z("AlignHorizontalDistributeEnd",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M10 2v20",key:"uyc634"}],["path",{d:"M20 2v20",key:"1tx262"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R9=Z("AlignHorizontalDistributeStart",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M4 2v20",key:"gtpd5x"}],["path",{d:"M14 2v20",key:"tg6bpw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F9=Z("AlignHorizontalJustifyCenter",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z9=Z("AlignHorizontalJustifyEnd",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"12",y:"7",rx:"2",key:"1ht384"}],["path",{d:"M22 2v20",key:"40qfg1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B9=Z("AlignHorizontalJustifyStart",[["rect",{width:"6",height:"14",x:"6",y:"5",rx:"2",key:"hsirpf"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $9=Z("AlignHorizontalSpaceAround",[["rect",{width:"6",height:"10",x:"9",y:"7",rx:"2",key:"yn7j0q"}],["path",{d:"M4 22V2",key:"tsjzd3"}],["path",{d:"M20 22V2",key:"1bnhr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q9=Z("AlignHorizontalSpaceBetween",[["rect",{width:"6",height:"14",x:"3",y:"5",rx:"2",key:"j77dae"}],["rect",{width:"6",height:"10",x:"15",y:"7",rx:"2",key:"bq30hj"}],["path",{d:"M3 2v20",key:"1d2pfg"}],["path",{d:"M21 2v20",key:"p059bm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U9=Z("AlignJustify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G4=Z("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K4=Z("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V9=Z("AlignStartHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H9=Z("AlignStartVertical",[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W9=Z("AlignVerticalDistributeCenter",[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G9=Z("AlignVerticalDistributeEnd",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K9=Z("AlignVerticalDistributeStart",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M2 4h20",key:"mda7wb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z9=Z("AlignVerticalJustifyCenter",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y9=Z("AlignVerticalJustifyEnd",[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X9=Z("AlignVerticalJustifyStart",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q9=Z("AlignVerticalSpaceAround",[["rect",{width:"10",height:"6",x:"7",y:"9",rx:"2",key:"b1zbii"}],["path",{d:"M22 20H2",key:"1p1f7z"}],["path",{d:"M22 4H2",key:"1b7qnq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J9=Z("AlignVerticalSpaceBetween",[["rect",{width:"14",height:"6",x:"5",y:"15",rx:"2",key:"1w91an"}],["rect",{width:"10",height:"6",x:"7",y:"3",rx:"2",key:"17wqzy"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M2 3h20",key:"91anmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eB=Z("Ambulance",[["path",{d:"M10 10H6",key:"1bsnug"}],["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.28a1 1 0 0 0-.684-.948l-1.923-.641a1 1 0 0 1-.578-.502l-1.539-3.076A1 1 0 0 0 16.382 8H14",key:"lrkjwd"}],["path",{d:"M8 8v4",key:"1fwk8c"}],["path",{d:"M9 18h6",key:"x1upvd"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tB=Z("Ampersand",[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sB=Z("Ampersands",[["path",{d:"M10 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"12lh1k"}],["path",{d:"M22 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"173c68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rB=Z("Amphora",[["path",{d:"M10 2v5.632c0 .424-.272.795-.653.982A6 6 0 0 0 6 14c.006 4 3 7 5 8",key:"1h8rid"}],["path",{d:"M10 5H8a2 2 0 0 0 0 4h.68",key:"3ezsi6"}],["path",{d:"M14 2v5.632c0 .424.272.795.652.982A6 6 0 0 1 18 14c0 4-3 7-5 8",key:"yt6q09"}],["path",{d:"M14 5h2a2 2 0 0 1 0 4h-.68",key:"8f95yk"}],["path",{d:"M18 22H6",key:"mg6kv4"}],["path",{d:"M9 2h6",key:"1jrp98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nB=Z("Anchor",[["path",{d:"M12 22V8",key:"qkxhtm"}],["path",{d:"M5 12H2a10 10 0 0 0 20 0h-3",key:"1hv3nh"}],["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aB=Z("Angry",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["path",{d:"M7.5 8 10 9",key:"olxxln"}],["path",{d:"m14 9 2.5-1",key:"1j6cij"}],["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iB=Z("Annoyed",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M14 9h2",key:"116p9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oB=Z("Antenna",[["path",{d:"M2 12 7 2",key:"117k30"}],["path",{d:"m7 12 5-10",key:"1tvx22"}],["path",{d:"m12 12 5-10",key:"ev1o1a"}],["path",{d:"m17 12 5-10",key:"1e4ti3"}],["path",{d:"M4.5 7h15",key:"vlsxkz"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lB=Z("Anvil",[["path",{d:"M7 10H6a4 4 0 0 1-4-4 1 1 0 0 1 1-1h4",key:"1hjpb6"}],["path",{d:"M7 5a1 1 0 0 1 1-1h13a1 1 0 0 1 1 1 7 7 0 0 1-7 7H8a1 1 0 0 1-1-1z",key:"1qn45f"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M5 20a3 3 0 0 1 3-3h8a3 3 0 0 1 3 3 1 1 0 0 1-1 1H6a1 1 0 0 1-1-1",key:"1fi4x8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cB=Z("Aperture",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dB=Z("AppWindowMac",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M14 8h.01",key:"1primd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HI=Z("AppWindow",[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uB=Z("Apple",[["path",{d:"M12 20.94c1.5 0 2.75 1.06 4 1.06 3 0 6-8 6-12.22A4.91 4.91 0 0 0 17 5c-2.22 0-4 1.44-5 2-1-.56-2.78-2-5-2a4.9 4.9 0 0 0-5 4.78C2 14 5 22 8 22c1.25 0 2.5-1.06 4-1.06Z",key:"3s7exb"}],["path",{d:"M10 2c1 .5 2 2 2 5",key:"fcco2y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WI=Z("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hB=Z("ArchiveX",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"m9.5 17 5-5",key:"nakeu6"}],["path",{d:"m9.5 12 5 5",key:"1hccrj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kM=Z("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mB=Z("Armchair",[["path",{d:"M19 9V6a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v3",key:"irtipd"}],["path",{d:"M3 16a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"1qyhux"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pB=Z("ArrowBigDownDash",[["path",{d:"M15 5H9",key:"1tp3ed"}],["path",{d:"M15 9v3h4l-7 7-7-7h4V9z",key:"ncdc4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fB=Z("ArrowBigDown",[["path",{d:"M15 6v6h4l-7 7-7-7h4V6h6z",key:"1thax2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xB=Z("ArrowBigLeftDash",[["path",{d:"M19 15V9",key:"1hci5f"}],["path",{d:"M15 15h-3v4l-7-7 7-7v4h3v6z",key:"16tjna"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gB=Z("ArrowBigLeft",[["path",{d:"M18 15h-6v4l-7-7 7-7v4h6v6z",key:"lbrdak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yB=Z("ArrowBigRightDash",[["path",{d:"M5 9v6",key:"158jrl"}],["path",{d:"M9 9h3V5l7 7-7 7v-4H9V9z",key:"1sg2xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vB=Z("ArrowBigRight",[["path",{d:"M6 9h6V5l7 7-7 7v-4H6V9z",key:"7fvt9c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bB=Z("ArrowBigUpDash",[["path",{d:"M9 19h6",key:"456am0"}],["path",{d:"M9 15v-3H5l7-7 7 7h-4v3H9z",key:"1r2uve"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _B=Z("ArrowBigUp",[["path",{d:"M9 18v-6H5l7-7 7 7h-4v6H9z",key:"1x06kx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wB=Z("ArrowDown01",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jB=Z("ArrowDown10",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y2=Z("ArrowDownAZ",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NB=Z("ArrowDownFromLine",[["path",{d:"M19 3H5",key:"1236rx"}],["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m6 15 6 6 6-6",key:"h15q88"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kB=Z("ArrowDownLeft",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SB=Z("ArrowDownNarrowWide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GI=Z("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CB=Z("ArrowDownToDot",[["path",{d:"M12 2v14",key:"jyx4ut"}],["path",{d:"m19 9-7 7-7-7",key:"1oe3oy"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MB=Z("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TB=Z("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X2=Z("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q2=Z("ArrowDownZA",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wh=Z("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AB=Z("ArrowLeftFromLine",[["path",{d:"m9 6-6 6 6 6",key:"7v63n9"}],["path",{d:"M3 12h14",key:"13k4hi"}],["path",{d:"M21 19V5",key:"b4bplr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EB=Z("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PB=Z("ArrowLeftToLine",[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ja=Z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IB=Z("ArrowRightFromLine",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s1=Z("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LB=Z("ArrowRightToLine",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qa=Z("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DB=Z("ArrowUp01",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OB=Z("ArrowUp10",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J2=Z("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bd=Z("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RB=Z("ArrowUpFromDot",[["path",{d:"m5 9 7-7 7 7",key:"1hw5ic"}],["path",{d:"M12 16V2",key:"ywoabb"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FB=Z("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zB=Z("ArrowUpLeft",[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ej=Z("ArrowUpNarrowWide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KI=Z("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BB=Z("ArrowUpToLine",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $B=Z("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tj=Z("ArrowUpZA",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ku=Z("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qB=Z("ArrowsUpFromLine",[["path",{d:"m4 6 3-3 3 3",key:"9aidw8"}],["path",{d:"M7 17V3",key:"19qxw1"}],["path",{d:"m14 6 3-3 3 3",key:"6iy689"}],["path",{d:"M17 17V3",key:"o0fmgi"}],["path",{d:"M4 21h16",key:"1h09gz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UB=Z("Asterisk",[["path",{d:"M12 6v12",key:"1vza4d"}],["path",{d:"M17.196 9 6.804 15",key:"1ah31z"}],["path",{d:"m6.804 9 10.392 6",key:"1b6pxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VB=Z("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HB=Z("Atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WB=Z("AudioLines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GB=Z("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nc=Z("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KB=Z("Axe",[["path",{d:"m14 12-8.5 8.5a2.12 2.12 0 1 1-3-3L11 9",key:"csbz4o"}],["path",{d:"M15 13 9 7l4-4 6 6h3a8 8 0 0 1-7 7z",key:"113wfo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sj=Z("Axis3d",[["path",{d:"M4 4v16h16",key:"1s015l"}],["path",{d:"m4 20 7-7",key:"17qe9y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZB=Z("Baby",[["path",{d:"M9 12h.01",key:"157uk2"}],["path",{d:"M15 12h.01",key:"1k8ypt"}],["path",{d:"M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5",key:"1u7htd"}],["path",{d:"M19 6.3a9 9 0 0 1 1.8 3.9 2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1",key:"5yv0yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YB=Z("Backpack",[["path",{d:"M4 10a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z",key:"1ol0lm"}],["path",{d:"M8 10h8",key:"c7uz4u"}],["path",{d:"M8 18h8",key:"1no2b1"}],["path",{d:"M8 22v-6a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v6",key:"1fr6do"}],["path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2",key:"donm21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XB=Z("BadgeAlert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QB=Z("BadgeCent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M15.4 10a4 4 0 1 0 0 4",key:"2eqtx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rj=Z("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JB=Z("BadgeDollarSign",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e$=Z("BadgeEuro",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M7 12h5",key:"gblrwe"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t$=Z("BadgeHelp",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s$=Z("BadgeIndianRupee",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 8h8",key:"1bis0t"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m13 17-5-1h1a4 4 0 0 0 0-8",key:"nu2bwa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r$=Z("BadgeInfo",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"16",y2:"12",key:"1y1yb1"}],["line",{x1:"12",x2:"12.01",y1:"8",y2:"8",key:"110wyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n$=Z("BadgeJapaneseYen",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 8 3 3v7",key:"17yadx"}],["path",{d:"m12 11 3-3",key:"p4cfq1"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M9 16h6",key:"8wimt3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a$=Z("BadgeMinus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i$=Z("BadgePercent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o$=Z("BadgePlus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"16",key:"10p56q"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l$=Z("BadgePoundSterling",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 12h4",key:"qz6y1c"}],["path",{d:"M10 16V9.5a2.5 2.5 0 0 1 5 0",key:"3mlbjk"}],["path",{d:"M8 16h7",key:"sbedsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c$=Z("BadgeRussianRuble",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9 16h5",key:"1syiyw"}],["path",{d:"M9 12h5a2 2 0 1 0 0-4h-3v9",key:"1ge9c1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d$=Z("BadgeSwissFranc",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M11 17V8h4",key:"1bfq6y"}],["path",{d:"M11 12h3",key:"2eqnfz"}],["path",{d:"M9 16h4",key:"1skf3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u$=Z("BadgeX",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h$=Z("Badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m$=Z("BaggageClaim",[["path",{d:"M22 18H6a2 2 0 0 1-2-2V7a2 2 0 0 0-2-2",key:"4irg2o"}],["path",{d:"M17 14V4a2 2 0 0 0-2-2h-1a2 2 0 0 0-2 2v10",key:"14fcyx"}],["rect",{width:"13",height:"8",x:"8",y:"6",rx:"1",key:"o6oiis"}],["circle",{cx:"18",cy:"20",r:"2",key:"t9985n"}],["circle",{cx:"9",cy:"20",r:"2",key:"e5v82j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZI=Z("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p$=Z("Banana",[["path",{d:"M4 13c3.5-2 8-2 10 2a5.5 5.5 0 0 1 8 5",key:"1cscit"}],["path",{d:"M5.15 17.89c5.52-1.52 8.65-6.89 7-12C11.55 4 11.5 2 13 2c3.22 0 5 5.5 5 8 0 6.5-4.2 12-10.49 12C5.11 22 2 22 2 20c0-1.5 1.14-1.55 3.15-2.11Z",key:"1y1nbv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f$=Z("Bandage",[["path",{d:"M10 10.01h.01",key:"1e9xi7"}],["path",{d:"M10 14.01h.01",key:"ac23bv"}],["path",{d:"M14 10.01h.01",key:"2wfrvf"}],["path",{d:"M14 14.01h.01",key:"8tw8yn"}],["path",{d:"M18 6v11.5",key:"dkbidh"}],["path",{d:"M6 6v12",key:"vkc79e"}],["rect",{x:"2",y:"6",width:"20",height:"12",rx:"2",key:"1wpnh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x$=Z("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g$=Z("Barcode",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M8 5v14",key:"1ybrkv"}],["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"M17 5v14",key:"ycjyhj"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y$=Z("Baseline",[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ju=Z("Bath",[["path",{d:"M10 4 8 6",key:"1rru8s"}],["path",{d:"M17 19v2",key:"ts1sot"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M7 19v2",key:"12npes"}],["path",{d:"M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5",key:"14ym8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v$=Z("BatteryCharging",[["path",{d:"M15 7h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1sdynx"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h1",key:"1gkd3k"}],["path",{d:"m11 7-3 5h4l-3 5",key:"b4a64w"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b$=Z("BatteryFull",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"13",key:"c6fn6x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _$=Z("BatteryLow",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w$=Z("BatteryMedium",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j$=Z("BatteryWarning",[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 7h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1x5o8m"}],["path",{d:"M22 11v2",key:"1wo06k"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"1mdjgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N$=Z("Battery",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k$=Z("Beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S$=Z("BeanOff",[["path",{d:"M9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22a13.96 13.96 0 0 0 9.9-4.1",key:"bq3udt"}],["path",{d:"M10.75 5.093A6 6 0 0 1 22 8c0 2.411-.61 4.68-1.683 6.66",key:"17ccse"}],["path",{d:"M5.341 10.62a4 4 0 0 0 6.487 1.208M10.62 5.341a4.015 4.015 0 0 1 2.039 2.04",key:"18zqgq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C$=Z("Bean",[["path",{d:"M10.165 6.598C9.954 7.478 9.64 8.36 9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22c7.732 0 14-6.268 14-14a6 6 0 0 0-11.835-1.402Z",key:"1tvzk7"}],["path",{d:"M5.341 10.62a4 4 0 1 0 5.279-5.28",key:"2cyri2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z4=Z("BedDouble",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M$=Z("BedSingle",[["path",{d:"M3 20v-8a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v8",key:"1wm6mi"}],["path",{d:"M5 10V6a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v4",key:"4k93s5"}],["path",{d:"M3 18h18",key:"1h113x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Im=Z("Bed",[["path",{d:"M2 4v16",key:"vw9hq8"}],["path",{d:"M2 8h18a2 2 0 0 1 2 2v10",key:"1dgv2r"}],["path",{d:"M2 17h20",key:"18nfp3"}],["path",{d:"M6 8v9",key:"1yriud"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T$=Z("Beef",[["circle",{cx:"12.5",cy:"8.5",r:"2.5",key:"9738u8"}],["path",{d:"M12.5 2a6.5 6.5 0 0 0-6.22 4.6c-1.1 3.13-.78 3.9-3.18 6.08A3 3 0 0 0 5 18c4 0 8.4-1.8 11.4-4.3A6.5 6.5 0 0 0 12.5 2Z",key:"o0f6za"}],["path",{d:"m18.5 6 2.19 4.5a6.48 6.48 0 0 1 .31 2 6.49 6.49 0 0 1-2.6 5.2C15.4 20.2 11 22 7 22a3 3 0 0 1-2.68-1.66L2.4 16.5",key:"k7p6i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A$=Z("BeerOff",[["path",{d:"M13 13v5",key:"igwfh0"}],["path",{d:"M17 11.47V8",key:"16yw0g"}],["path",{d:"M17 11h1a3 3 0 0 1 2.745 4.211",key:"1xbt65"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-3",key:"c55o3e"}],["path",{d:"M7.536 7.535C6.766 7.649 6.154 8 5.5 8a2.5 2.5 0 0 1-1.768-4.268",key:"1ydug7"}],["path",{d:"M8.727 3.204C9.306 2.767 9.885 2 11 2c1.56 0 2 1.5 3 1.5s1.72-.5 2.5-.5a1 1 0 1 1 0 5c-.78 0-1.5-.5-2.5-.5a3.149 3.149 0 0 0-.842.12",key:"q81o7q"}],["path",{d:"M9 14.6V18",key:"20ek98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E$=Z("Beer",[["path",{d:"M17 11h1a3 3 0 0 1 0 6h-1",key:"1yp76v"}],["path",{d:"M9 12v6",key:"1u1cab"}],["path",{d:"M13 12v6",key:"1sugkk"}],["path",{d:"M14 7.5c-1 0-1.44.5-3 .5s-2-.5-3-.5-1.72.5-2.5.5a2.5 2.5 0 0 1 0-5c.78 0 1.57.5 2.5.5S9.44 2 11 2s2 1.5 3 1.5 1.72-.5 2.5-.5a2.5 2.5 0 0 1 0 5c-.78 0-1.5-.5-2.5-.5Z",key:"1510fo"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"19jb7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P$=Z("BellDot",[["path",{d:"M19.4 14.9C20.2 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 .7 0 1.3.1 1.9.3",key:"xcehk"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["circle",{cx:"18",cy:"8",r:"3",key:"1g0gzu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I$=Z("BellElectric",[["path",{d:"M18.8 4A6.3 8.7 0 0 1 20 9",key:"xve1fh"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["rect",{width:"10",height:"6",x:"4",y:"16",rx:"2",key:"17f3te"}],["path",{d:"M14 19c3 0 4.6-1.6 4.6-1.6",key:"n7odp6"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L$=Z("BellMinus",[["path",{d:"M18.4 12c.8 3.8 2.6 5 2.6 5H3s3-2 3-9c0-3.3 2.7-6 6-6 1.8 0 3.4.8 4.5 2",key:"eck70s"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r1=Z("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D$=Z("BellPlus",[["path",{d:"M19.3 14.8C20.1 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 1 0 1.9.2 2.8.7",key:"guizqy"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}],["path",{d:"M18 5v6",key:"g5ayrv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O$=Z("BellRing",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lm=Z("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nj=Z("BetweenHorizontalEnd",[["rect",{width:"13",height:"7",x:"3",y:"3",rx:"1",key:"11xb64"}],["path",{d:"m22 15-3-3 3-3",key:"26chmm"}],["rect",{width:"13",height:"7",x:"3",y:"14",rx:"1",key:"k6ky7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aj=Z("BetweenHorizontalStart",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R$=Z("BetweenVerticalEnd",[["rect",{width:"7",height:"13",x:"3",y:"3",rx:"1",key:"1fdu0f"}],["path",{d:"m9 22 3-3 3 3",key:"17z65a"}],["rect",{width:"7",height:"13",x:"14",y:"3",rx:"1",key:"1squn4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F$=Z("BetweenVerticalStart",[["rect",{width:"7",height:"13",x:"3",y:"8",rx:"1",key:"1fjrkv"}],["path",{d:"m15 2-3 3-3-3",key:"1uh6eb"}],["rect",{width:"7",height:"13",x:"14",y:"8",rx:"1",key:"w3fjg8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z$=Z("BicepsFlexed",[["path",{d:"M12.409 13.017A5 5 0 0 1 22 15c0 3.866-4 7-9 7-4.077 0-8.153-.82-10.371-2.462-.426-.316-.631-.832-.62-1.362C2.118 12.723 2.627 2 10 2a3 3 0 0 1 3 3 2 2 0 0 1-2 2c-1.105 0-1.64-.444-2-1",key:"1pmlyh"}],["path",{d:"M15 14a5 5 0 0 0-7.584 2",key:"5rb254"}],["path",{d:"M9.964 6.825C8.019 7.977 9.5 13 8 15",key:"kbvsx9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B$=Z("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $$=Z("Binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q$=Z("Binoculars",[["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3",key:"3apit1"}],["path",{d:"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z",key:"rhpgnw"}],["path",{d:"M 22 16 L 2 16",key:"14lkq7"}],["path",{d:"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z",key:"104b3k"}],["path",{d:"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3",key:"14fczp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U$=Z("Biohazard",[["circle",{cx:"12",cy:"11.9",r:"2",key:"e8h31w"}],["path",{d:"M6.7 3.4c-.9 2.5 0 5.2 2.2 6.7C6.5 9 3.7 9.6 2 11.6",key:"17bolr"}],["path",{d:"m8.9 10.1 1.4.8",key:"15ezny"}],["path",{d:"M17.3 3.4c.9 2.5 0 5.2-2.2 6.7 2.4-1.2 5.2-.6 6.9 1.5",key:"wtwa5u"}],["path",{d:"m15.1 10.1-1.4.8",key:"1r0b28"}],["path",{d:"M16.7 20.8c-2.6-.4-4.6-2.6-4.7-5.3-.2 2.6-2.1 4.8-4.7 5.2",key:"m7qszh"}],["path",{d:"M12 13.9v1.6",key:"zfyyim"}],["path",{d:"M13.5 5.4c-1-.2-2-.2-3 0",key:"1bi9q0"}],["path",{d:"M17 16.4c.7-.7 1.2-1.6 1.5-2.5",key:"1rhjqw"}],["path",{d:"M5.5 13.9c.3.9.8 1.8 1.5 2.5",key:"8gsud3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V$=Z("Bird",[["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20",key:"oj1oa8"}],["path",{d:"m20 7 2 .5-2 .5",key:"12nv4d"}],["path",{d:"M10 18v3",key:"1yea0a"}],["path",{d:"M14 17.75V21",key:"1pymcb"}],["path",{d:"M7 18a6 6 0 0 0 3.84-10.61",key:"1npnn0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H$=Z("Bitcoin",[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W$=Z("Blend",[["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["circle",{cx:"15",cy:"15",r:"7",key:"19ennj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G$=Z("Blinds",[["path",{d:"M3 3h18",key:"o7r712"}],["path",{d:"M20 7H8",key:"gd2fo2"}],["path",{d:"M20 11H8",key:"1ynp89"}],["path",{d:"M10 19h10",key:"19hjk5"}],["path",{d:"M8 15h12",key:"1yqzne"}],["path",{d:"M4 3v14",key:"fggqzn"}],["circle",{cx:"4",cy:"19",r:"2",key:"p3m9r0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K$=Z("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z$=Z("BluetoothConnected",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["line",{x1:"18",x2:"21",y1:"12",y2:"12",key:"1rsjjs"}],["line",{x1:"3",x2:"6",y1:"12",y2:"12",key:"11yl8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y$=Z("BluetoothOff",[["path",{d:"m17 17-5 5V12l-5 5",key:"v5aci6"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M14.5 9.5 17 7l-5-5v4.5",key:"1kddfz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X$=Z("BluetoothSearching",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["path",{d:"M20.83 14.83a4 4 0 0 0 0-5.66",key:"k8tn1j"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q$=Z("Bluetooth",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y4=Z("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J$=Z("Bolt",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eq=Z("Bomb",[["circle",{cx:"11",cy:"13",r:"9",key:"hd149"}],["path",{d:"M14.35 4.65 16.3 2.7a2.41 2.41 0 0 1 3.4 0l1.6 1.6a2.4 2.4 0 0 1 0 3.4l-1.95 1.95",key:"jp4j1b"}],["path",{d:"m22 2-1.5 1.5",key:"ay92ug"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tq=Z("Bone",[["path",{d:"M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",key:"w610uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sq=Z("BookA",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m8 13 4-7 4 7",key:"4rari8"}],["path",{d:"M9.1 11h5.7",key:"1gkovt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rq=Z("BookAudio",[["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8v3",key:"gejaml"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 8v3",key:"1qzp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nq=Z("BookCheck",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 9.5 2 2 4-4",key:"1dth82"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aq=Z("BookCopy",[["path",{d:"M2 16V4a2 2 0 0 1 2-2h11",key:"spzkk5"}],["path",{d:"M22 18H11a2 2 0 1 0 0 4h10.5a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5H11a2 2 0 0 0-2 2v12",key:"1wz07i"}],["path",{d:"M5 14H4a2 2 0 1 0 0 4h1",key:"16gqf9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ij=Z("BookDashed",[["path",{d:"M12 17h2",key:"13u4lk"}],["path",{d:"M12 22h2",key:"kn7ki6"}],["path",{d:"M12 2h2",key:"cvn524"}],["path",{d:"M18 22h1a1 1 0 0 0 1-1",key:"w6gbqz"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v1",key:"1vpra5"}],["path",{d:"M20 15v2h-2",key:"fph276"}],["path",{d:"M20 8v3",key:"deu0bs"}],["path",{d:"M4 11V9",key:"v3xsx8"}],["path",{d:"M4 19.5V15",key:"6gr39e"}],["path",{d:"M4 5v-.5A2.5 2.5 0 0 1 6.5 2H8",key:"wywhs9"}],["path",{d:"M8 22H6.5a1 1 0 0 1 0-5H8",key:"1cu73q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iq=Z("BookDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3 3 3-3",key:"zt5b4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oq=Z("BookHeadphones",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 12v-2a4 4 0 0 1 8 0v2",key:"1vsqkj"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lq=Z("BookHeart",[["path",{d:"M16 8.2A2.22 2.22 0 0 0 13.8 6c-.8 0-1.4.3-1.8.9-.4-.6-1-.9-1.8-.9A2.22 2.22 0 0 0 8 8.2c0 .6.3 1.2.7 1.6A226.652 226.652 0 0 0 12 13a404 404 0 0 0 3.3-3.1 2.413 2.413 0 0 0 .7-1.7",key:"1t75a8"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cq=Z("BookImage",[["path",{d:"m20 13.7-2.1-2.1a2 2 0 0 0-2.8 0L9.7 17",key:"q6ojf0"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"10",cy:"8",r:"2",key:"2qkj4p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dq=Z("BookKey",[["path",{d:"m19 3 1 1",key:"ze14oc"}],["path",{d:"m20 2-4.5 4.5",key:"1sppr8"}],["path",{d:"M20 8v13a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1ocbpn"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H14",key:"1gfsgw"}],["circle",{cx:"14",cy:"8",r:"2",key:"u49eql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uq=Z("BookLock",[["path",{d:"M18 6V4a2 2 0 1 0-4 0v2",key:"1aquzs"}],["path",{d:"M20 15v6a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1rkj32"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H10",key:"18wgow"}],["rect",{x:"12",y:"6",width:"8",height:"5",rx:"1",key:"73l30o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hq=Z("BookMarked",[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mq=Z("BookMinus",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pq=Z("BookOpenCheck",[["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m16 12 2 2 4-4",key:"mdajum"}],["path",{d:"M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3",key:"8arnkb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fq=Z("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sh=Z("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xq=Z("BookPlus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gq=Z("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yq=Z("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vq=Z("BookUp2",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"161d7n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2",key:"1lorq7"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bq=Z("BookUp",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _q=Z("BookUser",[["path",{d:"M15 13a3 3 0 1 0-6 0",key:"10j68g"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wq=Z("BookX",[["path",{d:"m14.5 7-5 5",key:"dy991v"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9.5 7 5 5",key:"s45iea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jq=Z("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nq=Z("BookmarkCheck",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kq=Z("BookmarkMinus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YI=Z("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sq=Z("BookmarkX",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kx=Z("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cq=Z("BoomBox",[["path",{d:"M4 9V5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"vvzvr1"}],["path",{d:"M8 8v1",key:"xcqmfk"}],["path",{d:"M12 8v1",key:"1rj8u4"}],["path",{d:"M16 8v1",key:"1q12zr"}],["rect",{width:"20",height:"12",x:"2",y:"9",rx:"2",key:"igpb89"}],["circle",{cx:"8",cy:"15",r:"2",key:"fa4a8s"}],["circle",{cx:"16",cy:"15",r:"2",key:"14c3ya"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mq=Z("BotMessageSquare",[["path",{d:"M12 6V2H8",key:"1155em"}],["path",{d:"m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z",key:"w2lp3e"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M9 11v2",key:"1ueba0"}],["path",{d:"M15 11v2",key:"i11awn"}],["path",{d:"M20 12h2",key:"1q8mjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tq=Z("BotOff",[["path",{d:"M13.67 8H18a2 2 0 0 1 2 2v4.33",key:"7az073"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}],["path",{d:"M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586",key:"s09a7a"}],["path",{d:"M9 13v2",key:"rq6x2g"}],["path",{d:"M9.67 4H12v2.33",key:"110xot"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SM=Z("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aq=Z("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eq=Z("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oj=Z("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pq=Z("Brackets",[["path",{d:"M16 3h3v18h-3",key:"1yor1f"}],["path",{d:"M8 21H5V3h3",key:"1qrfwo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iq=Z("BrainCircuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lq=Z("BrainCog",[["path",{d:"M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588 4 4 0 0 0 7.636 2.106 3.2 3.2 0 0 0 .164-.546c.028-.13.306-.13.335 0a3.2 3.2 0 0 0 .163.546 4 4 0 0 0 7.636-2.106 4 4 0 0 0 .556-6.588 4 4 0 0 0-2.526-5.77A3 3 0 1 0 12 5",key:"1kgmhc"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m15.7 10.4-.9.4",key:"ayzo6p"}],["path",{d:"m9.2 13.2-.9.4",key:"1uzb3g"}],["path",{d:"m13.6 15.7-.4-.9",key:"11ifqf"}],["path",{d:"m10.8 9.2-.4-.9",key:"1pmk2v"}],["path",{d:"m15.7 13.5-.9-.4",key:"7ng02m"}],["path",{d:"m9.2 10.9-.9-.4",key:"1x66zd"}],["path",{d:"m10.5 15.7.4-.9",key:"3js94g"}],["path",{d:"m13.1 9.2.4-.9",key:"18n7mc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XI=Z("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dq=Z("BrickWall",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 9v6",key:"199k2o"}],["path",{d:"M16 15v6",key:"8rj2es"}],["path",{d:"M16 3v6",key:"1j6rpj"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 15v6",key:"1stoo3"}],["path",{d:"M8 3v6",key:"vlvjmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oq=Z("BriefcaseBusiness",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M22 13a18.15 18.15 0 0 1-20 0",key:"12hx5q"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rq=Z("BriefcaseConveyorBelt",[["path",{d:"M10 20v2",key:"1n8e1g"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M18 20v2",key:"10uadw"}],["path",{d:"M21 20H3",key:"kdqkdp"}],["path",{d:"M6 20v2",key:"a9bc87"}],["path",{d:"M8 16V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v12",key:"17n9tx"}],["rect",{x:"4",y:"6",width:"16",height:"10",rx:"2",key:"1097i5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fq=Z("BriefcaseMedical",[["path",{d:"M12 11v4",key:"a6ujw6"}],["path",{d:"M14 13h-4",key:"1pl8zg"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M18 6v14",key:"1mu4gy"}],["path",{d:"M6 6v14",key:"1s15cj"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gh=Z("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zq=Z("BringToFront",[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2",key:"yj20xf"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2",key:"1ltk23"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2",key:"1q24h9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bq=Z("Brush",[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08",key:"1styjt"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z",key:"z0l1mu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $q=Z("BugOff",[["path",{d:"M15 7.13V6a3 3 0 0 0-5.14-2.1L8 2",key:"vl8zik"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M22 13h-4v-2a4 4 0 0 0-4-4h-1.3",key:"1ou0bd"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7.7 7.7A4 4 0 0 0 6 11v3a6 6 0 0 0 11.13 3.13",key:"1njkjs"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qq=Z("BugPlay",[["path",{d:"M12.765 21.522a.5.5 0 0 1-.765-.424v-8.196a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"17shqo"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M18 11a4 4 0 0 0-4-4h-4a4 4 0 0 0-4 4v3a6.1 6.1 0 0 0 2 4.5",key:"1tjixy"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uq=Z("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ka=Z("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X4=Z("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vq=Z("BusFront",[["path",{d:"M4 6 2 7",key:"1mqr15"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"m22 7-2-1",key:"1umjhc"}],["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 21v-2",key:"sqyl04"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hq=Z("Bus",[["path",{d:"M8 6v6",key:"18i7km"}],["path",{d:"M15 6v6",key:"1sg6z9"}],["path",{d:"M2 12h19.6",key:"de5uta"}],["path",{d:"M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3",key:"1wwztk"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}],["path",{d:"M9 18h5",key:"lrx6i"}],["circle",{cx:"16",cy:"18",r:"2",key:"1v4tcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wq=Z("CableCar",[["path",{d:"M10 3h.01",key:"lbucoy"}],["path",{d:"M14 2h.01",key:"1k8aa1"}],["path",{d:"m2 9 20-5",key:"1kz0j5"}],["path",{d:"M12 12V6.5",key:"1vbrij"}],["rect",{width:"16",height:"10",x:"4",y:"12",rx:"3",key:"if91er"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gq=Z("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kq=Z("CakeSlice",[["circle",{cx:"9",cy:"7",r:"2",key:"1305pl"}],["path",{d:"M7.2 7.9 3 11v9c0 .6.4 1 1 1h16c.6 0 1-.4 1-1v-9c0-2-3-6-7-8l-3.6 2.6",key:"xle13f"}],["path",{d:"M16 13H3",key:"1wpj08"}],["path",{d:"M16 17H3",key:"3lvfcd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ch=Z("Cake",[["path",{d:"M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8",key:"1w3rig"}],["path",{d:"M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1",key:"n2jgmb"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M7 8v3",key:"1qtyvj"}],["path",{d:"M12 8v3",key:"hwp4zt"}],["path",{d:"M17 8v3",key:"1i6e5u"}],["path",{d:"M7 4h.01",key:"1bh4kh"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M17 4h.01",key:"1upcoc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QI=Z("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zq=Z("Calendar1",[["path",{d:"M11 14h1v4",key:"fy54vd"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yq=Z("CalendarArrowDown",[["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 14v8",key:"irew45"}],["path",{d:"M21 11.354V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.343",key:"bse4f3"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xq=Z("CalendarArrowUp",[["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 22v-8",key:"su0gjh"}],["path",{d:"M21 11.343V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h9",key:"1exg90"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qq=Z("CalendarCheck2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 14V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"bce9hv"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JI=Z("CalendarCheck",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eL=Z("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jq=Z("CalendarCog",[["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"M21 10.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"11kmuh"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Od=Z("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eU=Z("CalendarFold",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 17V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11Z",key:"kg77oy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M15 22v-4a2 2 0 0 1 2-2h4",key:"1gnbqr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tU=Z("CalendarHeart",[["path",{d:"M3 10h18V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7",key:"136lmk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21.29 14.7a2.43 2.43 0 0 0-2.65-.52c-.3.12-.57.3-.8.53l-.34.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L17.5 22l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1t7hil"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sU=Z("CalendarMinus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rU=Z("CalendarMinus",[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 15V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1scpom"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tL=Z("CalendarOff",[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nU=Z("CalendarPlus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}],["path",{d:"M12 14v4",key:"1thi36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R_=Z("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aU=Z("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iU=Z("CalendarSearch",[["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 11.75V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.25",key:"1jrsq6"}],["path",{d:"m22 22-1.875-1.875",key:"13zax7"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oU=Z("CalendarSync",[["path",{d:"M11 10v4h4",key:"172dkj"}],["path",{d:"m11 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"vu0qm5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m21 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"1qgeyt"}],["path",{d:"M21 22v-4h-4",key:"hrummi"}],["path",{d:"M21 8.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h4.3",key:"mctw84"}],["path",{d:"M3 10h4",key:"1el30a"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lU=Z("CalendarX2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m17 22 5-5",key:"1k6ppv"}],["path",{d:"m17 17 5 5",key:"p7ous7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cU=Z("CalendarX",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hn=Z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dU=Z("CameraOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16",key:"qmtpty"}],["path",{d:"M9.5 4h5L17 7h3a2 2 0 0 1 2 2v7.5",key:"1ufyfc"}],["path",{d:"M14.121 15.121A3 3 0 1 1 9.88 10.88",key:"11zox6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sx=Z("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uU=Z("CandyCane",[["path",{d:"M5.7 21a2 2 0 0 1-3.5-2l8.6-14a6 6 0 0 1 10.4 6 2 2 0 1 1-3.464-2 2 2 0 1 0-3.464-2Z",key:"isaq8g"}],["path",{d:"M17.75 7 15 2.1",key:"12x7e8"}],["path",{d:"M10.9 4.8 13 9",key:"100a87"}],["path",{d:"m7.9 9.7 2 4.4",key:"ntfhaj"}],["path",{d:"M4.9 14.7 7 18.9",key:"1x43jy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hU=Z("CandyOff",[["path",{d:"m8.5 8.5-1 1a4.95 4.95 0 0 0 7 7l1-1",key:"1ff4ui"}],["path",{d:"M11.843 6.187A4.947 4.947 0 0 1 16.5 7.5a4.947 4.947 0 0 1 1.313 4.657",key:"1sbrv4"}],["path",{d:"M14 16.5V14",key:"1maf8j"}],["path",{d:"M14 6.5v1.843",key:"1a6u6t"}],["path",{d:"M10 10v7.5",key:"80pj65"}],["path",{d:"m16 7 1-5 1.367.683A3 3 0 0 0 19.708 3H21v1.292a3 3 0 0 0 .317 1.341L22 7l-5 1",key:"11a9mt"}],["path",{d:"m8 17-1 5-1.367-.683A3 3 0 0 0 4.292 21H3v-1.292a3 3 0 0 0-.317-1.341L2 17l5-1",key:"3mjmon"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mU=Z("Candy",[["path",{d:"m9.5 7.5-2 2a4.95 4.95 0 1 0 7 7l2-2a4.95 4.95 0 1 0-7-7Z",key:"ue6khb"}],["path",{d:"M14 6.5v10",key:"5xnk7c"}],["path",{d:"M10 7.5v10",key:"1uew51"}],["path",{d:"m16 7 1-5 1.37.68A3 3 0 0 0 19.7 3H21v1.3c0 .46.1.92.32 1.33L22 7l-5 1",key:"b9cp6k"}],["path",{d:"m8 17-1 5-1.37-.68A3 3 0 0 0 4.3 21H3v-1.3a3 3 0 0 0-.32-1.33L2 17l5-1",key:"5lney8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pU=Z("Cannabis",[["path",{d:"M12 22v-4",key:"1utk9m"}],["path",{d:"M7 12c-1.5 0-4.5 1.5-5 3 3.5 1.5 6 1 6 1-1.5 1.5-2 3.5-2 5 2.5 0 4.5-1.5 6-3 1.5 1.5 3.5 3 6 3 0-1.5-.5-3.5-2-5 0 0 2.5.5 6-1-.5-1.5-3.5-3-5-3 1.5-1 4-4 4-6-2.5 0-5.5 1.5-7 3 0-2.5-.5-5-2-7-1.5 2-2 4.5-2 7-1.5-1.5-4.5-3-7-3 0 2 2.5 5 4 6",key:"1mezod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fU=Z("CaptionsOff",[["path",{d:"M10.5 5H19a2 2 0 0 1 2 2v8.5",key:"jqtk4d"}],["path",{d:"M17 11h-.5",key:"1961ue"}],["path",{d:"M19 19H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2",key:"1keqsi"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7 11h4",key:"1o1z6v"}],["path",{d:"M7 15h2.5",key:"1ina1g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lj=Z("Captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xU=Z("CarFront",[["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gU=Z("CarTaxiFront",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CM=Z("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yU=Z("Caravan",[["path",{d:"M18 19V9a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v8a2 2 0 0 0 2 2h2",key:"19jm3t"}],["path",{d:"M2 9h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2",key:"13hakp"}],["path",{d:"M22 17v1a1 1 0 0 1-1 1H10v-9a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v9",key:"1crci8"}],["circle",{cx:"8",cy:"19",r:"2",key:"t8fc5s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vU=Z("Carrot",[["path",{d:"M2.27 21.7s9.87-3.5 12.73-6.36a4.5 4.5 0 0 0-6.36-6.37C5.77 11.84 2.27 21.7 2.27 21.7zM8.64 14l-2.05-2.04M15.34 15l-2.46-2.46",key:"rfqxbe"}],["path",{d:"M22 9s-1.33-2-3.5-2C16.86 7 15 9 15 9s1.33 2 3.5 2S22 9 22 9z",key:"6b25w4"}],["path",{d:"M15 2s-2 1.33-2 3.5S15 9 15 9s2-1.84 2-3.5C17 3.33 15 2 15 2z",key:"fn65lo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bU=Z("CaseLower",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _U=Z("CaseSensitive",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["circle",{cx:"18",cy:"12",r:"3",key:"1kchzo"}],["path",{d:"M21 9v6",key:"anns31"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wU=Z("CaseUpper",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["path",{d:"M15 11h4.5a2 2 0 0 1 0 4H15V7h4a2 2 0 0 1 0 4",key:"1sqfas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jU=Z("CassetteTape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["circle",{cx:"8",cy:"10",r:"2",key:"1xl4ub"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"10",r:"2",key:"r14t7q"}],["path",{d:"m6 20 .7-2.9A1.4 1.4 0 0 1 8.1 16h7.8a1.4 1.4 0 0 1 1.4 1l.7 3",key:"l01ucn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NU=Z("Cast",[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kU=Z("Castle",[["path",{d:"M22 20v-9H2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2Z",key:"109fe4"}],["path",{d:"M18 11V4H6v7",key:"mon5oj"}],["path",{d:"M15 22v-4a3 3 0 0 0-3-3a3 3 0 0 0-3 3v4",key:"1k4jtn"}],["path",{d:"M22 11V9",key:"3zbp94"}],["path",{d:"M2 11V9",key:"1x5rnq"}],["path",{d:"M6 4V2",key:"1rsq15"}],["path",{d:"M18 4V2",key:"1jsdo1"}],["path",{d:"M10 4V2",key:"75d9ly"}],["path",{d:"M14 4V2",key:"8nj3z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SU=Z("Cat",[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CU=Z("Cctv",[["path",{d:"M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97",key:"ir91b5"}],["path",{d:"M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z",key:"jlp8i1"}],["path",{d:"M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15",key:"19bib8"}],["path",{d:"M2 21v-4",key:"l40lih"}],["path",{d:"M7 9h.01",key:"19b3jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cj=Z("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dj=Z("ChartBarBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MU=Z("ChartBarDecreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h3",key:"ur6vzw"}],["path",{d:"M7 6h12",key:"sz5b0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TU=Z("ChartBarIncreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h12",key:"wsnu98"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AU=Z("ChartBarStacked",[["path",{d:"M11 13v4",key:"vyy2rb"}],["path",{d:"M15 5v4",key:"1gx88a"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uj=Z("ChartBar",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hj=Z("ChartCandlestick",[["path",{d:"M9 5v4",key:"14uxtq"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1",key:"f4fvz0"}],["path",{d:"M9 15v2",key:"r5rk32"}],["path",{d:"M17 3v2",key:"1l2re6"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1",key:"z38je5"}],["path",{d:"M17 13v3",key:"5l0wba"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mj=Z("ChartColumnBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EU=Z("ChartColumnDecreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17v-3",key:"1sqioe"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17V5",key:"1wzmnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pj=Z("ChartColumnIncreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PU=Z("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const No=Z("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IU=Z("ChartGantt",[["path",{d:"M10 6h8",key:"zvc2xc"}],["path",{d:"M12 16h6",key:"yi5mkt"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 11h7",key:"wz2hg0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fj=Z("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LU=Z("ChartNetwork",[["path",{d:"m13.11 7.664 1.78 2.672",key:"go2gg9"}],["path",{d:"m14.162 12.788-3.324 1.424",key:"11x848"}],["path",{d:"m20 4-6.06 1.515",key:"1wxxh7"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["circle",{cx:"12",cy:"6",r:"2",key:"1jj5th"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}],["circle",{cx:"9",cy:"15",r:"2",key:"lf2ghp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DU=Z("ChartNoAxesColumnDecreasing",[["path",{d:"M12 20V10",key:"g8npz5"}],["path",{d:"M18 20v-4",key:"8uic4z"}],["path",{d:"M6 20V4",key:"1w1bmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xj=Z("ChartNoAxesColumnIncreasing",[["line",{x1:"12",x2:"12",y1:"20",y2:"10",key:"1vz5eb"}],["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["line",{x1:"6",x2:"6",y1:"20",y2:"16",key:"hq0ia6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gj=Z("ChartNoAxesColumn",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OU=Z("ChartNoAxesCombined",[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yj=Z("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vj=Z("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bj=Z("ChartScatter",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RU=Z("ChartSpline",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7",key:"lw07rv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sL=Z("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const va=Z("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FU=Z("ChefHat",[["path",{d:"M17 21a1 1 0 0 0 1-1v-5.35c0-.457.316-.844.727-1.041a4 4 0 0 0-2.134-7.589 5 5 0 0 0-9.186 0 4 4 0 0 0-2.134 7.588c.411.198.727.585.727 1.041V20a1 1 0 0 0 1 1Z",key:"1qvrer"}],["path",{d:"M6 17h12",key:"1jwigz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zU=Z("Cherry",[["path",{d:"M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"cvxqlc"}],["path",{d:"M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"1ostrc"}],["path",{d:"M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12",key:"hqx58h"}],["path",{d:"M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z",key:"eykp1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eo=Z("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BU=Z("ChevronFirst",[["path",{d:"m17 18-6-6 6-6",key:"1yerx2"}],["path",{d:"M7 6v12",key:"1p53r6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $U=Z("ChevronLast",[["path",{d:"m7 18 6-6-6-6",key:"lwmzdw"}],["path",{d:"M17 6v12",key:"1o0aio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cl=Z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const da=Z("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ff=Z("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qU=Z("ChevronsDownUp",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UU=Z("ChevronsDown",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VU=Z("ChevronsLeftRightEllipsis",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HU=Z("ChevronsLeftRight",[["path",{d:"m9 7-5 5 5 5",key:"j5w590"}],["path",{d:"m15 7 5 5-5 5",key:"1bl6da"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WU=Z("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GU=Z("ChevronsRightLeft",[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KU=Z("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cx=Z("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZU=Z("ChevronsUp",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YU=Z("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XU=Z("Church",[["path",{d:"M10 9h4",key:"u4k05v"}],["path",{d:"M12 7v5",key:"ma6bk"}],["path",{d:"M14 22v-4a2 2 0 0 0-4 0v4",key:"1pdhuj"}],["path",{d:"M18 22V5.618a1 1 0 0 0-.553-.894l-4.553-2.277a2 2 0 0 0-1.788 0L6.553 4.724A1 1 0 0 0 6 5.618V22",key:"1rkokr"}],["path",{d:"m18 7 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.618a1 1 0 0 1 .553-.894L6 7",key:"1w6esw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QU=Z("CigaretteOff",[["path",{d:"M12 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h13",key:"1gdiyg"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 12a1 1 0 0 1 1 1v2a1 1 0 0 1-.5.866",key:"166zjj"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JU=Z("Cigarette",[["path",{d:"M17 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h14",key:"1mb5g1"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"M21 16a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"1yl5r7"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kl=Z("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _j=Z("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wj=Z("CircleArrowLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jj=Z("CircleArrowOutDownLeft",[["path",{d:"M2 12a10 10 0 1 1 10 10",key:"1yn6ov"}],["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"M8 22H2v-6",key:"sulq54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nj=Z("CircleArrowOutDownRight",[["path",{d:"M12 22a10 10 0 1 1 10-10",key:"130bv5"}],["path",{d:"M22 22 12 12",key:"131aw7"}],["path",{d:"M22 16v6h-6",key:"1gvm70"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kj=Z("CircleArrowOutUpLeft",[["path",{d:"M2 8V2h6",key:"hiwtdz"}],["path",{d:"m2 2 10 10",key:"1oh8rs"}],["path",{d:"M12 2A10 10 0 1 1 2 12",key:"rrk4fa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sj=Z("CircleArrowOutUpRight",[["path",{d:"M22 12A10 10 0 1 1 12 2",key:"1fm58d"}],["path",{d:"M22 2 12 12",key:"yg2myt"}],["path",{d:"M16 2h6v6",key:"zan5cs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cj=Z("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mj=Z("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xi=Z("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sa=Z("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tj=Z("CircleChevronDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aj=Z("CircleChevronLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ej=Z("CircleChevronRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pj=Z("CircleChevronUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eV=Z("CircleDashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ij=Z("CircleDivide",[["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tV=Z("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sV=Z("CircleDotDashed",[["path",{d:"M10.1 2.18a9.93 9.93 0 0 1 3.8 0",key:"1qdqn0"}],["path",{d:"M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7",key:"1bq7p6"}],["path",{d:"M21.82 10.1a9.93 9.93 0 0 1 0 3.8",key:"1rlaqf"}],["path",{d:"M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69",key:"1xk03u"}],["path",{d:"M13.9 21.82a9.94 9.94 0 0 1-3.8 0",key:"l7re25"}],["path",{d:"M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7",key:"1v18p6"}],["path",{d:"M2.18 13.9a9.93 9.93 0 0 1 0-3.8",key:"xdo6bj"}],["path",{d:"M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69",key:"1jjmaz"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rV=Z("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nV=Z("CircleEllipsis",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aV=Z("CircleEqual",[["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iV=Z("CircleFadingArrowUp",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oV=Z("CircleFadingPlus",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lj=Z("CircleGauge",[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rv=Z("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dj=Z("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lV=Z("CircleOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oj=Z("CircleParkingOff",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m5 5 14 14",key:"11anup"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.34",key:"a9qo08"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rj=Z("CircleParking",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fj=Z("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zj=Z("CirclePercent",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pp=Z("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bj=Z("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $j=Z("CirclePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qj=Z("CircleSlash2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cV=Z("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uj=Z("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vj=Z("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hj=Z("CircleUser",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vc=Z("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _d=Z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dV=Z("CircuitBoard",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uV=Z("Citrus",[["path",{d:"M21.66 17.67a1.08 1.08 0 0 1-.04 1.6A12 12 0 0 1 4.73 2.38a1.1 1.1 0 0 1 1.61-.04z",key:"4ite01"}],["path",{d:"M19.65 15.66A8 8 0 0 1 8.35 4.34",key:"1gxipu"}],["path",{d:"m14 10-5.5 5.5",key:"92pfem"}],["path",{d:"M14 17.85V10H6.15",key:"xqmtsk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hV=Z("Clapperboard",[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MM=Z("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mV=Z("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F_=Z("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pV=Z("ClipboardMinus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fV=Z("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wj=Z("ClipboardPenLine",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.5",key:"1but9f"}],["path",{d:"M16 4h2a2 2 0 0 1 1.73 1",key:"1p8n7l"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gj=Z("ClipboardPen",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-5.5",key:"cereej"}],["path",{d:"M4 13.5V6a2 2 0 0 1 2-2h2",key:"5ua5vh"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xV=Z("ClipboardPlus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}],["path",{d:"M12 17v-6",key:"1y8rbf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gV=Z("ClipboardType",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 12v-1h6v1",key:"iehl6m"}],["path",{d:"M11 17h2",key:"12w5me"}],["path",{d:"M12 11v6",key:"1bwqyc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yV=Z("ClipboardX",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m15 11-6 6",key:"1toa9n"}],["path",{d:"m9 11 6 6",key:"wlibny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vV=Z("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bV=Z("Clock1",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 8",key:"12zbmj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _V=Z("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wV=Z("Clock11",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 8",key:"l5bg6f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jV=Z("Clock12",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12",key:"1fub01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NV=Z("Clock2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 10",key:"1g230d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kV=Z("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SV=Z("Clock4",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CV=Z("Clock5",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 16",key:"1pcbox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MV=Z("Clock6",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 12 16.5",key:"hb2qv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TV=Z("Clock7",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 16",key:"ka3394"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AV=Z("Clock8",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 14",key:"tmc9b4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EV=Z("Clock9",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 7.5 12",key:"1k60p0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PV=Z("ClockAlert",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M16 21.16a10 10 0 1 1 5-13.516",key:"cxo92l"}],["path",{d:"M20 11.5v6",key:"2ei3xq"}],["path",{d:"M20 21.5h.01",key:"1r2dzp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IV=Z("ClockArrowDown",[["path",{d:"M12.338 21.994A10 10 0 1 1 21.925 13.227",key:"1i7shu"}],["path",{d:"M12 6v6l2 1",key:"19cm8n"}],["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M18 14v8",key:"irew45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LV=Z("ClockArrowUp",[["path",{d:"M13.228 21.925A10 10 0 1 1 21.994 12.338",key:"1fzlyi"}],["path",{d:"M12 6v6l1.562.781",key:"1ujuk9"}],["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M18 22v-8",key:"su0gjh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const un=Z("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DV=Z("CloudAlert",[["path",{d:"M12 12v4",key:"tww15h"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M17 18h.5a1 1 0 0 0 0-9h-1.79A7 7 0 1 0 7 17.708",key:"xsb5ju"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OV=Z("CloudCog",[["circle",{cx:"12",cy:"17",r:"3",key:"1spfwm"}],["path",{d:"M4.2 15.1A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"zaobp"}],["path",{d:"m15.7 18.4-.9-.3",key:"4qxpbn"}],["path",{d:"m9.2 15.9-.9-.3",key:"17q7o2"}],["path",{d:"m10.6 20.7.3-.9",key:"1pf4s2"}],["path",{d:"m13.1 14.2.3-.9",key:"1mnuqm"}],["path",{d:"m13.6 20.7-.4-1",key:"1jpd1m"}],["path",{d:"m10.8 14.3-.4-1",key:"17ugyy"}],["path",{d:"m8.3 18.6 1-.4",key:"s42vdx"}],["path",{d:"m14.7 15.8 1-.4",key:"2wizun"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kj=Z("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RV=Z("CloudDrizzle",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 19v1",key:"1dk2by"}],["path",{d:"M8 14v1",key:"84yxot"}],["path",{d:"M16 19v1",key:"v220m7"}],["path",{d:"M16 14v1",key:"g12gj6"}],["path",{d:"M12 21v1",key:"q8vafk"}],["path",{d:"M12 16v1",key:"1mx6rx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FV=Z("CloudFog",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 17H7",key:"pygtm1"}],["path",{d:"M17 21H9",key:"1u2q02"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zV=Z("CloudHail",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v2",key:"a1is7l"}],["path",{d:"M8 14v2",key:"1e9m6t"}],["path",{d:"M16 20h.01",key:"xwek51"}],["path",{d:"M8 20h.01",key:"1vjney"}],["path",{d:"M12 16v2",key:"z66u1j"}],["path",{d:"M12 22h.01",key:"1urd7a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BV=Z("CloudLightning",[["path",{d:"M6 16.326A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 .5 8.973",key:"1cez44"}],["path",{d:"m13 12-3 5h4l-3 5",key:"1t22er"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $V=Z("CloudMoonRain",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qV=Z("CloudMoon",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M13 16a3 3 0 1 1 0 6H7a5 5 0 1 1 4.9-6Z",key:"p44pc9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UV=Z("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VV=Z("CloudRainWind",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m9.2 22 3-7",key:"sb5f6j"}],["path",{d:"m9 13-3 7",key:"500co5"}],["path",{d:"m17 13-3 7",key:"8t2fiy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HV=Z("CloudRain",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v6",key:"1j4efv"}],["path",{d:"M8 14v6",key:"17c4r9"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WV=Z("CloudSnow",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M8 19h.01",key:"puxtts"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M12 21h.01",key:"h35vbk"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M16 19h.01",key:"1vcnzz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GV=Z("CloudSunRain",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KV=Z("CloudSun",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zj=Z("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZV=Z("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YV=Z("Cloudy",[["path",{d:"M17.5 21H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"gqqjvc"}],["path",{d:"M22 10a3 3 0 0 0-3-3h-2.207a5.502 5.502 0 0 0-10.702.5",key:"1p2s76"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yv=Z("Clover",[["path",{d:"M16.17 7.83 2 22",key:"t58vo8"}],["path",{d:"M4.02 12a2.827 2.827 0 1 1 3.81-4.17A2.827 2.827 0 1 1 12 4.02a2.827 2.827 0 1 1 4.17 3.81A2.827 2.827 0 1 1 19.98 12a2.827 2.827 0 1 1-3.81 4.17A2.827 2.827 0 1 1 12 19.98a2.827 2.827 0 1 1-4.17-3.81A1 1 0 1 1 4 12",key:"17k36q"}],["path",{d:"m7.83 7.83 8.34 8.34",key:"1d7sxk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XV=Z("Club",[["path",{d:"M17.28 9.05a5.5 5.5 0 1 0-10.56 0A5.5 5.5 0 1 0 12 17.66a5.5 5.5 0 1 0 5.28-8.6Z",key:"27yuqz"}],["path",{d:"M12 17.66L12 22",key:"ogfahf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yj=Z("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q4=Z("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QV=Z("Codepen",[["polygon",{points:"12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2",key:"srzb37"}],["line",{x1:"12",x2:"12",y1:"22",y2:"15.5",key:"1t73f2"}],["polyline",{points:"22 8.5 12 15.5 2 8.5",key:"ajlxae"}],["polyline",{points:"2 15.5 12 8.5 22 15.5",key:"susrui"}],["line",{x1:"12",x2:"12",y1:"2",y2:"8.5",key:"2cldga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JV=Z("Codesandbox",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["polyline",{points:"7.5 4.21 12 6.81 16.5 4.21",key:"fabo96"}],["polyline",{points:"7.5 19.79 7.5 14.6 3 12",key:"z377f1"}],["polyline",{points:"21 12 16.5 14.6 16.5 19.79",key:"9nrev1"}],["polyline",{points:"3.27 6.96 12 12.01 20.73 6.96",key:"1180pa"}],["line",{x1:"12",x2:"12",y1:"22.08",y2:"12",key:"3z3uq6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J4=Z("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eH=Z("Cog",[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rL=Z("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xj=Z("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qj=Z("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tH=Z("Columns4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7.5 3v18",key:"w0wo6v"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M16.5 3v18",key:"10tjh1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sH=Z("Combine",[["path",{d:"M10 18H5a3 3 0 0 1-3-3v-1",key:"ru65g8"}],["path",{d:"M14 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"e30een"}],["path",{d:"M20 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"2ahx8o"}],["path",{d:"m7 21 3-3-3-3",key:"127cv2"}],["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rH=Z("Command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nH=Z("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aH=Z("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iH=Z("Computer",[["rect",{width:"14",height:"8",x:"5",y:"2",rx:"2",key:"wc9tft"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h2",key:"rwmk9e"}],["path",{d:"M12 18h6",key:"aqd8w3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oH=Z("ConciergeBell",[["path",{d:"M3 20a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1Z",key:"1pvr1r"}],["path",{d:"M20 16a8 8 0 1 0-16 0",key:"1pa543"}],["path",{d:"M12 4v4",key:"1bq03y"}],["path",{d:"M10 4h4",key:"1xpv9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lH=Z("Cone",[["path",{d:"m20.9 18.55-8-15.98a1 1 0 0 0-1.8 0l-8 15.98",key:"53pte7"}],["ellipse",{cx:"12",cy:"19",rx:"9",ry:"3",key:"1ji25f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cH=Z("Construction",[["rect",{x:"2",y:"6",width:"20",height:"8",rx:"1",key:"1estib"}],["path",{d:"M17 14v7",key:"7m2elx"}],["path",{d:"M7 14v7",key:"1cm7wv"}],["path",{d:"M17 3v3",key:"1v4jwn"}],["path",{d:"M7 3v3",key:"7o6guu"}],["path",{d:"M10 14 2.3 6.3",key:"1023jk"}],["path",{d:"m14 6 7.7 7.7",key:"1s8pl2"}],["path",{d:"m8 6 8 8",key:"hl96qh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jj=Z("ContactRound",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M17.915 22a6 6 0 0 0-12 0",key:"suqz9p"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eS=Z("Contact",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M7 22v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1waht3"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"11",r:"3",key:"itu57m"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dH=Z("Container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uH=Z("Contrast",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hH=Z("Cookie",[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mH=Z("CookingPot",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"u0tga0"}],["path",{d:"m4 8 16-4",key:"16g0ng"}],["path",{d:"m8.86 6.78-.45-1.81a2 2 0 0 1 1.45-2.43l1.94-.48a2 2 0 0 1 2.43 1.46l.45 1.8",key:"12cejc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pH=Z("CopyCheck",[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fH=Z("CopyMinus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xH=Z("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gH=Z("CopySlash",[["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yH=Z("CopyX",[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gi=Z("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vH=Z("Copyleft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.17 14.83a4 4 0 1 0 0-5.66",key:"1sveal"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bH=Z("Copyright",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M14.83 14.83a4 4 0 1 1 0-5.66",key:"1i56pz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _H=Z("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wH=Z("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jH=Z("CornerLeftDown",[["polyline",{points:"14 15 9 20 4 15",key:"nkc4i"}],["path",{d:"M20 4h-7a4 4 0 0 0-4 4v12",key:"nbpdq2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NH=Z("CornerLeftUp",[["polyline",{points:"14 9 9 4 4 9",key:"m9oyvo"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kH=Z("CornerRightDown",[["polyline",{points:"10 15 15 20 20 15",key:"axus6l"}],["path",{d:"M4 4h7a4 4 0 0 1 4 4v12",key:"wcbgct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SH=Z("CornerRightUp",[["polyline",{points:"10 9 15 4 20 9",key:"1lr6px"}],["path",{d:"M4 20h7a4 4 0 0 0 4-4V4",key:"1plgdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CH=Z("CornerUpLeft",[["polyline",{points:"9 14 4 9 9 4",key:"881910"}],["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MH=Z("CornerUpRight",[["polyline",{points:"15 14 20 9 15 4",key:"1tbx3s"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TH=Z("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AH=Z("CreativeCommons",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M10 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1ss3eq"}],["path",{d:"M17 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1od56t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mx=Z("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EH=Z("Croissant",[["path",{d:"m4.6 13.11 5.79-3.21c1.89-1.05 4.79 1.78 3.71 3.71l-3.22 5.81C8.8 23.16.79 15.23 4.6 13.11Z",key:"1ozxlb"}],["path",{d:"m10.5 9.5-1-2.29C9.2 6.48 8.8 6 8 6H4.5C2.79 6 2 6.5 2 8.5a7.71 7.71 0 0 0 2 4.83",key:"ffuyb5"}],["path",{d:"M8 6c0-1.55.24-4-2-4-2 0-2.5 2.17-2.5 4",key:"osnpzi"}],["path",{d:"m14.5 13.5 2.29 1c.73.3 1.21.7 1.21 1.5v3.5c0 1.71-.5 2.5-2.5 2.5a7.71 7.71 0 0 1-4.83-2",key:"1vubaw"}],["path",{d:"M18 16c1.55 0 4-.24 4 2 0 2-2.17 2.5-4 2.5",key:"wxr772"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PH=Z("Crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IH=Z("Cross",[["path",{d:"M4 9a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h4a1 1 0 0 1 1 1v4a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-4a1 1 0 0 1 1-1h4a2 2 0 0 0 2-2v-2a2 2 0 0 0-2-2h-4a1 1 0 0 1-1-1V4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4a1 1 0 0 1-1 1z",key:"1xbrqy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LH=Z("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dm=Z("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DH=Z("Cuboid",[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OH=Z("CupSoda",[["path",{d:"m6 8 1.75 12.28a2 2 0 0 0 2 1.72h4.54a2 2 0 0 0 2-1.72L18 8",key:"8166m8"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"yjz344"}],["path",{d:"m12 8 1-6h2",key:"3ybfa4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RH=Z("Currency",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["line",{x1:"3",x2:"6",y1:"3",y2:"6",key:"1jkytn"}],["line",{x1:"21",x2:"18",y1:"3",y2:"6",key:"14zfjt"}],["line",{x1:"3",x2:"6",y1:"21",y2:"18",key:"iusuec"}],["line",{x1:"21",x2:"18",y1:"21",y2:"18",key:"yj2dd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FH=Z("Cylinder",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zH=Z("Dam",[["path",{d:"M11 11.31c1.17.56 1.54 1.69 3.5 1.69 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"157kva"}],["path",{d:"M11.75 18c.35.5 1.45 1 2.75 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"d7q6m6"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M7 3a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1L10 4a1 1 0 0 0-1-1z",key:"pr6s65"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BH=Z("DatabaseBackup",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 12a9 3 0 0 0 5 2.69",key:"1ui2ym"}],["path",{d:"M21 9.3V5",key:"6k6cib"}],["path",{d:"M3 5v14a9 3 0 0 0 6.47 2.88",key:"i62tjy"}],["path",{d:"M12 12v4h4",key:"1bxaet"}],["path",{d:"M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",key:"1f4ei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $H=Z("DatabaseZap",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 15 21.84",key:"14ibmq"}],["path",{d:"M21 5V8",key:"1marbg"}],["path",{d:"M21 12L18 17H22L19 22",key:"zafso"}],["path",{d:"M3 12A9 3 0 0 0 14.59 14.87",key:"1y4wr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nL=Z("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qH=Z("Delete",[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UH=Z("Dessert",[["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["path",{d:"M10.2 3.2C5.5 4 2 8.1 2 13a2 2 0 0 0 4 0v-1a2 2 0 0 1 4 0v4a2 2 0 0 0 4 0v-4a2 2 0 0 1 4 0v1a2 2 0 0 0 4 0c0-4.9-3.5-9-8.2-9.8",key:"lfo06j"}],["path",{d:"M3.2 14.8a9 9 0 0 0 17.6 0",key:"12xarc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VH=Z("Diameter",[["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}],["path",{d:"M6.48 3.66a10 10 0 0 1 13.86 13.86",key:"xr8kdq"}],["path",{d:"m6.41 6.41 11.18 11.18",key:"uhpjw7"}],["path",{d:"M3.66 6.48a10 10 0 0 0 13.86 13.86",key:"cldpwv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HH=Z("DiamondMinus",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eN=Z("DiamondPercent",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0Z",key:"1tpxz2"}],["path",{d:"M9.2 9.2h.01",key:"1b7bvt"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"M14.7 14.8h.01",key:"17nsh4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WH=Z("DiamondPlus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GH=Z("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KH=Z("Dice1",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZH=Z("Dice2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M9 15h.01",key:"fzyn71"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YH=Z("Dice3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XH=Z("Dice4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QH=Z("Dice5",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JH=Z("Dice6",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eW=Z("Dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tW=Z("Diff",[["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sW=Z("Disc2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rW=Z("Disc3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M6 12c0-1.7.7-3.2 1.8-4.2",key:"oqkarx"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M18 12c0 1.7-.7 3.2-1.8 4.2",key:"1eah9h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nW=Z("DiscAlbum",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"5",key:"nd82uf"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aW=Z("Disc",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iW=Z("Divide",[["circle",{cx:"12",cy:"6",r:"1",key:"1bh7o1"}],["line",{x1:"5",x2:"19",y1:"12",y2:"12",key:"13b5wn"}],["circle",{cx:"12",cy:"18",r:"1",key:"lqb9t5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oW=Z("DnaOff",[["path",{d:"M15 2c-1.35 1.5-2.092 3-2.5 4.5L14 8",key:"1bivrr"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c3.333-3 6.667-3 10-3",key:"nxix30"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M22 9c-1.5 1.35-3 2.092-4.5 2.5l-1-1",key:"18cutr"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.35-1.5 2.092-3 2.5-4.5L10 16",key:"rlvei3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lW=Z("Dna",[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cW=Z("Dock",[["path",{d:"M2 8h20",key:"d11cs7"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 16h12",key:"u522kt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dW=Z("Dog",[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ac=Z("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uW=Z("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hW=Z("DoorClosed",[["path",{d:"M18 20V6a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v14",key:"36qu9e"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M14 12v.01",key:"xfcn54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n1=Z("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mW=Z("Dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yi=Z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pW=Z("DraftingCompass",[["path",{d:"m12.99 6.74 1.93 3.44",key:"iwagvd"}],["path",{d:"M19.136 12a10 10 0 0 1-14.271 0",key:"ppmlo4"}],["path",{d:"m21 21-2.16-3.84",key:"vylbct"}],["path",{d:"m3 21 8.02-14.26",key:"1ssaw4"}],["circle",{cx:"12",cy:"5",r:"2",key:"f1ur92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fW=Z("Drama",[["path",{d:"M10 11h.01",key:"d2at3l"}],["path",{d:"M14 6h.01",key:"k028ub"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6.5 13.1h.01",key:"1748ia"}],["path",{d:"M22 5c0 9-4 12-6 12s-6-3-6-12c0-2 2-3 6-3s6 1 6 3",key:"172yzv"}],["path",{d:"M17.4 9.9c-.8.8-2 .8-2.8 0",key:"1obv0w"}],["path",{d:"M10.1 7.1C9 7.2 7.7 7.7 6 8.6c-3.5 2-4.7 3.9-3.7 5.6 4.5 7.8 9.5 8.4 11.2 7.4.9-.5 1.9-2.1 1.9-4.7",key:"rqjl8i"}],["path",{d:"M9.1 16.5c.3-1.1 1.4-1.7 2.4-1.4",key:"1mr6wy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xW=Z("Dribbble",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M19.13 5.09C15.22 9.14 10 10.44 2.25 10.94",key:"hpej1"}],["path",{d:"M21.75 12.84c-6.62-1.41-12.14 1-16.38 6.32",key:"1tr44o"}],["path",{d:"M8.56 2.75c4.37 6 6 9.42 8 17.72",key:"kbh691"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gW=Z("Drill",[["path",{d:"M10 18a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a3 3 0 0 1-3-3 1 1 0 0 1 1-1z",key:"ioqxb1"}],["path",{d:"M13 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1l-.81 3.242a1 1 0 0 1-.97.758H8",key:"1rs59n"}],["path",{d:"M14 4h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3",key:"105ega"}],["path",{d:"M18 6h4",key:"66u95g"}],["path",{d:"m5 10-2 8",key:"xt2lic"}],["path",{d:"m7 18 2-8",key:"1bzku2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yW=Z("Droplet",[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xg=Z("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vW=Z("Drum",[["path",{d:"m2 2 8 8",key:"1v6059"}],["path",{d:"m22 2-8 8",key:"173r8a"}],["ellipse",{cx:"12",cy:"9",rx:"10",ry:"5",key:"liohsx"}],["path",{d:"M7 13.4v7.9",key:"1yi6u9"}],["path",{d:"M12 14v8",key:"1tn2tj"}],["path",{d:"M17 13.4v7.9",key:"eqz2v3"}],["path",{d:"M2 9v8a10 5 0 0 0 20 0V9",key:"1750ul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bW=Z("Drumstick",[["path",{d:"M15.4 15.63a7.875 6 135 1 1 6.23-6.23 4.5 3.43 135 0 0-6.23 6.23",key:"1dtqwm"}],["path",{d:"m8.29 12.71-2.6 2.6a2.5 2.5 0 1 0-1.65 4.65A2.5 2.5 0 1 0 8.7 18.3l2.59-2.59",key:"1oq1fw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _W=Z("Dumbbell",[["path",{d:"M14.4 14.4 9.6 9.6",key:"ic80wn"}],["path",{d:"M18.657 21.485a2 2 0 1 1-2.829-2.828l-1.767 1.768a2 2 0 1 1-2.829-2.829l6.364-6.364a2 2 0 1 1 2.829 2.829l-1.768 1.767a2 2 0 1 1 2.828 2.829z",key:"nnl7wr"}],["path",{d:"m21.5 21.5-1.4-1.4",key:"1f1ice"}],["path",{d:"M3.9 3.9 2.5 2.5",key:"1evmna"}],["path",{d:"M6.404 12.768a2 2 0 1 1-2.829-2.829l1.768-1.767a2 2 0 1 1-2.828-2.829l2.828-2.828a2 2 0 1 1 2.829 2.828l1.767-1.768a2 2 0 1 1 2.829 2.829z",key:"yhosts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wW=Z("EarOff",[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jW=Z("Ear",[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NW=Z("EarthLock",[["path",{d:"M7 3.34V5a3 3 0 0 0 3 3",key:"w732o8"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"f02343"}],["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M12 2a10 10 0 1 0 9.54 13",key:"zjsr6q"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tN=Z("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kW=Z("Eclipse",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a7 7 0 1 0 10 10",key:"1yuj32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SW=Z("EggFried",[["circle",{cx:"11.5",cy:"12.5",r:"3.5",key:"1cl1mi"}],["path",{d:"M3 8c0-3.5 2.5-6 6.5-6 5 0 4.83 3 7.5 5s5 2 5 6c0 4.5-2.5 6.5-7 6.5-2.5 0-2.5 2.5-6 2.5s-7-2-7-5.5c0-3 1.5-3 1.5-5C3.5 10 3 9 3 8Z",key:"165ef9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CW=Z("EggOff",[["path",{d:"M6.399 6.399C5.362 8.157 4.65 10.189 4.5 12c-.37 4.43 1.27 9.95 7.5 10 3.256-.026 5.259-1.547 6.375-3.625",key:"6et380"}],["path",{d:"M19.532 13.875A14.07 14.07 0 0 0 19.5 12c-.36-4.34-3.95-9.96-7.5-10-1.04.012-2.082.502-3.046 1.297",key:"gcdc3f"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TM=Z("Egg",[["path",{d:"M12 22c6.23-.05 7.87-5.57 7.5-10-.36-4.34-3.95-9.96-7.5-10-3.55.04-7.14 5.66-7.5 10-.37 4.43 1.27 9.95 7.5 10z",key:"1c39pg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const px=Z("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fx=Z("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MW=Z("EqualApproximately",[["path",{d:"M5 15a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"yrdkhy"}],["path",{d:"M5 9a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"gzkvyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TW=Z("EqualNot",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AW=Z("Equal",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EW=Z("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PW=Z("EthernetPort",[["path",{d:"m15 20 3-3h2a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h2l3 3z",key:"rbahqx"}],["path",{d:"M6 8v1",key:"1636ez"}],["path",{d:"M10 8v1",key:"1talb4"}],["path",{d:"M14 8v1",key:"1rsfgr"}],["path",{d:"M18 8v1",key:"gnkwox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IW=Z("Euro",[["path",{d:"M4 10h12",key:"1y6xl8"}],["path",{d:"M4 14h9",key:"1loblj"}],["path",{d:"M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2",key:"1j6lzo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aL=Z("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tn=Z("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LW=Z("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kp=Z("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ln=Z("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Su=Z("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DW=Z("Factory",[["path",{d:"M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"159hny"}],["path",{d:"M17 18h1",key:"uldtlt"}],["path",{d:"M12 18h1",key:"s9uhes"}],["path",{d:"M7 18h1",key:"1neino"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OW=Z("Fan",[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RW=Z("FastForward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FW=Z("Feather",[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zW=Z("Fence",[["path",{d:"M4 3 2 5v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"1n2rgs"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M6 18h4",key:"12yh4b"}],["path",{d:"m12 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"3ha7mj"}],["path",{d:"M14 8h4",key:"1r8wg2"}],["path",{d:"M14 18h4",key:"1t3kbu"}],["path",{d:"m20 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"dfd4e2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BW=Z("FerrisWheel",[["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m6.8 15-3.5 2",key:"hjy98k"}],["path",{d:"m20.7 7-3.5 2",key:"f08gto"}],["path",{d:"M6.8 9 3.3 7",key:"1aevh4"}],["path",{d:"m20.7 17-3.5-2",key:"1liqo3"}],["path",{d:"m9 22 3-8 3 8",key:"wees03"}],["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M18 18.7a9 9 0 1 0-12 0",key:"dhzg4g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $W=Z("Figma",[["path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z",key:"1340ok"}],["path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z",key:"1hz3m3"}],["path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z",key:"1oz8n2"}],["path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z",key:"1ff65i"}],["path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z",key:"pdip6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qW=Z("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UW=Z("FileAudio2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"3",cy:"17",r:"1",key:"vo6nti"}],["path",{d:"M2 17v-3a4 4 0 0 1 8 0v3",key:"1ggdre"}],["circle",{cx:"9",cy:"17",r:"1",key:"bc1fq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VW=Z("FileAudio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sN=Z("FileAxis3d",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 18 4-4",key:"12zab0"}],["path",{d:"M8 10v8h8",key:"tlaukw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HW=Z("FileBadge2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14 12.5 1 5.5-3-1-3 1 1-5.5",key:"14xlky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WW=Z("FileBadge",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"12ixgl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M5 17a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"u0c8gj"}],["path",{d:"M7 16.5 8 22l-3-1-3 1 1-5.5",key:"5gm2nr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GW=Z("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rN=Z("FileChartColumnIncreasing",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nN=Z("FileChartColumn",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-1",key:"zg0ygc"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"M16 18v-3",key:"j5jt4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aN=Z("FileChartLine",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m16 13-3.5 3.5-2-2L8 17",key:"zz7yod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iN=Z("FileChartPie",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3.5",key:"13ddob"}],["path",{d:"M4.017 11.512a6 6 0 1 0 8.466 8.475",key:"s6vs5t"}],["path",{d:"M9 16a1 1 0 0 1-1-1v-4c0-.552.45-1.008.995-.917a6 6 0 0 1 4.922 4.922c.091.544-.365.995-.917.995z",key:"1dl6s6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KW=Z("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZW=Z("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YW=Z("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XW=Z("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QW=Z("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oN=Z("FileCog",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JW=Z("FileDiff",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eG=Z("FileDigit",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tG=Z("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sG=Z("FileHeart",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10.29 10.7a2.43 2.43 0 0 0-2.66-.52c-.29.12-.56.3-.78.53l-.35.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L6.5 18l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1c1fso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z_=Z("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rG=Z("FileInput",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nG=Z("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aG=Z("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iG=Z("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oG=Z("FileKey",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"10",cy:"16",r:"2",key:"4ckbqe"}],["path",{d:"m16 10-4.5 4.5",key:"7p3ebg"}],["path",{d:"m15 11 1 1",key:"1bsyx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lG=Z("FileLock2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v1",key:"jmtmu2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"5",x:"2",y:"13",rx:"1",key:"10y5wo"}],["path",{d:"M8 13v-2a2 2 0 1 0-4 0v2",key:"1pdxzg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cG=Z("FileLock",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["rect",{width:"8",height:"6",x:"8",y:"12",rx:"1",key:"3yr8at"}],["path",{d:"M10 12v-2a2 2 0 1 1 4 0v2",key:"j4i8d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dG=Z("FileMinus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uG=Z("FileMinus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hG=Z("FileMusic",[["path",{d:"M10.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v8.4",key:"1d3kfm"}],["path",{d:"M8 18v-7.7L16 9v7",key:"1oie6o"}],["circle",{cx:"14",cy:"16",r:"2",key:"1bzzi3"}],["circle",{cx:"6",cy:"18",r:"2",key:"1fncim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mG=Z("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lN=Z("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cN=Z("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pG=Z("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fG=Z("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xG=Z("FileQuestion",[["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gG=Z("FileScan",[["path",{d:"M20 10V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h4",key:"1rdf37"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 14a2 2 0 0 0-2 2",key:"ceaadl"}],["path",{d:"M20 14a2 2 0 0 1 2 2",key:"1ny6zw"}],["path",{d:"M20 22a2 2 0 0 0 2-2",key:"1l9q4k"}],["path",{d:"M16 22a2 2 0 0 1-2-2",key:"1wqh5n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yG=Z("FileSearch2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vG=Z("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bG=Z("FileSliders",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M10 11v2",key:"1s651w"}],["path",{d:"M8 17h8",key:"wh5c61"}],["path",{d:"M14 16v2",key:"12fp5e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a1=Z("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iL=Z("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _G=Z("FileSymlink",[["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 11V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"50q2rw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wG=Z("FileTerminal",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sn=Z("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jG=Z("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M5 12v6",key:"150t9c"}],["path",{d:"M4 18h2",key:"1xrofg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NG=Z("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kG=Z("FileUp",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SG=Z("FileUser",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 18a3 3 0 1 0-6 0",key:"16awa0"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CG=Z("FileVideo2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"6",x:"2",y:"12",rx:"1",key:"1a6c1e"}],["path",{d:"m10 15.5 4 2.5v-6l-4 2.5",key:"t7cp39"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MG=Z("FileVideo",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TG=Z("FileVolume2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M11.5 13.5a2.5 2.5 0 0 1 0 3",key:"1fccat"}],["path",{d:"M15 12a5 5 0 0 1 0 6",key:"ps46cm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AG=Z("FileVolume",[["path",{d:"M11 11a5 5 0 0 1 0 6",key:"193qb2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 6.765V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-.93-.23",key:"ifyjnl"}],["path",{d:"M7 10.51a.5.5 0 0 0-.826-.38l-1.893 1.628A1 1 0 0 1 3.63 12H2.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h1.129a1 1 0 0 1 .652.242l1.893 1.63a.5.5 0 0 0 .826-.38z",key:"mk8rxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EG=Z("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PG=Z("FileX2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 12.5-5 5",key:"b853mi"}],["path",{d:"m3 12.5 5 5",key:"1qls4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IG=Z("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AM=Z("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LG=Z("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gu=Z("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DG=Z("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qg=Z("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OG=Z("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RG=Z("FireExtinguisher",[["path",{d:"M15 6.5V3a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3.5",key:"sqyvz"}],["path",{d:"M9 18h8",key:"i7pszb"}],["path",{d:"M18 3h-3",key:"7idoqj"}],["path",{d:"M11 3a6 6 0 0 0-6 6v11",key:"1v5je3"}],["path",{d:"M5 13h4",key:"svpcxo"}],["path",{d:"M17 10a4 4 0 0 0-8 0v10a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2Z",key:"vsjego"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FG=Z("FishOff",[["path",{d:"M18 12.47v.03m0-.5v.47m-.475 5.056A6.744 6.744 0 0 1 15 18c-3.56 0-7.56-2.53-8.5-6 .348-1.28 1.114-2.433 2.121-3.38m3.444-2.088A8.802 8.802 0 0 1 15 6c3.56 0 6.06 2.54 7 6-.309 1.14-.786 2.177-1.413 3.058",key:"1j1hse"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33m7.48-4.372A9.77 9.77 0 0 1 16 6.07m0 11.86a9.77 9.77 0 0 1-1.728-3.618",key:"1q46z8"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98M8.53 3h5.27a2 2 0 0 1 1.98 1.67l.23 1.4M2 2l20 20",key:"1407gh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zG=Z("FishSymbol",[["path",{d:"M2 16s9-15 20-4C11 23 2 8 2 8",key:"h4oh4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BG=Z("Fish",[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $G=Z("FlagOff",[["path",{d:"M8 2c3 0 5 2 8 2s4-1 4-1v11",key:"9rwyz9"}],["path",{d:"M4 22V4",key:"1plyxx"}],["path",{d:"M4 15s1-1 4-1 5 2 8 2",key:"1myooe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qG=Z("FlagTriangleLeft",[["path",{d:"M17 22V2L7 7l10 5",key:"1rmf0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UG=Z("FlagTriangleRight",[["path",{d:"M7 22V2l10 5-10 5",key:"17n18y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i1=Z("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VG=Z("FlameKindling",[["path",{d:"M12 2c1 3 2.5 3.5 3.5 4.5A5 5 0 0 1 17 10a5 5 0 1 1-10 0c0-.3 0-.6.1-.9a2 2 0 1 0 3.3-2C8 4.5 11 2 12 2Z",key:"1ir223"}],["path",{d:"m5 22 14-4",key:"1brv4h"}],["path",{d:"m5 18 14 4",key:"lgyyje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eh=Z("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HG=Z("FlashlightOff",[["path",{d:"M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4",key:"1r120k"}],["path",{d:"M7 2h11v4c0 2-2 2-2 4v1",key:"dz1920"}],["line",{x1:"11",x2:"18",y1:"6",y2:"6",key:"bi1vpe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WG=Z("Flashlight",[["path",{d:"M18 6c0 2-2 2-2 4v10a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4V2h12z",key:"1orkel"}],["line",{x1:"6",x2:"18",y1:"6",y2:"6",key:"1z11jq"}],["line",{x1:"12",x2:"12",y1:"12",y2:"12",key:"1f4yc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GG=Z("FlaskConicalOff",[["path",{d:"M10 10 4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-1.272-2.542",key:"59ek9y"}],["path",{d:"M10 2v2.343",key:"15t272"}],["path",{d:"M14 2v6.343",key:"sxr80q"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h9",key:"t5njau"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B_=Z("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KG=Z("FlaskRound",[["path",{d:"M10 2v7.31",key:"5d1hyh"}],["path",{d:"M14 9.3V1.99",key:"14k4l0"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14 9.3a6.5 6.5 0 1 1-4 0",key:"1r8fvy"}],["path",{d:"M5.52 16h12.96",key:"46hh1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZG=Z("FlipHorizontal2",[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oL=Z("FlipHorizontal",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h3",key:"1i73f7"}],["path",{d:"M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3",key:"saxlbk"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YG=Z("FlipVertical2",[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XG=Z("FlipVertical",[["path",{d:"M21 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v3",key:"14bfxa"}],["path",{d:"M21 16v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3",key:"14rx03"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wg=Z("Flower2",[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QG=Z("Flower",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 16.5A4.5 4.5 0 1 1 7.5 12 4.5 4.5 0 1 1 12 7.5a4.5 4.5 0 1 1 4.5 4.5 4.5 4.5 0 1 1-4.5 4.5",key:"14wa3c"}],["path",{d:"M12 7.5V9",key:"1oy5b0"}],["path",{d:"M7.5 12H9",key:"eltsq1"}],["path",{d:"M16.5 12H15",key:"vk5kw4"}],["path",{d:"M12 16.5V15",key:"k7eayi"}],["path",{d:"m8 8 1.88 1.88",key:"nxy4qf"}],["path",{d:"M14.12 9.88 16 8",key:"1lst6k"}],["path",{d:"m8 16 1.88-1.88",key:"h2eex1"}],["path",{d:"M14.12 14.12 16 16",key:"uqkrx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JG=Z("Focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eK=Z("FoldHorizontal",[["path",{d:"M2 12h6",key:"1wqiqv"}],["path",{d:"M22 12h-6",key:"1eg9hc"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 9-3 3 3 3",key:"12ol22"}],["path",{d:"m5 15 3-3-3-3",key:"1kdhjc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tK=Z("FoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sK=Z("FolderArchive",[["circle",{cx:"15",cy:"19",r:"2",key:"u2pros"}],["path",{d:"M20.9 19.8A2 2 0 0 0 22 18V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h5.1",key:"1jj40k"}],["path",{d:"M15 11v-1",key:"cntcp"}],["path",{d:"M15 17v-2",key:"1279jj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rK=Z("FolderCheck",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nK=Z("FolderClock",[["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"M7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2",key:"1urifu"}],["path",{d:"M16 14v2l1 1",key:"xth2jh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aK=Z("FolderClosed",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iK=Z("FolderCode",[["path",{d:"M10 10.5 8 13l2 2.5",key:"m4t9c1"}],["path",{d:"m14 10.5 2 2.5-2 2.5",key:"14w2eb"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z",key:"1u1bxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dN=Z("FolderCog",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v3.3",key:"1k8050"}],["path",{d:"m21.7 19.4-.9-.3",key:"1qgwi9"}],["path",{d:"m15.2 16.9-.9-.3",key:"1t7mvx"}],["path",{d:"m16.6 21.7.3-.9",key:"1j67ps"}],["path",{d:"m19.1 15.2.3-.9",key:"18r7jp"}],["path",{d:"m19.6 21.7-.4-1",key:"z2vh2"}],["path",{d:"m16.8 15.3-.4-1",key:"1ei7r6"}],["path",{d:"m14.3 19.6 1-.4",key:"11sv9r"}],["path",{d:"m20.7 16.8 1-.4",key:"19m87a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oK=Z("FolderDot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"1",key:"49l61u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lK=Z("FolderDown",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cK=Z("FolderGit2",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dK=Z("FolderGit",[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uK=Z("FolderHeart",[["path",{d:"M11 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v1.5",key:"6hud8k"}],["path",{d:"M13.9 17.45c-1.2-1.2-1.14-2.8-.2-3.73a2.43 2.43 0 0 1 3.44 0l.36.34.34-.34a2.43 2.43 0 0 1 3.45-.01c.95.95 1 2.53-.2 3.74L17.5 21Z",key:"wpff58"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hK=Z("FolderInput",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mK=Z("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pK=Z("FolderKey",[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fK=Z("FolderLock",[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xK=Z("FolderMinus",[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gK=Z("FolderOpenDot",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}],["circle",{cx:"14",cy:"15",r:"1",key:"1gm4qj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Om=Z("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yK=Z("FolderOutput",[["path",{d:"M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5",key:"1yk7aj"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m5 10-3 3 3 3",key:"1r8ie0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uN=Z("FolderPen",[["path",{d:"M2 11.5V5a2 2 0 0 1 2-2h3.9c.7 0 1.3.3 1.7.9l.8 1.2c.4.6 1 .9 1.7.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-9.5",key:"a8xqs0"}],["path",{d:"M11.378 13.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1saktj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vK=Z("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bK=Z("FolderRoot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M12 15v5",key:"11xva1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _K=Z("FolderSearch2",[["circle",{cx:"11.5",cy:"12.5",r:"2.5",key:"1ea5ju"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M13.3 14.3 15 16",key:"1y4v1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wK=Z("FolderSearch",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jK=Z("FolderSymlink",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"x1c07l"}],["path",{d:"m8 16 3-3-3-3",key:"rlqrt1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NK=Z("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kK=Z("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SK=Z("FolderUp",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CK=Z("FolderX",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MK=Z("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TK=Z("Folders",[["path",{d:"M20 17a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.9a2 2 0 0 1-1.69-.9l-.81-1.2a2 2 0 0 0-1.67-.9H8a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2Z",key:"4u7rpt"}],["path",{d:"M2 8v11a2 2 0 0 0 2 2h14",key:"1eicx1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AK=Z("Footprints",[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EK=Z("Forklift",[["path",{d:"M12 12H5a2 2 0 0 0-2 2v5",key:"7zsz91"}],["circle",{cx:"13",cy:"19",r:"2",key:"wjnkru"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M8 19h3m5-17v17h6M6 12V7c0-1.1.9-2 2-2h3l5 5",key:"13bk1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PK=Z("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IK=Z("Frame",[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LK=Z("Framer",[["path",{d:"M5 16V9h14V2H5l14 14h-7m-7 0 7 7v-7m-7 0h7",key:"1a2nng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DK=Z("Frown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OK=Z("Fuel",[["line",{x1:"3",x2:"15",y1:"22",y2:"22",key:"xegly4"}],["line",{x1:"4",x2:"14",y1:"9",y2:"9",key:"xcnuvu"}],["path",{d:"M14 22V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v18",key:"16j0yd"}],["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 2 2a2 2 0 0 0 2-2V9.83a2 2 0 0 0-.59-1.42L18 5",key:"7cu91f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RK=Z("Fullscreen",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FK=Z("GalleryHorizontalEnd",[["path",{d:"M2 7v10",key:"a2pl2d"}],["path",{d:"M6 5v14",key:"1kq3d7"}],["rect",{width:"12",height:"18",x:"10",y:"3",rx:"2",key:"13i7bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zK=Z("GalleryHorizontal",[["path",{d:"M2 3v18",key:"pzttux"}],["rect",{width:"12",height:"18",x:"6",y:"3",rx:"2",key:"btr8bg"}],["path",{d:"M22 3v18",key:"6jf3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BK=Z("GalleryThumbnails",[["rect",{width:"18",height:"14",x:"3",y:"3",rx:"2",key:"74y24f"}],["path",{d:"M4 21h1",key:"16zlid"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M19 21h1",key:"edywat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $K=Z("GalleryVerticalEnd",[["path",{d:"M7 2h10",key:"nczekb"}],["path",{d:"M5 6h14",key:"u2x4p"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qK=Z("GalleryVertical",[["path",{d:"M3 2h18",key:"15qxfx"}],["rect",{width:"18",height:"12",x:"3",y:"6",rx:"2",key:"1439r6"}],["path",{d:"M3 22h18",key:"8prr45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UK=Z("Gamepad2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VK=Z("Gamepad",[["line",{x1:"6",x2:"10",y1:"12",y2:"12",key:"161bw2"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"15",x2:"15.01",y1:"13",y2:"13",key:"dqpgro"}],["line",{x1:"18",x2:"18.01",y1:"11",y2:"11",key:"meh2c"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HK=Z("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WK=Z("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GK=Z("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tS=Z("Ghost",[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ko=Z("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KK=Z("GitBranchPlus",[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZK=Z("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hN=Z("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YK=Z("GitCommitVertical",[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XK=Z("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QK=Z("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JK=Z("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eZ=Z("GitGraph",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tZ=Z("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sZ=Z("GitPullRequestArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rZ=Z("GitPullRequestClosed",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"m21 3-6 6",key:"16nqsk"}],["path",{d:"m21 9-6-6",key:"9j17rh"}],["path",{d:"M18 11.5V15",key:"65xf6f"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nZ=Z("GitPullRequestCreateArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v3",key:"1rbwk6"}],["path",{d:"M19 15v6",key:"10aioa"}],["path",{d:"M22 18h-6",key:"1d5gi5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aZ=Z("GitPullRequestCreate",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v3",key:"1jb6z3"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iZ=Z("GitPullRequestDraft",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M18 6V5",key:"1oao2s"}],["path",{d:"M18 11v-1",key:"11c8tz"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oZ=Z("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lZ=Z("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cZ=Z("Gitlab",[["path",{d:"m22 13.29-3.33-10a.42.42 0 0 0-.14-.18.38.38 0 0 0-.22-.11.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18l-2.26 6.67H8.32L6.1 3.26a.42.42 0 0 0-.1-.18.38.38 0 0 0-.26-.08.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18L2 13.29a.74.74 0 0 0 .27.83L12 21l9.69-6.88a.71.71 0 0 0 .31-.83Z",key:"148pdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dZ=Z("GlassWater",[["path",{d:"M5.116 4.104A1 1 0 0 1 6.11 3h11.78a1 1 0 0 1 .994 1.105L17.19 20.21A2 2 0 0 1 15.2 22H8.8a2 2 0 0 1-2-1.79z",key:"p55z4y"}],["path",{d:"M6 12a5 5 0 0 1 6 0 5 5 0 0 0 6 0",key:"mjntcy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uZ=Z("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hZ=Z("GlobeLock",[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const su=Z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mZ=Z("Goal",[["path",{d:"M12 13V2l8 4-8 4",key:"5wlwwj"}],["path",{d:"M20.561 10.222a9 9 0 1 1-12.55-5.29",key:"1c0wjv"}],["path",{d:"M8.002 9.997a5 5 0 1 0 8.9 2.02",key:"gb1g7m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pZ=Z("Grab",[["path",{d:"M18 11.5V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"edstyy"}],["path",{d:"M14 10V8a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"19wdwo"}],["path",{d:"M10 9.9V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"1lugqo"}],["path",{d:"M6 14a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1hbeus"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-4a8 8 0 0 1-8-8 2 2 0 1 1 4 0",key:"1etffm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kh=Z("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fZ=Z("Grape",[["path",{d:"M22 5V2l-5.89 5.89",key:"1eenpo"}],["circle",{cx:"16.6",cy:"15.89",r:"3",key:"xjtalx"}],["circle",{cx:"8.11",cy:"7.4",r:"3",key:"u2fv6i"}],["circle",{cx:"12.35",cy:"11.65",r:"3",key:"i6i8g7"}],["circle",{cx:"13.91",cy:"5.85",r:"3",key:"6ye0dv"}],["circle",{cx:"18.15",cy:"10.09",r:"3",key:"snx9no"}],["circle",{cx:"6.56",cy:"13.2",r:"3",key:"17x4xg"}],["circle",{cx:"10.8",cy:"17.44",r:"3",key:"1hogw9"}],["circle",{cx:"5",cy:"19",r:"3",key:"1sn6vo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xZ=Z("Grid2x2Check",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mN=Z("Grid2x2Plus",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 22v-6",key:"qhmiwi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gZ=Z("Grid2x2X",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 16 5 5",key:"8tpb07"}],["path",{d:"m16 21 5-5",key:"193jll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pN=Z("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ax=Z("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yZ=Z("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cu=Z("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vZ=Z("Grip",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bZ=Z("Group",[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Z=Z("Guitar",[["path",{d:"m11.9 12.1 4.514-4.514",key:"109xqo"}],["path",{d:"M20.1 2.3a1 1 0 0 0-1.4 0l-1.114 1.114A2 2 0 0 0 17 4.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 17.828 7h1.344a2 2 0 0 0 1.414-.586L21.7 5.3a1 1 0 0 0 0-1.4z",key:"txyc8t"}],["path",{d:"m6 16 2 2",key:"16qmzd"}],["path",{d:"M8.2 9.9C8.7 8.8 9.8 8 11 8c2.8 0 5 2.2 5 5 0 1.2-.8 2.3-1.9 2.8l-.9.4A2 2 0 0 0 12 18a4 4 0 0 1-4 4c-3.3 0-6-2.7-6-6a4 4 0 0 1 4-4 2 2 0 0 0 1.8-1.2z",key:"1u8q3z"}],["circle",{cx:"11.5",cy:"12.5",r:".5",fill:"currentColor",key:"16onso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wZ=Z("Ham",[["path",{d:"M13.144 21.144A7.274 10.445 45 1 0 2.856 10.856",key:"1k1t7q"}],["path",{d:"M13.144 21.144A7.274 4.365 45 0 0 2.856 10.856a7.274 4.365 45 0 0 10.288 10.288",key:"153t1g"}],["path",{d:"M16.565 10.435 18.6 8.4a2.501 2.501 0 1 0 1.65-4.65 2.5 2.5 0 1 0-4.66 1.66l-2.024 2.025",key:"gzrt0n"}],["path",{d:"m8.5 16.5-1-1",key:"otr954"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jZ=Z("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NZ=Z("HandCoins",[["path",{d:"M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17",key:"geh8rc"}],["path",{d:"m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"1fto5m"}],["path",{d:"m2 16 6 6",key:"1pfhp9"}],["circle",{cx:"16",cy:"9",r:"2.9",key:"1n0dlu"}],["circle",{cx:"6",cy:"5",r:"3",key:"151irh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kZ=Z("HandHeart",[["path",{d:"M11 14h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 16",key:"1ifwr1"}],["path",{d:"m7 20 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"17abbs"}],["path",{d:"m2 15 6 6",key:"10dquu"}],["path",{d:"M19.5 8.5c.7-.7 1.5-1.6 1.5-2.7A2.73 2.73 0 0 0 16 4a2.78 2.78 0 0 0-5 1.8c0 1.2.8 2 1.5 2.8L16 12Z",key:"1h3036"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fN=Z("HandHelping",[["path",{d:"M11 12h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 14",key:"1j4xps"}],["path",{d:"m7 18 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"uospg8"}],["path",{d:"m2 13 6 6",key:"16e5sb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SZ=Z("HandMetal",[["path",{d:"M18 12.5V10a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"wc6myp"}],["path",{d:"M14 11V9a2 2 0 1 0-4 0v2",key:"94qvcw"}],["path",{d:"M10 10.5V5a2 2 0 1 0-4 0v9",key:"m1ah89"}],["path",{d:"m7 15-1.76-1.76a2 2 0 0 0-2.83 2.82l3.6 3.6C7.5 21.14 9.2 22 12 22h2a8 8 0 0 0 8-8V7a2 2 0 1 0-4 0v5",key:"t1skq1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CZ=Z("HandPlatter",[["path",{d:"M12 3V2",key:"ar7q03"}],["path",{d:"m15.4 17.4 3.2-2.8a2 2 0 1 1 2.8 2.9l-3.6 3.3c-.7.8-1.7 1.2-2.8 1.2h-4c-1.1 0-2.1-.4-2.8-1.2l-1.302-1.464A1 1 0 0 0 6.151 19H5",key:"n2g93r"}],["path",{d:"M2 14h12a2 2 0 0 1 0 4h-2",key:"1o2jem"}],["path",{d:"M4 10h16",key:"img6z1"}],["path",{d:"M5 10a7 7 0 0 1 14 0",key:"1ega1o"}],["path",{d:"M5 14v6a1 1 0 0 1-1 1H2",key:"1hescx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lL=Z("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cL=Z("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MZ=Z("HardDriveDownload",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TZ=Z("HardDriveUpload",[["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M12 2v8",key:"1q4o3n"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dL=Z("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AZ=Z("HardHat",[["path",{d:"M10 10V5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v5",key:"1p9q5i"}],["path",{d:"M14 6a6 6 0 0 1 6 6v3",key:"1hnv84"}],["path",{d:"M4 15v-3a6 6 0 0 1 6-6",key:"9ciidu"}],["rect",{x:"2",y:"15",width:"20",height:"4",rx:"1",key:"g3x8cw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $_=Z("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EZ=Z("Haze",[["path",{d:"m5.2 6.2 1.4 1.4",key:"17imol"}],["path",{d:"M2 13h2",key:"13gyu8"}],["path",{d:"M20 13h2",key:"16rner"}],["path",{d:"m17.4 7.6 1.4-1.4",key:"t4xlah"}],["path",{d:"M22 17H2",key:"1gtaj3"}],["path",{d:"M22 21H2",key:"1gy6en"}],["path",{d:"M16 13a4 4 0 0 0-8 0",key:"1dyczq"}],["path",{d:"M12 5V2.5",key:"1vytko"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PZ=Z("HdmiPort",[["path",{d:"M22 9a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h1l2 2h12l2-2h1a1 1 0 0 0 1-1Z",key:"2128wb"}],["path",{d:"M7.5 12h9",key:"1t0ckc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EM=Z("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PM=Z("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uL=Z("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IZ=Z("Heading4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LZ=Z("Heading5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DZ=Z("Heading6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OZ=Z("Heading",[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RZ=Z("HeadphoneOff",[["path",{d:"M21 14h-1.343",key:"1jdnxi"}],["path",{d:"M9.128 3.47A9 9 0 0 1 21 12v3.343",key:"6kipu2"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.414 20.414A2 2 0 0 1 19 21h-1a2 2 0 0 1-2-2v-3",key:"9x50f4"}],["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 2.636-6.364",key:"1bkxnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FZ=Z("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zZ=Z("Headset",[["path",{d:"M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3Z",key:"12oyoe"}],["path",{d:"M21 16v2a4 4 0 0 1-4 4h-5",key:"1x7m43"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BZ=Z("HeartCrack",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"m12 13-1-1 2-2-3-3 2-2",key:"xjdxli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Z=Z("HeartHandshake",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M12 5 9.04 7.96a2.17 2.17 0 0 0 0 3.08c.82.82 2.13.85 3 .07l2.07-1.9a2.82 2.82 0 0 1 3.79 0l2.96 2.66",key:"4oyue0"}],["path",{d:"m18 15-2-2",key:"60u0ii"}],["path",{d:"m15 18-2-2",key:"6p76be"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qZ=Z("HeartOff",[["line",{x1:"2",y1:"2",x2:"22",y2:"22",key:"1w4vcy"}],["path",{d:"M16.5 16.5 12 21l-7-7c-1.5-1.45-3-3.2-3-5.5a5.5 5.5 0 0 1 2.14-4.35",key:"3mpagl"}],["path",{d:"M8.76 3.1c1.15.22 2.13.78 3.24 1.9 1.5-1.5 2.74-2 4.5-2A5.5 5.5 0 0 1 22 8.5c0 2.12-1.3 3.78-2.67 5.17",key:"1gh3v3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UZ=Z("HeartPulse",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"1uw2ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ni=Z("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VZ=Z("Heater",[["path",{d:"M11 8c2-3-2-3 0-6",key:"1ldv5m"}],["path",{d:"M15.5 8c2-3-2-3 0-6",key:"1otqoz"}],["path",{d:"M6 10h.01",key:"1lbq93"}],["path",{d:"M6 14h.01",key:"zudwn7"}],["path",{d:"M10 16v-4",key:"1c25yv"}],["path",{d:"M14 16v-4",key:"1dkbt8"}],["path",{d:"M18 16v-4",key:"1yg9me"}],["path",{d:"M20 6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h3",key:"1ubg90"}],["path",{d:"M5 20v2",key:"1abpe8"}],["path",{d:"M19 20v2",key:"kqn6ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HZ=Z("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WZ=Z("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IM=Z("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GZ=Z("HopOff",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.28.01.53-.09.7-.27",key:"qyzcap"}],["path",{d:"M11.14 20.57c.52.24 2.44 1.12 4.08 1.37.46.06.86-.25.9-.71.12-1.52-.3-3.43-.5-4.28",key:"y078lb"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .7-.26",key:"1utre3"}],["path",{d:"M17.99 5.52a20.83 20.83 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-1.17.1-2.5.02-3.9-.25",key:"17o9hm"}],["path",{d:"M20.57 11.14c.24.52 1.12 2.44 1.37 4.08.04.3-.08.59-.31.75",key:"1d1n4p"}],["path",{d:"M4.93 4.93a10 10 0 0 0-.67 13.4c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.85.85 0 0 0 .48-.24",key:"9uv3tt"}],["path",{d:"M5.52 17.99c1.05.95 2.91 2.42 4.5 3.15a.8.8 0 0 0 1.13-.68c.2-2.34-.33-5.3-1.57-8.28",key:"1292wz"}],["path",{d:"M8.35 2.68a10 10 0 0 1 9.98 1.58c.43.35.4.96-.12 1.17-1.5.6-4.3.98-6.07 1.05",key:"7ozu9p"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KZ=Z("Hop",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.55.03 1-.42.97-.97-.06-1.27-.26-3.5-.85-5.18",key:"18lxf1"}],["path",{d:"M11.5 6.5c1.64 0 5-.38 6.71-1.07.52-.2.55-.82.12-1.17A10 10 0 0 0 4.26 18.33c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.88.88 0 0 0 .73-.74c.3-2.14-.15-3.5-.61-4.88",key:"vtfxrw"}],["path",{d:"M15.62 16.95c.2.85.62 2.76.5 4.28a.77.77 0 0 1-.9.7 16.64 16.64 0 0 1-4.08-1.36",key:"13hl71"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .96-.96 17.68 17.68 0 0 0-.9-4.87",key:"1sl8oj"}],["path",{d:"M16.94 15.62c.86.2 2.77.62 4.29.5a.77.77 0 0 0 .7-.9 16.64 16.64 0 0 0-1.36-4.08",key:"19c6kt"}],["path",{d:"M17.99 5.52a20.82 20.82 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-2.33.2-5.3-.32-8.27-1.57",key:"85ghs3"}],["path",{d:"M4.93 4.93 3 3a.7.7 0 0 1 0-1",key:"x087yj"}],["path",{d:"M9.58 12.18c1.24 2.98 1.77 5.95 1.57 8.28a.8.8 0 0 1-1.13.68 20.82 20.82 0 0 1-4.5-3.15",key:"11xdqo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZZ=Z("Hospital",[["path",{d:"M12 6v4",key:"16clxf"}],["path",{d:"M14 14h-4",key:"esezmu"}],["path",{d:"M14 18h-4",key:"16mqa2"}],["path",{d:"M14 8h-4",key:"z8ypaz"}],["path",{d:"M18 12h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2",key:"b1k337"}],["path",{d:"M18 22V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v18",key:"16g51d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YZ=Z("Hotel",[["path",{d:"M10 22v-6.57",key:"1wmca3"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M12 7h.01",key:"1ivr5q"}],["path",{d:"M14 15.43V22",key:"1q2vjd"}],["path",{d:"M15 16a5 5 0 0 0-6 0",key:"o9wqvi"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 7h.01",key:"1vti4s"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XZ=Z("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QZ=Z("HousePlug",[["path",{d:"M10 12V8.964",key:"1vll13"}],["path",{d:"M14 12V8.964",key:"1x3qvg"}],["path",{d:"M15 12a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2a1 1 0 0 1 1-1z",key:"ppykja"}],["path",{d:"M8.5 21H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-2",key:"1gvg2z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JZ=Z("HousePlus",[["path",{d:"M13.22 2.416a2 2 0 0 0-2.511.057l-7 5.999A2 2 0 0 0 3 10v9a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7.354",key:"5phn05"}],["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 3v6",key:"x1uolp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bn=Z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xN=Z("IceCreamBowl",[["path",{d:"M12 17c5 0 8-2.69 8-6H4c0 3.31 3 6 8 6m-4 4h8m-4-3v3M5.14 11a3.5 3.5 0 1 1 6.71 0",key:"1uxfcu"}],["path",{d:"M12.14 11a3.5 3.5 0 1 1 6.71 0",key:"4k3m1s"}],["path",{d:"M15.5 6.5a3.5 3.5 0 1 0-7 0",key:"zmuahr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gN=Z("IceCreamCone",[["path",{d:"m7 11 4.08 10.35a1 1 0 0 0 1.84 0L17 11",key:"1v6356"}],["path",{d:"M17 7A5 5 0 0 0 7 7",key:"151p3v"}],["path",{d:"M17 7a2 2 0 0 1 0 4H7a2 2 0 0 1 0-4",key:"1sdaij"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eY=Z("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tY=Z("ImageDown",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sY=Z("ImageMinus",[["path",{d:"M21 9v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"m87ecr"}],["line",{x1:"16",x2:"22",y1:"5",y2:"5",key:"ez7e4s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rY=Z("ImageOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nY=Z("ImagePlay",[["path",{d:"m11 16-5 5",key:"j5f7ct"}],["path",{d:"M11 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6.5",key:"7s81lt"}],["path",{d:"M15.765 22a.5.5 0 0 1-.765-.424V13.38a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"1omb6s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o1=Z("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aY=Z("ImageUp",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19.5 3-3 3 3",key:"9vmjn0"}],["path",{d:"M17 22v-5.5",key:"1aa6fl"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iY=Z("ImageUpscale",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M17 21h2a2 2 0 0 0 2-2",key:"130fy9"}],["path",{d:"M21 12v3",key:"1wzk3p"}],["path",{d:"m21 3-5 5",key:"1g5oa7"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2",key:"kk3yz1"}],["path",{d:"m5 21 4.144-4.144a1.21 1.21 0 0 1 1.712 0L13 19",key:"fyekpt"}],["path",{d:"M9 3h3",key:"d52fa"}],["rect",{x:"3",y:"11",width:"10",height:"10",rx:"1",key:"1wpmix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gl=Z("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oY=Z("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lY=Z("Import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cY=Z("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yN=Z("IndentDecrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m7 8-4 4 4 4",key:"o5hrat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vN=Z("IndentIncrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m3 8 4 4-4 4",key:"1a3j6y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dY=Z("IndianRupee",[["path",{d:"M6 3h12",key:"ggurg9"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"m6 13 8.5 8",key:"u1kupk"}],["path",{d:"M6 13h3",key:"wdp6ag"}],["path",{d:"M9 13c6.667 0 6.667-10 0-10",key:"1nkvk2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uY=Z("Infinity",[["path",{d:"M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z",key:"1z0uae"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hL=Z("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hY=Z("InspectionPanel",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h.01",key:"7u93v4"}],["path",{d:"M17 7h.01",key:"14a9sn"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mu=Z("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sS=Z("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mY=Z("IterationCcw",[["path",{d:"M20 10c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8h8",key:"4znkd0"}],["polyline",{points:"16 14 20 18 16 22",key:"11njsm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pY=Z("IterationCw",[["path",{d:"M4 10c0-4.4 3.6-8 8-8s8 3.6 8 8-3.6 8-8 8H4",key:"tuf4su"}],["polyline",{points:"8 22 4 18 8 14",key:"evkj9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fY=Z("JapaneseYen",[["path",{d:"M12 9.5V21m0-11.5L6 3m6 6.5L18 3",key:"2ej80x"}],["path",{d:"M6 15h12",key:"1hwgt5"}],["path",{d:"M6 11h12",key:"wf4gp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xY=Z("Joystick",[["path",{d:"M21 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-2Z",key:"jg2n2t"}],["path",{d:"M6 15v-2",key:"gd6mvg"}],["path",{d:"M12 15V9",key:"8c7uyn"}],["circle",{cx:"12",cy:"6",r:"3",key:"1gm2ql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m0=Z("Kanban",[["path",{d:"M6 5v11",key:"mdvv1e"}],["path",{d:"M12 5v6",key:"14ar3b"}],["path",{d:"M18 5v14",key:"7ji314"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rS=Z("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gY=Z("KeySquare",[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814",key:"1ubxi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sp=Z("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yY=Z("KeyboardMusic",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M6 12v4",key:"dy92yo"}],["path",{d:"M10 12v4",key:"1fxnav"}],["path",{d:"M14 12v4",key:"1hft58"}],["path",{d:"M18 12v4",key:"tjjnbz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vY=Z("KeyboardOff",[["path",{d:"M 20 4 A2 2 0 0 1 22 6",key:"1g1fkt"}],["path",{d:"M 22 6 L 22 16.41",key:"1qjg3w"}],["path",{d:"M 7 16 L 16 16",key:"n0yqwb"}],["path",{d:"M 9.69 4 L 20 4",key:"kbpcgx"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20 20H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2",key:"s23sx2"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M8 12h.01",key:"czm47f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bY=Z("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Y=Z("LampCeiling",[["path",{d:"M12 2v5",key:"nd4vlx"}],["path",{d:"M6 7h12l4 9H2l4-9Z",key:"123d64"}],["path",{d:"M9.17 16a3 3 0 1 0 5.66 0",key:"1061mw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wY=Z("LampDesk",[["path",{d:"m14 5-3 3 2 7 8-8-7-2Z",key:"1b0msb"}],["path",{d:"m14 5-3 3-3-3 3-3 3 3Z",key:"1uemms"}],["path",{d:"M9.5 6.5 4 12l3 6",key:"1bx08v"}],["path",{d:"M3 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H3Z",key:"wap775"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jY=Z("LampFloor",[["path",{d:"M9 2h6l3 7H6l3-7Z",key:"wcx6mj"}],["path",{d:"M12 9v13",key:"3n1su1"}],["path",{d:"M9 22h6",key:"1rlq3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NY=Z("LampWallDown",[["path",{d:"M11 13h6l3 7H8l3-7Z",key:"9n3qlo"}],["path",{d:"M14 13V8a2 2 0 0 0-2-2H8",key:"1hu4hb"}],["path",{d:"M4 9h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H4v6Z",key:"s053bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kY=Z("LampWallUp",[["path",{d:"M11 4h6l3 7H8l3-7Z",key:"11x1ee"}],["path",{d:"M14 11v5a2 2 0 0 1-2 2H8",key:"eutp5o"}],["path",{d:"M4 15h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H4v-6Z",key:"1iuthr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SY=Z("Lamp",[["path",{d:"M8 2h8l4 10H4L8 2Z",key:"9dma5w"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M8 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H8Z",key:"mwf4oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CY=Z("LandPlot",[["path",{d:"m12 8 6-3-6-3v10",key:"mvpnpy"}],["path",{d:"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12",key:"ek95tt"}],["path",{d:"m6.49 12.85 11.02 6.3",key:"1kt42w"}],["path",{d:"M17.51 12.85 6.5 19.15",key:"v55bdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MY=Z("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TY=Z("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AY=Z("LaptopMinimalCheck",[["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{x:"3",y:"4",width:"18",height:"12",rx:"2",key:"8ur36m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bN=Z("LaptopMinimal",[["rect",{width:"18",height:"12",x:"3",y:"4",rx:"2",ry:"2",key:"1qhy41"}],["line",{x1:"2",x2:"22",y1:"20",y2:"20",key:"ni3hll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EY=Z("Laptop",[["path",{d:"M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16",key:"tarvll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PY=Z("LassoSelect",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M7 16.93c.96.43 1.96.74 2.99.91",key:"ybbtv3"}],["path",{d:"M3.34 14A6.8 6.8 0 0 1 2 10c0-4.42 4.48-8 10-8s10 3.58 10 8a7.19 7.19 0 0 1-.33 2",key:"gt5e1w"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}],["path",{d:"M14.33 22h-.09a.35.35 0 0 1-.24-.32v-10a.34.34 0 0 1 .33-.34c.08 0 .15.03.21.08l7.34 6a.33.33 0 0 1-.21.59h-4.49l-2.57 3.85a.35.35 0 0 1-.28.14z",key:"72q637"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IY=Z("Lasso",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M3.3 14A6.8 6.8 0 0 1 2 10c0-4.4 4.5-8 10-8s10 3.6 10 8-4.5 8-10 8a12 12 0 0 1-5-1",key:"146dds"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LY=Z("Laugh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DY=Z("Layers2",[["path",{d:"m16.02 12 5.48 3.13a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74L7.98 12",key:"1cuww1"}],["path",{d:"M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74Z",key:"pdlvxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OY=Z("Layers3",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m6.08 9.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1e5n1m"}],["path",{d:"m6.08 14.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1iwflc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LM=Z("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nS=Z("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cp=Z("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RY=Z("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FY=Z("LayoutPanelLeft",[["rect",{width:"7",height:"18",x:"3",y:"3",rx:"1",key:"2obqm"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zY=Z("LayoutPanelTop",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aS=Z("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BY=Z("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Y=Z("LeafyGreen",[["path",{d:"M2 22c1.25-.987 2.27-1.975 3.9-2.2a5.56 5.56 0 0 1 3.8 1.5 4 4 0 0 0 6.187-2.353 3.5 3.5 0 0 0 3.69-5.116A3.5 3.5 0 0 0 20.95 8 3.5 3.5 0 1 0 16 3.05a3.5 3.5 0 0 0-5.831 1.373 3.5 3.5 0 0 0-5.116 3.69 4 4 0 0 0-2.348 6.155C3.499 15.42 4.409 16.712 4.2 18.1 3.926 19.743 3.014 20.732 2 22",key:"1134nt"}],["path",{d:"M2 22 17 7",key:"1q7jp2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qY=Z("Lectern",[["path",{d:"M16 12h3a2 2 0 0 0 1.902-1.38l1.056-3.333A1 1 0 0 0 21 6H3a1 1 0 0 0-.958 1.287l1.056 3.334A2 2 0 0 0 5 12h3",key:"13jjxg"}],["path",{d:"M18 6V3a1 1 0 0 0-1-1h-3",key:"1550fe"}],["rect",{width:"8",height:"12",x:"8",y:"10",rx:"1",key:"qmu8b6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UY=Z("LetterText",[["path",{d:"M15 12h6",key:"upa0zy"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"m3 13 3.553-7.724a.5.5 0 0 1 .894 0L11 13",key:"blevx4"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M4 11h6",key:"olkgv1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VY=Z("LibraryBig",[["rect",{width:"8",height:"18",x:"3",y:"3",rx:"1",key:"oynpb5"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z",key:"1qboyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DM=Z("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OM=Z("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HY=Z("Ligature",[["path",{d:"M8 20V8c0-2.2 1.8-4 4-4 1.5 0 2.8.8 3.5 2",key:"1rtphz"}],["path",{d:"M6 12h4",key:"a4o3ry"}],["path",{d:"M14 12h2v8",key:"c1fccl"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 20h4",key:"lzx1xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WY=Z("LightbulbOff",[["path",{d:"M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5",key:"1fkcox"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5",key:"10m8kw"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q_=Z("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GY=Z("Link2Off",[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dl=Z("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bo=Z("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mp=Z("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KY=Z("ListCheck",[["path",{d:"M11 18H3",key:"n3j2dh"}],["path",{d:"m15 18 2 2 4-4",key:"1szwhi"}],["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZY=Z("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YY=Z("ListCollapse",[["path",{d:"m3 10 2.5-2.5L3 5",key:"i6eama"}],["path",{d:"m3 19 2.5-2.5L3 14",key:"w2gmor"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XY=Z("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QY=Z("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JY=Z("ListMinus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eX=Z("ListMusic",[["path",{d:"M21 15V6",key:"h1cx4g"}],["path",{d:"M18.5 18a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z",key:"8saifv"}],["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p0=Z("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tX=Z("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sX=Z("ListRestart",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 18H3",key:"1sijw9"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rX=Z("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nX=Z("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aX=Z("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iX=Z("ListVideo",[["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}],["path",{d:"m16 12 5 3-5 3v-6Z",key:"zpskkp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oX=Z("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mh=Z("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ws=Z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lX=Z("LoaderPinwheel",[["path",{d:"M22 12a1 1 0 0 1-10 0 1 1 0 0 0-10 0",key:"1lzz15"}],["path",{d:"M7 20.7a1 1 0 1 1 5-8.7 1 1 0 1 0 5-8.6",key:"1gnrpi"}],["path",{d:"M7 3.3a1 1 0 1 1 5 8.6 1 1 0 1 0 5 8.6",key:"u9yy5q"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cX=Z("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dX=Z("LocateFixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uX=Z("LocateOff",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["path",{d:"M7.11 7.11C5.83 8.39 5 10.1 5 12c0 3.87 3.13 7 7 7 1.9 0 3.61-.83 4.89-2.11",key:"1oh7ia"}],["path",{d:"M18.71 13.96c.19-.63.29-1.29.29-1.96 0-3.87-3.13-7-7-7-.67 0-1.33.1-1.96.29",key:"3qdecy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hX=Z("Locate",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _N=Z("LockKeyholeOpen",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}],["path",{d:"M7 10V7a5 5 0 0 1 9.33-2.5",key:"car5b7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mX=Z("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wN=Z("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Th=Z("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iS=Z("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oS=Z("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pX=Z("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fX=Z("Lollipop",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M11 11a2 2 0 0 0 4 0 4 4 0 0 0-8 0 6 6 0 0 0 12 0",key:"107gwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xX=Z("Luggage",[["path",{d:"M6 20a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1m57jg"}],["path",{d:"M8 18V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v14",key:"1l99gc"}],["path",{d:"M10 20h4",key:"ni2waw"}],["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gX=Z("Magnet",[["path",{d:"m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15",key:"1i3lhw"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}],["path",{d:"m12 15 4 4",key:"lnac28"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yX=Z("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vX=Z("MailMinus",[["path",{d:"M22 15V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"fuxbkv"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bX=Z("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mL=Z("MailPlus",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _X=Z("MailQuestion",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"7z9rxb"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wX=Z("MailSearch",[["path",{d:"M22 12.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h7.5",key:"w80f2v"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"8lzu5m"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.5-1.5",key:"1x83k4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jX=Z("MailWarning",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M20 14v4",key:"1hm744"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pL=Z("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cr=Z("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NX=Z("Mailbox",[["path",{d:"M22 17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.5C2 7 4 5 6.5 5H18c2.2 0 4 1.8 4 4v8Z",key:"1lbycx"}],["polyline",{points:"15,9 18,9 18,11",key:"1pm9c0"}],["path",{d:"M6.5 5C9 5 11 7 11 9.5V17a2 2 0 0 1-2 2",key:"15i455"}],["line",{x1:"6",x2:"7",y1:"10",y2:"10",key:"1e2scm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kX=Z("Mails",[["rect",{width:"16",height:"13",x:"6",y:"4",rx:"2",key:"1drq3f"}],["path",{d:"m22 7-7.1 3.78c-.57.3-1.23.3-1.8 0L6 7",key:"xn252p"}],["path",{d:"M2 8v11c0 1.1.9 2 2 2h14",key:"n13cji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SX=Z("MapPinCheckInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CX=Z("MapPinCheck",[["path",{d:"M19.43 12.935c.357-.967.57-1.955.57-2.935a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32.197 32.197 0 0 0 .813-.728",key:"1dq61d"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m16 18 2 2 4-4",key:"1mkfmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MX=Z("MapPinHouse",[["path",{d:"M15 22a1 1 0 0 1-1-1v-4a1 1 0 0 1 .445-.832l3-2a1 1 0 0 1 1.11 0l3 2A1 1 0 0 1 22 17v4a1 1 0 0 1-1 1z",key:"1p1rcz"}],["path",{d:"M18 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 .601.2",key:"mcbcs9"}],["path",{d:"M18 22v-3",key:"1t1ugv"}],["circle",{cx:"10",cy:"10",r:"3",key:"1ns7v1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TX=Z("MapPinMinusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AX=Z("MapPinMinus",[["path",{d:"M18.977 14C19.6 12.701 20 11.343 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"11uxia"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EX=Z("MapPinOff",[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16",key:"1d4wjd"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568",key:"12yil7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533",key:"lhrkcz"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74",key:"13wojd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PX=Z("MapPinPlusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IX=Z("MapPinPlus",[["path",{d:"M19.914 11.105A7.298 7.298 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"fcdtly"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}],["path",{d:"M19 15v6",key:"10aioa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LX=Z("MapPinXInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DX=Z("MapPinX",[["path",{d:"M19.752 11.901A7.78 7.78 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 19 19 0 0 0 .09-.077",key:"y0ewhp"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m21.5 15.5-5 5",key:"11iqnx"}],["path",{d:"m21.5 20.5-5-5",key:"1bylgx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ma=Z("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OX=Z("MapPinned",[["path",{d:"M18 8c0 3.613-3.869 7.429-5.393 8.795a1 1 0 0 1-1.214 0C9.87 15.429 6 11.613 6 8a6 6 0 0 1 12 0",key:"11u0oz"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M8.714 14h-3.71a1 1 0 0 0-.948.683l-2.004 6A1 1 0 0 0 3 22h18a1 1 0 0 0 .948-1.316l-2-6a1 1 0 0 0-.949-.684h-3.712",key:"q8zwxj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l1=Z("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RX=Z("Martini",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M12 11v11",key:"ur9y6a"}],["path",{d:"m19 3-7 8-7-8Z",key:"1sgpiw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FX=Z("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lS=Z("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c1=Z("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zX=Z("MegaphoneOff",[["path",{d:"M9.26 9.26 3 11v3l14.14 3.14",key:"3429n"}],["path",{d:"M21 15.34V6l-7.31 2.03",key:"4o1dh8"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ah=Z("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BX=Z("Meh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"8",x2:"16",y1:"15",y2:"15",key:"1xb1d9"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $X=Z("MemoryStick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RM=Z("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qX=Z("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UX=Z("MessageCircleCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22z",key:"k85zhp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VX=Z("MessageCircleDashed",[["path",{d:"M13.5 3.1c-.5 0-1-.1-1.5-.1s-1 .1-1.5.1",key:"16ll65"}],["path",{d:"M19.3 6.8a10.45 10.45 0 0 0-2.1-2.1",key:"1nq77a"}],["path",{d:"M20.9 13.5c.1-.5.1-1 .1-1.5s-.1-1-.1-1.5",key:"1sf7wn"}],["path",{d:"M17.2 19.3a10.45 10.45 0 0 0 2.1-2.1",key:"x1hs5g"}],["path",{d:"M10.5 20.9c.5.1 1 .1 1.5.1s1-.1 1.5-.1",key:"19m18z"}],["path",{d:"M3.5 17.5 2 22l4.5-1.5",key:"1f36qi"}],["path",{d:"M3.1 10.5c0 .5-.1 1-.1 1.5s.1 1 .1 1.5",key:"1vz3ju"}],["path",{d:"M6.8 4.7a10.45 10.45 0 0 0-2.1 2.1",key:"19f9do"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FM=Z("MessageCircleHeart",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M15.8 9.2a2.5 2.5 0 0 0-3.5 0l-.3.4-.35-.3a2.42 2.42 0 1 0-3.2 3.6l3.6 3.5 3.6-3.5c1.2-1.2 1.1-2.7.2-3.7",key:"43lnbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HX=Z("MessageCircleMore",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WX=Z("MessageCircleOff",[["path",{d:"M20.5 14.9A9 9 0 0 0 9.1 3.5",key:"1iebmn"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.6 5.6C3 8.3 2.2 12.5 4 16l-2 6 6-2c3.4 1.8 7.6 1.1 10.3-1.7",key:"1ov8ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GX=Z("MessageCirclePlus",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fL=Z("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KX=Z("MessageCircleReply",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}],["path",{d:"M7 12h7a2 2 0 0 1 2 2v1",key:"1gheu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZX=Z("MessageCircleWarning",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YX=Z("MessageCircleX",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $c=Z("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XX=Z("MessageSquareCode",[["path",{d:"M10 7.5 8 10l2 2.5",key:"xb17xw"}],["path",{d:"m14 7.5 2 2.5-2 2.5",key:"5rap1v"}],["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QX=Z("MessageSquareDashed",[["path",{d:"M10 17H7l-4 4v-7",key:"1r71xu"}],["path",{d:"M14 17h1",key:"nufu4t"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 14v1a2 2 0 0 1-2 2",key:"29akq3"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JX=Z("MessageSquareDiff",[["path",{d:"m5 19-2 2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1xuzuj"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eQ=Z("MessageSquareDot",[["path",{d:"M11.7 3H5a2 2 0 0 0-2 2v16l4-4h12a2 2 0 0 0 2-2v-2.7",key:"uodpkb"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tQ=Z("MessageSquareHeart",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8",key:"1blaws"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sQ=Z("MessageSquareLock",[["path",{d:"M19 15v-2a2 2 0 1 0-4 0v2",key:"h3d1vz"}],["path",{d:"M9 17H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3.5",key:"xsnnhn"}],["rect",{x:"13",y:"15",width:"8",height:"5",rx:"1",key:"1ccwuk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xL=Z("MessageSquareMore",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rQ=Z("MessageSquareOff",[["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M3.6 3.6c-.4.3-.6.8-.6 1.4v16l4-4h10",key:"pwpm4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zM=Z("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gL=Z("MessageSquareQuote",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nQ=Z("MessageSquareReply",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m10 7-3 3 3 3",key:"1eugdv"}],["path",{d:"M17 13v-1a2 2 0 0 0-2-2H7",key:"ernfh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aQ=Z("MessageSquareShare",[["path",{d:"M21 12v3a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h7",key:"tqtdkg"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"m16 8 5-5",key:"15mbrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iQ=Z("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oQ=Z("MessageSquareWarning",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v2",key:"stiyo7"}],["path",{d:"M12 13h.01",key:"y0uutt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lQ=Z("MessageSquareX",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const so=Z("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cQ=Z("MessagesSquare",[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dQ=Z("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jN=Z("MicVocal",[["path",{d:"m11 7.601-5.994 8.19a1 1 0 0 0 .1 1.298l.817.818a1 1 0 0 0 1.314.087L15.09 12",key:"80a601"}],["path",{d:"M16.5 21.174C15.5 20.5 14.372 20 13 20c-2.058 0-3.928 2.356-6 2-2.072-.356-2.775-3.369-1.5-4.5",key:"j0ngtp"}],["circle",{cx:"16",cy:"7",r:"5",key:"d08jfb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yL=Z("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uQ=Z("Microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hQ=Z("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mQ=Z("Microwave",[["rect",{width:"20",height:"15",x:"2",y:"4",rx:"2",key:"2no95f"}],["rect",{width:"8",height:"7",x:"6",y:"8",rx:"1",key:"zh9wx"}],["path",{d:"M18 8v7",key:"o5zi4n"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 19v2",key:"1dawf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pQ=Z("Milestone",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z",key:"1btarq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fQ=Z("MilkOff",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v1.343M15 2v2.789a4 4 0 0 0 .672 2.219l.656.984a4 4 0 0 1 .672 2.22v1.131M7.8 7.8l-.128.192A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-3",key:"y0ejgx"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.472 6.472 0 0 0 3.435.435",key:"iaxqsy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xQ=Z("Milk",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v2.789a4 4 0 0 1-.672 2.219l-.656.984A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-9.789a4 4 0 0 0-.672-2.219l-.656-.984A4 4 0 0 1 15 4.788V2",key:"qtp12x"}],["path",{d:"M7 15a6.472 6.472 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"ygeh44"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gQ=Z("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yQ=Z("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f0=Z("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vQ=Z("MonitorCheck",[["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bQ=Z("MonitorCog",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m15.2 4.9-.9-.4",key:"12wd2u"}],["path",{d:"m15.2 7.1-.9.4",key:"1r2vl7"}],["path",{d:"m16.9 3.2-.4-.9",key:"3zbo91"}],["path",{d:"m16.9 8.8-.4.9",key:"1qr2dn"}],["path",{d:"m19.5 2.3-.4.9",key:"1rjrkq"}],["path",{d:"m19.5 9.7-.4-.9",key:"heryx5"}],["path",{d:"m21.7 4.5-.9.4",key:"17fqt1"}],["path",{d:"m21.7 7.5-.9-.4",key:"14zyni"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Q=Z("MonitorDot",[["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M22 12v3a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9",key:"1fet9y"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wQ=Z("MonitorDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jQ=Z("MonitorOff",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NQ=Z("MonitorPause",[["path",{d:"M10 13V7",key:"1u13u9"}],["path",{d:"M14 13V7",key:"1vj9om"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kQ=Z("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SQ=Z("MonitorSmartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CQ=Z("MonitorSpeaker",[["path",{d:"M5.5 20H8",key:"1k40s5"}],["path",{d:"M17 9h.01",key:"1j24nn"}],["rect",{width:"10",height:"16",x:"12",y:"4",rx:"2",key:"ixliua"}],["path",{d:"M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4",key:"1mp6e1"}],["circle",{cx:"17",cy:"15",r:"1",key:"tqvash"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MQ=Z("MonitorStop",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}],["rect",{x:"9",y:"7",width:"6",height:"6",rx:"1",key:"5m2oou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cS=Z("MonitorUp",[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TQ=Z("MonitorX",[["path",{d:"m14.5 12.5-5-5",key:"1jahn5"}],["path",{d:"m9.5 12.5 5-5",key:"1k2t7b"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dS=Z("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AQ=Z("MoonStar",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EQ=Z("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PQ=Z("MountainSnow",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}],["path",{d:"M4.14 15.08c2.62-1.57 5.24-1.43 7.86.42 2.74 1.94 5.49 2 8.23.19",key:"1pvmmp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IQ=Z("Mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LQ=Z("MouseOff",[["path",{d:"M12 6v.343",key:"1gyhex"}],["path",{d:"M18.218 18.218A7 7 0 0 1 5 15V9a7 7 0 0 1 .782-3.218",key:"ukzz01"}],["path",{d:"M19 13.343V9A7 7 0 0 0 8.56 2.902",key:"104jy9"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DQ=Z("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OQ=Z("MousePointerBan",[["path",{d:"M2.034 2.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.944L8.204 7.545a1 1 0 0 0-.66.66l-1.066 3.443a.5.5 0 0 1-.944.033z",key:"11pp1i"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"m11.8 11.8 8.4 8.4",key:"oogvdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jg=Z("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wh=Z("MousePointer",[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RQ=Z("Mouse",[["rect",{x:"5",y:"2",width:"14",height:"20",rx:"7",key:"11ol66"}],["path",{d:"M12 6v4",key:"16clxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NN=Z("Move3d",[["path",{d:"M5 3v16h16",key:"1mqmf9"}],["path",{d:"m5 19 6-6",key:"jh6hbb"}],["path",{d:"m2 6 3-3 3 3",key:"tkyvxa"}],["path",{d:"m18 16 3 3-3 3",key:"1d4glt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FQ=Z("MoveDiagonal2",[["path",{d:"M19 13v6h-6",key:"1hxl6d"}],["path",{d:"M5 11V5h6",key:"12e2xe"}],["path",{d:"m5 5 14 14",key:"11anup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zQ=Z("MoveDiagonal",[["path",{d:"M11 19H5v-6",key:"8awifj"}],["path",{d:"M13 5h6v6",key:"7voy1q"}],["path",{d:"M19 5 5 19",key:"wwaj1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BQ=Z("MoveDownLeft",[["path",{d:"M11 19H5V13",key:"1akmht"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Q=Z("MoveDownRight",[["path",{d:"M19 13V19H13",key:"10vkzq"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qQ=Z("MoveDown",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UQ=Z("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VQ=Z("MoveLeft",[["path",{d:"M6 8L2 12L6 16",key:"kyvwex"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HQ=Z("MoveRight",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WQ=Z("MoveUpLeft",[["path",{d:"M5 11V5H11",key:"3q78g9"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GQ=Z("MoveUpRight",[["path",{d:"M13 5H19V11",key:"1n1gyv"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KQ=Z("MoveUp",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZQ=Z("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YQ=Z("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XQ=Z("Music2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QQ=Z("Music3",[["circle",{cx:"12",cy:"18",r:"4",key:"m3r9ws"}],["path",{d:"M16 18V2",key:"40x2m5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JQ=Z("Music4",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["path",{d:"m9 9 12-2",key:"1e64n2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eJ=Z("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tJ=Z("Navigation2Off",[["path",{d:"M9.31 9.31 5 21l7-4 7 4-1.17-3.17",key:"qoq2o2"}],["path",{d:"M14.53 8.88 12 2l-1.17 3.17",key:"k3sjzy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sJ=Z("Navigation2",[["polygon",{points:"12 2 19 21 12 17 5 21 12 2",key:"x8c0qg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rJ=Z("NavigationOff",[["path",{d:"M8.43 8.43 3 11l8 2 2 8 2.57-5.43",key:"1vdtb7"}],["path",{d:"M17.39 11.73 22 2l-9.73 4.61",key:"tya3r6"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nJ=Z("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aJ=Z("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d1=Z("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iJ=Z("Nfc",[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oJ=Z("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lJ=Z("NotebookTabs",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M15 2v20",key:"dcj49h"}],["path",{d:"M15 7h5",key:"1xj5lc"}],["path",{d:"M15 12h5",key:"w5shd9"}],["path",{d:"M15 17h5",key:"1qaofu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cJ=Z("NotebookText",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dJ=Z("Notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uJ=Z("NotepadTextDashed",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v2",key:"j91f56"}],["path",{d:"M20 12v2",key:"w8o0tu"}],["path",{d:"M20 18v2a2 2 0 0 1-2 2h-1",key:"1c9ggx"}],["path",{d:"M13 22h-2",key:"191ugt"}],["path",{d:"M7 22H6a2 2 0 0 1-2-2v-2",key:"1rt9px"}],["path",{d:"M4 14v-2",key:"1v0sqh"}],["path",{d:"M4 8V6a2 2 0 0 1 2-2h2",key:"1mwabg"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hJ=Z("NotepadText",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"16",height:"18",x:"4",y:"4",rx:"2",key:"1u9h20"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mJ=Z("NutOff",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592a7.01 7.01 0 0 0 4.125-2.939",key:"1xcvy9"}],["path",{d:"M19 10v3.343",key:"163tfc"}],["path",{d:"M12 12c-1.349-.573-1.905-1.005-2.5-2-.546.902-1.048 1.353-2.5 2-1.018-.644-1.46-1.08-2-2-1.028.71-1.69.918-3 1 1.081-1.048 1.757-2.03 2-3 .194-.776.84-1.551 1.79-2.21m11.654 5.997c.887-.457 1.28-.891 1.556-1.787 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4-.74 0-1.461.068-2.15.192",key:"17914v"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pJ=Z("Nut",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592A7.003 7.003 0 0 0 19 14v-4",key:"1tgyif"}],["path",{d:"M12 4C8 4 4.5 6 4 8c-.243.97-.919 1.952-2 3 1.31-.082 1.972-.29 3-1 .54.92.982 1.356 2 2 1.452-.647 1.954-1.098 2.5-2 .595.995 1.151 1.427 2.5 2 1.31-.621 1.862-1.058 2.5-2 .629.977 1.162 1.423 2.5 2 1.209-.548 1.68-.967 2-2 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4Z",key:"tnsqj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fv=Z("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fJ=Z("OctagonMinus",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kN=Z("OctagonPause",[["path",{d:"M10 15V9",key:"1lckn7"}],["path",{d:"M14 15V9",key:"1muqhk"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SN=Z("OctagonX",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xJ=Z("Octagon",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gJ=Z("Omega",[["path",{d:"M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21",key:"1x94xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yJ=Z("Option",[["path",{d:"M3 3h6l6 18h6",key:"ph9rgk"}],["path",{d:"M14 3h7",key:"16f0ms"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vJ=Z("Orbit",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M10.4 21.9a10 10 0 0 0 9.941-15.416",key:"eohfx2"}],["path",{d:"M13.5 2.1a10 10 0 0 0-9.841 15.416",key:"19pvbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bJ=Z("Origami",[["path",{d:"M12 12V4a1 1 0 0 1 1-1h6.297a1 1 0 0 1 .651 1.759l-4.696 4.025",key:"1bx4vc"}],["path",{d:"m12 21-7.414-7.414A2 2 0 0 1 4 12.172V6.415a1.002 1.002 0 0 1 1.707-.707L20 20.009",key:"1h3km6"}],["path",{d:"m12.214 3.381 8.414 14.966a1 1 0 0 1-.167 1.199l-1.168 1.163a1 1 0 0 1-.706.291H6.351a1 1 0 0 1-.625-.219L3.25 18.8a1 1 0 0 1 .631-1.781l4.165.027",key:"1hj4wg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _J=Z("Package2",[["path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z",key:"1ront0"}],["path",{d:"m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9",key:"19h2x1"}],["path",{d:"M12 3v6",key:"1holv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wJ=Z("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jJ=Z("PackageMinus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NJ=Z("PackageOpen",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kJ=Z("PackagePlus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SJ=Z("PackageSearch",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["circle",{cx:"18.5",cy:"15.5",r:"2.5",key:"b5zd12"}],["path",{d:"M20.27 17.27 22 19",key:"1l4muz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CJ=Z("PackageX",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ml=Z("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MJ=Z("PaintBucket",[["path",{d:"m19 11-8-8-8.6 8.6a2 2 0 0 0 0 2.8l5.2 5.2c.8.8 2 .8 2.8 0L19 11Z",key:"irua1i"}],["path",{d:"m5 2 5 5",key:"1lls2c"}],["path",{d:"M2 13h15",key:"1hkzvu"}],["path",{d:"M22 20a2 2 0 1 1-4 0c0-1.6 1.7-2.4 2-4 .3 1.6 2 2.4 2 4Z",key:"xk76lq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TJ=Z("PaintRoller",[["rect",{width:"16",height:"6",x:"2",y:"2",rx:"2",key:"jcyz7m"}],["path",{d:"M10 16v-2a2 2 0 0 1 2-2h8a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1b9h7c"}],["rect",{width:"4",height:"6",x:"8",y:"16",rx:"1",key:"d6e7yl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CN=Z("PaintbrushVertical",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v4",key:"qmzblu"}],["path",{d:"M17 2a1 1 0 0 1 1 1v9H6V3a1 1 0 0 1 1-1z",key:"ycvu00"}],["path",{d:"M6 12a1 1 0 0 0-1 1v1a2 2 0 0 0 2 2h2a1 1 0 0 1 1 1v2.9a2 2 0 1 0 4 0V17a1 1 0 0 1 1-1h2a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1",key:"iw4wnp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AJ=Z("Paintbrush",[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ic=Z("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EJ=Z("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MN=Z("PanelBottomDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 15h1",key:"171nev"}],["path",{d:"M19 15h2",key:"1vnucp"}],["path",{d:"M3 15h2",key:"8bym0q"}],["path",{d:"M9 15h1",key:"1tg3ks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PJ=Z("PanelBottomOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IJ=Z("PanelBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TN=Z("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AN=Z("PanelLeftDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 14v1",key:"askpd8"}],["path",{d:"M9 19v2",key:"16tejx"}],["path",{d:"M9 3v2",key:"1noubl"}],["path",{d:"M9 9v1",key:"19ebxg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EN=Z("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PN=Z("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LJ=Z("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IN=Z("PanelRightDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 14v1",key:"ilsfch"}],["path",{d:"M15 19v2",key:"1fst2f"}],["path",{d:"M15 3v2",key:"z204g4"}],["path",{d:"M15 9v1",key:"z2a8b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DJ=Z("PanelRightOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OJ=Z("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RJ=Z("PanelTopClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LN=Z("PanelTopDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 9h1",key:"l0svgy"}],["path",{d:"M19 9h2",key:"te2zfg"}],["path",{d:"M3 9h2",key:"1h4ldw"}],["path",{d:"M9 9h1",key:"15jzuz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FJ=Z("PanelTopOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m15 14-3 3-3-3",key:"g215vf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zJ=Z("PanelTop",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BJ=Z("PanelsLeftBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M9 15h12",key:"5ijen5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $J=Z("PanelsRightBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h12",key:"1wkqb3"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zv=Z("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uS=Z("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qJ=Z("Parentheses",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UJ=Z("ParkingMeter",[["path",{d:"M11 15h2",key:"199qp6"}],["path",{d:"M12 12v3",key:"158kv8"}],["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15.282 19a1 1 0 0 0 .948-.68l2.37-6.988a7 7 0 1 0-13.2 0l2.37 6.988a1 1 0 0 0 .948.68z",key:"1jofit"}],["path",{d:"M9 9a3 3 0 1 1 6 0",key:"jdoeu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ru=Z("PartyPopper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rm=Z("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VJ=Z("PawPrint",[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HJ=Z("PcCase",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",key:"1uq1d7"}],["path",{d:"M15 14h.01",key:"1kp3bh"}],["path",{d:"M9 6h6",key:"dgm16u"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bv=Z("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WJ=Z("PenOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U_=Z("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e0=Z("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GJ=Z("PencilLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}],["path",{d:"m15 5 3 3",key:"1w25hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KJ=Z("PencilOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZJ=Z("PencilRuler",[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ra=Z("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YJ=Z("Pentagon",[["path",{d:"M10.83 2.38a2 2 0 0 1 2.34 0l8 5.74a2 2 0 0 1 .73 2.25l-3.04 9.26a2 2 0 0 1-1.9 1.37H7.04a2 2 0 0 1-1.9-1.37L2.1 10.37a2 2 0 0 1 .73-2.25z",key:"2hea0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hS=Z("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XJ=Z("PersonStanding",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["path",{d:"m9 20 3-6 3 6",key:"se2kox"}],["path",{d:"m6 8 6 2 6-2",key:"4o3us4"}],["path",{d:"M12 10v4",key:"1kjpxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QJ=Z("PhilippinePeso",[["path",{d:"M20 11H4",key:"6ut86h"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"M7 21V4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 12H7",key:"1ana5r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JJ=Z("PhoneCall",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}],["path",{d:"M14.05 2a9 9 0 0 1 8 7.94",key:"vmijpz"}],["path",{d:"M14.05 6A5 5 0 0 1 18 10",key:"13nbpp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eee=Z("PhoneForwarded",[["polyline",{points:"18 2 22 6 18 10",key:"6vjanh"}],["line",{x1:"14",x2:"22",y1:"6",y2:"6",key:"1jsywh"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tee=Z("PhoneIncoming",[["polyline",{points:"16 2 16 8 22 8",key:"1ygljm"}],["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const see=Z("PhoneMissed",[["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["line",{x1:"16",x2:"22",y1:"2",y2:"8",key:"13zxdn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ree=Z("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nee=Z("PhoneOutgoing",[["polyline",{points:"22 8 22 2 16 2",key:"1g204g"}],["line",{x1:"16",x2:"22",y1:"8",y2:"2",key:"1ggias"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Un=Z("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aee=Z("Pi",[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iee=Z("Piano",[["path",{d:"M18.5 8c-1.4 0-2.6-.8-3.2-2A6.87 6.87 0 0 0 2 9v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-8.5C22 9.6 20.4 8 18.5 8",key:"lag0yf"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M6 14v4",key:"9ng0ue"}],["path",{d:"M10 14v4",key:"1v8uk5"}],["path",{d:"M14 14v4",key:"1tqops"}],["path",{d:"M18 14v4",key:"18uqwm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oee=Z("Pickaxe",[["path",{d:"M14.531 12.469 6.619 20.38a1 1 0 1 1-3-3l7.912-7.912",key:"we99rg"}],["path",{d:"M15.686 4.314A12.5 12.5 0 0 0 5.461 2.958 1 1 0 0 0 5.58 4.71a22 22 0 0 1 6.318 3.393",key:"1w6hck"}],["path",{d:"M17.7 3.7a1 1 0 0 0-1.4 0l-4.6 4.6a1 1 0 0 0 0 1.4l2.6 2.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4z",key:"15hgfx"}],["path",{d:"M19.686 8.314a12.501 12.501 0 0 1 1.356 10.225 1 1 0 0 1-1.751-.119 22 22 0 0 0-3.393-6.319",key:"452b4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lee=Z("PictureInPicture2",[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cee=Z("PictureInPicture",[["path",{d:"M8 4.5v5H3m-1-6 6 6m13 0v-3c0-1.16-.84-2-2-2h-7m-9 9v2c0 1.05.95 2 2 2h3",key:"bcd8fb"}],["rect",{width:"10",height:"7",x:"12",y:"13.5",ry:"2",key:"136fx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dee=Z("PiggyBank",[["path",{d:"M19 5c-1.5 0-2.8 1.4-3 2-3.5-1.5-11-.3-11 5 0 1.8 0 3 2 4.5V20h4v-2h3v2h4v-4c1-.5 1.7-1 2-2h2v-4h-2c0-1-.5-1.5-1-2V5z",key:"1ivx2i"}],["path",{d:"M2 9v1c0 1.1.9 2 2 2h1",key:"nm575m"}],["path",{d:"M16 11h.01",key:"xkw8gn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uee=Z("PilcrowLeft",[["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"M14 9h-3a3 3 0 0 1 0-6h9",key:"1ulc19"}],["path",{d:"M18 3v11",key:"1phi0r"}],["path",{d:"M22 18H2l4-4",key:"yt65j9"}],["path",{d:"m6 22-4-4",key:"6jgyf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hee=Z("PilcrowRight",[["path",{d:"M10 3v11",key:"o3l5kj"}],["path",{d:"M10 9H7a1 1 0 0 1 0-6h8",key:"1wb1nc"}],["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"m18 14 4 4H2",key:"4r8io1"}],["path",{d:"m22 18-4 4",key:"1hjjrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mee=Z("Pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pee=Z("PillBottle",[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fee=Z("Pill",[["path",{d:"m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z",key:"wa1lgi"}],["path",{d:"m8.5 8.5 7 7",key:"rvfmvr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vL=Z("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V_=Z("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xee=Z("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gee=Z("Pizza",[["path",{d:"m12 14-1 1",key:"11onhr"}],["path",{d:"m13.75 18.25-1.25 1.42",key:"1yisr3"}],["path",{d:"M17.775 5.654a15.68 15.68 0 0 0-12.121 12.12",key:"1qtqk6"}],["path",{d:"M18.8 9.3a1 1 0 0 0 2.1 7.7",key:"fbbbr2"}],["path",{d:"M21.964 20.732a1 1 0 0 1-1.232 1.232l-18-5a1 1 0 0 1-.695-1.232A19.68 19.68 0 0 1 15.732 2.037a1 1 0 0 1 1.232.695z",key:"1hyfdd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yee=Z("PlaneLanding",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M3.77 10.77 2 9l2-4.5 1.1.55c.55.28.9.84.9 1.45s.35 1.17.9 1.45L8 8.5l3-6 1.05.53a2 2 0 0 1 1.09 1.52l.72 5.4a2 2 0 0 0 1.09 1.52l4.4 2.2c.42.22.78.55 1.01.96l.6 1.03c.49.88-.06 1.98-1.06 2.1l-1.18.15c-.47.06-.95-.02-1.37-.24L4.29 11.15a2 2 0 0 1-.52-.38Z",key:"1ma21e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vee=Z("PlaneTakeoff",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M6.36 17.4 4 17l-2-4 1.1-.55a2 2 0 0 1 1.8 0l.17.1a2 2 0 0 0 1.8 0L8 12 5 6l.9-.45a2 2 0 0 1 2.09.2l4.02 3a2 2 0 0 0 2.1.2l4.19-2.06a2.41 2.41 0 0 1 1.73-.17L21 7a1.4 1.4 0 0 1 .87 1.99l-.38.76c-.23.46-.6.84-1.07 1.08L7.58 17.2a2 2 0 0 1-1.22.18Z",key:"fkigj9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bee=Z("Plane",[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nl=Z("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ee=Z("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0Z",key:"wtfw2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DN=Z("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bL=Z("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $s=Z("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wee=Z("PocketKnife",[["path",{d:"M3 2v1c0 1 2 1 2 2S3 6 3 7s2 1 2 2-2 1-2 2 2 1 2 2",key:"19w3oe"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M20.83 8.83a4 4 0 0 0-5.66-5.66l-12 12a4 4 0 1 0 5.66 5.66Z",key:"6fykxj"}],["path",{d:"M18 11.66V22a4 4 0 0 0 4-4V6",key:"1utzek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jee=Z("Pocket",[["path",{d:"M4 3h16a2 2 0 0 1 2 2v6a10 10 0 0 1-10 10A10 10 0 0 1 2 11V5a2 2 0 0 1 2-2z",key:"1mz881"}],["polyline",{points:"8 10 12 14 16 10",key:"w4mbv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nee=Z("Podcast",[["path",{d:"M16.85 18.58a9 9 0 1 0-9.7 0",key:"d71mpg"}],["path",{d:"M8 14a5 5 0 1 1 8 0",key:"fc81rn"}],["circle",{cx:"12",cy:"11",r:"1",key:"1gvufo"}],["path",{d:"M13 17a1 1 0 1 0-2 0l.5 4.5a.5.5 0 1 0 1 0Z",key:"za5kbj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kee=Z("PointerOff",[["path",{d:"M10 4.5V4a2 2 0 0 0-2.41-1.957",key:"jsi14n"}],["path",{d:"M13.9 8.4a2 2 0 0 0-1.26-1.295",key:"hirc7f"}],["path",{d:"M21.7 16.2A8 8 0 0 0 22 14v-3a2 2 0 1 0-4 0v-1a2 2 0 0 0-3.63-1.158",key:"1jxb2e"}],["path",{d:"m7 15-1.8-1.8a2 2 0 0 0-2.79 2.86L6 19.7a7.74 7.74 0 0 0 6 2.3h2a8 8 0 0 0 5.657-2.343",key:"10r7hm"}],["path",{d:"M6 6v8",key:"tv5xkp"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const See=Z("Pointer",[["path",{d:"M22 14a8 8 0 0 1-8 8",key:"56vcr3"}],["path",{d:"M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1agjmk"}],["path",{d:"M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1",key:"wdbh2u"}],["path",{d:"M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10",key:"1ibuk9"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"g6ys72"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cee=Z("Popcorn",[["path",{d:"M18 8a2 2 0 0 0 0-4 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0 0 4",key:"10td1f"}],["path",{d:"M10 22 9 8",key:"yjptiv"}],["path",{d:"m14 22 1-14",key:"8jwc8b"}],["path",{d:"M20 8c.5 0 .9.4.8 1l-2.6 12c-.1.5-.7 1-1.2 1H7c-.6 0-1.1-.4-1.2-1L3.2 9c-.1-.6.3-1 .8-1Z",key:"1qo33t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mee=Z("Popsicle",[["path",{d:"M18.6 14.4c.8-.8.8-2 0-2.8l-8.1-8.1a4.95 4.95 0 1 0-7.1 7.1l8.1 8.1c.9.7 2.1.7 2.9-.1Z",key:"1o68ps"}],["path",{d:"m22 22-5.5-5.5",key:"17o70y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tee=Z("PoundSterling",[["path",{d:"M18 7c0-5.333-8-5.333-8 0",key:"1prm2n"}],["path",{d:"M10 7v14",key:"18tmcs"}],["path",{d:"M6 21h12",key:"4dkmi1"}],["path",{d:"M6 13h10",key:"ybwr4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aee=Z("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _L=Z("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ey=Z("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eee=Z("PrinterCheck",[["path",{d:"M13.5 22H7a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v.5",key:"qeb09x"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v2",key:"1md90i"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wL=Z("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pee=Z("Projector",[["path",{d:"M5 7 3 5",key:"1yys58"}],["path",{d:"M9 6V3",key:"1ptz9u"}],["path",{d:"m13 7 2-2",key:"1w3vmq"}],["circle",{cx:"9",cy:"13",r:"3",key:"1mma13"}],["path",{d:"M11.83 12H20a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h2.17",key:"2frwzc"}],["path",{d:"M16 16h2",key:"dnq2od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iee=Z("Proportions",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M12 9v11",key:"1fnkrn"}],["path",{d:"M2 9h13a2 2 0 0 1 2 2v9",key:"11z3ex"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lee=Z("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dee=Z("Pyramid",[["path",{d:"M2.5 16.88a1 1 0 0 1-.32-1.43l9-13.02a1 1 0 0 1 1.64 0l9 13.01a1 1 0 0 1-.32 1.44l-8.51 4.86a2 2 0 0 1-1.98 0Z",key:"aenxs0"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u1=Z("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H_=Z("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oee=Z("Rabbit",[["path",{d:"M13 16a3 3 0 0 1 2.24 5",key:"1epib5"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M18 21h-8a4 4 0 0 1-4-4 7 7 0 0 1 7-7h.2L9.6 6.4a1 1 0 1 1 2.8-2.8L15.8 7h.2c3.3 0 6 2.7 6 6v1a2 2 0 0 1-2 2h-1a3 3 0 0 0-3 3",key:"ue9ozu"}],["path",{d:"M20 8.54V4a2 2 0 1 0-4 0v3",key:"49iql8"}],["path",{d:"M7.612 12.524a3 3 0 1 0-1.6 4.3",key:"1e33i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ree=Z("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fee=Z("Radiation",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7.5 4.2c-.3-.5-.9-.7-1.3-.4C3.9 5.5 2.3 8.1 2 11c-.1.5.4 1 1 1h5c0-1.5.8-2.8 2-3.4-1.1-1.9-2-3.5-2.5-4.4z",key:"wy49g3"}],["path",{d:"M21 12c.6 0 1-.4 1-1-.3-2.9-1.8-5.5-4.1-7.1-.4-.3-1.1-.2-1.3.3-.6.9-1.5 2.5-2.6 4.3 1.2.7 2 2 2 3.5h5z",key:"vklnvr"}],["path",{d:"M7.5 19.8c-.3.5-.1 1.1.4 1.3 2.6 1.2 5.6 1.2 8.2 0 .5-.2.7-.8.4-1.3-.5-.9-1.4-2.5-2.5-4.3-1.2.7-2.8.7-4 0-1.1 1.8-2 3.4-2.5 4.3z",key:"wkdf1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zee=Z("Radical",[["path",{d:"M3 12h3.28a1 1 0 0 1 .948.684l2.298 7.934a.5.5 0 0 0 .96-.044L13.82 4.771A1 1 0 0 1 14.792 4H21",key:"1mqj8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bee=Z("RadioReceiver",[["path",{d:"M5 16v2",key:"g5qcv5"}],["path",{d:"M19 16v2",key:"1gbaio"}],["rect",{width:"20",height:"8",x:"2",y:"8",rx:"2",key:"vjsjur"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ee=Z("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h1=Z("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qee=Z("Radius",[["path",{d:"M20.34 17.52a10 10 0 1 0-2.82 2.82",key:"fydyku"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["path",{d:"m13.41 13.41 4.18 4.18",key:"1gqbwc"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uee=Z("RailSymbol",[["path",{d:"M5 15h14",key:"m0yey3"}],["path",{d:"M5 9h14",key:"7tsvo6"}],["path",{d:"m14 20-5-5 6-6-5-5",key:"1jo42i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vee=Z("Rainbow",[["path",{d:"M22 17a10 10 0 0 0-20 0",key:"ozegv"}],["path",{d:"M6 17a6 6 0 0 1 12 0",key:"5giftw"}],["path",{d:"M10 17a2 2 0 0 1 4 0",key:"gnsikk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hee=Z("Rat",[["path",{d:"M17 5c0-1.7-1.3-3-3-3s-3 1.3-3 3c0 .8.3 1.5.8 2H11c-3.9 0-7 3.1-7 7c0 2.2 1.8 4 4 4",key:"1wq71c"}],["path",{d:"M16.8 3.9c.3-.3.6-.5 1-.7 1.5-.6 3.3.1 3.9 1.6.6 1.5-.1 3.3-1.6 3.9l1.6 2.8c.2.3.2.7.2 1-.2.8-.9 1.2-1.7 1.1 0 0-1.6-.3-2.7-.6H17c-1.7 0-3 1.3-3 3",key:"1crdmb"}],["path",{d:"M13.2 18a3 3 0 0 0-2.2-5",key:"1ol3lk"}],["path",{d:"M13 22H4a2 2 0 0 1 0-4h12",key:"bt3f23"}],["path",{d:"M16 9h.01",key:"1bdo4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wee=Z("Ratio",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gee=Z("ReceiptCent",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M12 6.5v11",key:"ecfhkf"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kee=Z("ReceiptEuro",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 12h5",key:"1g6qi8"}],["path",{d:"M16 9.5a4 4 0 1 0 0 5.2",key:"b2px4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zee=Z("ReceiptIndianRupee",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 7h8",key:"i86dvs"}],["path",{d:"M12 17.5 8 15h1a4 4 0 0 0 0-8",key:"grpkl4"}],["path",{d:"M8 11h8",key:"vwpz6n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yee=Z("ReceiptJapaneseYen",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"m12 10 3-3",key:"1mc12w"}],["path",{d:"m9 7 3 3v7.5",key:"39i0xv"}],["path",{d:"M9 11h6",key:"1fldmi"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xee=Z("ReceiptPoundSterling",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 13h5",key:"1k9z8w"}],["path",{d:"M10 17V9.5a2.5 2.5 0 0 1 5 0",key:"1dzgp0"}],["path",{d:"M8 17h7",key:"8mjdqu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qee=Z("ReceiptRussianRuble",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 15h5",key:"vxg57a"}],["path",{d:"M8 11h5a2 2 0 1 0 0-4h-3v10",key:"1usi5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jee=Z("ReceiptSwissFranc",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M10 17V7h5",key:"k7jq18"}],["path",{d:"M10 11h4",key:"1i0mka"}],["path",{d:"M8 15h5",key:"vxg57a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ete=Z("ReceiptText",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tte=Z("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ON=Z("RectangleEllipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ste=Z("RectangleHorizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rte=Z("RectangleVertical",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nte=Z("Recycle",[["path",{d:"M7 19H4.815a1.83 1.83 0 0 1-1.57-.881 1.785 1.785 0 0 1-.004-1.784L7.196 9.5",key:"x6z5xu"}],["path",{d:"M11 19h8.203a1.83 1.83 0 0 0 1.556-.89 1.784 1.784 0 0 0 0-1.775l-1.226-2.12",key:"1x4zh5"}],["path",{d:"m14 16-3 3 3 3",key:"f6jyew"}],["path",{d:"M8.293 13.596 7.196 9.5 3.1 10.598",key:"wf1obh"}],["path",{d:"m9.344 5.811 1.093-1.892A1.83 1.83 0 0 1 11.985 3a1.784 1.784 0 0 1 1.546.888l3.943 6.843",key:"9tzpgr"}],["path",{d:"m13.378 9.633 4.096 1.098 1.097-4.096",key:"1oe83g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ate=Z("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ite=Z("RedoDot",[["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}],["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mS=Z("Redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ote=Z("RefreshCcwDot",[["path",{d:"M3 2v6h6",key:"18ldww"}],["path",{d:"M21 12A9 9 0 0 0 6 5.3L3 8",key:"1pbrqz"}],["path",{d:"M21 22v-6h-6",key:"usdfbe"}],["path",{d:"M3 12a9 9 0 0 0 15 6.7l3-2.7",key:"1hosoe"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BM=Z("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lte=Z("RefreshCwOff",[["path",{d:"M21 8L18.74 5.74A9.75 9.75 0 0 0 12 3C11 3 10.03 3.16 9.13 3.47",key:"1krf6h"}],["path",{d:"M8 16H3v5",key:"1cv678"}],["path",{d:"M3 12C3 9.51 4 7.26 5.64 5.64",key:"ruvoct"}],["path",{d:"m3 16 2.26 2.26A9.75 9.75 0 0 0 12 21c2.49 0 4.74-1 6.36-2.64",key:"19q130"}],["path",{d:"M21 12c0 1-.16 1.97-.47 2.87",key:"4w8emr"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Go=Z("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cte=Z("Refrigerator",[["path",{d:"M5 6a4 4 0 0 1 4-4h6a4 4 0 0 1 4 4v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6Z",key:"fpq118"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M15 7v6",key:"1nx30x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dte=Z("Regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ute=Z("RemoveFormatting",[["path",{d:"M4 7V4h16v3",key:"9msm58"}],["path",{d:"M5 20h6",key:"1h6pxn"}],["path",{d:"M13 4 8 20",key:"kqq6aj"}],["path",{d:"m15 15 5 5",key:"me55sn"}],["path",{d:"m20 15-5 5",key:"11p7ol"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hte=Z("Repeat1",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mte=Z("Repeat2",[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jL=Z("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pte=Z("ReplaceAll",[["path",{d:"M14 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"1yyzbs"}],["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"zfj4xr"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a 3 3 0 0 1 3-3h1",key:"1ageje"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fte=Z("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xte=Z("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NL=Z("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gte=Z("Rewind",[["polygon",{points:"11 19 2 12 11 5 11 19",key:"14yba5"}],["polygon",{points:"22 19 13 12 22 5 22 19",key:"1pi1cj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yte=Z("Ribbon",[["path",{d:"M12 11.22C11 9.997 10 9 10 8a2 2 0 0 1 4 0c0 1-.998 2.002-2.01 3.22",key:"1rnhq3"}],["path",{d:"m12 18 2.57-3.5",key:"116vt7"}],["path",{d:"M6.243 9.016a7 7 0 0 1 11.507-.009",key:"10dq0b"}],["path",{d:"M9.35 14.53 12 11.22",key:"tdsyp2"}],["path",{d:"M9.35 14.53C7.728 12.246 6 10.221 6 7a6 5 0 0 1 12 0c-.005 3.22-1.778 5.235-3.43 7.5l3.557 4.527a1 1 0 0 1-.203 1.43l-1.894 1.36a1 1 0 0 1-1.384-.215L12 18l-2.679 3.593a1 1 0 0 1-1.39.213l-1.865-1.353a1 1 0 0 1-.203-1.422z",key:"nmifey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x0=Z("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vte=Z("RockingChair",[["polyline",{points:"3.5 2 6.5 12.5 18 12.5",key:"y3iy52"}],["line",{x1:"9.5",x2:"5.5",y1:"12.5",y2:"20",key:"19vg5i"}],["line",{x1:"15",x2:"18.5",y1:"12.5",y2:"20",key:"1inpmv"}],["path",{d:"M2.75 18a13 13 0 0 0 18.5 0",key:"1nquas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bte=Z("RollerCoaster",[["path",{d:"M6 19V5",key:"1r845m"}],["path",{d:"M10 19V6.8",key:"9j2tfs"}],["path",{d:"M14 19v-7.8",key:"10s8qv"}],["path",{d:"M18 5v4",key:"1tajlv"}],["path",{d:"M18 19v-6",key:"ielfq3"}],["path",{d:"M22 19V9",key:"158nzp"}],["path",{d:"M2 19V9a4 4 0 0 1 4-4c2 0 4 1.33 6 4s4 4 6 4a4 4 0 1 0-3-6.65",key:"1930oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RN=Z("Rotate3d",[["path",{d:"M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2",key:"10n0gc"}],["path",{d:"m15.194 13.707 3.814 1.86-1.86 3.814",key:"16shm9"}],["path",{d:"M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4",key:"1lxi77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _te=Z("RotateCcwSquare",[["path",{d:"M20 9V7a2 2 0 0 0-2-2h-6",key:"19z8uc"}],["path",{d:"m15 2-3 3 3 3",key:"177bxs"}],["path",{d:"M20 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2",key:"d36hnl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m1=Z("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wte=Z("RotateCwSquare",[["path",{d:"M12 5H6a2 2 0 0 0-2 2v3",key:"l96uqu"}],["path",{d:"m9 8 3-3-3-3",key:"1gzgc3"}],["path",{d:"M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1w2k5h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kL=Z("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jte=Z("RouteOff",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5c.4 0 .9-.1 1.3-.2",key:"1effex"}],["path",{d:"M5.2 5.2A3.5 3.53 0 0 0 6.5 12H12",key:"k9y2ds"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 15.3a3.5 3.5 0 0 0-3.3-3.3",key:"11nlu2"}],["path",{d:"M15 5h-4.3",key:"6537je"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nte=Z("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kte=Z("Router",[["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6.01 18H6",key:"19vcac"}],["path",{d:"M10.01 18H10",key:"uamcmx"}],["path",{d:"M15 10v4",key:"qjz1xs"}],["path",{d:"M17.84 7.17a4 4 0 0 0-5.66 0",key:"1rif40"}],["path",{d:"M20.66 4.34a8 8 0 0 0-11.31 0",key:"6a5xfq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FN=Z("Rows2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zN=Z("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ste=Z("Rows4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 7.5H3",key:"1hm9pq"}],["path",{d:"M21 12H3",key:"2avoz0"}],["path",{d:"M21 16.5H3",key:"n7jzkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cte=Z("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g0=Z("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mte=Z("RussianRuble",[["path",{d:"M6 11h8a4 4 0 0 0 0-8H9v18",key:"18ai8t"}],["path",{d:"M6 15h8",key:"1y8f6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tte=Z("Sailboat",[["path",{d:"M22 18H2a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4Z",key:"1404fh"}],["path",{d:"M21 14 10 2 3 14h18Z",key:"1nzg7v"}],["path",{d:"M10 2v16",key:"1labyt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ate=Z("Salad",[["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M11.38 12a2.4 2.4 0 0 1-.4-4.77 2.4 2.4 0 0 1 3.2-2.77 2.4 2.4 0 0 1 3.47-.63 2.4 2.4 0 0 1 3.37 3.37 2.4 2.4 0 0 1-1.1 3.7 2.51 2.51 0 0 1 .03 1.1",key:"10xrj0"}],["path",{d:"m13 12 4-4",key:"1hckqy"}],["path",{d:"M10.9 7.25A3.99 3.99 0 0 0 4 10c0 .73.2 1.41.54 2",key:"1p4srx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ete=Z("Sandwich",[["path",{d:"m2.37 11.223 8.372-6.777a2 2 0 0 1 2.516 0l8.371 6.777",key:"f1wd0e"}],["path",{d:"M21 15a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-5.25",key:"1pfu07"}],["path",{d:"M3 15a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h9",key:"1oq9qw"}],["path",{d:"m6.67 15 6.13 4.6a2 2 0 0 0 2.8-.4l3.15-4.2",key:"1fnwu5"}],["rect",{width:"20",height:"4",x:"2",y:"11",rx:"1",key:"itshg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pte=Z("SatelliteDish",[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ite=Z("Satellite",[["path",{d:"M13 7 9 3 5 7l4 4",key:"vyckw6"}],["path",{d:"m17 11 4 4-4 4-4-4",key:"rchckc"}],["path",{d:"m8 12 4 4 6-6-4-4Z",key:"1sshf7"}],["path",{d:"m16 8 3-3",key:"x428zp"}],["path",{d:"M9 21a6 6 0 0 0-6-6",key:"1iajcf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lte=Z("SaveAll",[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dte=Z("SaveOff",[["path",{d:"M13 13H8a1 1 0 0 0-1 1v7",key:"h8g396"}],["path",{d:"M14 8h1",key:"1lfen6"}],["path",{d:"M17 21v-4",key:"1yknxs"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.41 20.41A2 2 0 0 1 19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 .59-1.41",key:"1t4vdl"}],["path",{d:"M29.5 11.5s5 5 4 5",key:"zzn4i6"}],["path",{d:"M9 3h6.2a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V15",key:"24cby9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qc=Z("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BN=Z("Scale3d",[["path",{d:"M5 7v11a1 1 0 0 0 1 1h11",key:"13dt1j"}],["path",{d:"M5.293 18.707 11 13",key:"ezgbsx"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SL=Z("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ote=Z("Scaling",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M14 15H9v-5",key:"pi4jk9"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M21 3 9 15",key:"15kdhq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rte=Z("ScanBarcode",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 7v10",key:"23sfjj"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M17 7v10",key:"578dap"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fte=Z("ScanEye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zte=Z("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bte=Z("ScanLine",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $te=Z("ScanQrCode",[["path",{d:"M17 12v4a1 1 0 0 1-1 1h-4",key:"uk4fdo"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M17 8V7",key:"q2g9wo"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{x:"7",y:"7",width:"5",height:"5",rx:"1",key:"m9kyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qte=Z("ScanSearch",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ute=Z("ScanText",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 8h8",key:"1jbsf9"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h6",key:"1vyc9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vte=Z("Scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hte=Z("School",[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2mlk"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wte=Z("ScissorsLineDashed",[["path",{d:"M5.42 9.42 8 12",key:"12pkuq"}],["circle",{cx:"4",cy:"8",r:"2",key:"107mxr"}],["path",{d:"m14 6-8.58 8.58",key:"gvzu5l"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"M10.8 14.8 14 18",key:"ax7m9r"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gte=Z("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kte=Z("ScreenShareOff",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zte=Z("ScreenShare",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m17 8 5-5",key:"fqif7o"}],["path",{d:"M17 3h5v5",key:"1o3tu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yte=Z("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xte=Z("Scroll",[["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qte=Z("SearchCheck",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jte=Z("SearchCode",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ese=Z("SearchSlash",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CL=Z("SearchX",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cn=Z("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tse=Z("Section",[["path",{d:"M16 5a4 3 0 0 0-8 0c0 4 8 3 8 7a4 3 0 0 1-8 0",key:"vqan6v"}],["path",{d:"M8 19a4 3 0 0 0 8 0c0-4-8-3-8-7a4 3 0 0 1 8 0",key:"wdjd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $N=Z("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sse=Z("SendToBack",[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1",key:"pao6x6"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1",key:"19tdru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bn=Z("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rse=Z("SeparatorHorizontal",[["line",{x1:"3",x2:"21",y1:"12",y2:"12",key:"10d38w"}],["polyline",{points:"8 8 12 4 16 8",key:"zo8t4w"}],["polyline",{points:"16 16 12 20 8 16",key:"1oyrid"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nse=Z("SeparatorVertical",[["line",{x1:"12",x2:"12",y1:"3",y2:"21",key:"1efggb"}],["polyline",{points:"8 8 4 12 8 16",key:"bnfmv4"}],["polyline",{points:"16 16 20 12 16 8",key:"u90052"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ase=Z("ServerCog",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m15.7 13.4-.9-.3",key:"1jwmzr"}],["path",{d:"m9.2 10.9-.9-.3",key:"qapnim"}],["path",{d:"m10.6 15.7.3-.9",key:"quwk0k"}],["path",{d:"m13.6 15.7-.4-1",key:"cb9xp7"}],["path",{d:"m10.8 9.3-.4-1",key:"1uaiz5"}],["path",{d:"m8.3 13.6 1-.4",key:"s6srou"}],["path",{d:"m14.7 10.8 1-.4",key:"4d31cq"}],["path",{d:"m13.4 8.3-.3.9",key:"1bm987"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ise=Z("ServerCrash",[["path",{d:"M6 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2",key:"4b9dqc"}],["path",{d:"M6 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2",key:"22nnkd"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m13 6-4 6h6l-4 6",key:"14hqih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ose=Z("ServerOff",[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lse=Z("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ML=Z("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xo=Z("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cse=Z("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wd=Z("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TL=Z("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dse=Z("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const use=Z("Shell",[["path",{d:"M14 11a2 2 0 1 1-4 0 4 4 0 0 1 8 0 6 6 0 0 1-12 0 8 8 0 0 1 16 0 10 10 0 1 1-20 0 11.93 11.93 0 0 1 2.42-7.22 2 2 0 1 1 3.16 2.44",key:"1cn552"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hse=Z("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mse=Z("ShieldBan",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m4.243 5.21 14.39 12.472",key:"1c9a7c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AL=Z("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pse=Z("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fse=Z("ShieldHalf",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 22V2",key:"zs6s6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xse=Z("ShieldMinus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gse=Z("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yse=Z("ShieldPlus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vse=Z("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qN=Z("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const th=Z("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bse=Z("ShipWheel",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["path",{d:"M12 2v7.5",key:"1e5rl5"}],["path",{d:"m19 5-5.23 5.23",key:"1ezxxf"}],["path",{d:"M22 12h-7.5",key:"le1719"}],["path",{d:"m19 19-5.23-5.23",key:"p3fmgn"}],["path",{d:"M12 14.5V22",key:"dgcmos"}],["path",{d:"M10.23 13.77 5 19",key:"qwopd4"}],["path",{d:"M9.5 12H2",key:"r7bup8"}],["path",{d:"M10.23 10.23 5 5",key:"k2y7lj"}],["circle",{cx:"12",cy:"12",r:"2.5",key:"ix0uyj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _se=Z("Ship",[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wse=Z("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y0=Z("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jse=Z("ShoppingBasket",[["path",{d:"m15 11-1 9",key:"5wnq3a"}],["path",{d:"m19 11-4-7",key:"cnml18"}],["path",{d:"M2 11h20",key:"3eubbj"}],["path",{d:"m3.5 11 1.6 7.4a2 2 0 0 0 2 1.6h9.8a2 2 0 0 0 2-1.6l1.7-7.4",key:"yiazzp"}],["path",{d:"M4.5 15.5h15",key:"13mye1"}],["path",{d:"m5 11 4-7",key:"116ra9"}],["path",{d:"m9 11 1 9",key:"1ojof7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vp=Z("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nse=Z("Shovel",[["path",{d:"M2 22v-5l5-5 5 5-5 5z",key:"1fh25c"}],["path",{d:"M9.5 14.5 16 8",key:"1smz5x"}],["path",{d:"m17 2 5 5-.5.5a3.53 3.53 0 0 1-5 0s0 0 0 0a3.53 3.53 0 0 1 0-5L17 2",key:"1q8uv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kse=Z("ShowerHead",[["path",{d:"m4 4 2.5 2.5",key:"uv2vmf"}],["path",{d:"M13.5 6.5a4.95 4.95 0 0 0-7 7",key:"frdkwv"}],["path",{d:"M15 5 5 15",key:"1ag8rq"}],["path",{d:"M14 17v.01",key:"eokfpp"}],["path",{d:"M10 16v.01",key:"14uyyl"}],["path",{d:"M13 13v.01",key:"1v1k97"}],["path",{d:"M16 10v.01",key:"5169yg"}],["path",{d:"M11 20v.01",key:"cj92p8"}],["path",{d:"M17 14v.01",key:"11cswd"}],["path",{d:"M20 11v.01",key:"19e0od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sse=Z("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cse=Z("Shrub",[["path",{d:"M12 22v-7l-2-2",key:"eqv9mc"}],["path",{d:"M17 8v.8A6 6 0 0 1 13.8 20H10A6.5 6.5 0 0 1 7 8a5 5 0 0 1 10 0Z",key:"ubcgy"}],["path",{d:"m14 14-2 2",key:"847xa2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pS=Z("Shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mse=Z("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tse=Z("SignalHigh",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ase=Z("SignalLow",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ese=Z("SignalMedium",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pse=Z("SignalZero",[["path",{d:"M2 20h.01",key:"4haj6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ise=Z("Signal",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lse=Z("Signature",[["path",{d:"m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284",key:"y32ogt"}],["path",{d:"M3 21h18",key:"itz85i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dse=Z("SignpostBig",[["path",{d:"M10 9H4L2 7l2-2h6",key:"1hq7x2"}],["path",{d:"M14 5h6l2 2-2 2h-6",key:"bv62ej"}],["path",{d:"M10 22V4a2 2 0 1 1 4 0v18",key:"eqpcf2"}],["path",{d:"M8 22h8",key:"rmew8v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ose=Z("Signpost",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M18 6a2 2 0 0 1 1.387.56l2.307 2.22a1 1 0 0 1 0 1.44l-2.307 2.22A2 2 0 0 1 18 13H6a2 2 0 0 1-1.387-.56l-2.306-2.22a1 1 0 0 1 0-1.44l2.306-2.22A2 2 0 0 1 6 6z",key:"gqqp9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rse=Z("Siren",[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fse=Z("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zse=Z("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bse=Z("Skull",[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $se=Z("Slack",[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qse=Z("Slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Use=Z("Slice",[["path",{d:"M11 16.586V19a1 1 0 0 1-1 1H2L18.37 3.63a1 1 0 1 1 3 3l-9.663 9.663a1 1 0 0 1-1.414 0L8 14",key:"1sllp5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W_=Z("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UN=Z("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vse=Z("SmartphoneCharging",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12.667 8 10 12h4l-2.667 4",key:"h9lk2d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hse=Z("SmartphoneNfc",[["rect",{width:"7",height:"12",x:"2",y:"6",rx:"1",key:"5nje8w"}],["path",{d:"M13 8.32a7.43 7.43 0 0 1 0 7.36",key:"1g306n"}],["path",{d:"M16.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"uqvjvo"}],["path",{d:"M19.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"ujntz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v0=Z("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wse=Z("SmilePlus",[["path",{d:"M22 11v1a10 10 0 1 1-9-10",key:"ew0xw9"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}],["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gse=Z("Smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kse=Z("Snail",[["path",{d:"M2 13a6 6 0 1 0 12 0 4 4 0 1 0-8 0 2 2 0 0 0 4 0",key:"hneq2s"}],["circle",{cx:"10",cy:"13",r:"8",key:"194lz3"}],["path",{d:"M2 21h12c4.4 0 8-3.6 8-8V7a2 2 0 1 0-4 0v6",key:"ixqyt7"}],["path",{d:"M18 3 19.1 5.2",key:"9tjm43"}],["path",{d:"M22 3 20.9 5.2",key:"j3odrs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a0=Z("Snowflake",[["line",{x1:"2",x2:"22",y1:"12",y2:"12",key:"1dnqot"}],["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"m20 16-4-4 4-4",key:"rquw4f"}],["path",{d:"m4 8 4 4-4 4",key:"12s3z9"}],["path",{d:"m16 4-4 4-4-4",key:"1tumq1"}],["path",{d:"m8 20 4-4 4 4",key:"9p200w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zse=Z("Sofa",[["path",{d:"M20 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v3",key:"1dgpiv"}],["path",{d:"M2 16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"xacw8m"}],["path",{d:"M4 18v2",key:"jwo5n2"}],["path",{d:"M20 18v2",key:"1ar1qi"}],["path",{d:"M12 4v9",key:"oqhhn3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yse=Z("Soup",[["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M19.5 12 22 6",key:"shfsr5"}],["path",{d:"M16.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.73 1.62",key:"rpc6vp"}],["path",{d:"M11.25 3c.27.1.8.53.74 1.36-.05.83-.93 1.2-.98 2.02-.06.78.33 1.24.72 1.62",key:"1lf63m"}],["path",{d:"M6.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.74 1.62",key:"97tijn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xse=Z("Space",[["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qse=Z("Spade",[["path",{d:"M5 9c-1.5 1.5-3 3.2-3 5.5A5.5 5.5 0 0 0 7.5 20c1.8 0 3-.5 4.5-2 1.5 1.5 2.7 2 4.5 2a5.5 5.5 0 0 0 5.5-5.5c0-2.3-1.5-4-3-5.5l-7-7-7 7Z",key:"40bo9n"}],["path",{d:"M12 18v4",key:"jadmvz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jse=Z("Sparkle",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pn=Z("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ere=Z("Speaker",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["circle",{cx:"12",cy:"14",r:"4",key:"1jruaj"}],["path",{d:"M12 14h.01",key:"1etili"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tre=Z("Speech",[["path",{d:"M8.8 20v-4.1l1.9.2a2.3 2.3 0 0 0 2.164-2.1V8.3A5.37 5.37 0 0 0 2 8.25c0 2.8.656 3.054 1 4.55a5.77 5.77 0 0 1 .029 2.758L2 20",key:"11atix"}],["path",{d:"M19.8 17.8a7.5 7.5 0 0 0 .003-10.603",key:"yol142"}],["path",{d:"M17 15a3.5 3.5 0 0 0-.025-4.975",key:"ssbmkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sre=Z("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rre=Z("SpellCheck",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nre=Z("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const are=Z("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ire=Z("SprayCan",[["path",{d:"M3 3h.01",key:"159qn6"}],["path",{d:"M7 5h.01",key:"1hq22a"}],["path",{d:"M11 7h.01",key:"1osv80"}],["path",{d:"M3 7h.01",key:"1xzrh3"}],["path",{d:"M7 9h.01",key:"19b3jx"}],["path",{d:"M3 11h.01",key:"1eifu7"}],["rect",{width:"4",height:"4",x:"15",y:"5",key:"mri9e4"}],["path",{d:"m19 9 2 2v10c0 .6-.4 1-1 1h-6c-.6 0-1-.4-1-1V11l2-2",key:"aib6hk"}],["path",{d:"m13 14 8-2",key:"1d7bmk"}],["path",{d:"m13 19 8-2",key:"1y2vml"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ore=Z("Sprout",[["path",{d:"M7 20h10",key:"e6iznv"}],["path",{d:"M10 20c5.5-2.5.8-6.4 3-10",key:"161w41"}],["path",{d:"M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z",key:"9gtqwd"}],["path",{d:"M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z",key:"bkxnd2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VN=Z("SquareActivity",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HN=Z("SquareArrowDownLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 8-8 8",key:"166keh"}],["path",{d:"M16 16H8V8",key:"1w2ppm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WN=Z("SquareArrowDownRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"M16 8v8H8",key:"1lbpgo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GN=Z("SquareArrowDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KN=Z("SquareArrowLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}],["path",{d:"M16 12H8",key:"1fr5h0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZN=Z("SquareArrowOutDownLeft",[["path",{d:"M13 21h6a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6",key:"14qz4y"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YN=Z("SquareArrowOutDownRight",[["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}],["path",{d:"m21 21-9-9",key:"1et2py"}],["path",{d:"M21 15v6h-6",key:"1jko0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XN=Z("SquareArrowOutUpLeft",[["path",{d:"M13 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-6",key:"14mv1t"}],["path",{d:"m3 3 9 9",key:"rks13r"}],["path",{d:"M3 9V3h6",key:"ira0h2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QN=Z("SquareArrowOutUpRight",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JN=Z("SquareArrowRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ek=Z("SquareArrowUpLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8h8",key:"19xb1h"}],["path",{d:"M16 16 8 8",key:"1qdy8n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tk=Z("SquareArrowUpRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 8h8v8",key:"b65dnt"}],["path",{d:"m8 16 8-8",key:"13b9ih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sk=Z("SquareArrowUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rk=Z("SquareAsterisk",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8.5 14 7-4",key:"12hpby"}],["path",{d:"m8.5 10 7 4",key:"wwy2dy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nk=Z("SquareBottomDashedScissors",[["path",{d:"M4 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2",key:"1vzg26"}],["path",{d:"M10 22H8",key:"euku7a"}],["path",{d:"M16 22h-2",key:"18d249"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vy=Z("SquareChartGantt",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 8h7",key:"kbo1nt"}],["path",{d:"M8 12h6",key:"ikassy"}],["path",{d:"M11 16h5",key:"oq65wt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $v=Z("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ak=Z("SquareCheck",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ik=Z("SquareChevronDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ok=Z("SquareChevronLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lk=Z("SquareChevronRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ck=Z("SquareChevronUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dk=Z("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lre=Z("SquareDashedBottomCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cre=Z("SquareDashedBottom",[["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uk=Z("SquareDashedKanban",[["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M21 14v1",key:"169vum"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M3 9v1",key:"1r0deq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hk=Z("SquareDashedMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h2",key:"1qve2z"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v2",key:"p14lih"}],["path",{d:"M3 14v1",key:"vnatye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mk=Z("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pk=Z("SquareDivide",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fk=Z("SquareDot",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xk=Z("SquareEqual",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gk=Z("SquareFunction",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yk=Z("SquareKanban",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vk=Z("SquareLibrary",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7v10",key:"d5nglc"}],["path",{d:"M11 7v10",key:"pptsnr"}],["path",{d:"m15 7 2 10",key:"1m7qm5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bk=Z("SquareM",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _k=Z("SquareMenu",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 8h10",key:"1jw688"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wk=Z("SquareMinus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jk=Z("SquareMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nk=Z("SquareParkingOff",[["path",{d:"M3.6 3.6A2 2 0 0 1 5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-.59 1.41",key:"9l1ft6"}],["path",{d:"M3 8.7V19a2 2 0 0 0 2 2h10.3",key:"17knke"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.3",key:"1jxgo2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kk=Z("SquareParking",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hd=Z("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sk=Z("SquarePercent",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ck=Z("SquarePi",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h10",key:"udp07y"}],["path",{d:"M10 7v10",key:"i1d9ee"}],["path",{d:"M16 17a2 2 0 0 1-2-2V7",key:"ftwdc7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mk=Z("SquarePilcrow",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 12H9.5a2.5 2.5 0 0 1 0-5H17",key:"1l9586"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M16 7v10",key:"lavkr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tk=Z("SquarePlay",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ak=Z("SquarePlus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ek=Z("SquarePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dre=Z("SquareRadical",[["path",{d:"M7 12h2l2 5 2-10h4",key:"1fxv6h"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pk=Z("SquareScissors",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"2",key:"1btzen"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ik=Z("SquareSigma",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M16 8.9V7H8l4 5-4 5h8v-1.9",key:"9nih0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lk=Z("SquareSlash",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dk=Z("SquareSplitHorizontal",[["path",{d:"M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3",key:"lubmu8"}],["path",{d:"M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3",key:"1ag34g"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ok=Z("SquareSplitVertical",[["path",{d:"M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3",key:"1pi83i"}],["path",{d:"M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3",key:"ido5k7"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ure=Z("SquareSquare",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hre=Z("SquareStack",[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rk=Z("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fk=Z("SquareUserRound",[["path",{d:"M18 21a6 6 0 0 0-12 0",key:"kaz2du"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zk=Z("SquareUser",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 21v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1m6ac2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bk=Z("SquareX",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b0=Z("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mre=Z("Squircle",[["path",{d:"M12 3c7.2 0 9 1.8 9 9s-1.8 9-9 9-9-1.8-9-9 1.8-9 9-9",key:"garfkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pre=Z("Squirrel",[["path",{d:"M15.236 22a3 3 0 0 0-2.2-5",key:"21bitc"}],["path",{d:"M16 20a3 3 0 0 1 3-3h1a2 2 0 0 0 2-2v-2a4 4 0 0 0-4-4V4",key:"oh0fg0"}],["path",{d:"M18 13h.01",key:"9veqaj"}],["path",{d:"M18 6a4 4 0 0 0-4 4 7 7 0 0 0-7 7c0-5 4-5 4-10.5a4.5 4.5 0 1 0-9 0 2.5 2.5 0 0 0 5 0C7 10 3 11 3 17c0 2.8 2.2 5 5 5h10",key:"980v8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fre=Z("Stamp",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M19.27 13.73A2.5 2.5 0 0 0 17.5 13h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-1.5c0-.66-.26-1.3-.73-1.77Z",key:"1sy9ra"}],["path",{d:"M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-3-3c-1.66 0-3 1-3 3s1 2 1 3.5V13",key:"cnxgux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xre=Z("StarHalf",[["path",{d:"M12 18.338a2.1 2.1 0 0 0-.987.244L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16l2.309-4.679A.53.53 0 0 1 12 2",key:"2ksp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gre=Z("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jn=Z("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yre=Z("StepBack",[["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["polygon",{points:"14,20 4,12 14,4",key:"ypakod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vre=Z("StepForward",[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bre=Z("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _re=Z("Sticker",[["path",{d:"M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z",key:"1wis1t"}],["path",{d:"M14 3v4a2 2 0 0 0 2 2h4",key:"36rjfy"}],["path",{d:"M8 13h.01",key:"1sbv64"}],["path",{d:"M16 13h.01",key:"wip0gl"}],["path",{d:"M10 16s.8 1 2 1c1.3 0 2-1 2-1",key:"1vvgv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wre=Z("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $M=Z("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jre=Z("StretchHorizontal",[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nre=Z("StretchVertical",[["rect",{width:"6",height:"20",x:"4",y:"2",rx:"2",key:"19qu7m"}],["rect",{width:"6",height:"20",x:"14",y:"2",rx:"2",key:"24v0nk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EL=Z("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kre=Z("Subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sre=Z("SunDim",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M20 12h.01",key:"1ykeid"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M4 12h.01",key:"158zrr"}],["path",{d:"M17.657 6.343h.01",key:"31pqzk"}],["path",{d:"M17.657 17.657h.01",key:"jehnf4"}],["path",{d:"M6.343 17.657h.01",key:"gdk6ow"}],["path",{d:"M6.343 6.343h.01",key:"1uurf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cre=Z("SunMedium",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 3v1",key:"1asbbs"}],["path",{d:"M12 20v1",key:"1wcdkc"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M20 12h1",key:"1vloll"}],["path",{d:"m18.364 5.636-.707.707",key:"1hakh0"}],["path",{d:"m6.343 17.657-.707.707",key:"18m9nf"}],["path",{d:"m5.636 5.636.707.707",key:"1xv1c5"}],["path",{d:"m17.657 17.657.707.707",key:"vl76zb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mre=Z("SunMoon",[["path",{d:"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4",key:"1fu5g2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.9 4.9 1.4 1.4",key:"b9915j"}],["path",{d:"m17.7 17.7 1.4 1.4",key:"qc3ed3"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.3 17.7-1.4 1.4",key:"5gca6"}],["path",{d:"m19.1 4.9-1.4 1.4",key:"wpu9u6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tre=Z("SunSnow",[["path",{d:"M10 9a3 3 0 1 0 0 6",key:"6zmtdl"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M14 21V3",key:"1llu3z"}],["path",{d:"M10 4V3",key:"pkzwkn"}],["path",{d:"M10 21v-1",key:"1u8rkd"}],["path",{d:"m3.64 18.36.7-.7",key:"105rm9"}],["path",{d:"m4.34 6.34-.7-.7",key:"d3unjp"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 4-3 3",key:"15jcng"}],["path",{d:"m14 17 3 3",key:"6tlq38"}],["path",{d:"m21 15-3-3 3-3",key:"1nlnje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p1=Z("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Are=Z("Sunrise",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ere=Z("Sunset",[["path",{d:"M12 10V2",key:"16sf7g"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pre=Z("Superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ire=Z("SwatchBook",[["path",{d:"M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z",key:"1ldrpk"}],["path",{d:"M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7",key:"11i5po"}],["path",{d:"M 7 17h.01",key:"1euzgo"}],["path",{d:"m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8",key:"o2gii7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lre=Z("SwissFranc",[["path",{d:"M10 21V3h8",key:"br2l0g"}],["path",{d:"M6 16h9",key:"2py0wn"}],["path",{d:"M10 9.5h7",key:"13dmhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dre=Z("SwitchCamera",[["path",{d:"M11 19H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5",key:"mtk2lu"}],["path",{d:"M13 5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5",key:"120jsl"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m18 22-3-3 3-3",key:"kgdoj7"}],["path",{d:"m6 2 3 3-3 3",key:"1fnbkv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ore=Z("Sword",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rre=Z("Swords",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fre=Z("Syringe",[["path",{d:"m18 2 4 4",key:"22kx64"}],["path",{d:"m17 7 3-3",key:"1w1zoj"}],["path",{d:"M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5",key:"1exhtz"}],["path",{d:"m9 11 4 4",key:"rovt3i"}],["path",{d:"m5 19-3 3",key:"59f2uf"}],["path",{d:"m14 4 6 6",key:"yqp9t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qM=Z("Table2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zre=Z("TableCellsMerge",[["path",{d:"M12 21v-6",key:"lihzve"}],["path",{d:"M12 9V3",key:"da5inc"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bre=Z("TableCellsSplit",[["path",{d:"M12 15V9",key:"8c7uyn"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $re=Z("TableColumnsSplit",[["path",{d:"M14 14v2",key:"w2a1xv"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M14 8v2",key:"i67w9a"}],["path",{d:"M2 15h8",key:"82wtch"}],["path",{d:"M2 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H2",key:"up0l64"}],["path",{d:"M2 9h8",key:"yelfik"}],["path",{d:"M22 15h-4",key:"1es58f"}],["path",{d:"M22 3h-2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h2",key:"pdjoqf"}],["path",{d:"M22 9h-4",key:"1luja7"}],["path",{d:"M5 3v18",key:"14hmio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qre=Z("TableOfContents",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M21 12h.01",key:"msek7k"}],["path",{d:"M21 18h.01",key:"1e8rq1"}],["path",{d:"M21 6h.01",key:"1koanj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ure=Z("TableProperties",[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vre=Z("TableRowsSplit",[["path",{d:"M14 10h2",key:"1lstlu"}],["path",{d:"M15 22v-8",key:"1fwwgm"}],["path",{d:"M15 2v4",key:"1044rn"}],["path",{d:"M2 10h2",key:"1r8dkt"}],["path",{d:"M20 10h2",key:"1ug425"}],["path",{d:"M3 19h18",key:"awlh7x"}],["path",{d:"M3 22v-6a2 2 135 0 1 2-2h14a2 2 45 0 1 2 2v6",key:"ibqhof"}],["path",{d:"M3 2v2a2 2 45 0 0 2 2h14a2 2 135 0 0 2-2V2",key:"1uenja"}],["path",{d:"M8 10h2",key:"66od0"}],["path",{d:"M9 22v-8",key:"fmnu31"}],["path",{d:"M9 2v4",key:"j1yeou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UM=Z("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hre=Z("TabletSmartphone",[["rect",{width:"10",height:"14",x:"3",y:"8",rx:"2",key:"1vrsiq"}],["path",{d:"M5 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2h-2.4",key:"1j4zmg"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wre=Z("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gre=Z("Tablets",[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fm=Z("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kre=Z("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zre=Z("Tally1",[["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yre=Z("Tally2",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xre=Z("Tally3",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qre=Z("Tally4",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jre=Z("Tally5",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}],["path",{d:"M22 6 2 18",key:"h9moai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ene=Z("Tangent",[["circle",{cx:"17",cy:"4",r:"2",key:"y5j2s2"}],["path",{d:"M15.59 5.41 5.41 15.59",key:"l0vprr"}],["circle",{cx:"4",cy:"17",r:"2",key:"9p4efm"}],["path",{d:"M12 22s-4-9-1.5-11.5S22 12 22 12",key:"1twk4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zm=Z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tne=Z("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sne=Z("TentTree",[["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}],["path",{d:"m14 5 3-3 3 3",key:"1sorif"}],["path",{d:"m14 10 3-3 3 3",key:"1jyi9h"}],["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M17 14H7l-5 8h20Z",key:"13ar7p"}],["path",{d:"M8 14v8",key:"1ghmqk"}],["path",{d:"m9 14 5 8",key:"13pgi6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rne=Z("Tent",[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nne=Z("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $k=Z("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ane=Z("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ine=Z("TestTubes",[["path",{d:"M9 2v17.5A2.5 2.5 0 0 1 6.5 22A2.5 2.5 0 0 1 4 19.5V2",key:"1hjrqt"}],["path",{d:"M20 2v17.5a2.5 2.5 0 0 1-2.5 2.5a2.5 2.5 0 0 1-2.5-2.5V2",key:"16lc8n"}],["path",{d:"M3 2h7",key:"7s29d5"}],["path",{d:"M14 2h7",key:"7sicin"}],["path",{d:"M9 16H4",key:"1bfye3"}],["path",{d:"M20 16h-5",key:"ddnjpe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const one=Z("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lne=Z("TextCursor",[["path",{d:"M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1",key:"uvaxm9"}],["path",{d:"M7 22h1a4 4 0 0 0 4-4v-1",key:"11xy8d"}],["path",{d:"M7 2h1a4 4 0 0 1 4 4v1",key:"1uw06m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cne=Z("TextQuote",[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dne=Z("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qk=Z("TextSelect",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}],["line",{x1:"7",x2:"15",y1:"8",y2:"8",key:"1758g8"}],["line",{x1:"7",x2:"17",y1:"12",y2:"12",key:"197423"}],["line",{x1:"7",x2:"13",y1:"16",y2:"16",key:"37cgm6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const une=Z("Text",[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hne=Z("Theater",[["path",{d:"M2 10s3-3 3-8",key:"3xiif0"}],["path",{d:"M22 10s-3-3-3-8",key:"ioaa5q"}],["path",{d:"M10 2c0 4.4-3.6 8-8 8",key:"16fkpi"}],["path",{d:"M14 2c0 4.4 3.6 8 8 8",key:"b9eulq"}],["path",{d:"M2 10s2 2 2 5",key:"1au1lb"}],["path",{d:"M22 10s-2 2-2 5",key:"qi2y5e"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M2 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"1vsc2m"}],["path",{d:"M14 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"hrha4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mne=Z("ThermometerSnowflake",[["path",{d:"M2 12h10",key:"19562f"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"m3 9 3 3-3 3",key:"1sas0l"}],["path",{d:"M12 6 9 9 6 6",key:"pfrgxu"}],["path",{d:"m6 18 3-3 1.5 1.5",key:"1e277p"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pne=Z("ThermometerSun",[["path",{d:"M12 9a4 4 0 0 0-2 7.5",key:"1jvsq6"}],["path",{d:"M12 3v2",key:"1w22ol"}],["path",{d:"m6.6 18.4-1.4 1.4",key:"w2yidj"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}],["path",{d:"M4 13H2",key:"118le4"}],["path",{d:"M6.34 7.34 4.93 5.93",key:"1brd51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PL=Z("Thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IL=Z("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sh=Z("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fne=Z("TicketCheck",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xne=Z("TicketMinus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gne=Z("TicketPercent",[["path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"1l48ns"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yne=Z("TicketPlus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vne=Z("TicketSlash",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bne=Z("TicketX",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LL=Z("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ne=Z("TicketsPlane",[["path",{d:"M10.5 17h1.227a2 2 0 0 0 1.345-.52L18 12",key:"16muxl"}],["path",{d:"m12 13.5 3.75.5",key:"1i9qhk"}],["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wne=Z("Tickets",[["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jne=Z("TimerOff",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nne=Z("TimerReset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kne=Z("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sne=Z("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cne=Z("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mne=Z("Toilet",[["path",{d:"M7 12h13a1 1 0 0 1 1 1 5 5 0 0 1-5 5h-.598a.5.5 0 0 0-.424.765l1.544 2.47a.5.5 0 0 1-.424.765H5.402a.5.5 0 0 1-.424-.765L7 18",key:"kc4kqr"}],["path",{d:"M8 18a5 5 0 0 1-5-5V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8",key:"1tqs57"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tne=Z("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ane=Z("Torus",[["ellipse",{cx:"12",cy:"11",rx:"3",ry:"2",key:"1b2qxu"}],["ellipse",{cx:"12",cy:"12.5",rx:"10",ry:"8.5",key:"h8emeu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ene=Z("TouchpadOff",[["path",{d:"M4 4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16",key:"lnt0bk"}],["path",{d:"M2 14h12",key:"d8icqz"}],["path",{d:"M22 14h-2",key:"jrx26d"}],["path",{d:"M12 20v-6",key:"1rm09r"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M22 16V6a2 2 0 0 0-2-2H10",key:"11y8e4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pne=Z("Touchpad",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ine=Z("TowerControl",[["path",{d:"M18.2 12.27 20 6H4l1.8 6.27a1 1 0 0 0 .95.73h10.5a1 1 0 0 0 .96-.73Z",key:"1pledb"}],["path",{d:"M8 13v9",key:"hmv0ci"}],["path",{d:"M16 22v-9",key:"ylnf1u"}],["path",{d:"m9 6 1 7",key:"dpdgam"}],["path",{d:"m15 6-1 7",key:"ls7zgu"}],["path",{d:"M12 6V2",key:"1pj48d"}],["path",{d:"M13 2h-2",key:"mj6ths"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lne=Z("ToyBrick",[["rect",{width:"18",height:"12",x:"3",y:"8",rx:"1",key:"158fvp"}],["path",{d:"M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3",key:"s0042v"}],["path",{d:"M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3",key:"9wmeh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dne=Z("Tractor",[["path",{d:"m10 11 11 .9a1 1 0 0 1 .8 1.1l-.665 4.158a1 1 0 0 1-.988.842H20",key:"she1j9"}],["path",{d:"M16 18h-5",key:"bq60fd"}],["path",{d:"M18 5a1 1 0 0 0-1 1v5.573",key:"1kv8ia"}],["path",{d:"M3 4h8.129a1 1 0 0 1 .99.863L13 11.246",key:"1q1ert"}],["path",{d:"M4 11V4",key:"9ft8pt"}],["path",{d:"M7 15h.01",key:"k5ht0j"}],["path",{d:"M8 10.1V4",key:"1jgyzo"}],["circle",{cx:"18",cy:"18",r:"2",key:"1emm8v"}],["circle",{cx:"7",cy:"15",r:"5",key:"ddtuc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const One=Z("TrafficCone",[["path",{d:"M9.3 6.2a4.55 4.55 0 0 0 5.4 0",key:"flyxqv"}],["path",{d:"M7.9 10.7c.9.8 2.4 1.3 4.1 1.3s3.2-.5 4.1-1.3",key:"1nlxxg"}],["path",{d:"M13.9 3.5a1.93 1.93 0 0 0-3.8-.1l-3 10c-.1.2-.1.4-.1.6 0 1.7 2.2 3 5 3s5-1.3 5-3c0-.2 0-.4-.1-.5Z",key:"vz7x1l"}],["path",{d:"m7.5 12.2-4.7 2.7c-.5.3-.8.7-.8 1.1s.3.8.8 1.1l7.6 4.5c.9.5 2.1.5 3 0l7.6-4.5c.7-.3 1-.7 1-1.1s-.3-.8-.8-1.1l-4.7-2.8",key:"1xfzlw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rne=Z("TrainFrontTunnel",[["path",{d:"M2 22V12a10 10 0 1 1 20 0v10",key:"o0fyp0"}],["path",{d:"M15 6.8v1.4a3 2.8 0 1 1-6 0V6.8",key:"m8q3n9"}],["path",{d:"M10 15h.01",key:"44in9x"}],["path",{d:"M14 15h.01",key:"5mohn5"}],["path",{d:"M10 19a4 4 0 0 1-4-4v-3a6 6 0 1 1 12 0v3a4 4 0 0 1-4 4Z",key:"hckbmu"}],["path",{d:"m9 19-2 3",key:"iij7hm"}],["path",{d:"m15 19 2 3",key:"npx8sa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fne=Z("TrainFront",[["path",{d:"M8 3.1V7a4 4 0 0 0 8 0V3.1",key:"1v71zp"}],["path",{d:"m9 15-1-1",key:"1yrq24"}],["path",{d:"m15 15 1-1",key:"1t0d6s"}],["path",{d:"M9 19c-2.8 0-5-2.2-5-5v-4a8 8 0 0 1 16 0v4c0 2.8-2.2 5-5 5Z",key:"1p0hjs"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m16 19 2 3",key:"xo31yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zne=Z("TrainTrack",[["path",{d:"M2 17 17 2",key:"18b09t"}],["path",{d:"m2 14 8 8",key:"1gv9hu"}],["path",{d:"m5 11 8 8",key:"189pqp"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"m11 5 8 8",key:"ummqn6"}],["path",{d:"m14 2 8 8",key:"1vk7dn"}],["path",{d:"M7 22 22 7",key:"15mb1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uk=Z("TramFront",[["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M12 3v8",key:"1h2ygw"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m18 22-2-3",key:"1p0ohu"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nr=Z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bne=Z("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ne=Z("TreeDeciduous",[["path",{d:"M8 19a4 4 0 0 1-2.24-7.32A3.5 3.5 0 0 1 9 6.03V6a3 3 0 1 1 6 0v.04a3.5 3.5 0 0 1 3.24 5.65A4 4 0 0 1 16 19Z",key:"oadzkq"}],["path",{d:"M12 19v3",key:"npa21l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vk=Z("TreePalm",[["path",{d:"M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4",key:"foxbe7"}],["path",{d:"M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3",key:"18arnh"}],["path",{d:"M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35",key:"ywahnh"}],["path",{d:"M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14",key:"ft0feo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f1=Z("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qne=Z("Trees",[["path",{d:"M10 10v.2A3 3 0 0 1 8.9 16H5a3 3 0 0 1-1-5.8V10a3 3 0 0 1 6 0Z",key:"1l6gj6"}],["path",{d:"M7 16v6",key:"1a82de"}],["path",{d:"M13 19v3",key:"13sx9i"}],["path",{d:"M12 19h8.3a1 1 0 0 0 .7-1.7L18 14h.3a1 1 0 0 0 .7-1.7L16 9h.2a1 1 0 0 0 .8-1.7L13 3l-1.4 1.5",key:"1sj9kv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Une=Z("Trello",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["rect",{width:"3",height:"9",x:"7",y:"7",key:"14n3xi"}],["rect",{width:"3",height:"5",x:"14",y:"7",key:"s4azjd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fS=Z("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vne=Z("TrendingUpDown",[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ul=Z("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ku=Z("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hne=Z("TriangleRight",[["path",{d:"M22 18a2 2 0 0 1-2 2H3c-1.1 0-1.3-.6-.4-1.3L20.4 4.3c.9-.7 1.6-.4 1.6.7Z",key:"183wce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wne=Z("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xo=Z("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DL=Z("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gne=Z("Turtle",[["path",{d:"m12 10 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a8 8 0 1 0-16 0v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3l2-4h4Z",key:"1lbbv7"}],["path",{d:"M4.82 7.9 8 10",key:"m9wose"}],["path",{d:"M15.18 7.9 12 10",key:"p8dp2u"}],["path",{d:"M16.93 10H20a2 2 0 0 1 0 4H2",key:"12nsm7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kne=Z("TvMinimalPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hk=Z("TvMinimal",[["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zne=Z("Tv",[["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",ry:"2",key:"10ag99"}],["polyline",{points:"17 2 12 7 7 2",key:"11pgbg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yne=Z("Twitch",[["path",{d:"M21 2H3v16h5v4l4-4h5l4-4V2zm-10 9V7m5 4V7",key:"c0yzno"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xne=Z("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qne=Z("TypeOutline",[["path",{d:"M14 16.5a.5.5 0 0 0 .5.5h.5a2 2 0 0 1 0 4H9a2 2 0 0 1 0-4h.5a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5V8a2 2 0 0 1-4 0V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3a2 2 0 0 1-4 0v-.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5Z",key:"1reda3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jne=Z("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eae=Z("UmbrellaOff",[["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"M15.5 21a1.85 1.85 0 0 1-3.5-1v-8H2a10 10 0 0 1 3.428-6.575",key:"eki10q"}],["path",{d:"M17.5 12H22A10 10 0 0 0 9.004 3.455",key:"n2ayka"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tae=Z("Umbrella",[["path",{d:"M22 12a10.06 10.06 1 0 0-20 0Z",key:"1teyop"}],["path",{d:"M12 12v8a2 2 0 0 0 4 0",key:"ulpmoc"}],["path",{d:"M12 2v1",key:"11qlp1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OL=Z("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sae=Z("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rae=Z("UndoDot",[["path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13",key:"8mp6z9"}],["path",{d:"M3 7v6h6",key:"1v2h90"}],["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xS=Z("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nae=Z("UnfoldHorizontal",[["path",{d:"M16 12h6",key:"15xry1"}],["path",{d:"M8 12H2",key:"1jqql6"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 15 3-3-3-3",key:"wjy7rq"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aae=Z("UnfoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iae=Z("Ungroup",[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wk=Z("University",[["circle",{cx:"12",cy:"10",r:"1",key:"1gnqs8"}],["path",{d:"M22 20V8h-4l-6-4-6 4H2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"1qj5sn"}],["path",{d:"M6 17v.01",key:"roodi6"}],["path",{d:"M6 13v.01",key:"67c122"}],["path",{d:"M18 17v.01",key:"12ktxm"}],["path",{d:"M18 13v.01",key:"tn1rt1"}],["path",{d:"M14 22v-5a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"11g7fi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oae=Z("Unlink2",[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gS=Z("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lae=Z("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const li=Z("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cae=Z("Usb",[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G_=Z("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RL=Z("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FL=Z("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dae=Z("UserPen",[["path",{d:"M11.5 15H7a4 4 0 0 0-4 4v2",key:"15lzij"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tl=Z("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gk=Z("UserRoundCheck",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kk=Z("UserRoundCog",[["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zk=Z("UserRoundMinus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uae=Z("UserRoundPen",[["path",{d:"M2 21a8 8 0 0 1 10.821-7.487",key:"1c8h7z"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yk=Z("UserRoundPlus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hae=Z("UserRoundSearch",[["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.9-1.9",key:"1e5ubv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xk=Z("UserRoundX",[["path",{d:"M2 21a8 8 0 0 1 11.873-7",key:"74fkxq"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m17 17 5 5",key:"p7ous7"}],["path",{d:"m22 17-5 5",key:"gqnmv0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qk=Z("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mae=Z("UserSearch",[["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}],["path",{d:"M10.3 15H7a4 4 0 0 0-4 4v2",key:"3bnktk"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pae=Z("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const to=Z("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jk=Z("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pr=Z("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e4=Z("UtensilsCrossed",[["path",{d:"m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8",key:"n7qcjb"}],["path",{d:"M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7",key:"d0u48b"}],["path",{d:"m2.1 21.8 6.4-6.3",key:"yn04lh"}],["path",{d:"m19 5-7 7",key:"194lzd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t4=Z("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fae=Z("UtilityPole",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M3 3v2",key:"9imdir"}],["path",{d:"M7 3v2",key:"n0os7"}],["path",{d:"M17 3v2",key:"1l2re6"}],["path",{d:"M21 3v2",key:"1duuac"}],["path",{d:"m19 5-7 7-7-7",key:"133zxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VM=Z("Variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xae=Z("Vault",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["path",{d:"m7.9 7.9 2.7 2.7",key:"hpeyl3"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}],["path",{d:"m13.4 10.6 2.7-2.7",key:"264c1n"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["path",{d:"m7.9 16.1 2.7-2.7",key:"p81g5e"}],["circle",{cx:"16.5",cy:"16.5",r:".5",fill:"currentColor",key:"fubopw"}],["path",{d:"m13.4 13.4 2.7 2.7",key:"abhel3"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gae=Z("Vegan",[["path",{d:"M16 8q6 0 6-6-6 0-6 6",key:"qsyyc4"}],["path",{d:"M17.41 3.59a10 10 0 1 0 3 3",key:"41m9h7"}],["path",{d:"M2 2a26.6 26.6 0 0 1 10 20c.9-6.82 1.5-9.5 4-14",key:"qiv7li"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yae=Z("VenetianMask",[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vae=Z("VibrateOff",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["path",{d:"M8 8v10c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2",key:"1hbad5"}],["path",{d:"M16 10.34V6c0-.55-.45-1-1-1h-4.34",key:"1x5tf0"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bae=Z("Vibrate",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["rect",{width:"8",height:"14",x:"8",y:"5",rx:"1",key:"1oyrl4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ae=Z("VideoOff",[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const An=Z("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wae=Z("Videotape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 8h20",key:"d11cs7"}],["circle",{cx:"8",cy:"14",r:"2",key:"1k2qr5"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"14",r:"2",key:"14k7lr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jae=Z("View",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nae=Z("Voicemail",[["circle",{cx:"6",cy:"12",r:"4",key:"1ehtga"}],["circle",{cx:"18",cy:"12",r:"4",key:"4vafl8"}],["line",{x1:"6",x2:"18",y1:"16",y2:"16",key:"pmt8us"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kae=Z("Volleyball",[["path",{d:"M11.1 7.1a16.55 16.55 0 0 1 10.9 4",key:"2880wi"}],["path",{d:"M12 12a12.6 12.6 0 0 1-8.7 5",key:"113sja"}],["path",{d:"M16.8 13.6a16.55 16.55 0 0 1-9 7.5",key:"1qmsgl"}],["path",{d:"M20.7 17a12.8 12.8 0 0 0-8.7-5 13.3 13.3 0 0 1 0-10",key:"1bmeqp"}],["path",{d:"M6.3 3.8a16.55 16.55 0 0 0 1.9 11.5",key:"iekzv9"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sae=Z("Volume1",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cae=Z("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mae=Z("VolumeOff",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tae=Z("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aae=Z("Volume",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eae=Z("Vote",[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pae=Z("WalletCards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s4=Z("WalletMinimal",[["path",{d:"M17 14h.01",key:"7oqj8z"}],["path",{d:"M7 7h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14",key:"u1rqew"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zL=Z("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iae=Z("Wallpaper",[["circle",{cx:"8",cy:"9",r:"2",key:"gjzl9d"}],["path",{d:"m9 17 6.1-6.1a2 2 0 0 1 2.81.01L22 15V5a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"69xh40"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qv=Z("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lae=Z("Wand",[["path",{d:"M15 4V2",key:"z1p9b7"}],["path",{d:"M15 16v-2",key:"px0unx"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M17.8 11.8 19 13",key:"yihg8r"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M17.8 6.2 19 5",key:"fd4us0"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M12.2 6.2 11 5",key:"i3da3b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dae=Z("Warehouse",[["path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z",key:"gksnxg"}],["path",{d:"M6 18h12",key:"9pbo8z"}],["path",{d:"M6 14h12",key:"4cwo0f"}],["rect",{width:"12",height:"12",x:"6",y:"10",key:"apd30q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oae=Z("WashingMachine",[["path",{d:"M3 6h3",key:"155dbl"}],["path",{d:"M17 6h.01",key:"e2y6kg"}],["rect",{width:"18",height:"20",x:"3",y:"2",rx:"2",key:"od3kk9"}],["circle",{cx:"12",cy:"13",r:"5",key:"nlbqau"}],["path",{d:"M12 18a2.5 2.5 0 0 0 0-5 2.5 2.5 0 0 1 0-5",key:"17lach"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rae=Z("Watch",[["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["polyline",{points:"12 10 12 12 13 13",key:"19dquz"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BL=Z("Waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fae=Z("Waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zae=Z("Webcam",[["circle",{cx:"12",cy:"10",r:"8",key:"1gshiw"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 22h10",key:"10w4w3"}],["path",{d:"M12 22v-4",key:"1utk9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bae=Z("WebhookOff",[["path",{d:"M17 17h-5c-1.09-.02-1.94.92-2.5 1.9A3 3 0 1 1 2.57 15",key:"1tvl6x"}],["path",{d:"M9 3.4a4 4 0 0 1 6.52.66",key:"q04jfq"}],["path",{d:"m6 17 3.1-5.8a2.5 2.5 0 0 0 .057-2.05",key:"azowf0"}],["path",{d:"M20.3 20.3a4 4 0 0 1-2.3.7",key:"5joiws"}],["path",{d:"M18.6 13a4 4 0 0 1 3.357 3.414",key:"cangb8"}],["path",{d:"m12 6 .6 1",key:"tpjl1n"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ae=Z("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qae=Z("Weight",[["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}],["path",{d:"M6.5 8a2 2 0 0 0-1.905 1.46L2.1 18.5A2 2 0 0 0 4 21h16a2 2 0 0 0 1.925-2.54L19.4 9.5A2 2 0 0 0 17.48 8Z",key:"56o5sh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uae=Z("WheatOff",[["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"m16 8-1.17 1.17",key:"1qqm82"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"m8 8-.53.53a3.5 3.5 0 0 0 0 4.94L9 15l1.53-1.53c.55-.55.88-1.25.98-1.97",key:"4wz8re"}],["path",{d:"M10.91 5.26c.15-.26.34-.51.56-.73L13 3l1.53 1.53a3.5 3.5 0 0 1 .28 4.62",key:"rves66"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"m16 16-.53.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.49 3.49 0 0 1 1.97-.98",key:"ak46r"}],["path",{d:"M18.74 13.09c.26-.15.51-.34.73-.56L21 11l-1.53-1.53a3.5 3.5 0 0 0-4.62-.28",key:"1tw520"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vae=Z("Wheat",[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hae=Z("WholeWord",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wae=Z("WifiHigh",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gae=Z("WifiLow",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kae=Z("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zae=Z("WifiZero",[["path",{d:"M12 20h.01",key:"zekei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yae=Z("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xae=Z("WindArrowDown",[["path",{d:"M10 2v8",key:"d4bbey"}],["path",{d:"M12.8 21.6A2 2 0 1 0 14 18H2",key:"19kp1d"}],["path",{d:"M17.5 10a2.5 2.5 0 1 1 2 4H2",key:"19kpjc"}],["path",{d:"m6 6 4 4 4-4",key:"k13n16"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qae=Z("Wind",[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jae=Z("WineOff",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h3m7 0h-1.343",key:"v48bem"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M7.307 7.307A12.33 12.33 0 0 0 7 10a5 5 0 0 0 7.391 4.391M8.638 2.981C8.75 2.668 8.872 2.34 9 2h6c1.5 4 2 6 2 8 0 .407-.05.809-.145 1.198",key:"1ymjlu"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eie=Z("Wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tie=Z("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sie=Z("Worm",[["path",{d:"m19 12-1.5 3",key:"9bcu4o"}],["path",{d:"M19.63 18.81 22 20",key:"121v98"}],["path",{d:"M6.47 8.23a1.68 1.68 0 0 1 2.44 1.93l-.64 2.08a6.76 6.76 0 0 0 10.16 7.67l.42-.27a1 1 0 1 0-2.73-4.21l-.42.27a1.76 1.76 0 0 1-2.63-1.99l.64-2.08A6.66 6.66 0 0 0 3.94 3.9l-.7.4a1 1 0 1 0 2.55 4.34z",key:"1tij6q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rie=Z("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ty=Z("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rr=Z("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nie=Z("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aie=Z("ZapOff",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zh=Z("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K_=Z("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HM=Z("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bxt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:_9,AArrowUp:w9,ALargeSmall:j9,Accessibility:N9,Activity:kh,AirVent:k9,Airplay:S9,AlarmClock:M9,AlarmClockCheck:G2,AlarmClockMinus:K2,AlarmClockOff:C9,AlarmClockPlus:Z2,AlarmSmoke:T9,Album:A9,AlignCenter:W4,AlignCenterHorizontal:E9,AlignCenterVertical:P9,AlignEndHorizontal:I9,AlignEndVertical:L9,AlignHorizontalDistributeCenter:D9,AlignHorizontalDistributeEnd:O9,AlignHorizontalDistributeStart:R9,AlignHorizontalJustifyCenter:F9,AlignHorizontalJustifyEnd:z9,AlignHorizontalJustifyStart:B9,AlignHorizontalSpaceAround:$9,AlignHorizontalSpaceBetween:q9,AlignJustify:U9,AlignLeft:G4,AlignRight:K4,AlignStartHorizontal:V9,AlignStartVertical:H9,AlignVerticalDistributeCenter:W9,AlignVerticalDistributeEnd:G9,AlignVerticalDistributeStart:K9,AlignVerticalJustifyCenter:Z9,AlignVerticalJustifyEnd:Y9,AlignVerticalJustifyStart:X9,AlignVerticalSpaceAround:Q9,AlignVerticalSpaceBetween:J9,Ambulance:eB,Ampersand:tB,Ampersands:sB,Amphora:rB,Anchor:nB,Angry:aB,Annoyed:iB,Antenna:oB,Anvil:lB,Aperture:cB,AppWindow:HI,AppWindowMac:dB,Apple:uB,Archive:kM,ArchiveRestore:WI,ArchiveX:hB,Armchair:mB,ArrowBigDown:fB,ArrowBigDownDash:pB,ArrowBigLeft:gB,ArrowBigLeftDash:xB,ArrowBigRight:vB,ArrowBigRightDash:yB,ArrowBigUp:_B,ArrowBigUpDash:bB,ArrowDown:Wh,ArrowDown01:wB,ArrowDown10:jB,ArrowDownAZ:Y2,ArrowDownFromLine:NB,ArrowDownLeft:kB,ArrowDownNarrowWide:SB,ArrowDownRight:GI,ArrowDownToDot:CB,ArrowDownToLine:MB,ArrowDownUp:TB,ArrowDownWideNarrow:X2,ArrowDownZA:Q2,ArrowLeft:Ja,ArrowLeftFromLine:AB,ArrowLeftRight:EB,ArrowLeftToLine:PB,ArrowRight:Qa,ArrowRightFromLine:IB,ArrowRightLeft:s1,ArrowRightToLine:LB,ArrowUp:ku,ArrowUp01:DB,ArrowUp10:OB,ArrowUpAZ:J2,ArrowUpDown:bd,ArrowUpFromDot:RB,ArrowUpFromLine:FB,ArrowUpLeft:zB,ArrowUpNarrowWide:ej,ArrowUpRight:KI,ArrowUpToLine:BB,ArrowUpWideNarrow:$B,ArrowUpZA:tj,ArrowsUpFromLine:qB,Asterisk:UB,AtSign:VB,Atom:HB,AudioLines:WB,AudioWaveform:GB,Award:Nc,Axe:KB,Axis3d:sj,Baby:ZB,Backpack:YB,Badge:h$,BadgeAlert:XB,BadgeCent:QB,BadgeCheck:rj,BadgeDollarSign:JB,BadgeEuro:e$,BadgeHelp:t$,BadgeIndianRupee:s$,BadgeInfo:r$,BadgeJapaneseYen:n$,BadgeMinus:a$,BadgePercent:i$,BadgePlus:o$,BadgePoundSterling:l$,BadgeRussianRuble:c$,BadgeSwissFranc:d$,BadgeX:u$,BaggageClaim:m$,Ban:ZI,Banana:p$,Bandage:f$,Banknote:x$,Barcode:g$,Baseline:y$,Bath:Ju,Battery:N$,BatteryCharging:v$,BatteryFull:b$,BatteryLow:_$,BatteryMedium:w$,BatteryWarning:j$,Beaker:k$,Bean:C$,BeanOff:S$,Bed:Im,BedDouble:Z4,BedSingle:M$,Beef:T$,Beer:E$,BeerOff:A$,Bell:Lm,BellDot:P$,BellElectric:I$,BellMinus:L$,BellOff:r1,BellPlus:D$,BellRing:O$,BetweenHorizontalEnd:nj,BetweenHorizontalStart:aj,BetweenVerticalEnd:R$,BetweenVerticalStart:F$,BicepsFlexed:z$,Bike:B$,Binary:$$,Binoculars:q$,Biohazard:U$,Bird:V$,Bitcoin:H$,Blend:W$,Blinds:G$,Blocks:K$,Bluetooth:Q$,BluetoothConnected:Z$,BluetoothOff:Y$,BluetoothSearching:X$,Bold:Y4,Bolt:J$,Bomb:eq,Bone:tq,Book:jq,BookA:sq,BookAudio:rq,BookCheck:nq,BookCopy:aq,BookDashed:ij,BookDown:iq,BookHeadphones:oq,BookHeart:lq,BookImage:cq,BookKey:dq,BookLock:uq,BookMarked:hq,BookMinus:mq,BookOpen:Sh,BookOpenCheck:pq,BookOpenText:fq,BookPlus:xq,BookText:gq,BookType:yq,BookUp:bq,BookUp2:vq,BookUser:_q,BookX:wq,Bookmark:kx,BookmarkCheck:Nq,BookmarkMinus:kq,BookmarkPlus:YI,BookmarkX:Sq,BoomBox:Cq,Bot:SM,BotMessageSquare:Mq,BotOff:Tq,Box:Aq,Boxes:Eq,Braces:oj,Brackets:Pq,Brain:XI,BrainCircuit:Iq,BrainCog:Lq,BrickWall:Dq,Briefcase:Gh,BriefcaseBusiness:Oq,BriefcaseConveyorBelt:Rq,BriefcaseMedical:Fq,BringToFront:zq,Brush:Bq,Bug:Uq,BugOff:$q,BugPlay:qq,Building:X4,Building2:ka,Bus:Hq,BusFront:Vq,Cable:Gq,CableCar:Wq,Cake:Ch,CakeSlice:Kq,Calculator:QI,Calendar:hn,Calendar1:Zq,CalendarArrowDown:Yq,CalendarArrowUp:Xq,CalendarCheck:JI,CalendarCheck2:Qq,CalendarClock:eL,CalendarCog:Jq,CalendarDays:Od,CalendarFold:eU,CalendarHeart:tU,CalendarMinus:rU,CalendarMinus2:sU,CalendarOff:tL,CalendarPlus:R_,CalendarPlus2:nU,CalendarRange:aU,CalendarSearch:iU,CalendarSync:oU,CalendarX:cU,CalendarX2:lU,Camera:Sx,CameraOff:dU,Candy:mU,CandyCane:uU,CandyOff:hU,Cannabis:pU,Captions:lj,CaptionsOff:fU,Car:CM,CarFront:xU,CarTaxiFront:gU,Caravan:yU,Carrot:vU,CaseLower:bU,CaseSensitive:_U,CaseUpper:wU,CassetteTape:jU,Cast:NU,Castle:kU,Cat:SU,Cctv:CU,ChartArea:cj,ChartBar:uj,ChartBarBig:dj,ChartBarDecreasing:MU,ChartBarIncreasing:TU,ChartBarStacked:AU,ChartCandlestick:hj,ChartColumn:No,ChartColumnBig:mj,ChartColumnDecreasing:EU,ChartColumnIncreasing:pj,ChartColumnStacked:PU,ChartGantt:IU,ChartLine:fj,ChartNetwork:LU,ChartNoAxesColumn:gj,ChartNoAxesColumnDecreasing:DU,ChartNoAxesColumnIncreasing:xj,ChartNoAxesCombined:OU,ChartNoAxesGantt:yj,ChartPie:vj,ChartScatter:bj,ChartSpline:RU,Check:va,CheckCheck:sL,ChefHat:FU,Cherry:zU,ChevronDown:Eo,ChevronFirst:BU,ChevronLast:$U,ChevronLeft:cl,ChevronRight:da,ChevronUp:ff,ChevronsDown:UU,ChevronsDownUp:qU,ChevronsLeft:WU,ChevronsLeftRight:HU,ChevronsLeftRightEllipsis:VU,ChevronsRight:KU,ChevronsRightLeft:GU,ChevronsUp:ZU,ChevronsUpDown:Cx,Chrome:YU,Church:XU,Cigarette:JU,CigaretteOff:QU,Circle:_d,CircleAlert:kl,CircleArrowDown:_j,CircleArrowLeft:wj,CircleArrowOutDownLeft:jj,CircleArrowOutDownRight:Nj,CircleArrowOutUpLeft:kj,CircleArrowOutUpRight:Sj,CircleArrowRight:Cj,CircleArrowUp:Mj,CircleCheck:sa,CircleCheckBig:xi,CircleChevronDown:Tj,CircleChevronLeft:Aj,CircleChevronRight:Ej,CircleChevronUp:Pj,CircleDashed:eV,CircleDivide:Ij,CircleDollarSign:tV,CircleDot:rV,CircleDotDashed:sV,CircleEllipsis:nV,CircleEqual:aV,CircleFadingArrowUp:iV,CircleFadingPlus:oV,CircleGauge:Lj,CircleHelp:Rv,CircleMinus:Dj,CircleOff:lV,CircleParking:Rj,CircleParkingOff:Oj,CirclePause:Fj,CirclePercent:zj,CirclePlay:pp,CirclePlus:Bj,CirclePower:$j,CircleSlash:cV,CircleSlash2:qj,CircleStop:Uj,CircleUser:Hj,CircleUserRound:Vj,CircleX:vc,CircuitBoard:dV,Citrus:uV,Clapperboard:hV,Clipboard:vV,ClipboardCheck:MM,ClipboardCopy:mV,ClipboardList:F_,ClipboardMinus:pV,ClipboardPaste:fV,ClipboardPen:Gj,ClipboardPenLine:Wj,ClipboardPlus:xV,ClipboardType:gV,ClipboardX:yV,Clock:un,Clock1:bV,Clock10:_V,Clock11:wV,Clock12:jV,Clock2:NV,Clock3:kV,Clock4:SV,Clock5:CV,Clock6:MV,Clock7:TV,Clock8:AV,Clock9:EV,ClockAlert:PV,ClockArrowDown:IV,ClockArrowUp:LV,Cloud:ZV,CloudAlert:DV,CloudCog:OV,CloudDownload:Kj,CloudDrizzle:RV,CloudFog:FV,CloudHail:zV,CloudLightning:BV,CloudMoon:qV,CloudMoonRain:$V,CloudOff:UV,CloudRain:HV,CloudRainWind:VV,CloudSnow:WV,CloudSun:KV,CloudSunRain:GV,CloudUpload:Zj,Cloudy:YV,Clover:Yv,Club:XV,Code:Q4,CodeXml:Yj,Codepen:QV,Codesandbox:JV,Coffee:J4,Cog:eH,Coins:rL,Columns2:Xj,Columns3:Qj,Columns4:tH,Combine:sH,Command:rH,Compass:nH,Component:aH,Computer:iH,ConciergeBell:oH,Cone:lH,Construction:cH,Contact:eS,ContactRound:Jj,Container:dH,Contrast:uH,Cookie:hH,CookingPot:mH,Copy:gi,CopyCheck:pH,CopyMinus:fH,CopyPlus:xH,CopySlash:gH,CopyX:yH,Copyleft:vH,Copyright:bH,CornerDownLeft:_H,CornerDownRight:wH,CornerLeftDown:jH,CornerLeftUp:NH,CornerRightDown:kH,CornerRightUp:SH,CornerUpLeft:CH,CornerUpRight:MH,Cpu:TH,CreativeCommons:AH,CreditCard:Mx,Croissant:EH,Crop:PH,Cross:IH,Crosshair:LH,Crown:Dm,Cuboid:DH,CupSoda:OH,Currency:RH,Cylinder:FH,Dam:zH,Database:nL,DatabaseBackup:BH,DatabaseZap:$H,Delete:qH,Dessert:UH,Diameter:VH,Diamond:GH,DiamondMinus:HH,DiamondPercent:eN,DiamondPlus:WH,Dice1:KH,Dice2:ZH,Dice3:YH,Dice4:XH,Dice5:QH,Dice6:JH,Dices:eW,Diff:tW,Disc:aW,Disc2:sW,Disc3:rW,DiscAlbum:nW,Divide:iW,Dna:lW,DnaOff:oW,Dock:cW,Dog:dW,DollarSign:ac,Donut:uW,DoorClosed:hW,DoorOpen:n1,Dot:mW,Download:yi,DraftingCompass:pW,Drama:fW,Dribbble:xW,Drill:gW,Droplet:yW,Droplets:Xg,Drum:vW,Drumstick:bW,Dumbbell:_W,Ear:jW,EarOff:wW,Earth:tN,EarthLock:NW,Eclipse:kW,Egg:TM,EggFried:SW,EggOff:CW,Ellipsis:fx,EllipsisVertical:px,Equal:AW,EqualApproximately:MW,EqualNot:TW,Eraser:EW,EthernetPort:PW,Euro:IW,Expand:aL,ExternalLink:tn,Eye:Ln,EyeClosed:LW,EyeOff:kp,Facebook:Su,Factory:DW,Fan:OW,FastForward:RW,Feather:FW,Fence:zW,FerrisWheel:BW,Figma:$W,File:AM,FileArchive:qW,FileAudio:VW,FileAudio2:UW,FileAxis3d:sN,FileBadge:WW,FileBadge2:HW,FileBox:GW,FileChartColumn:nN,FileChartColumnIncreasing:rN,FileChartLine:aN,FileChartPie:iN,FileCheck:ZW,FileCheck2:KW,FileClock:YW,FileCode:QW,FileCode2:XW,FileCog:oN,FileDiff:JW,FileDigit:eG,FileDown:tG,FileHeart:sG,FileImage:z_,FileInput:rG,FileJson:aG,FileJson2:nG,FileKey:oG,FileKey2:iG,FileLock:cG,FileLock2:lG,FileMinus:uG,FileMinus2:dG,FileMusic:hG,FileOutput:mG,FilePen:cN,FilePenLine:lN,FilePlus:fG,FilePlus2:pG,FileQuestion:xG,FileScan:gG,FileSearch:vG,FileSearch2:yG,FileSliders:bG,FileSpreadsheet:a1,FileStack:iL,FileSymlink:_G,FileTerminal:wG,FileText:Sn,FileType:NG,FileType2:jG,FileUp:kG,FileUser:SG,FileVideo:MG,FileVideo2:CG,FileVolume:AG,FileVolume2:TG,FileWarning:EG,FileX:IG,FileX2:PG,Files:LG,Film:gu,Filter:Qg,FilterX:DG,Fingerprint:OG,FireExtinguisher:RG,Fish:BG,FishOff:FG,FishSymbol:zG,Flag:i1,FlagOff:$G,FlagTriangleLeft:qG,FlagTriangleRight:UG,Flame:eh,FlameKindling:VG,Flashlight:WG,FlashlightOff:HG,FlaskConical:B_,FlaskConicalOff:GG,FlaskRound:KG,FlipHorizontal:oL,FlipHorizontal2:ZG,FlipVertical:XG,FlipVertical2:YG,Flower:QG,Flower2:Wg,Focus:JG,FoldHorizontal:eK,FoldVertical:tK,Folder:MK,FolderArchive:sK,FolderCheck:rK,FolderClock:nK,FolderClosed:aK,FolderCode:iK,FolderCog:dN,FolderDot:oK,FolderDown:lK,FolderGit:dK,FolderGit2:cK,FolderHeart:uK,FolderInput:hK,FolderKanban:mK,FolderKey:pK,FolderLock:fK,FolderMinus:xK,FolderOpen:Om,FolderOpenDot:gK,FolderOutput:yK,FolderPen:uN,FolderPlus:vK,FolderRoot:bK,FolderSearch:wK,FolderSearch2:_K,FolderSymlink:jK,FolderSync:NK,FolderTree:kK,FolderUp:SK,FolderX:CK,Folders:TK,Footprints:AK,Forklift:EK,Forward:PK,Frame:IK,Framer:LK,Frown:DK,Fuel:OK,Fullscreen:RK,GalleryHorizontal:zK,GalleryHorizontalEnd:FK,GalleryThumbnails:BK,GalleryVertical:qK,GalleryVerticalEnd:$K,Gamepad:VK,Gamepad2:UK,Gauge:HK,Gavel:WK,Gem:GK,Ghost:tS,Gift:ko,GitBranch:ZK,GitBranchPlus:KK,GitCommitHorizontal:hN,GitCommitVertical:YK,GitCompare:QK,GitCompareArrows:XK,GitFork:JK,GitGraph:eZ,GitMerge:tZ,GitPullRequest:oZ,GitPullRequestArrow:sZ,GitPullRequestClosed:rZ,GitPullRequestCreate:aZ,GitPullRequestCreateArrow:nZ,GitPullRequestDraft:iZ,Github:lZ,Gitlab:cZ,GlassWater:dZ,Glasses:uZ,Globe:su,GlobeLock:hZ,Goal:mZ,Grab:pZ,GraduationCap:Kh,Grape:fZ,Grid2x2:pN,Grid2x2Check:xZ,Grid2x2Plus:mN,Grid2x2X:gZ,Grid3x3:ax,Grip:vZ,GripHorizontal:yZ,GripVertical:Cu,Group:bZ,Guitar:_Z,Ham:wZ,Hammer:jZ,Hand:lL,HandCoins:NZ,HandHeart:kZ,HandHelping:fN,HandMetal:SZ,HandPlatter:CZ,Handshake:cL,HardDrive:dL,HardDriveDownload:MZ,HardDriveUpload:TZ,HardHat:AZ,Hash:$_,Haze:EZ,HdmiPort:PZ,Heading:OZ,Heading1:EM,Heading2:PM,Heading3:uL,Heading4:IZ,Heading5:LZ,Heading6:DZ,HeadphoneOff:RZ,Headphones:FZ,Headset:zZ,Heart:ni,HeartCrack:BZ,HeartHandshake:$Z,HeartOff:qZ,HeartPulse:UZ,Heater:VZ,Hexagon:HZ,Highlighter:WZ,History:IM,Hop:KZ,HopOff:GZ,Hospital:ZZ,Hotel:YZ,Hourglass:XZ,House:bn,HousePlug:QZ,HousePlus:JZ,IceCreamBowl:xN,IceCreamCone:gN,IdCard:eY,Image:gl,ImageDown:tY,ImageMinus:sY,ImageOff:rY,ImagePlay:nY,ImagePlus:o1,ImageUp:aY,ImageUpscale:iY,Images:oY,Import:lY,Inbox:cY,IndentDecrease:yN,IndentIncrease:vN,IndianRupee:dY,Infinity:uY,Info:hL,InspectionPanel:hY,Instagram:Mu,Italic:sS,IterationCcw:mY,IterationCw:pY,JapaneseYen:fY,Joystick:xY,Kanban:m0,Key:Sp,KeyRound:rS,KeySquare:gY,Keyboard:bY,KeyboardMusic:yY,KeyboardOff:vY,Lamp:SY,LampCeiling:_Y,LampDesk:wY,LampFloor:jY,LampWallDown:NY,LampWallUp:kY,LandPlot:CY,Landmark:MY,Languages:TY,Laptop:EY,LaptopMinimal:bN,LaptopMinimalCheck:AY,Lasso:IY,LassoSelect:PY,Laugh:LY,Layers:LM,Layers2:DY,Layers3:OY,LayoutDashboard:nS,LayoutGrid:Cp,LayoutList:RY,LayoutPanelLeft:FY,LayoutPanelTop:zY,LayoutTemplate:aS,Leaf:BY,LeafyGreen:$Y,Lectern:qY,LetterText:UY,Library:DM,LibraryBig:VY,LifeBuoy:OM,Ligature:HY,Lightbulb:q_,LightbulbOff:WY,Link:Bo,Link2:dl,Link2Off:GY,Linkedin:Mp,List:Mh,ListCheck:KY,ListChecks:ZY,ListCollapse:YY,ListEnd:XY,ListFilter:QY,ListMinus:JY,ListMusic:eX,ListOrdered:p0,ListPlus:tX,ListRestart:sX,ListStart:rX,ListTodo:nX,ListTree:aX,ListVideo:iX,ListX:oX,Loader:cX,LoaderCircle:ws,LoaderPinwheel:lX,Locate:hX,LocateFixed:dX,LocateOff:uX,Lock:Th,LockKeyhole:mX,LockKeyholeOpen:_N,LockOpen:wN,LogIn:iS,LogOut:oS,Logs:pX,Lollipop:fX,Luggage:xX,Magnet:gX,Mail:cr,MailCheck:yX,MailMinus:vX,MailOpen:bX,MailPlus:mL,MailQuestion:_X,MailSearch:wX,MailWarning:jX,MailX:pL,Mailbox:NX,Mails:kX,Map:l1,MapPin:ma,MapPinCheck:CX,MapPinCheckInside:SX,MapPinHouse:MX,MapPinMinus:AX,MapPinMinusInside:TX,MapPinOff:EX,MapPinPlus:IX,MapPinPlusInside:PX,MapPinX:DX,MapPinXInside:LX,MapPinned:OX,Martini:RX,Maximize:lS,Maximize2:FX,Medal:c1,Megaphone:Ah,MegaphoneOff:zX,Meh:BX,MemoryStick:$X,Menu:RM,Merge:qX,MessageCircle:$c,MessageCircleCode:UX,MessageCircleDashed:VX,MessageCircleHeart:FM,MessageCircleMore:HX,MessageCircleOff:WX,MessageCirclePlus:GX,MessageCircleQuestion:fL,MessageCircleReply:KX,MessageCircleWarning:ZX,MessageCircleX:YX,MessageSquare:so,MessageSquareCode:XX,MessageSquareDashed:QX,MessageSquareDiff:JX,MessageSquareDot:eQ,MessageSquareHeart:tQ,MessageSquareLock:sQ,MessageSquareMore:xL,MessageSquareOff:rQ,MessageSquarePlus:zM,MessageSquareQuote:gL,MessageSquareReply:nQ,MessageSquareShare:aQ,MessageSquareText:iQ,MessageSquareWarning:oQ,MessageSquareX:lQ,MessagesSquare:cQ,Mic:yL,MicOff:dQ,MicVocal:jN,Microchip:uQ,Microscope:hQ,Microwave:mQ,Milestone:pQ,Milk:xQ,MilkOff:fQ,Minimize:yQ,Minimize2:gQ,Minus:f0,Monitor:dS,MonitorCheck:vQ,MonitorCog:bQ,MonitorDot:_Q,MonitorDown:wQ,MonitorOff:jQ,MonitorPause:NQ,MonitorPlay:kQ,MonitorSmartphone:SQ,MonitorSpeaker:CQ,MonitorStop:MQ,MonitorUp:cS,MonitorX:TQ,Moon:EQ,MoonStar:AQ,Mountain:IQ,MountainSnow:PQ,Mouse:RQ,MouseOff:LQ,MousePointer:wh,MousePointer2:DQ,MousePointerBan:OQ,MousePointerClick:Jg,Move:YQ,Move3d:NN,MoveDiagonal:zQ,MoveDiagonal2:FQ,MoveDown:qQ,MoveDownLeft:BQ,MoveDownRight:$Q,MoveHorizontal:UQ,MoveLeft:VQ,MoveRight:HQ,MoveUp:KQ,MoveUpLeft:WQ,MoveUpRight:GQ,MoveVertical:ZQ,Music:eJ,Music2:XQ,Music3:QQ,Music4:JQ,Navigation:nJ,Navigation2:sJ,Navigation2Off:tJ,NavigationOff:rJ,Network:aJ,Newspaper:d1,Nfc:iJ,Notebook:dJ,NotebookPen:oJ,NotebookTabs:lJ,NotebookText:cJ,NotepadText:hJ,NotepadTextDashed:uJ,Nut:pJ,NutOff:mJ,Octagon:xJ,OctagonAlert:Fv,OctagonMinus:fJ,OctagonPause:kN,OctagonX:SN,Omega:gJ,Option:yJ,Orbit:vJ,Origami:bJ,Package:Ml,Package2:_J,PackageCheck:wJ,PackageMinus:jJ,PackageOpen:NJ,PackagePlus:kJ,PackageSearch:SJ,PackageX:CJ,PaintBucket:MJ,PaintRoller:TJ,Paintbrush:AJ,PaintbrushVertical:CN,Palette:ic,PanelBottom:IJ,PanelBottomClose:EJ,PanelBottomDashed:MN,PanelBottomOpen:PJ,PanelLeft:PN,PanelLeftClose:TN,PanelLeftDashed:AN,PanelLeftOpen:EN,PanelRight:OJ,PanelRightClose:LJ,PanelRightDashed:IN,PanelRightOpen:DJ,PanelTop:zJ,PanelTopClose:RJ,PanelTopDashed:LN,PanelTopOpen:FJ,PanelsLeftBottom:BJ,PanelsRightBottom:$J,PanelsTopLeft:zv,Paperclip:uS,Parentheses:qJ,ParkingMeter:UJ,PartyPopper:ru,Pause:Rm,PawPrint:VJ,PcCase:HJ,Pen:e0,PenLine:Bv,PenOff:WJ,PenTool:U_,Pencil:Ra,PencilLine:GJ,PencilOff:KJ,PencilRuler:ZJ,Pentagon:YJ,Percent:hS,PersonStanding:XJ,PhilippinePeso:QJ,Phone:Un,PhoneCall:JJ,PhoneForwarded:eee,PhoneIncoming:tee,PhoneMissed:see,PhoneOff:ree,PhoneOutgoing:nee,Pi:aee,Piano:iee,Pickaxe:oee,PictureInPicture:cee,PictureInPicture2:lee,PiggyBank:dee,Pilcrow:mee,PilcrowLeft:uee,PilcrowRight:hee,Pill:fee,PillBottle:pee,Pin:V_,PinOff:vL,Pipette:xee,Pizza:gee,Plane:bee,PlaneLanding:yee,PlaneTakeoff:vee,Play:nl,Plug:bL,Plug2:_ee,PlugZap:DN,Plus:$s,Pocket:jee,PocketKnife:wee,Podcast:Nee,Pointer:See,PointerOff:kee,Popcorn:Cee,Popsicle:Mee,PoundSterling:Tee,Power:_L,PowerOff:Aee,Presentation:ey,Printer:wL,PrinterCheck:Eee,Projector:Pee,Proportions:Iee,Puzzle:Lee,Pyramid:Dee,QrCode:u1,Quote:H_,Rabbit:Oee,Radar:Ree,Radiation:Fee,Radical:zee,Radio:h1,RadioReceiver:Bee,RadioTower:$ee,Radius:qee,RailSymbol:Uee,Rainbow:Vee,Rat:Hee,Ratio:Wee,Receipt:tte,ReceiptCent:Gee,ReceiptEuro:Kee,ReceiptIndianRupee:Zee,ReceiptJapaneseYen:Yee,ReceiptPoundSterling:Xee,ReceiptRussianRuble:Qee,ReceiptSwissFranc:Jee,ReceiptText:ete,RectangleEllipsis:ON,RectangleHorizontal:ste,RectangleVertical:rte,Recycle:nte,Redo:mS,Redo2:ate,RedoDot:ite,RefreshCcw:BM,RefreshCcwDot:ote,RefreshCw:Go,RefreshCwOff:lte,Refrigerator:cte,Regex:dte,RemoveFormatting:ute,Repeat:jL,Repeat1:hte,Repeat2:mte,Replace:fte,ReplaceAll:pte,Reply:NL,ReplyAll:xte,Rewind:gte,Ribbon:yte,Rocket:x0,RockingChair:vte,RollerCoaster:bte,Rotate3d:RN,RotateCcw:m1,RotateCcwSquare:_te,RotateCw:kL,RotateCwSquare:wte,Route:Nte,RouteOff:jte,Router:kte,Rows2:FN,Rows3:zN,Rows4:Ste,Rss:Cte,Ruler:g0,RussianRuble:Mte,Sailboat:Tte,Salad:Ate,Sandwich:Ete,Satellite:Ite,SatelliteDish:Pte,Save:qc,SaveAll:Lte,SaveOff:Dte,Scale:SL,Scale3d:BN,Scaling:Ote,Scan:Vte,ScanBarcode:Rte,ScanEye:Fte,ScanFace:zte,ScanLine:Bte,ScanQrCode:$te,ScanSearch:qte,ScanText:Ute,School:Hte,Scissors:Gte,ScissorsLineDashed:Wte,ScreenShare:Zte,ScreenShareOff:Kte,Scroll:Xte,ScrollText:Yte,Search:cn,SearchCheck:Qte,SearchCode:Jte,SearchSlash:ese,SearchX:CL,Section:tse,Send:Bn,SendHorizontal:$N,SendToBack:sse,SeparatorHorizontal:rse,SeparatorVertical:nse,Server:lse,ServerCog:ase,ServerCrash:ise,ServerOff:ose,Settings:Xo,Settings2:ML,Shapes:cse,Share:TL,Share2:wd,Sheet:dse,Shell:use,Shield:th,ShieldAlert:hse,ShieldBan:mse,ShieldCheck:AL,ShieldEllipsis:pse,ShieldHalf:fse,ShieldMinus:xse,ShieldOff:gse,ShieldPlus:yse,ShieldQuestion:vse,ShieldX:qN,Ship:_se,ShipWheel:bse,Shirt:wse,ShoppingBag:y0,ShoppingBasket:jse,ShoppingCart:vp,Shovel:Nse,ShowerHead:kse,Shrink:Sse,Shrub:Cse,Shuffle:pS,Sigma:Mse,Signal:Ise,SignalHigh:Tse,SignalLow:Ase,SignalMedium:Ese,SignalZero:Pse,Signature:Lse,Signpost:Ose,SignpostBig:Dse,Siren:Rse,SkipBack:Fse,SkipForward:zse,Skull:Bse,Slack:$se,Slash:qse,Slice:Use,SlidersHorizontal:W_,SlidersVertical:UN,Smartphone:v0,SmartphoneCharging:Vse,SmartphoneNfc:Hse,Smile:Gse,SmilePlus:Wse,Snail:Kse,Snowflake:a0,Sofa:Zse,Soup:Yse,Space:Xse,Spade:Qse,Sparkle:Jse,Sparkles:pn,Speaker:ere,Speech:tre,SpellCheck:rre,SpellCheck2:sre,Spline:nre,Split:are,SprayCan:ire,Sprout:ore,Square:b0,SquareActivity:VN,SquareArrowDown:GN,SquareArrowDownLeft:HN,SquareArrowDownRight:WN,SquareArrowLeft:KN,SquareArrowOutDownLeft:ZN,SquareArrowOutDownRight:YN,SquareArrowOutUpLeft:XN,SquareArrowOutUpRight:QN,SquareArrowRight:JN,SquareArrowUp:sk,SquareArrowUpLeft:ek,SquareArrowUpRight:tk,SquareAsterisk:rk,SquareBottomDashedScissors:nk,SquareChartGantt:Vy,SquareCheck:ak,SquareCheckBig:$v,SquareChevronDown:ik,SquareChevronLeft:ok,SquareChevronRight:lk,SquareChevronUp:ck,SquareCode:dk,SquareDashed:mk,SquareDashedBottom:cre,SquareDashedBottomCode:lre,SquareDashedKanban:uk,SquareDashedMousePointer:hk,SquareDivide:pk,SquareDot:fk,SquareEqual:xk,SquareFunction:gk,SquareKanban:yk,SquareLibrary:vk,SquareM:bk,SquareMenu:_k,SquareMinus:wk,SquareMousePointer:jk,SquareParking:kk,SquareParkingOff:Nk,SquarePen:hd,SquarePercent:Sk,SquarePi:Ck,SquarePilcrow:Mk,SquarePlay:Tk,SquarePlus:Ak,SquarePower:Ek,SquareRadical:dre,SquareScissors:Pk,SquareSigma:Ik,SquareSlash:Lk,SquareSplitHorizontal:Dk,SquareSplitVertical:Ok,SquareSquare:ure,SquareStack:hre,SquareTerminal:Rk,SquareUser:zk,SquareUserRound:Fk,SquareX:Bk,Squircle:mre,Squirrel:pre,Stamp:fre,Star:Jn,StarHalf:xre,StarOff:gre,StepBack:yre,StepForward:vre,Stethoscope:bre,Sticker:_re,StickyNote:wre,Store:$M,StretchHorizontal:jre,StretchVertical:Nre,Strikethrough:EL,Subscript:kre,Sun:p1,SunDim:Sre,SunMedium:Cre,SunMoon:Mre,SunSnow:Tre,Sunrise:Are,Sunset:Ere,Superscript:Pre,SwatchBook:Ire,SwissFranc:Lre,SwitchCamera:Dre,Sword:Ore,Swords:Rre,Syringe:Fre,Table:UM,Table2:qM,TableCellsMerge:zre,TableCellsSplit:Bre,TableColumnsSplit:$re,TableOfContents:qre,TableProperties:Ure,TableRowsSplit:Vre,Tablet:Wre,TabletSmartphone:Hre,Tablets:Gre,Tag:Fm,Tags:Kre,Tally1:Zre,Tally2:Yre,Tally3:Xre,Tally4:Qre,Tally5:Jre,Tangent:ene,Target:zm,Telescope:tne,Tent:rne,TentTree:sne,Terminal:nne,TestTube:ane,TestTubeDiagonal:$k,TestTubes:ine,Text:une,TextCursor:lne,TextCursorInput:one,TextQuote:cne,TextSearch:dne,TextSelect:qk,Theater:hne,Thermometer:PL,ThermometerSnowflake:mne,ThermometerSun:pne,ThumbsDown:IL,ThumbsUp:sh,Ticket:LL,TicketCheck:fne,TicketMinus:xne,TicketPercent:gne,TicketPlus:yne,TicketSlash:vne,TicketX:bne,Tickets:wne,TicketsPlane:_ne,Timer:kne,TimerOff:jne,TimerReset:Nne,ToggleLeft:Sne,ToggleRight:Cne,Toilet:Mne,Tornado:Tne,Torus:Ane,Touchpad:Pne,TouchpadOff:Ene,TowerControl:Ine,ToyBrick:Lne,Tractor:Dne,TrafficCone:One,TrainFront:Fne,TrainFrontTunnel:Rne,TrainTrack:zne,TramFront:Uk,Trash:Bne,Trash2:Nr,TreeDeciduous:$ne,TreePalm:Vk,TreePine:f1,Trees:qne,Trello:Une,TrendingDown:fS,TrendingUp:ul,TrendingUpDown:Vne,Triangle:Wne,TriangleAlert:Ku,TriangleRight:Hne,Trophy:xo,Truck:DL,Turtle:Gne,Tv:Zne,TvMinimal:Hk,TvMinimalPlay:Kne,Twitch:Yne,Twitter:Xne,Type:Jne,TypeOutline:Qne,Umbrella:tae,UmbrellaOff:eae,Underline:OL,Undo:xS,Undo2:sae,UndoDot:rae,UnfoldHorizontal:nae,UnfoldVertical:aae,Ungroup:iae,University:Wk,Unlink:gS,Unlink2:oae,Unplug:lae,Upload:li,Usb:cae,User:to,UserCheck:G_,UserCog:RL,UserMinus:FL,UserPen:dae,UserPlus:Tl,UserRound:Qk,UserRoundCheck:Gk,UserRoundCog:Kk,UserRoundMinus:Zk,UserRoundPen:uae,UserRoundPlus:Yk,UserRoundSearch:hae,UserRoundX:Xk,UserSearch:mae,UserX:pae,Users:pr,UsersRound:Jk,Utensils:t4,UtensilsCrossed:e4,UtilityPole:fae,Variable:VM,Vault:xae,Vegan:gae,VenetianMask:yae,Vibrate:bae,VibrateOff:vae,Video:An,VideoOff:_ae,Videotape:wae,View:jae,Voicemail:Nae,Volleyball:kae,Volume:Aae,Volume1:Sae,Volume2:Cae,VolumeOff:Mae,VolumeX:Tae,Vote:Eae,Wallet:zL,WalletCards:Pae,WalletMinimal:s4,Wallpaper:Iae,Wand:Lae,WandSparkles:qv,Warehouse:Dae,WashingMachine:Oae,Watch:Rae,Waves:BL,Waypoints:Fae,Webcam:zae,Webhook:$ae,WebhookOff:Bae,Weight:qae,Wheat:Vae,WheatOff:Uae,WholeWord:Hae,Wifi:Yae,WifiHigh:Wae,WifiLow:Gae,WifiOff:Kae,WifiZero:Zae,Wind:Qae,WindArrowDown:Xae,Wine:eie,WineOff:Jae,Workflow:tie,Worm:sie,WrapText:rie,Wrench:ty,X:Rr,Youtube:nie,Zap:Zh,ZapOff:aie,ZoomIn:K_,ZoomOut:HM},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 g2e=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:_9,AArrowDownIcon:_9,AArrowUp:w9,AArrowUpIcon:w9,ALargeSmall:j9,ALargeSmallIcon:j9,Accessibility:N9,AccessibilityIcon:N9,Activity:kh,ActivityIcon:kh,ActivitySquare:VN,ActivitySquareIcon:VN,AirVent:k9,AirVentIcon:k9,Airplay:S9,AirplayIcon:S9,AlarmCheck:G2,AlarmCheckIcon:G2,AlarmClock:M9,AlarmClockCheck:G2,AlarmClockCheckIcon:G2,AlarmClockIcon:M9,AlarmClockMinus:K2,AlarmClockMinusIcon:K2,AlarmClockOff:C9,AlarmClockOffIcon:C9,AlarmClockPlus:Z2,AlarmClockPlusIcon:Z2,AlarmMinus:K2,AlarmMinusIcon:K2,AlarmPlus:Z2,AlarmPlusIcon:Z2,AlarmSmoke:T9,AlarmSmokeIcon:T9,Album:A9,AlbumIcon:A9,AlertCircle:kl,AlertCircleIcon:kl,AlertOctagon:Fv,AlertOctagonIcon:Fv,AlertTriangle:Ku,AlertTriangleIcon:Ku,AlignCenter:W4,AlignCenterHorizontal:E9,AlignCenterHorizontalIcon:E9,AlignCenterIcon:W4,AlignCenterVertical:P9,AlignCenterVerticalIcon:P9,AlignEndHorizontal:I9,AlignEndHorizontalIcon:I9,AlignEndVertical:L9,AlignEndVerticalIcon:L9,AlignHorizontalDistributeCenter:D9,AlignHorizontalDistributeCenterIcon:D9,AlignHorizontalDistributeEnd:O9,AlignHorizontalDistributeEndIcon:O9,AlignHorizontalDistributeStart:R9,AlignHorizontalDistributeStartIcon:R9,AlignHorizontalJustifyCenter:F9,AlignHorizontalJustifyCenterIcon:F9,AlignHorizontalJustifyEnd:z9,AlignHorizontalJustifyEndIcon:z9,AlignHorizontalJustifyStart:B9,AlignHorizontalJustifyStartIcon:B9,AlignHorizontalSpaceAround:$9,AlignHorizontalSpaceAroundIcon:$9,AlignHorizontalSpaceBetween:q9,AlignHorizontalSpaceBetweenIcon:q9,AlignJustify:U9,AlignJustifyIcon:U9,AlignLeft:G4,AlignLeftIcon:G4,AlignRight:K4,AlignRightIcon:K4,AlignStartHorizontal:V9,AlignStartHorizontalIcon:V9,AlignStartVertical:H9,AlignStartVerticalIcon:H9,AlignVerticalDistributeCenter:W9,AlignVerticalDistributeCenterIcon:W9,AlignVerticalDistributeEnd:G9,AlignVerticalDistributeEndIcon:G9,AlignVerticalDistributeStart:K9,AlignVerticalDistributeStartIcon:K9,AlignVerticalJustifyCenter:Z9,AlignVerticalJustifyCenterIcon:Z9,AlignVerticalJustifyEnd:Y9,AlignVerticalJustifyEndIcon:Y9,AlignVerticalJustifyStart:X9,AlignVerticalJustifyStartIcon:X9,AlignVerticalSpaceAround:Q9,AlignVerticalSpaceAroundIcon:Q9,AlignVerticalSpaceBetween:J9,AlignVerticalSpaceBetweenIcon:J9,Ambulance:eB,AmbulanceIcon:eB,Ampersand:tB,AmpersandIcon:tB,Ampersands:sB,AmpersandsIcon:sB,Amphora:rB,AmphoraIcon:rB,Anchor:nB,AnchorIcon:nB,Angry:aB,AngryIcon:aB,Annoyed:iB,AnnoyedIcon:iB,Antenna:oB,AntennaIcon:oB,Anvil:lB,AnvilIcon:lB,Aperture:cB,ApertureIcon:cB,AppWindow:HI,AppWindowIcon:HI,AppWindowMac:dB,AppWindowMacIcon:dB,Apple:uB,AppleIcon:uB,Archive:kM,ArchiveIcon:kM,ArchiveRestore:WI,ArchiveRestoreIcon:WI,ArchiveX:hB,ArchiveXIcon:hB,AreaChart:cj,AreaChartIcon:cj,Armchair:mB,ArmchairIcon:mB,ArrowBigDown:fB,ArrowBigDownDash:pB,ArrowBigDownDashIcon:pB,ArrowBigDownIcon:fB,ArrowBigLeft:gB,ArrowBigLeftDash:xB,ArrowBigLeftDashIcon:xB,ArrowBigLeftIcon:gB,ArrowBigRight:vB,ArrowBigRightDash:yB,ArrowBigRightDashIcon:yB,ArrowBigRightIcon:vB,ArrowBigUp:_B,ArrowBigUpDash:bB,ArrowBigUpDashIcon:bB,ArrowBigUpIcon:_B,ArrowDown:Wh,ArrowDown01:wB,ArrowDown01Icon:wB,ArrowDown10:jB,ArrowDown10Icon:jB,ArrowDownAZ:Y2,ArrowDownAZIcon:Y2,ArrowDownAz:Y2,ArrowDownAzIcon:Y2,ArrowDownCircle:_j,ArrowDownCircleIcon:_j,ArrowDownFromLine:NB,ArrowDownFromLineIcon:NB,ArrowDownIcon:Wh,ArrowDownLeft:kB,ArrowDownLeftFromCircle:jj,ArrowDownLeftFromCircleIcon:jj,ArrowDownLeftFromSquare:ZN,ArrowDownLeftFromSquareIcon:ZN,ArrowDownLeftIcon:kB,ArrowDownLeftSquare:HN,ArrowDownLeftSquareIcon:HN,ArrowDownNarrowWide:SB,ArrowDownNarrowWideIcon:SB,ArrowDownRight:GI,ArrowDownRightFromCircle:Nj,ArrowDownRightFromCircleIcon:Nj,ArrowDownRightFromSquare:YN,ArrowDownRightFromSquareIcon:YN,ArrowDownRightIcon:GI,ArrowDownRightSquare:WN,ArrowDownRightSquareIcon:WN,ArrowDownSquare:GN,ArrowDownSquareIcon:GN,ArrowDownToDot:CB,ArrowDownToDotIcon:CB,ArrowDownToLine:MB,ArrowDownToLineIcon:MB,ArrowDownUp:TB,ArrowDownUpIcon:TB,ArrowDownWideNarrow:X2,ArrowDownWideNarrowIcon:X2,ArrowDownZA:Q2,ArrowDownZAIcon:Q2,ArrowDownZa:Q2,ArrowDownZaIcon:Q2,ArrowLeft:Ja,ArrowLeftCircle:wj,ArrowLeftCircleIcon:wj,ArrowLeftFromLine:AB,ArrowLeftFromLineIcon:AB,ArrowLeftIcon:Ja,ArrowLeftRight:EB,ArrowLeftRightIcon:EB,ArrowLeftSquare:KN,ArrowLeftSquareIcon:KN,ArrowLeftToLine:PB,ArrowLeftToLineIcon:PB,ArrowRight:Qa,ArrowRightCircle:Cj,ArrowRightCircleIcon:Cj,ArrowRightFromLine:IB,ArrowRightFromLineIcon:IB,ArrowRightIcon:Qa,ArrowRightLeft:s1,ArrowRightLeftIcon:s1,ArrowRightSquare:JN,ArrowRightSquareIcon:JN,ArrowRightToLine:LB,ArrowRightToLineIcon:LB,ArrowUp:ku,ArrowUp01:DB,ArrowUp01Icon:DB,ArrowUp10:OB,ArrowUp10Icon:OB,ArrowUpAZ:J2,ArrowUpAZIcon:J2,ArrowUpAz:J2,ArrowUpAzIcon:J2,ArrowUpCircle:Mj,ArrowUpCircleIcon:Mj,ArrowUpDown:bd,ArrowUpDownIcon:bd,ArrowUpFromDot:RB,ArrowUpFromDotIcon:RB,ArrowUpFromLine:FB,ArrowUpFromLineIcon:FB,ArrowUpIcon:ku,ArrowUpLeft:zB,ArrowUpLeftFromCircle:kj,ArrowUpLeftFromCircleIcon:kj,ArrowUpLeftFromSquare:XN,ArrowUpLeftFromSquareIcon:XN,ArrowUpLeftIcon:zB,ArrowUpLeftSquare:ek,ArrowUpLeftSquareIcon:ek,ArrowUpNarrowWide:ej,ArrowUpNarrowWideIcon:ej,ArrowUpRight:KI,ArrowUpRightFromCircle:Sj,ArrowUpRightFromCircleIcon:Sj,ArrowUpRightFromSquare:QN,ArrowUpRightFromSquareIcon:QN,ArrowUpRightIcon:KI,ArrowUpRightSquare:tk,ArrowUpRightSquareIcon:tk,ArrowUpSquare:sk,ArrowUpSquareIcon:sk,ArrowUpToLine:BB,ArrowUpToLineIcon:BB,ArrowUpWideNarrow:$B,ArrowUpWideNarrowIcon:$B,ArrowUpZA:tj,ArrowUpZAIcon:tj,ArrowUpZa:tj,ArrowUpZaIcon:tj,ArrowsUpFromLine:qB,ArrowsUpFromLineIcon:qB,Asterisk:UB,AsteriskIcon:UB,AsteriskSquare:rk,AsteriskSquareIcon:rk,AtSign:VB,AtSignIcon:VB,Atom:HB,AtomIcon:HB,AudioLines:WB,AudioLinesIcon:WB,AudioWaveform:GB,AudioWaveformIcon:GB,Award:Nc,AwardIcon:Nc,Axe:KB,AxeIcon:KB,Axis3D:sj,Axis3DIcon:sj,Axis3d:sj,Axis3dIcon:sj,Baby:ZB,BabyIcon:ZB,Backpack:YB,BackpackIcon:YB,Badge:h$,BadgeAlert:XB,BadgeAlertIcon:XB,BadgeCent:QB,BadgeCentIcon:QB,BadgeCheck:rj,BadgeCheckIcon:rj,BadgeDollarSign:JB,BadgeDollarSignIcon:JB,BadgeEuro:e$,BadgeEuroIcon:e$,BadgeHelp:t$,BadgeHelpIcon:t$,BadgeIcon:h$,BadgeIndianRupee:s$,BadgeIndianRupeeIcon:s$,BadgeInfo:r$,BadgeInfoIcon:r$,BadgeJapaneseYen:n$,BadgeJapaneseYenIcon:n$,BadgeMinus:a$,BadgeMinusIcon:a$,BadgePercent:i$,BadgePercentIcon:i$,BadgePlus:o$,BadgePlusIcon:o$,BadgePoundSterling:l$,BadgePoundSterlingIcon:l$,BadgeRussianRuble:c$,BadgeRussianRubleIcon:c$,BadgeSwissFranc:d$,BadgeSwissFrancIcon:d$,BadgeX:u$,BadgeXIcon:u$,BaggageClaim:m$,BaggageClaimIcon:m$,Ban:ZI,BanIcon:ZI,Banana:p$,BananaIcon:p$,Bandage:f$,BandageIcon:f$,Banknote:x$,BanknoteIcon:x$,BarChart:xj,BarChart2:gj,BarChart2Icon:gj,BarChart3:No,BarChart3Icon:No,BarChart4:pj,BarChart4Icon:pj,BarChartBig:mj,BarChartBigIcon:mj,BarChartHorizontal:uj,BarChartHorizontalBig:dj,BarChartHorizontalBigIcon:dj,BarChartHorizontalIcon:uj,BarChartIcon:xj,Barcode:g$,BarcodeIcon:g$,Baseline:y$,BaselineIcon:y$,Bath:Ju,BathIcon:Ju,Battery:N$,BatteryCharging:v$,BatteryChargingIcon:v$,BatteryFull:b$,BatteryFullIcon:b$,BatteryIcon:N$,BatteryLow:_$,BatteryLowIcon:_$,BatteryMedium:w$,BatteryMediumIcon:w$,BatteryWarning:j$,BatteryWarningIcon:j$,Beaker:k$,BeakerIcon:k$,Bean:C$,BeanIcon:C$,BeanOff:S$,BeanOffIcon:S$,Bed:Im,BedDouble:Z4,BedDoubleIcon:Z4,BedIcon:Im,BedSingle:M$,BedSingleIcon:M$,Beef:T$,BeefIcon:T$,Beer:E$,BeerIcon:E$,BeerOff:A$,BeerOffIcon:A$,Bell:Lm,BellDot:P$,BellDotIcon:P$,BellElectric:I$,BellElectricIcon:I$,BellIcon:Lm,BellMinus:L$,BellMinusIcon:L$,BellOff:r1,BellOffIcon:r1,BellPlus:D$,BellPlusIcon:D$,BellRing:O$,BellRingIcon:O$,BetweenHorizonalEnd:nj,BetweenHorizonalEndIcon:nj,BetweenHorizonalStart:aj,BetweenHorizonalStartIcon:aj,BetweenHorizontalEnd:nj,BetweenHorizontalEndIcon:nj,BetweenHorizontalStart:aj,BetweenHorizontalStartIcon:aj,BetweenVerticalEnd:R$,BetweenVerticalEndIcon:R$,BetweenVerticalStart:F$,BetweenVerticalStartIcon:F$,BicepsFlexed:z$,BicepsFlexedIcon:z$,Bike:B$,BikeIcon:B$,Binary:$$,BinaryIcon:$$,Binoculars:q$,BinocularsIcon:q$,Biohazard:U$,BiohazardIcon:U$,Bird:V$,BirdIcon:V$,Bitcoin:H$,BitcoinIcon:H$,Blend:W$,BlendIcon:W$,Blinds:G$,BlindsIcon:G$,Blocks:K$,BlocksIcon:K$,Bluetooth:Q$,BluetoothConnected:Z$,BluetoothConnectedIcon:Z$,BluetoothIcon:Q$,BluetoothOff:Y$,BluetoothOffIcon:Y$,BluetoothSearching:X$,BluetoothSearchingIcon:X$,Bold:Y4,BoldIcon:Y4,Bolt:J$,BoltIcon:J$,Bomb:eq,BombIcon:eq,Bone:tq,BoneIcon:tq,Book:jq,BookA:sq,BookAIcon:sq,BookAudio:rq,BookAudioIcon:rq,BookCheck:nq,BookCheckIcon:nq,BookCopy:aq,BookCopyIcon:aq,BookDashed:ij,BookDashedIcon:ij,BookDown:iq,BookDownIcon:iq,BookHeadphones:oq,BookHeadphonesIcon:oq,BookHeart:lq,BookHeartIcon:lq,BookIcon:jq,BookImage:cq,BookImageIcon:cq,BookKey:dq,BookKeyIcon:dq,BookLock:uq,BookLockIcon:uq,BookMarked:hq,BookMarkedIcon:hq,BookMinus:mq,BookMinusIcon:mq,BookOpen:Sh,BookOpenCheck:pq,BookOpenCheckIcon:pq,BookOpenIcon:Sh,BookOpenText:fq,BookOpenTextIcon:fq,BookPlus:xq,BookPlusIcon:xq,BookTemplate:ij,BookTemplateIcon:ij,BookText:gq,BookTextIcon:gq,BookType:yq,BookTypeIcon:yq,BookUp:bq,BookUp2:vq,BookUp2Icon:vq,BookUpIcon:bq,BookUser:_q,BookUserIcon:_q,BookX:wq,BookXIcon:wq,Bookmark:kx,BookmarkCheck:Nq,BookmarkCheckIcon:Nq,BookmarkIcon:kx,BookmarkMinus:kq,BookmarkMinusIcon:kq,BookmarkPlus:YI,BookmarkPlusIcon:YI,BookmarkX:Sq,BookmarkXIcon:Sq,BoomBox:Cq,BoomBoxIcon:Cq,Bot:SM,BotIcon:SM,BotMessageSquare:Mq,BotMessageSquareIcon:Mq,BotOff:Tq,BotOffIcon:Tq,Box:Aq,BoxIcon:Aq,BoxSelect:mk,BoxSelectIcon:mk,Boxes:Eq,BoxesIcon:Eq,Braces:oj,BracesIcon:oj,Brackets:Pq,BracketsIcon:Pq,Brain:XI,BrainCircuit:Iq,BrainCircuitIcon:Iq,BrainCog:Lq,BrainCogIcon:Lq,BrainIcon:XI,BrickWall:Dq,BrickWallIcon:Dq,Briefcase:Gh,BriefcaseBusiness:Oq,BriefcaseBusinessIcon:Oq,BriefcaseConveyorBelt:Rq,BriefcaseConveyorBeltIcon:Rq,BriefcaseIcon:Gh,BriefcaseMedical:Fq,BriefcaseMedicalIcon:Fq,BringToFront:zq,BringToFrontIcon:zq,Brush:Bq,BrushIcon:Bq,Bug:Uq,BugIcon:Uq,BugOff:$q,BugOffIcon:$q,BugPlay:qq,BugPlayIcon:qq,Building:X4,Building2:ka,Building2Icon:ka,BuildingIcon:X4,Bus:Hq,BusFront:Vq,BusFrontIcon:Vq,BusIcon:Hq,Cable:Gq,CableCar:Wq,CableCarIcon:Wq,CableIcon:Gq,Cake:Ch,CakeIcon:Ch,CakeSlice:Kq,CakeSliceIcon:Kq,Calculator:QI,CalculatorIcon:QI,Calendar:hn,Calendar1:Zq,Calendar1Icon:Zq,CalendarArrowDown:Yq,CalendarArrowDownIcon:Yq,CalendarArrowUp:Xq,CalendarArrowUpIcon:Xq,CalendarCheck:JI,CalendarCheck2:Qq,CalendarCheck2Icon:Qq,CalendarCheckIcon:JI,CalendarClock:eL,CalendarClockIcon:eL,CalendarCog:Jq,CalendarCogIcon:Jq,CalendarDays:Od,CalendarDaysIcon:Od,CalendarFold:eU,CalendarFoldIcon:eU,CalendarHeart:tU,CalendarHeartIcon:tU,CalendarIcon:hn,CalendarMinus:rU,CalendarMinus2:sU,CalendarMinus2Icon:sU,CalendarMinusIcon:rU,CalendarOff:tL,CalendarOffIcon:tL,CalendarPlus:R_,CalendarPlus2:nU,CalendarPlus2Icon:nU,CalendarPlusIcon:R_,CalendarRange:aU,CalendarRangeIcon:aU,CalendarSearch:iU,CalendarSearchIcon:iU,CalendarSync:oU,CalendarSyncIcon:oU,CalendarX:cU,CalendarX2:lU,CalendarX2Icon:lU,CalendarXIcon:cU,Camera:Sx,CameraIcon:Sx,CameraOff:dU,CameraOffIcon:dU,CandlestickChart:hj,CandlestickChartIcon:hj,Candy:mU,CandyCane:uU,CandyCaneIcon:uU,CandyIcon:mU,CandyOff:hU,CandyOffIcon:hU,Cannabis:pU,CannabisIcon:pU,Captions:lj,CaptionsIcon:lj,CaptionsOff:fU,CaptionsOffIcon:fU,Car:CM,CarFront:xU,CarFrontIcon:xU,CarIcon:CM,CarTaxiFront:gU,CarTaxiFrontIcon:gU,Caravan:yU,CaravanIcon:yU,Carrot:vU,CarrotIcon:vU,CaseLower:bU,CaseLowerIcon:bU,CaseSensitive:_U,CaseSensitiveIcon:_U,CaseUpper:wU,CaseUpperIcon:wU,CassetteTape:jU,CassetteTapeIcon:jU,Cast:NU,CastIcon:NU,Castle:kU,CastleIcon:kU,Cat:SU,CatIcon:SU,Cctv:CU,CctvIcon:CU,ChartArea:cj,ChartAreaIcon:cj,ChartBar:uj,ChartBarBig:dj,ChartBarBigIcon:dj,ChartBarDecreasing:MU,ChartBarDecreasingIcon:MU,ChartBarIcon:uj,ChartBarIncreasing:TU,ChartBarIncreasingIcon:TU,ChartBarStacked:AU,ChartBarStackedIcon:AU,ChartCandlestick:hj,ChartCandlestickIcon:hj,ChartColumn:No,ChartColumnBig:mj,ChartColumnBigIcon:mj,ChartColumnDecreasing:EU,ChartColumnDecreasingIcon:EU,ChartColumnIcon:No,ChartColumnIncreasing:pj,ChartColumnIncreasingIcon:pj,ChartColumnStacked:PU,ChartColumnStackedIcon:PU,ChartGantt:IU,ChartGanttIcon:IU,ChartLine:fj,ChartLineIcon:fj,ChartNetwork:LU,ChartNetworkIcon:LU,ChartNoAxesColumn:gj,ChartNoAxesColumnDecreasing:DU,ChartNoAxesColumnDecreasingIcon:DU,ChartNoAxesColumnIcon:gj,ChartNoAxesColumnIncreasing:xj,ChartNoAxesColumnIncreasingIcon:xj,ChartNoAxesCombined:OU,ChartNoAxesCombinedIcon:OU,ChartNoAxesGantt:yj,ChartNoAxesGanttIcon:yj,ChartPie:vj,ChartPieIcon:vj,ChartScatter:bj,ChartScatterIcon:bj,ChartSpline:RU,ChartSplineIcon:RU,Check:va,CheckCheck:sL,CheckCheckIcon:sL,CheckCircle:xi,CheckCircle2:sa,CheckCircle2Icon:sa,CheckCircleIcon:xi,CheckIcon:va,CheckSquare:$v,CheckSquare2:ak,CheckSquare2Icon:ak,CheckSquareIcon:$v,ChefHat:FU,ChefHatIcon:FU,Cherry:zU,CherryIcon:zU,ChevronDown:Eo,ChevronDownCircle:Tj,ChevronDownCircleIcon:Tj,ChevronDownIcon:Eo,ChevronDownSquare:ik,ChevronDownSquareIcon:ik,ChevronFirst:BU,ChevronFirstIcon:BU,ChevronLast:$U,ChevronLastIcon:$U,ChevronLeft:cl,ChevronLeftCircle:Aj,ChevronLeftCircleIcon:Aj,ChevronLeftIcon:cl,ChevronLeftSquare:ok,ChevronLeftSquareIcon:ok,ChevronRight:da,ChevronRightCircle:Ej,ChevronRightCircleIcon:Ej,ChevronRightIcon:da,ChevronRightSquare:lk,ChevronRightSquareIcon:lk,ChevronUp:ff,ChevronUpCircle:Pj,ChevronUpCircleIcon:Pj,ChevronUpIcon:ff,ChevronUpSquare:ck,ChevronUpSquareIcon:ck,ChevronsDown:UU,ChevronsDownIcon:UU,ChevronsDownUp:qU,ChevronsDownUpIcon:qU,ChevronsLeft:WU,ChevronsLeftIcon:WU,ChevronsLeftRight:HU,ChevronsLeftRightEllipsis:VU,ChevronsLeftRightEllipsisIcon:VU,ChevronsLeftRightIcon:HU,ChevronsRight:KU,ChevronsRightIcon:KU,ChevronsRightLeft:GU,ChevronsRightLeftIcon:GU,ChevronsUp:ZU,ChevronsUpDown:Cx,ChevronsUpDownIcon:Cx,ChevronsUpIcon:ZU,Chrome:YU,ChromeIcon:YU,Church:XU,ChurchIcon:XU,Cigarette:JU,CigaretteIcon:JU,CigaretteOff:QU,CigaretteOffIcon:QU,Circle:_d,CircleAlert:kl,CircleAlertIcon:kl,CircleArrowDown:_j,CircleArrowDownIcon:_j,CircleArrowLeft:wj,CircleArrowLeftIcon:wj,CircleArrowOutDownLeft:jj,CircleArrowOutDownLeftIcon:jj,CircleArrowOutDownRight:Nj,CircleArrowOutDownRightIcon:Nj,CircleArrowOutUpLeft:kj,CircleArrowOutUpLeftIcon:kj,CircleArrowOutUpRight:Sj,CircleArrowOutUpRightIcon:Sj,CircleArrowRight:Cj,CircleArrowRightIcon:Cj,CircleArrowUp:Mj,CircleArrowUpIcon:Mj,CircleCheck:sa,CircleCheckBig:xi,CircleCheckBigIcon:xi,CircleCheckIcon:sa,CircleChevronDown:Tj,CircleChevronDownIcon:Tj,CircleChevronLeft:Aj,CircleChevronLeftIcon:Aj,CircleChevronRight:Ej,CircleChevronRightIcon:Ej,CircleChevronUp:Pj,CircleChevronUpIcon:Pj,CircleDashed:eV,CircleDashedIcon:eV,CircleDivide:Ij,CircleDivideIcon:Ij,CircleDollarSign:tV,CircleDollarSignIcon:tV,CircleDot:rV,CircleDotDashed:sV,CircleDotDashedIcon:sV,CircleDotIcon:rV,CircleEllipsis:nV,CircleEllipsisIcon:nV,CircleEqual:aV,CircleEqualIcon:aV,CircleFadingArrowUp:iV,CircleFadingArrowUpIcon:iV,CircleFadingPlus:oV,CircleFadingPlusIcon:oV,CircleGauge:Lj,CircleGaugeIcon:Lj,CircleHelp:Rv,CircleHelpIcon:Rv,CircleIcon:_d,CircleMinus:Dj,CircleMinusIcon:Dj,CircleOff:lV,CircleOffIcon:lV,CircleParking:Rj,CircleParkingIcon:Rj,CircleParkingOff:Oj,CircleParkingOffIcon:Oj,CirclePause:Fj,CirclePauseIcon:Fj,CirclePercent:zj,CirclePercentIcon:zj,CirclePlay:pp,CirclePlayIcon:pp,CirclePlus:Bj,CirclePlusIcon:Bj,CirclePower:$j,CirclePowerIcon:$j,CircleSlash:cV,CircleSlash2:qj,CircleSlash2Icon:qj,CircleSlashIcon:cV,CircleSlashed:qj,CircleSlashedIcon:qj,CircleStop:Uj,CircleStopIcon:Uj,CircleUser:Hj,CircleUserIcon:Hj,CircleUserRound:Vj,CircleUserRoundIcon:Vj,CircleX:vc,CircleXIcon:vc,CircuitBoard:dV,CircuitBoardIcon:dV,Citrus:uV,CitrusIcon:uV,Clapperboard:hV,ClapperboardIcon:hV,Clipboard:vV,ClipboardCheck:MM,ClipboardCheckIcon:MM,ClipboardCopy:mV,ClipboardCopyIcon:mV,ClipboardEdit:Gj,ClipboardEditIcon:Gj,ClipboardIcon:vV,ClipboardList:F_,ClipboardListIcon:F_,ClipboardMinus:pV,ClipboardMinusIcon:pV,ClipboardPaste:fV,ClipboardPasteIcon:fV,ClipboardPen:Gj,ClipboardPenIcon:Gj,ClipboardPenLine:Wj,ClipboardPenLineIcon:Wj,ClipboardPlus:xV,ClipboardPlusIcon:xV,ClipboardSignature:Wj,ClipboardSignatureIcon:Wj,ClipboardType:gV,ClipboardTypeIcon:gV,ClipboardX:yV,ClipboardXIcon:yV,Clock:un,Clock1:bV,Clock10:_V,Clock10Icon:_V,Clock11:wV,Clock11Icon:wV,Clock12:jV,Clock12Icon:jV,Clock1Icon:bV,Clock2:NV,Clock2Icon:NV,Clock3:kV,Clock3Icon:kV,Clock4:SV,Clock4Icon:SV,Clock5:CV,Clock5Icon:CV,Clock6:MV,Clock6Icon:MV,Clock7:TV,Clock7Icon:TV,Clock8:AV,Clock8Icon:AV,Clock9:EV,Clock9Icon:EV,ClockAlert:PV,ClockAlertIcon:PV,ClockArrowDown:IV,ClockArrowDownIcon:IV,ClockArrowUp:LV,ClockArrowUpIcon:LV,ClockIcon:un,Cloud:ZV,CloudAlert:DV,CloudAlertIcon:DV,CloudCog:OV,CloudCogIcon:OV,CloudDownload:Kj,CloudDownloadIcon:Kj,CloudDrizzle:RV,CloudDrizzleIcon:RV,CloudFog:FV,CloudFogIcon:FV,CloudHail:zV,CloudHailIcon:zV,CloudIcon:ZV,CloudLightning:BV,CloudLightningIcon:BV,CloudMoon:qV,CloudMoonIcon:qV,CloudMoonRain:$V,CloudMoonRainIcon:$V,CloudOff:UV,CloudOffIcon:UV,CloudRain:HV,CloudRainIcon:HV,CloudRainWind:VV,CloudRainWindIcon:VV,CloudSnow:WV,CloudSnowIcon:WV,CloudSun:KV,CloudSunIcon:KV,CloudSunRain:GV,CloudSunRainIcon:GV,CloudUpload:Zj,CloudUploadIcon:Zj,Cloudy:YV,CloudyIcon:YV,Clover:Yv,CloverIcon:Yv,Club:XV,ClubIcon:XV,Code:Q4,Code2:Yj,Code2Icon:Yj,CodeIcon:Q4,CodeSquare:dk,CodeSquareIcon:dk,CodeXml:Yj,CodeXmlIcon:Yj,Codepen:QV,CodepenIcon:QV,Codesandbox:JV,CodesandboxIcon:JV,Coffee:J4,CoffeeIcon:J4,Cog:eH,CogIcon:eH,Coins:rL,CoinsIcon:rL,Columns:Xj,Columns2:Xj,Columns2Icon:Xj,Columns3:Qj,Columns3Icon:Qj,Columns4:tH,Columns4Icon:tH,ColumnsIcon:Xj,Combine:sH,CombineIcon:sH,Command:rH,CommandIcon:rH,Compass:nH,CompassIcon:nH,Component:aH,ComponentIcon:aH,Computer:iH,ComputerIcon:iH,ConciergeBell:oH,ConciergeBellIcon:oH,Cone:lH,ConeIcon:lH,Construction:cH,ConstructionIcon:cH,Contact:eS,Contact2:Jj,Contact2Icon:Jj,ContactIcon:eS,ContactRound:Jj,ContactRoundIcon:Jj,Container:dH,ContainerIcon:dH,Contrast:uH,ContrastIcon:uH,Cookie:hH,CookieIcon:hH,CookingPot:mH,CookingPotIcon:mH,Copy:gi,CopyCheck:pH,CopyCheckIcon:pH,CopyIcon:gi,CopyMinus:fH,CopyMinusIcon:fH,CopyPlus:xH,CopyPlusIcon:xH,CopySlash:gH,CopySlashIcon:gH,CopyX:yH,CopyXIcon:yH,Copyleft:vH,CopyleftIcon:vH,Copyright:bH,CopyrightIcon:bH,CornerDownLeft:_H,CornerDownLeftIcon:_H,CornerDownRight:wH,CornerDownRightIcon:wH,CornerLeftDown:jH,CornerLeftDownIcon:jH,CornerLeftUp:NH,CornerLeftUpIcon:NH,CornerRightDown:kH,CornerRightDownIcon:kH,CornerRightUp:SH,CornerRightUpIcon:SH,CornerUpLeft:CH,CornerUpLeftIcon:CH,CornerUpRight:MH,CornerUpRightIcon:MH,Cpu:TH,CpuIcon:TH,CreativeCommons:AH,CreativeCommonsIcon:AH,CreditCard:Mx,CreditCardIcon:Mx,Croissant:EH,CroissantIcon:EH,Crop:PH,CropIcon:PH,Cross:IH,CrossIcon:IH,Crosshair:LH,CrosshairIcon:LH,Crown:Dm,CrownIcon:Dm,Cuboid:DH,CuboidIcon:DH,CupSoda:OH,CupSodaIcon:OH,CurlyBraces:oj,CurlyBracesIcon:oj,Currency:RH,CurrencyIcon:RH,Cylinder:FH,CylinderIcon:FH,Dam:zH,DamIcon:zH,Database:nL,DatabaseBackup:BH,DatabaseBackupIcon:BH,DatabaseIcon:nL,DatabaseZap:$H,DatabaseZapIcon:$H,Delete:qH,DeleteIcon:qH,Dessert:UH,DessertIcon:UH,Diameter:VH,DiameterIcon:VH,Diamond:GH,DiamondIcon:GH,DiamondMinus:HH,DiamondMinusIcon:HH,DiamondPercent:eN,DiamondPercentIcon:eN,DiamondPlus:WH,DiamondPlusIcon:WH,Dice1:KH,Dice1Icon:KH,Dice2:ZH,Dice2Icon:ZH,Dice3:YH,Dice3Icon:YH,Dice4:XH,Dice4Icon:XH,Dice5:QH,Dice5Icon:QH,Dice6:JH,Dice6Icon:JH,Dices:eW,DicesIcon:eW,Diff:tW,DiffIcon:tW,Disc:aW,Disc2:sW,Disc2Icon:sW,Disc3:rW,Disc3Icon:rW,DiscAlbum:nW,DiscAlbumIcon:nW,DiscIcon:aW,Divide:iW,DivideCircle:Ij,DivideCircleIcon:Ij,DivideIcon:iW,DivideSquare:pk,DivideSquareIcon:pk,Dna:lW,DnaIcon:lW,DnaOff:oW,DnaOffIcon:oW,Dock:cW,DockIcon:cW,Dog:dW,DogIcon:dW,DollarSign:ac,DollarSignIcon:ac,Donut:uW,DonutIcon:uW,DoorClosed:hW,DoorClosedIcon:hW,DoorOpen:n1,DoorOpenIcon:n1,Dot:mW,DotIcon:mW,DotSquare:fk,DotSquareIcon:fk,Download:yi,DownloadCloud:Kj,DownloadCloudIcon:Kj,DownloadIcon:yi,DraftingCompass:pW,DraftingCompassIcon:pW,Drama:fW,DramaIcon:fW,Dribbble:xW,DribbbleIcon:xW,Drill:gW,DrillIcon:gW,Droplet:yW,DropletIcon:yW,Droplets:Xg,DropletsIcon:Xg,Drum:vW,DrumIcon:vW,Drumstick:bW,DrumstickIcon:bW,Dumbbell:_W,DumbbellIcon:_W,Ear:jW,EarIcon:jW,EarOff:wW,EarOffIcon:wW,Earth:tN,EarthIcon:tN,EarthLock:NW,EarthLockIcon:NW,Eclipse:kW,EclipseIcon:kW,Edit:hd,Edit2:e0,Edit2Icon:e0,Edit3:Bv,Edit3Icon:Bv,EditIcon:hd,Egg:TM,EggFried:SW,EggFriedIcon:SW,EggIcon:TM,EggOff:CW,EggOffIcon:CW,Ellipsis:fx,EllipsisIcon:fx,EllipsisVertical:px,EllipsisVerticalIcon:px,Equal:AW,EqualApproximately:MW,EqualApproximatelyIcon:MW,EqualIcon:AW,EqualNot:TW,EqualNotIcon:TW,EqualSquare:xk,EqualSquareIcon:xk,Eraser:EW,EraserIcon:EW,EthernetPort:PW,EthernetPortIcon:PW,Euro:IW,EuroIcon:IW,Expand:aL,ExpandIcon:aL,ExternalLink:tn,ExternalLinkIcon:tn,Eye:Ln,EyeClosed:LW,EyeClosedIcon:LW,EyeIcon:Ln,EyeOff:kp,EyeOffIcon:kp,Facebook:Su,FacebookIcon:Su,Factory:DW,FactoryIcon:DW,Fan:OW,FanIcon:OW,FastForward:RW,FastForwardIcon:RW,Feather:FW,FeatherIcon:FW,Fence:zW,FenceIcon:zW,FerrisWheel:BW,FerrisWheelIcon:BW,Figma:$W,FigmaIcon:$W,File:AM,FileArchive:qW,FileArchiveIcon:qW,FileAudio:VW,FileAudio2:UW,FileAudio2Icon:UW,FileAudioIcon:VW,FileAxis3D:sN,FileAxis3DIcon:sN,FileAxis3d:sN,FileAxis3dIcon:sN,FileBadge:WW,FileBadge2:HW,FileBadge2Icon:HW,FileBadgeIcon:WW,FileBarChart:rN,FileBarChart2:nN,FileBarChart2Icon:nN,FileBarChartIcon:rN,FileBox:GW,FileBoxIcon:GW,FileChartColumn:nN,FileChartColumnIcon:nN,FileChartColumnIncreasing:rN,FileChartColumnIncreasingIcon:rN,FileChartLine:aN,FileChartLineIcon:aN,FileChartPie:iN,FileChartPieIcon:iN,FileCheck:ZW,FileCheck2:KW,FileCheck2Icon:KW,FileCheckIcon:ZW,FileClock:YW,FileClockIcon:YW,FileCode:QW,FileCode2:XW,FileCode2Icon:XW,FileCodeIcon:QW,FileCog:oN,FileCog2:oN,FileCog2Icon:oN,FileCogIcon:oN,FileDiff:JW,FileDiffIcon:JW,FileDigit:eG,FileDigitIcon:eG,FileDown:tG,FileDownIcon:tG,FileEdit:cN,FileEditIcon:cN,FileHeart:sG,FileHeartIcon:sG,FileIcon:AM,FileImage:z_,FileImageIcon:z_,FileInput:rG,FileInputIcon:rG,FileJson:aG,FileJson2:nG,FileJson2Icon:nG,FileJsonIcon:aG,FileKey:oG,FileKey2:iG,FileKey2Icon:iG,FileKeyIcon:oG,FileLineChart:aN,FileLineChartIcon:aN,FileLock:cG,FileLock2:lG,FileLock2Icon:lG,FileLockIcon:cG,FileMinus:uG,FileMinus2:dG,FileMinus2Icon:dG,FileMinusIcon:uG,FileMusic:hG,FileMusicIcon:hG,FileOutput:mG,FileOutputIcon:mG,FilePen:cN,FilePenIcon:cN,FilePenLine:lN,FilePenLineIcon:lN,FilePieChart:iN,FilePieChartIcon:iN,FilePlus:fG,FilePlus2:pG,FilePlus2Icon:pG,FilePlusIcon:fG,FileQuestion:xG,FileQuestionIcon:xG,FileScan:gG,FileScanIcon:gG,FileSearch:vG,FileSearch2:yG,FileSearch2Icon:yG,FileSearchIcon:vG,FileSignature:lN,FileSignatureIcon:lN,FileSliders:bG,FileSlidersIcon:bG,FileSpreadsheet:a1,FileSpreadsheetIcon:a1,FileStack:iL,FileStackIcon:iL,FileSymlink:_G,FileSymlinkIcon:_G,FileTerminal:wG,FileTerminalIcon:wG,FileText:Sn,FileTextIcon:Sn,FileType:NG,FileType2:jG,FileType2Icon:jG,FileTypeIcon:NG,FileUp:kG,FileUpIcon:kG,FileUser:SG,FileUserIcon:SG,FileVideo:MG,FileVideo2:CG,FileVideo2Icon:CG,FileVideoIcon:MG,FileVolume:AG,FileVolume2:TG,FileVolume2Icon:TG,FileVolumeIcon:AG,FileWarning:EG,FileWarningIcon:EG,FileX:IG,FileX2:PG,FileX2Icon:PG,FileXIcon:IG,Files:LG,FilesIcon:LG,Film:gu,FilmIcon:gu,Filter:Qg,FilterIcon:Qg,FilterX:DG,FilterXIcon:DG,Fingerprint:OG,FingerprintIcon:OG,FireExtinguisher:RG,FireExtinguisherIcon:RG,Fish:BG,FishIcon:BG,FishOff:FG,FishOffIcon:FG,FishSymbol:zG,FishSymbolIcon:zG,Flag:i1,FlagIcon:i1,FlagOff:$G,FlagOffIcon:$G,FlagTriangleLeft:qG,FlagTriangleLeftIcon:qG,FlagTriangleRight:UG,FlagTriangleRightIcon:UG,Flame:eh,FlameIcon:eh,FlameKindling:VG,FlameKindlingIcon:VG,Flashlight:WG,FlashlightIcon:WG,FlashlightOff:HG,FlashlightOffIcon:HG,FlaskConical:B_,FlaskConicalIcon:B_,FlaskConicalOff:GG,FlaskConicalOffIcon:GG,FlaskRound:KG,FlaskRoundIcon:KG,FlipHorizontal:oL,FlipHorizontal2:ZG,FlipHorizontal2Icon:ZG,FlipHorizontalIcon:oL,FlipVertical:XG,FlipVertical2:YG,FlipVertical2Icon:YG,FlipVerticalIcon:XG,Flower:QG,Flower2:Wg,Flower2Icon:Wg,FlowerIcon:QG,Focus:JG,FocusIcon:JG,FoldHorizontal:eK,FoldHorizontalIcon:eK,FoldVertical:tK,FoldVerticalIcon:tK,Folder:MK,FolderArchive:sK,FolderArchiveIcon:sK,FolderCheck:rK,FolderCheckIcon:rK,FolderClock:nK,FolderClockIcon:nK,FolderClosed:aK,FolderClosedIcon:aK,FolderCode:iK,FolderCodeIcon:iK,FolderCog:dN,FolderCog2:dN,FolderCog2Icon:dN,FolderCogIcon:dN,FolderDot:oK,FolderDotIcon:oK,FolderDown:lK,FolderDownIcon:lK,FolderEdit:uN,FolderEditIcon:uN,FolderGit:dK,FolderGit2:cK,FolderGit2Icon:cK,FolderGitIcon:dK,FolderHeart:uK,FolderHeartIcon:uK,FolderIcon:MK,FolderInput:hK,FolderInputIcon:hK,FolderKanban:mK,FolderKanbanIcon:mK,FolderKey:pK,FolderKeyIcon:pK,FolderLock:fK,FolderLockIcon:fK,FolderMinus:xK,FolderMinusIcon:xK,FolderOpen:Om,FolderOpenDot:gK,FolderOpenDotIcon:gK,FolderOpenIcon:Om,FolderOutput:yK,FolderOutputIcon:yK,FolderPen:uN,FolderPenIcon:uN,FolderPlus:vK,FolderPlusIcon:vK,FolderRoot:bK,FolderRootIcon:bK,FolderSearch:wK,FolderSearch2:_K,FolderSearch2Icon:_K,FolderSearchIcon:wK,FolderSymlink:jK,FolderSymlinkIcon:jK,FolderSync:NK,FolderSyncIcon:NK,FolderTree:kK,FolderTreeIcon:kK,FolderUp:SK,FolderUpIcon:SK,FolderX:CK,FolderXIcon:CK,Folders:TK,FoldersIcon:TK,Footprints:AK,FootprintsIcon:AK,ForkKnife:t4,ForkKnifeCrossed:e4,ForkKnifeCrossedIcon:e4,ForkKnifeIcon:t4,Forklift:EK,ForkliftIcon:EK,FormInput:ON,FormInputIcon:ON,Forward:PK,ForwardIcon:PK,Frame:IK,FrameIcon:IK,Framer:LK,FramerIcon:LK,Frown:DK,FrownIcon:DK,Fuel:OK,FuelIcon:OK,Fullscreen:RK,FullscreenIcon:RK,FunctionSquare:gk,FunctionSquareIcon:gk,GalleryHorizontal:zK,GalleryHorizontalEnd:FK,GalleryHorizontalEndIcon:FK,GalleryHorizontalIcon:zK,GalleryThumbnails:BK,GalleryThumbnailsIcon:BK,GalleryVertical:qK,GalleryVerticalEnd:$K,GalleryVerticalEndIcon:$K,GalleryVerticalIcon:qK,Gamepad:VK,Gamepad2:UK,Gamepad2Icon:UK,GamepadIcon:VK,GanttChart:yj,GanttChartIcon:yj,GanttChartSquare:Vy,GanttChartSquareIcon:Vy,Gauge:HK,GaugeCircle:Lj,GaugeCircleIcon:Lj,GaugeIcon:HK,Gavel:WK,GavelIcon:WK,Gem:GK,GemIcon:GK,Ghost:tS,GhostIcon:tS,Gift:ko,GiftIcon:ko,GitBranch:ZK,GitBranchIcon:ZK,GitBranchPlus:KK,GitBranchPlusIcon:KK,GitCommit:hN,GitCommitHorizontal:hN,GitCommitHorizontalIcon:hN,GitCommitIcon:hN,GitCommitVertical:YK,GitCommitVerticalIcon:YK,GitCompare:QK,GitCompareArrows:XK,GitCompareArrowsIcon:XK,GitCompareIcon:QK,GitFork:JK,GitForkIcon:JK,GitGraph:eZ,GitGraphIcon:eZ,GitMerge:tZ,GitMergeIcon:tZ,GitPullRequest:oZ,GitPullRequestArrow:sZ,GitPullRequestArrowIcon:sZ,GitPullRequestClosed:rZ,GitPullRequestClosedIcon:rZ,GitPullRequestCreate:aZ,GitPullRequestCreateArrow:nZ,GitPullRequestCreateArrowIcon:nZ,GitPullRequestCreateIcon:aZ,GitPullRequestDraft:iZ,GitPullRequestDraftIcon:iZ,GitPullRequestIcon:oZ,Github:lZ,GithubIcon:lZ,Gitlab:cZ,GitlabIcon:cZ,GlassWater:dZ,GlassWaterIcon:dZ,Glasses:uZ,GlassesIcon:uZ,Globe:su,Globe2:tN,Globe2Icon:tN,GlobeIcon:su,GlobeLock:hZ,GlobeLockIcon:hZ,Goal:mZ,GoalIcon:mZ,Grab:pZ,GrabIcon:pZ,GraduationCap:Kh,GraduationCapIcon:Kh,Grape:fZ,GrapeIcon:fZ,Grid:ax,Grid2X2:pN,Grid2X2Icon:pN,Grid2X2Plus:mN,Grid2X2PlusIcon:mN,Grid2x2:pN,Grid2x2Check:xZ,Grid2x2CheckIcon:xZ,Grid2x2Icon:pN,Grid2x2Plus:mN,Grid2x2PlusIcon:mN,Grid2x2X:gZ,Grid2x2XIcon:gZ,Grid3X3:ax,Grid3X3Icon:ax,Grid3x3:ax,Grid3x3Icon:ax,GridIcon:ax,Grip:vZ,GripHorizontal:yZ,GripHorizontalIcon:yZ,GripIcon:vZ,GripVertical:Cu,GripVerticalIcon:Cu,Group:bZ,GroupIcon:bZ,Guitar:_Z,GuitarIcon:_Z,Ham:wZ,HamIcon:wZ,Hammer:jZ,HammerIcon:jZ,Hand:lL,HandCoins:NZ,HandCoinsIcon:NZ,HandHeart:kZ,HandHeartIcon:kZ,HandHelping:fN,HandHelpingIcon:fN,HandIcon:lL,HandMetal:SZ,HandMetalIcon:SZ,HandPlatter:CZ,HandPlatterIcon:CZ,Handshake:cL,HandshakeIcon:cL,HardDrive:dL,HardDriveDownload:MZ,HardDriveDownloadIcon:MZ,HardDriveIcon:dL,HardDriveUpload:TZ,HardDriveUploadIcon:TZ,HardHat:AZ,HardHatIcon:AZ,Hash:$_,HashIcon:$_,Haze:EZ,HazeIcon:EZ,HdmiPort:PZ,HdmiPortIcon:PZ,Heading:OZ,Heading1:EM,Heading1Icon:EM,Heading2:PM,Heading2Icon:PM,Heading3:uL,Heading3Icon:uL,Heading4:IZ,Heading4Icon:IZ,Heading5:LZ,Heading5Icon:LZ,Heading6:DZ,Heading6Icon:DZ,HeadingIcon:OZ,HeadphoneOff:RZ,HeadphoneOffIcon:RZ,Headphones:FZ,HeadphonesIcon:FZ,Headset:zZ,HeadsetIcon:zZ,Heart:ni,HeartCrack:BZ,HeartCrackIcon:BZ,HeartHandshake:$Z,HeartHandshakeIcon:$Z,HeartIcon:ni,HeartOff:qZ,HeartOffIcon:qZ,HeartPulse:UZ,HeartPulseIcon:UZ,Heater:VZ,HeaterIcon:VZ,HelpCircle:Rv,HelpCircleIcon:Rv,HelpingHand:fN,HelpingHandIcon:fN,Hexagon:HZ,HexagonIcon:HZ,Highlighter:WZ,HighlighterIcon:WZ,History:IM,HistoryIcon:IM,Home:bn,HomeIcon:bn,Hop:KZ,HopIcon:KZ,HopOff:GZ,HopOffIcon:GZ,Hospital:ZZ,HospitalIcon:ZZ,Hotel:YZ,HotelIcon:YZ,Hourglass:XZ,HourglassIcon:XZ,House:bn,HouseIcon:bn,HousePlug:QZ,HousePlugIcon:QZ,HousePlus:JZ,HousePlusIcon:JZ,IceCream:gN,IceCream2:xN,IceCream2Icon:xN,IceCreamBowl:xN,IceCreamBowlIcon:xN,IceCreamCone:gN,IceCreamConeIcon:gN,IceCreamIcon:gN,Icon:iqe,IdCard:eY,IdCardIcon:eY,Image:gl,ImageDown:tY,ImageDownIcon:tY,ImageIcon:gl,ImageMinus:sY,ImageMinusIcon:sY,ImageOff:rY,ImageOffIcon:rY,ImagePlay:nY,ImagePlayIcon:nY,ImagePlus:o1,ImagePlusIcon:o1,ImageUp:aY,ImageUpIcon:aY,ImageUpscale:iY,ImageUpscaleIcon:iY,Images:oY,ImagesIcon:oY,Import:lY,ImportIcon:lY,Inbox:cY,InboxIcon:cY,Indent:vN,IndentDecrease:yN,IndentDecreaseIcon:yN,IndentIcon:vN,IndentIncrease:vN,IndentIncreaseIcon:vN,IndianRupee:dY,IndianRupeeIcon:dY,Infinity:uY,InfinityIcon:uY,Info:hL,InfoIcon:hL,Inspect:jk,InspectIcon:jk,InspectionPanel:hY,InspectionPanelIcon:hY,Instagram:Mu,InstagramIcon:Mu,Italic:sS,ItalicIcon:sS,IterationCcw:mY,IterationCcwIcon:mY,IterationCw:pY,IterationCwIcon:pY,JapaneseYen:fY,JapaneseYenIcon:fY,Joystick:xY,JoystickIcon:xY,Kanban:m0,KanbanIcon:m0,KanbanSquare:yk,KanbanSquareDashed:uk,KanbanSquareDashedIcon:uk,KanbanSquareIcon:yk,Key:Sp,KeyIcon:Sp,KeyRound:rS,KeyRoundIcon:rS,KeySquare:gY,KeySquareIcon:gY,Keyboard:bY,KeyboardIcon:bY,KeyboardMusic:yY,KeyboardMusicIcon:yY,KeyboardOff:vY,KeyboardOffIcon:vY,Lamp:SY,LampCeiling:_Y,LampCeilingIcon:_Y,LampDesk:wY,LampDeskIcon:wY,LampFloor:jY,LampFloorIcon:jY,LampIcon:SY,LampWallDown:NY,LampWallDownIcon:NY,LampWallUp:kY,LampWallUpIcon:kY,LandPlot:CY,LandPlotIcon:CY,Landmark:MY,LandmarkIcon:MY,Languages:TY,LanguagesIcon:TY,Laptop:EY,Laptop2:bN,Laptop2Icon:bN,LaptopIcon:EY,LaptopMinimal:bN,LaptopMinimalCheck:AY,LaptopMinimalCheckIcon:AY,LaptopMinimalIcon:bN,Lasso:IY,LassoIcon:IY,LassoSelect:PY,LassoSelectIcon:PY,Laugh:LY,LaughIcon:LY,Layers:LM,Layers2:DY,Layers2Icon:DY,Layers3:OY,Layers3Icon:OY,LayersIcon:LM,Layout:zv,LayoutDashboard:nS,LayoutDashboardIcon:nS,LayoutGrid:Cp,LayoutGridIcon:Cp,LayoutIcon:zv,LayoutList:RY,LayoutListIcon:RY,LayoutPanelLeft:FY,LayoutPanelLeftIcon:FY,LayoutPanelTop:zY,LayoutPanelTopIcon:zY,LayoutTemplate:aS,LayoutTemplateIcon:aS,Leaf:BY,LeafIcon:BY,LeafyGreen:$Y,LeafyGreenIcon:$Y,Lectern:qY,LecternIcon:qY,LetterText:UY,LetterTextIcon:UY,Library:DM,LibraryBig:VY,LibraryBigIcon:VY,LibraryIcon:DM,LibrarySquare:vk,LibrarySquareIcon:vk,LifeBuoy:OM,LifeBuoyIcon:OM,Ligature:HY,LigatureIcon:HY,Lightbulb:q_,LightbulbIcon:q_,LightbulbOff:WY,LightbulbOffIcon:WY,LineChart:fj,LineChartIcon:fj,Link:Bo,Link2:dl,Link2Icon:dl,Link2Off:GY,Link2OffIcon:GY,LinkIcon:Bo,Linkedin:Mp,LinkedinIcon:Mp,List:Mh,ListCheck:KY,ListCheckIcon:KY,ListChecks:ZY,ListChecksIcon:ZY,ListCollapse:YY,ListCollapseIcon:YY,ListEnd:XY,ListEndIcon:XY,ListFilter:QY,ListFilterIcon:QY,ListIcon:Mh,ListMinus:JY,ListMinusIcon:JY,ListMusic:eX,ListMusicIcon:eX,ListOrdered:p0,ListOrderedIcon:p0,ListPlus:tX,ListPlusIcon:tX,ListRestart:sX,ListRestartIcon:sX,ListStart:rX,ListStartIcon:rX,ListTodo:nX,ListTodoIcon:nX,ListTree:aX,ListTreeIcon:aX,ListVideo:iX,ListVideoIcon:iX,ListX:oX,ListXIcon:oX,Loader:cX,Loader2:ws,Loader2Icon:ws,LoaderCircle:ws,LoaderCircleIcon:ws,LoaderIcon:cX,LoaderPinwheel:lX,LoaderPinwheelIcon:lX,Locate:hX,LocateFixed:dX,LocateFixedIcon:dX,LocateIcon:hX,LocateOff:uX,LocateOffIcon:uX,Lock:Th,LockIcon:Th,LockKeyhole:mX,LockKeyholeIcon:mX,LockKeyholeOpen:_N,LockKeyholeOpenIcon:_N,LockOpen:wN,LockOpenIcon:wN,LogIn:iS,LogInIcon:iS,LogOut:oS,LogOutIcon:oS,Logs:pX,LogsIcon:pX,Lollipop:fX,LollipopIcon:fX,LucideAArrowDown:_9,LucideAArrowUp:w9,LucideALargeSmall:j9,LucideAccessibility:N9,LucideActivity:kh,LucideActivitySquare:VN,LucideAirVent:k9,LucideAirplay:S9,LucideAlarmCheck:G2,LucideAlarmClock:M9,LucideAlarmClockCheck:G2,LucideAlarmClockMinus:K2,LucideAlarmClockOff:C9,LucideAlarmClockPlus:Z2,LucideAlarmMinus:K2,LucideAlarmPlus:Z2,LucideAlarmSmoke:T9,LucideAlbum:A9,LucideAlertCircle:kl,LucideAlertOctagon:Fv,LucideAlertTriangle:Ku,LucideAlignCenter:W4,LucideAlignCenterHorizontal:E9,LucideAlignCenterVertical:P9,LucideAlignEndHorizontal:I9,LucideAlignEndVertical:L9,LucideAlignHorizontalDistributeCenter:D9,LucideAlignHorizontalDistributeEnd:O9,LucideAlignHorizontalDistributeStart:R9,LucideAlignHorizontalJustifyCenter:F9,LucideAlignHorizontalJustifyEnd:z9,LucideAlignHorizontalJustifyStart:B9,LucideAlignHorizontalSpaceAround:$9,LucideAlignHorizontalSpaceBetween:q9,LucideAlignJustify:U9,LucideAlignLeft:G4,LucideAlignRight:K4,LucideAlignStartHorizontal:V9,LucideAlignStartVertical:H9,LucideAlignVerticalDistributeCenter:W9,LucideAlignVerticalDistributeEnd:G9,LucideAlignVerticalDistributeStart:K9,LucideAlignVerticalJustifyCenter:Z9,LucideAlignVerticalJustifyEnd:Y9,LucideAlignVerticalJustifyStart:X9,LucideAlignVerticalSpaceAround:Q9,LucideAlignVerticalSpaceBetween:J9,LucideAmbulance:eB,LucideAmpersand:tB,LucideAmpersands:sB,LucideAmphora:rB,LucideAnchor:nB,LucideAngry:aB,LucideAnnoyed:iB,LucideAntenna:oB,LucideAnvil:lB,LucideAperture:cB,LucideAppWindow:HI,LucideAppWindowMac:dB,LucideApple:uB,LucideArchive:kM,LucideArchiveRestore:WI,LucideArchiveX:hB,LucideAreaChart:cj,LucideArmchair:mB,LucideArrowBigDown:fB,LucideArrowBigDownDash:pB,LucideArrowBigLeft:gB,LucideArrowBigLeftDash:xB,LucideArrowBigRight:vB,LucideArrowBigRightDash:yB,LucideArrowBigUp:_B,LucideArrowBigUpDash:bB,LucideArrowDown:Wh,LucideArrowDown01:wB,LucideArrowDown10:jB,LucideArrowDownAZ:Y2,LucideArrowDownAz:Y2,LucideArrowDownCircle:_j,LucideArrowDownFromLine:NB,LucideArrowDownLeft:kB,LucideArrowDownLeftFromCircle:jj,LucideArrowDownLeftFromSquare:ZN,LucideArrowDownLeftSquare:HN,LucideArrowDownNarrowWide:SB,LucideArrowDownRight:GI,LucideArrowDownRightFromCircle:Nj,LucideArrowDownRightFromSquare:YN,LucideArrowDownRightSquare:WN,LucideArrowDownSquare:GN,LucideArrowDownToDot:CB,LucideArrowDownToLine:MB,LucideArrowDownUp:TB,LucideArrowDownWideNarrow:X2,LucideArrowDownZA:Q2,LucideArrowDownZa:Q2,LucideArrowLeft:Ja,LucideArrowLeftCircle:wj,LucideArrowLeftFromLine:AB,LucideArrowLeftRight:EB,LucideArrowLeftSquare:KN,LucideArrowLeftToLine:PB,LucideArrowRight:Qa,LucideArrowRightCircle:Cj,LucideArrowRightFromLine:IB,LucideArrowRightLeft:s1,LucideArrowRightSquare:JN,LucideArrowRightToLine:LB,LucideArrowUp:ku,LucideArrowUp01:DB,LucideArrowUp10:OB,LucideArrowUpAZ:J2,LucideArrowUpAz:J2,LucideArrowUpCircle:Mj,LucideArrowUpDown:bd,LucideArrowUpFromDot:RB,LucideArrowUpFromLine:FB,LucideArrowUpLeft:zB,LucideArrowUpLeftFromCircle:kj,LucideArrowUpLeftFromSquare:XN,LucideArrowUpLeftSquare:ek,LucideArrowUpNarrowWide:ej,LucideArrowUpRight:KI,LucideArrowUpRightFromCircle:Sj,LucideArrowUpRightFromSquare:QN,LucideArrowUpRightSquare:tk,LucideArrowUpSquare:sk,LucideArrowUpToLine:BB,LucideArrowUpWideNarrow:$B,LucideArrowUpZA:tj,LucideArrowUpZa:tj,LucideArrowsUpFromLine:qB,LucideAsterisk:UB,LucideAsteriskSquare:rk,LucideAtSign:VB,LucideAtom:HB,LucideAudioLines:WB,LucideAudioWaveform:GB,LucideAward:Nc,LucideAxe:KB,LucideAxis3D:sj,LucideAxis3d:sj,LucideBaby:ZB,LucideBackpack:YB,LucideBadge:h$,LucideBadgeAlert:XB,LucideBadgeCent:QB,LucideBadgeCheck:rj,LucideBadgeDollarSign:JB,LucideBadgeEuro:e$,LucideBadgeHelp:t$,LucideBadgeIndianRupee:s$,LucideBadgeInfo:r$,LucideBadgeJapaneseYen:n$,LucideBadgeMinus:a$,LucideBadgePercent:i$,LucideBadgePlus:o$,LucideBadgePoundSterling:l$,LucideBadgeRussianRuble:c$,LucideBadgeSwissFranc:d$,LucideBadgeX:u$,LucideBaggageClaim:m$,LucideBan:ZI,LucideBanana:p$,LucideBandage:f$,LucideBanknote:x$,LucideBarChart:xj,LucideBarChart2:gj,LucideBarChart3:No,LucideBarChart4:pj,LucideBarChartBig:mj,LucideBarChartHorizontal:uj,LucideBarChartHorizontalBig:dj,LucideBarcode:g$,LucideBaseline:y$,LucideBath:Ju,LucideBattery:N$,LucideBatteryCharging:v$,LucideBatteryFull:b$,LucideBatteryLow:_$,LucideBatteryMedium:w$,LucideBatteryWarning:j$,LucideBeaker:k$,LucideBean:C$,LucideBeanOff:S$,LucideBed:Im,LucideBedDouble:Z4,LucideBedSingle:M$,LucideBeef:T$,LucideBeer:E$,LucideBeerOff:A$,LucideBell:Lm,LucideBellDot:P$,LucideBellElectric:I$,LucideBellMinus:L$,LucideBellOff:r1,LucideBellPlus:D$,LucideBellRing:O$,LucideBetweenHorizonalEnd:nj,LucideBetweenHorizonalStart:aj,LucideBetweenHorizontalEnd:nj,LucideBetweenHorizontalStart:aj,LucideBetweenVerticalEnd:R$,LucideBetweenVerticalStart:F$,LucideBicepsFlexed:z$,LucideBike:B$,LucideBinary:$$,LucideBinoculars:q$,LucideBiohazard:U$,LucideBird:V$,LucideBitcoin:H$,LucideBlend:W$,LucideBlinds:G$,LucideBlocks:K$,LucideBluetooth:Q$,LucideBluetoothConnected:Z$,LucideBluetoothOff:Y$,LucideBluetoothSearching:X$,LucideBold:Y4,LucideBolt:J$,LucideBomb:eq,LucideBone:tq,LucideBook:jq,LucideBookA:sq,LucideBookAudio:rq,LucideBookCheck:nq,LucideBookCopy:aq,LucideBookDashed:ij,LucideBookDown:iq,LucideBookHeadphones:oq,LucideBookHeart:lq,LucideBookImage:cq,LucideBookKey:dq,LucideBookLock:uq,LucideBookMarked:hq,LucideBookMinus:mq,LucideBookOpen:Sh,LucideBookOpenCheck:pq,LucideBookOpenText:fq,LucideBookPlus:xq,LucideBookTemplate:ij,LucideBookText:gq,LucideBookType:yq,LucideBookUp:bq,LucideBookUp2:vq,LucideBookUser:_q,LucideBookX:wq,LucideBookmark:kx,LucideBookmarkCheck:Nq,LucideBookmarkMinus:kq,LucideBookmarkPlus:YI,LucideBookmarkX:Sq,LucideBoomBox:Cq,LucideBot:SM,LucideBotMessageSquare:Mq,LucideBotOff:Tq,LucideBox:Aq,LucideBoxSelect:mk,LucideBoxes:Eq,LucideBraces:oj,LucideBrackets:Pq,LucideBrain:XI,LucideBrainCircuit:Iq,LucideBrainCog:Lq,LucideBrickWall:Dq,LucideBriefcase:Gh,LucideBriefcaseBusiness:Oq,LucideBriefcaseConveyorBelt:Rq,LucideBriefcaseMedical:Fq,LucideBringToFront:zq,LucideBrush:Bq,LucideBug:Uq,LucideBugOff:$q,LucideBugPlay:qq,LucideBuilding:X4,LucideBuilding2:ka,LucideBus:Hq,LucideBusFront:Vq,LucideCable:Gq,LucideCableCar:Wq,LucideCake:Ch,LucideCakeSlice:Kq,LucideCalculator:QI,LucideCalendar:hn,LucideCalendar1:Zq,LucideCalendarArrowDown:Yq,LucideCalendarArrowUp:Xq,LucideCalendarCheck:JI,LucideCalendarCheck2:Qq,LucideCalendarClock:eL,LucideCalendarCog:Jq,LucideCalendarDays:Od,LucideCalendarFold:eU,LucideCalendarHeart:tU,LucideCalendarMinus:rU,LucideCalendarMinus2:sU,LucideCalendarOff:tL,LucideCalendarPlus:R_,LucideCalendarPlus2:nU,LucideCalendarRange:aU,LucideCalendarSearch:iU,LucideCalendarSync:oU,LucideCalendarX:cU,LucideCalendarX2:lU,LucideCamera:Sx,LucideCameraOff:dU,LucideCandlestickChart:hj,LucideCandy:mU,LucideCandyCane:uU,LucideCandyOff:hU,LucideCannabis:pU,LucideCaptions:lj,LucideCaptionsOff:fU,LucideCar:CM,LucideCarFront:xU,LucideCarTaxiFront:gU,LucideCaravan:yU,LucideCarrot:vU,LucideCaseLower:bU,LucideCaseSensitive:_U,LucideCaseUpper:wU,LucideCassetteTape:jU,LucideCast:NU,LucideCastle:kU,LucideCat:SU,LucideCctv:CU,LucideChartArea:cj,LucideChartBar:uj,LucideChartBarBig:dj,LucideChartBarDecreasing:MU,LucideChartBarIncreasing:TU,LucideChartBarStacked:AU,LucideChartCandlestick:hj,LucideChartColumn:No,LucideChartColumnBig:mj,LucideChartColumnDecreasing:EU,LucideChartColumnIncreasing:pj,LucideChartColumnStacked:PU,LucideChartGantt:IU,LucideChartLine:fj,LucideChartNetwork:LU,LucideChartNoAxesColumn:gj,LucideChartNoAxesColumnDecreasing:DU,LucideChartNoAxesColumnIncreasing:xj,LucideChartNoAxesCombined:OU,LucideChartNoAxesGantt:yj,LucideChartPie:vj,LucideChartScatter:bj,LucideChartSpline:RU,LucideCheck:va,LucideCheckCheck:sL,LucideCheckCircle:xi,LucideCheckCircle2:sa,LucideCheckSquare:$v,LucideCheckSquare2:ak,LucideChefHat:FU,LucideCherry:zU,LucideChevronDown:Eo,LucideChevronDownCircle:Tj,LucideChevronDownSquare:ik,LucideChevronFirst:BU,LucideChevronLast:$U,LucideChevronLeft:cl,LucideChevronLeftCircle:Aj,LucideChevronLeftSquare:ok,LucideChevronRight:da,LucideChevronRightCircle:Ej,LucideChevronRightSquare:lk,LucideChevronUp:ff,LucideChevronUpCircle:Pj,LucideChevronUpSquare:ck,LucideChevronsDown:UU,LucideChevronsDownUp:qU,LucideChevronsLeft:WU,LucideChevronsLeftRight:HU,LucideChevronsLeftRightEllipsis:VU,LucideChevronsRight:KU,LucideChevronsRightLeft:GU,LucideChevronsUp:ZU,LucideChevronsUpDown:Cx,LucideChrome:YU,LucideChurch:XU,LucideCigarette:JU,LucideCigaretteOff:QU,LucideCircle:_d,LucideCircleAlert:kl,LucideCircleArrowDown:_j,LucideCircleArrowLeft:wj,LucideCircleArrowOutDownLeft:jj,LucideCircleArrowOutDownRight:Nj,LucideCircleArrowOutUpLeft:kj,LucideCircleArrowOutUpRight:Sj,LucideCircleArrowRight:Cj,LucideCircleArrowUp:Mj,LucideCircleCheck:sa,LucideCircleCheckBig:xi,LucideCircleChevronDown:Tj,LucideCircleChevronLeft:Aj,LucideCircleChevronRight:Ej,LucideCircleChevronUp:Pj,LucideCircleDashed:eV,LucideCircleDivide:Ij,LucideCircleDollarSign:tV,LucideCircleDot:rV,LucideCircleDotDashed:sV,LucideCircleEllipsis:nV,LucideCircleEqual:aV,LucideCircleFadingArrowUp:iV,LucideCircleFadingPlus:oV,LucideCircleGauge:Lj,LucideCircleHelp:Rv,LucideCircleMinus:Dj,LucideCircleOff:lV,LucideCircleParking:Rj,LucideCircleParkingOff:Oj,LucideCirclePause:Fj,LucideCirclePercent:zj,LucideCirclePlay:pp,LucideCirclePlus:Bj,LucideCirclePower:$j,LucideCircleSlash:cV,LucideCircleSlash2:qj,LucideCircleSlashed:qj,LucideCircleStop:Uj,LucideCircleUser:Hj,LucideCircleUserRound:Vj,LucideCircleX:vc,LucideCircuitBoard:dV,LucideCitrus:uV,LucideClapperboard:hV,LucideClipboard:vV,LucideClipboardCheck:MM,LucideClipboardCopy:mV,LucideClipboardEdit:Gj,LucideClipboardList:F_,LucideClipboardMinus:pV,LucideClipboardPaste:fV,LucideClipboardPen:Gj,LucideClipboardPenLine:Wj,LucideClipboardPlus:xV,LucideClipboardSignature:Wj,LucideClipboardType:gV,LucideClipboardX:yV,LucideClock:un,LucideClock1:bV,LucideClock10:_V,LucideClock11:wV,LucideClock12:jV,LucideClock2:NV,LucideClock3:kV,LucideClock4:SV,LucideClock5:CV,LucideClock6:MV,LucideClock7:TV,LucideClock8:AV,LucideClock9:EV,LucideClockAlert:PV,LucideClockArrowDown:IV,LucideClockArrowUp:LV,LucideCloud:ZV,LucideCloudAlert:DV,LucideCloudCog:OV,LucideCloudDownload:Kj,LucideCloudDrizzle:RV,LucideCloudFog:FV,LucideCloudHail:zV,LucideCloudLightning:BV,LucideCloudMoon:qV,LucideCloudMoonRain:$V,LucideCloudOff:UV,LucideCloudRain:HV,LucideCloudRainWind:VV,LucideCloudSnow:WV,LucideCloudSun:KV,LucideCloudSunRain:GV,LucideCloudUpload:Zj,LucideCloudy:YV,LucideClover:Yv,LucideClub:XV,LucideCode:Q4,LucideCode2:Yj,LucideCodeSquare:dk,LucideCodeXml:Yj,LucideCodepen:QV,LucideCodesandbox:JV,LucideCoffee:J4,LucideCog:eH,LucideCoins:rL,LucideColumns:Xj,LucideColumns2:Xj,LucideColumns3:Qj,LucideColumns4:tH,LucideCombine:sH,LucideCommand:rH,LucideCompass:nH,LucideComponent:aH,LucideComputer:iH,LucideConciergeBell:oH,LucideCone:lH,LucideConstruction:cH,LucideContact:eS,LucideContact2:Jj,LucideContactRound:Jj,LucideContainer:dH,LucideContrast:uH,LucideCookie:hH,LucideCookingPot:mH,LucideCopy:gi,LucideCopyCheck:pH,LucideCopyMinus:fH,LucideCopyPlus:xH,LucideCopySlash:gH,LucideCopyX:yH,LucideCopyleft:vH,LucideCopyright:bH,LucideCornerDownLeft:_H,LucideCornerDownRight:wH,LucideCornerLeftDown:jH,LucideCornerLeftUp:NH,LucideCornerRightDown:kH,LucideCornerRightUp:SH,LucideCornerUpLeft:CH,LucideCornerUpRight:MH,LucideCpu:TH,LucideCreativeCommons:AH,LucideCreditCard:Mx,LucideCroissant:EH,LucideCrop:PH,LucideCross:IH,LucideCrosshair:LH,LucideCrown:Dm,LucideCuboid:DH,LucideCupSoda:OH,LucideCurlyBraces:oj,LucideCurrency:RH,LucideCylinder:FH,LucideDam:zH,LucideDatabase:nL,LucideDatabaseBackup:BH,LucideDatabaseZap:$H,LucideDelete:qH,LucideDessert:UH,LucideDiameter:VH,LucideDiamond:GH,LucideDiamondMinus:HH,LucideDiamondPercent:eN,LucideDiamondPlus:WH,LucideDice1:KH,LucideDice2:ZH,LucideDice3:YH,LucideDice4:XH,LucideDice5:QH,LucideDice6:JH,LucideDices:eW,LucideDiff:tW,LucideDisc:aW,LucideDisc2:sW,LucideDisc3:rW,LucideDiscAlbum:nW,LucideDivide:iW,LucideDivideCircle:Ij,LucideDivideSquare:pk,LucideDna:lW,LucideDnaOff:oW,LucideDock:cW,LucideDog:dW,LucideDollarSign:ac,LucideDonut:uW,LucideDoorClosed:hW,LucideDoorOpen:n1,LucideDot:mW,LucideDotSquare:fk,LucideDownload:yi,LucideDownloadCloud:Kj,LucideDraftingCompass:pW,LucideDrama:fW,LucideDribbble:xW,LucideDrill:gW,LucideDroplet:yW,LucideDroplets:Xg,LucideDrum:vW,LucideDrumstick:bW,LucideDumbbell:_W,LucideEar:jW,LucideEarOff:wW,LucideEarth:tN,LucideEarthLock:NW,LucideEclipse:kW,LucideEdit:hd,LucideEdit2:e0,LucideEdit3:Bv,LucideEgg:TM,LucideEggFried:SW,LucideEggOff:CW,LucideEllipsis:fx,LucideEllipsisVertical:px,LucideEqual:AW,LucideEqualApproximately:MW,LucideEqualNot:TW,LucideEqualSquare:xk,LucideEraser:EW,LucideEthernetPort:PW,LucideEuro:IW,LucideExpand:aL,LucideExternalLink:tn,LucideEye:Ln,LucideEyeClosed:LW,LucideEyeOff:kp,LucideFacebook:Su,LucideFactory:DW,LucideFan:OW,LucideFastForward:RW,LucideFeather:FW,LucideFence:zW,LucideFerrisWheel:BW,LucideFigma:$W,LucideFile:AM,LucideFileArchive:qW,LucideFileAudio:VW,LucideFileAudio2:UW,LucideFileAxis3D:sN,LucideFileAxis3d:sN,LucideFileBadge:WW,LucideFileBadge2:HW,LucideFileBarChart:rN,LucideFileBarChart2:nN,LucideFileBox:GW,LucideFileChartColumn:nN,LucideFileChartColumnIncreasing:rN,LucideFileChartLine:aN,LucideFileChartPie:iN,LucideFileCheck:ZW,LucideFileCheck2:KW,LucideFileClock:YW,LucideFileCode:QW,LucideFileCode2:XW,LucideFileCog:oN,LucideFileCog2:oN,LucideFileDiff:JW,LucideFileDigit:eG,LucideFileDown:tG,LucideFileEdit:cN,LucideFileHeart:sG,LucideFileImage:z_,LucideFileInput:rG,LucideFileJson:aG,LucideFileJson2:nG,LucideFileKey:oG,LucideFileKey2:iG,LucideFileLineChart:aN,LucideFileLock:cG,LucideFileLock2:lG,LucideFileMinus:uG,LucideFileMinus2:dG,LucideFileMusic:hG,LucideFileOutput:mG,LucideFilePen:cN,LucideFilePenLine:lN,LucideFilePieChart:iN,LucideFilePlus:fG,LucideFilePlus2:pG,LucideFileQuestion:xG,LucideFileScan:gG,LucideFileSearch:vG,LucideFileSearch2:yG,LucideFileSignature:lN,LucideFileSliders:bG,LucideFileSpreadsheet:a1,LucideFileStack:iL,LucideFileSymlink:_G,LucideFileTerminal:wG,LucideFileText:Sn,LucideFileType:NG,LucideFileType2:jG,LucideFileUp:kG,LucideFileUser:SG,LucideFileVideo:MG,LucideFileVideo2:CG,LucideFileVolume:AG,LucideFileVolume2:TG,LucideFileWarning:EG,LucideFileX:IG,LucideFileX2:PG,LucideFiles:LG,LucideFilm:gu,LucideFilter:Qg,LucideFilterX:DG,LucideFingerprint:OG,LucideFireExtinguisher:RG,LucideFish:BG,LucideFishOff:FG,LucideFishSymbol:zG,LucideFlag:i1,LucideFlagOff:$G,LucideFlagTriangleLeft:qG,LucideFlagTriangleRight:UG,LucideFlame:eh,LucideFlameKindling:VG,LucideFlashlight:WG,LucideFlashlightOff:HG,LucideFlaskConical:B_,LucideFlaskConicalOff:GG,LucideFlaskRound:KG,LucideFlipHorizontal:oL,LucideFlipHorizontal2:ZG,LucideFlipVertical:XG,LucideFlipVertical2:YG,LucideFlower:QG,LucideFlower2:Wg,LucideFocus:JG,LucideFoldHorizontal:eK,LucideFoldVertical:tK,LucideFolder:MK,LucideFolderArchive:sK,LucideFolderCheck:rK,LucideFolderClock:nK,LucideFolderClosed:aK,LucideFolderCode:iK,LucideFolderCog:dN,LucideFolderCog2:dN,LucideFolderDot:oK,LucideFolderDown:lK,LucideFolderEdit:uN,LucideFolderGit:dK,LucideFolderGit2:cK,LucideFolderHeart:uK,LucideFolderInput:hK,LucideFolderKanban:mK,LucideFolderKey:pK,LucideFolderLock:fK,LucideFolderMinus:xK,LucideFolderOpen:Om,LucideFolderOpenDot:gK,LucideFolderOutput:yK,LucideFolderPen:uN,LucideFolderPlus:vK,LucideFolderRoot:bK,LucideFolderSearch:wK,LucideFolderSearch2:_K,LucideFolderSymlink:jK,LucideFolderSync:NK,LucideFolderTree:kK,LucideFolderUp:SK,LucideFolderX:CK,LucideFolders:TK,LucideFootprints:AK,LucideForkKnife:t4,LucideForkKnifeCrossed:e4,LucideForklift:EK,LucideFormInput:ON,LucideForward:PK,LucideFrame:IK,LucideFramer:LK,LucideFrown:DK,LucideFuel:OK,LucideFullscreen:RK,LucideFunctionSquare:gk,LucideGalleryHorizontal:zK,LucideGalleryHorizontalEnd:FK,LucideGalleryThumbnails:BK,LucideGalleryVertical:qK,LucideGalleryVerticalEnd:$K,LucideGamepad:VK,LucideGamepad2:UK,LucideGanttChart:yj,LucideGanttChartSquare:Vy,LucideGauge:HK,LucideGaugeCircle:Lj,LucideGavel:WK,LucideGem:GK,LucideGhost:tS,LucideGift:ko,LucideGitBranch:ZK,LucideGitBranchPlus:KK,LucideGitCommit:hN,LucideGitCommitHorizontal:hN,LucideGitCommitVertical:YK,LucideGitCompare:QK,LucideGitCompareArrows:XK,LucideGitFork:JK,LucideGitGraph:eZ,LucideGitMerge:tZ,LucideGitPullRequest:oZ,LucideGitPullRequestArrow:sZ,LucideGitPullRequestClosed:rZ,LucideGitPullRequestCreate:aZ,LucideGitPullRequestCreateArrow:nZ,LucideGitPullRequestDraft:iZ,LucideGithub:lZ,LucideGitlab:cZ,LucideGlassWater:dZ,LucideGlasses:uZ,LucideGlobe:su,LucideGlobe2:tN,LucideGlobeLock:hZ,LucideGoal:mZ,LucideGrab:pZ,LucideGraduationCap:Kh,LucideGrape:fZ,LucideGrid:ax,LucideGrid2X2:pN,LucideGrid2X2Plus:mN,LucideGrid2x2:pN,LucideGrid2x2Check:xZ,LucideGrid2x2Plus:mN,LucideGrid2x2X:gZ,LucideGrid3X3:ax,LucideGrid3x3:ax,LucideGrip:vZ,LucideGripHorizontal:yZ,LucideGripVertical:Cu,LucideGroup:bZ,LucideGuitar:_Z,LucideHam:wZ,LucideHammer:jZ,LucideHand:lL,LucideHandCoins:NZ,LucideHandHeart:kZ,LucideHandHelping:fN,LucideHandMetal:SZ,LucideHandPlatter:CZ,LucideHandshake:cL,LucideHardDrive:dL,LucideHardDriveDownload:MZ,LucideHardDriveUpload:TZ,LucideHardHat:AZ,LucideHash:$_,LucideHaze:EZ,LucideHdmiPort:PZ,LucideHeading:OZ,LucideHeading1:EM,LucideHeading2:PM,LucideHeading3:uL,LucideHeading4:IZ,LucideHeading5:LZ,LucideHeading6:DZ,LucideHeadphoneOff:RZ,LucideHeadphones:FZ,LucideHeadset:zZ,LucideHeart:ni,LucideHeartCrack:BZ,LucideHeartHandshake:$Z,LucideHeartOff:qZ,LucideHeartPulse:UZ,LucideHeater:VZ,LucideHelpCircle:Rv,LucideHelpingHand:fN,LucideHexagon:HZ,LucideHighlighter:WZ,LucideHistory:IM,LucideHome:bn,LucideHop:KZ,LucideHopOff:GZ,LucideHospital:ZZ,LucideHotel:YZ,LucideHourglass:XZ,LucideHouse:bn,LucideHousePlug:QZ,LucideHousePlus:JZ,LucideIceCream:gN,LucideIceCream2:xN,LucideIceCreamBowl:xN,LucideIceCreamCone:gN,LucideIdCard:eY,LucideImage:gl,LucideImageDown:tY,LucideImageMinus:sY,LucideImageOff:rY,LucideImagePlay:nY,LucideImagePlus:o1,LucideImageUp:aY,LucideImageUpscale:iY,LucideImages:oY,LucideImport:lY,LucideInbox:cY,LucideIndent:vN,LucideIndentDecrease:yN,LucideIndentIncrease:vN,LucideIndianRupee:dY,LucideInfinity:uY,LucideInfo:hL,LucideInspect:jk,LucideInspectionPanel:hY,LucideInstagram:Mu,LucideItalic:sS,LucideIterationCcw:mY,LucideIterationCw:pY,LucideJapaneseYen:fY,LucideJoystick:xY,LucideKanban:m0,LucideKanbanSquare:yk,LucideKanbanSquareDashed:uk,LucideKey:Sp,LucideKeyRound:rS,LucideKeySquare:gY,LucideKeyboard:bY,LucideKeyboardMusic:yY,LucideKeyboardOff:vY,LucideLamp:SY,LucideLampCeiling:_Y,LucideLampDesk:wY,LucideLampFloor:jY,LucideLampWallDown:NY,LucideLampWallUp:kY,LucideLandPlot:CY,LucideLandmark:MY,LucideLanguages:TY,LucideLaptop:EY,LucideLaptop2:bN,LucideLaptopMinimal:bN,LucideLaptopMinimalCheck:AY,LucideLasso:IY,LucideLassoSelect:PY,LucideLaugh:LY,LucideLayers:LM,LucideLayers2:DY,LucideLayers3:OY,LucideLayout:zv,LucideLayoutDashboard:nS,LucideLayoutGrid:Cp,LucideLayoutList:RY,LucideLayoutPanelLeft:FY,LucideLayoutPanelTop:zY,LucideLayoutTemplate:aS,LucideLeaf:BY,LucideLeafyGreen:$Y,LucideLectern:qY,LucideLetterText:UY,LucideLibrary:DM,LucideLibraryBig:VY,LucideLibrarySquare:vk,LucideLifeBuoy:OM,LucideLigature:HY,LucideLightbulb:q_,LucideLightbulbOff:WY,LucideLineChart:fj,LucideLink:Bo,LucideLink2:dl,LucideLink2Off:GY,LucideLinkedin:Mp,LucideList:Mh,LucideListCheck:KY,LucideListChecks:ZY,LucideListCollapse:YY,LucideListEnd:XY,LucideListFilter:QY,LucideListMinus:JY,LucideListMusic:eX,LucideListOrdered:p0,LucideListPlus:tX,LucideListRestart:sX,LucideListStart:rX,LucideListTodo:nX,LucideListTree:aX,LucideListVideo:iX,LucideListX:oX,LucideLoader:cX,LucideLoader2:ws,LucideLoaderCircle:ws,LucideLoaderPinwheel:lX,LucideLocate:hX,LucideLocateFixed:dX,LucideLocateOff:uX,LucideLock:Th,LucideLockKeyhole:mX,LucideLockKeyholeOpen:_N,LucideLockOpen:wN,LucideLogIn:iS,LucideLogOut:oS,LucideLogs:pX,LucideLollipop:fX,LucideLuggage:xX,LucideMSquare:bk,LucideMagnet:gX,LucideMail:cr,LucideMailCheck:yX,LucideMailMinus:vX,LucideMailOpen:bX,LucideMailPlus:mL,LucideMailQuestion:_X,LucideMailSearch:wX,LucideMailWarning:jX,LucideMailX:pL,LucideMailbox:NX,LucideMails:kX,LucideMap:l1,LucideMapPin:ma,LucideMapPinCheck:CX,LucideMapPinCheckInside:SX,LucideMapPinHouse:MX,LucideMapPinMinus:AX,LucideMapPinMinusInside:TX,LucideMapPinOff:EX,LucideMapPinPlus:IX,LucideMapPinPlusInside:PX,LucideMapPinX:DX,LucideMapPinXInside:LX,LucideMapPinned:OX,LucideMartini:RX,LucideMaximize:lS,LucideMaximize2:FX,LucideMedal:c1,LucideMegaphone:Ah,LucideMegaphoneOff:zX,LucideMeh:BX,LucideMemoryStick:$X,LucideMenu:RM,LucideMenuSquare:_k,LucideMerge:qX,LucideMessageCircle:$c,LucideMessageCircleCode:UX,LucideMessageCircleDashed:VX,LucideMessageCircleHeart:FM,LucideMessageCircleMore:HX,LucideMessageCircleOff:WX,LucideMessageCirclePlus:GX,LucideMessageCircleQuestion:fL,LucideMessageCircleReply:KX,LucideMessageCircleWarning:ZX,LucideMessageCircleX:YX,LucideMessageSquare:so,LucideMessageSquareCode:XX,LucideMessageSquareDashed:QX,LucideMessageSquareDiff:JX,LucideMessageSquareDot:eQ,LucideMessageSquareHeart:tQ,LucideMessageSquareLock:sQ,LucideMessageSquareMore:xL,LucideMessageSquareOff:rQ,LucideMessageSquarePlus:zM,LucideMessageSquareQuote:gL,LucideMessageSquareReply:nQ,LucideMessageSquareShare:aQ,LucideMessageSquareText:iQ,LucideMessageSquareWarning:oQ,LucideMessageSquareX:lQ,LucideMessagesSquare:cQ,LucideMic:yL,LucideMic2:jN,LucideMicOff:dQ,LucideMicVocal:jN,LucideMicrochip:uQ,LucideMicroscope:hQ,LucideMicrowave:mQ,LucideMilestone:pQ,LucideMilk:xQ,LucideMilkOff:fQ,LucideMinimize:yQ,LucideMinimize2:gQ,LucideMinus:f0,LucideMinusCircle:Dj,LucideMinusSquare:wk,LucideMonitor:dS,LucideMonitorCheck:vQ,LucideMonitorCog:bQ,LucideMonitorDot:_Q,LucideMonitorDown:wQ,LucideMonitorOff:jQ,LucideMonitorPause:NQ,LucideMonitorPlay:kQ,LucideMonitorSmartphone:SQ,LucideMonitorSpeaker:CQ,LucideMonitorStop:MQ,LucideMonitorUp:cS,LucideMonitorX:TQ,LucideMoon:EQ,LucideMoonStar:AQ,LucideMoreHorizontal:fx,LucideMoreVertical:px,LucideMountain:IQ,LucideMountainSnow:PQ,LucideMouse:RQ,LucideMouseOff:LQ,LucideMousePointer:wh,LucideMousePointer2:DQ,LucideMousePointerBan:OQ,LucideMousePointerClick:Jg,LucideMousePointerSquareDashed:hk,LucideMove:YQ,LucideMove3D:NN,LucideMove3d:NN,LucideMoveDiagonal:zQ,LucideMoveDiagonal2:FQ,LucideMoveDown:qQ,LucideMoveDownLeft:BQ,LucideMoveDownRight:$Q,LucideMoveHorizontal:UQ,LucideMoveLeft:VQ,LucideMoveRight:HQ,LucideMoveUp:KQ,LucideMoveUpLeft:WQ,LucideMoveUpRight:GQ,LucideMoveVertical:ZQ,LucideMusic:eJ,LucideMusic2:XQ,LucideMusic3:QQ,LucideMusic4:JQ,LucideNavigation:nJ,LucideNavigation2:sJ,LucideNavigation2Off:tJ,LucideNavigationOff:rJ,LucideNetwork:aJ,LucideNewspaper:d1,LucideNfc:iJ,LucideNotebook:dJ,LucideNotebookPen:oJ,LucideNotebookTabs:lJ,LucideNotebookText:cJ,LucideNotepadText:hJ,LucideNotepadTextDashed:uJ,LucideNut:pJ,LucideNutOff:mJ,LucideOctagon:xJ,LucideOctagonAlert:Fv,LucideOctagonMinus:fJ,LucideOctagonPause:kN,LucideOctagonX:SN,LucideOmega:gJ,LucideOption:yJ,LucideOrbit:vJ,LucideOrigami:bJ,LucideOutdent:yN,LucidePackage:Ml,LucidePackage2:_J,LucidePackageCheck:wJ,LucidePackageMinus:jJ,LucidePackageOpen:NJ,LucidePackagePlus:kJ,LucidePackageSearch:SJ,LucidePackageX:CJ,LucidePaintBucket:MJ,LucidePaintRoller:TJ,LucidePaintbrush:AJ,LucidePaintbrush2:CN,LucidePaintbrushVertical:CN,LucidePalette:ic,LucidePalmtree:Vk,LucidePanelBottom:IJ,LucidePanelBottomClose:EJ,LucidePanelBottomDashed:MN,LucidePanelBottomInactive:MN,LucidePanelBottomOpen:PJ,LucidePanelLeft:PN,LucidePanelLeftClose:TN,LucidePanelLeftDashed:AN,LucidePanelLeftInactive:AN,LucidePanelLeftOpen:EN,LucidePanelRight:OJ,LucidePanelRightClose:LJ,LucidePanelRightDashed:IN,LucidePanelRightInactive:IN,LucidePanelRightOpen:DJ,LucidePanelTop:zJ,LucidePanelTopClose:RJ,LucidePanelTopDashed:LN,LucidePanelTopInactive:LN,LucidePanelTopOpen:FJ,LucidePanelsLeftBottom:BJ,LucidePanelsLeftRight:Qj,LucidePanelsRightBottom:$J,LucidePanelsTopBottom:zN,LucidePanelsTopLeft:zv,LucidePaperclip:uS,LucideParentheses:qJ,LucideParkingCircle:Rj,LucideParkingCircleOff:Oj,LucideParkingMeter:UJ,LucideParkingSquare:kk,LucideParkingSquareOff:Nk,LucidePartyPopper:ru,LucidePause:Rm,LucidePauseCircle:Fj,LucidePauseOctagon:kN,LucidePawPrint:VJ,LucidePcCase:HJ,LucidePen:e0,LucidePenBox:hd,LucidePenLine:Bv,LucidePenOff:WJ,LucidePenSquare:hd,LucidePenTool:U_,LucidePencil:Ra,LucidePencilLine:GJ,LucidePencilOff:KJ,LucidePencilRuler:ZJ,LucidePentagon:YJ,LucidePercent:hS,LucidePercentCircle:zj,LucidePercentDiamond:eN,LucidePercentSquare:Sk,LucidePersonStanding:XJ,LucidePhilippinePeso:QJ,LucidePhone:Un,LucidePhoneCall:JJ,LucidePhoneForwarded:eee,LucidePhoneIncoming:tee,LucidePhoneMissed:see,LucidePhoneOff:ree,LucidePhoneOutgoing:nee,LucidePi:aee,LucidePiSquare:Ck,LucidePiano:iee,LucidePickaxe:oee,LucidePictureInPicture:cee,LucidePictureInPicture2:lee,LucidePieChart:vj,LucidePiggyBank:dee,LucidePilcrow:mee,LucidePilcrowLeft:uee,LucidePilcrowRight:hee,LucidePilcrowSquare:Mk,LucidePill:fee,LucidePillBottle:pee,LucidePin:V_,LucidePinOff:vL,LucidePipette:xee,LucidePizza:gee,LucidePlane:bee,LucidePlaneLanding:yee,LucidePlaneTakeoff:vee,LucidePlay:nl,LucidePlayCircle:pp,LucidePlaySquare:Tk,LucidePlug:bL,LucidePlug2:_ee,LucidePlugZap:DN,LucidePlugZap2:DN,LucidePlus:$s,LucidePlusCircle:Bj,LucidePlusSquare:Ak,LucidePocket:jee,LucidePocketKnife:wee,LucidePodcast:Nee,LucidePointer:See,LucidePointerOff:kee,LucidePopcorn:Cee,LucidePopsicle:Mee,LucidePoundSterling:Tee,LucidePower:_L,LucidePowerCircle:$j,LucidePowerOff:Aee,LucidePowerSquare:Ek,LucidePresentation:ey,LucidePrinter:wL,LucidePrinterCheck:Eee,LucideProjector:Pee,LucideProportions:Iee,LucidePuzzle:Lee,LucidePyramid:Dee,LucideQrCode:u1,LucideQuote:H_,LucideRabbit:Oee,LucideRadar:Ree,LucideRadiation:Fee,LucideRadical:zee,LucideRadio:h1,LucideRadioReceiver:Bee,LucideRadioTower:$ee,LucideRadius:qee,LucideRailSymbol:Uee,LucideRainbow:Vee,LucideRat:Hee,LucideRatio:Wee,LucideReceipt:tte,LucideReceiptCent:Gee,LucideReceiptEuro:Kee,LucideReceiptIndianRupee:Zee,LucideReceiptJapaneseYen:Yee,LucideReceiptPoundSterling:Xee,LucideReceiptRussianRuble:Qee,LucideReceiptSwissFranc:Jee,LucideReceiptText:ete,LucideRectangleEllipsis:ON,LucideRectangleHorizontal:ste,LucideRectangleVertical:rte,LucideRecycle:nte,LucideRedo:mS,LucideRedo2:ate,LucideRedoDot:ite,LucideRefreshCcw:BM,LucideRefreshCcwDot:ote,LucideRefreshCw:Go,LucideRefreshCwOff:lte,LucideRefrigerator:cte,LucideRegex:dte,LucideRemoveFormatting:ute,LucideRepeat:jL,LucideRepeat1:hte,LucideRepeat2:mte,LucideReplace:fte,LucideReplaceAll:pte,LucideReply:NL,LucideReplyAll:xte,LucideRewind:gte,LucideRibbon:yte,LucideRocket:x0,LucideRockingChair:vte,LucideRollerCoaster:bte,LucideRotate3D:RN,LucideRotate3d:RN,LucideRotateCcw:m1,LucideRotateCcwSquare:_te,LucideRotateCw:kL,LucideRotateCwSquare:wte,LucideRoute:Nte,LucideRouteOff:jte,LucideRouter:kte,LucideRows:FN,LucideRows2:FN,LucideRows3:zN,LucideRows4:Ste,LucideRss:Cte,LucideRuler:g0,LucideRussianRuble:Mte,LucideSailboat:Tte,LucideSalad:Ate,LucideSandwich:Ete,LucideSatellite:Ite,LucideSatelliteDish:Pte,LucideSave:qc,LucideSaveAll:Lte,LucideSaveOff:Dte,LucideScale:SL,LucideScale3D:BN,LucideScale3d:BN,LucideScaling:Ote,LucideScan:Vte,LucideScanBarcode:Rte,LucideScanEye:Fte,LucideScanFace:zte,LucideScanLine:Bte,LucideScanQrCode:$te,LucideScanSearch:qte,LucideScanText:Ute,LucideScatterChart:bj,LucideSchool:Hte,LucideSchool2:Wk,LucideScissors:Gte,LucideScissorsLineDashed:Wte,LucideScissorsSquare:Pk,LucideScissorsSquareDashedBottom:nk,LucideScreenShare:Zte,LucideScreenShareOff:Kte,LucideScroll:Xte,LucideScrollText:Yte,LucideSearch:cn,LucideSearchCheck:Qte,LucideSearchCode:Jte,LucideSearchSlash:ese,LucideSearchX:CL,LucideSection:tse,LucideSend:Bn,LucideSendHorizonal:$N,LucideSendHorizontal:$N,LucideSendToBack:sse,LucideSeparatorHorizontal:rse,LucideSeparatorVertical:nse,LucideServer:lse,LucideServerCog:ase,LucideServerCrash:ise,LucideServerOff:ose,LucideSettings:Xo,LucideSettings2:ML,LucideShapes:cse,LucideShare:TL,LucideShare2:wd,LucideSheet:dse,LucideShell:use,LucideShield:th,LucideShieldAlert:hse,LucideShieldBan:mse,LucideShieldCheck:AL,LucideShieldClose:qN,LucideShieldEllipsis:pse,LucideShieldHalf:fse,LucideShieldMinus:xse,LucideShieldOff:gse,LucideShieldPlus:yse,LucideShieldQuestion:vse,LucideShieldX:qN,LucideShip:_se,LucideShipWheel:bse,LucideShirt:wse,LucideShoppingBag:y0,LucideShoppingBasket:jse,LucideShoppingCart:vp,LucideShovel:Nse,LucideShowerHead:kse,LucideShrink:Sse,LucideShrub:Cse,LucideShuffle:pS,LucideSidebar:PN,LucideSidebarClose:TN,LucideSidebarOpen:EN,LucideSigma:Mse,LucideSigmaSquare:Ik,LucideSignal:Ise,LucideSignalHigh:Tse,LucideSignalLow:Ase,LucideSignalMedium:Ese,LucideSignalZero:Pse,LucideSignature:Lse,LucideSignpost:Ose,LucideSignpostBig:Dse,LucideSiren:Rse,LucideSkipBack:Fse,LucideSkipForward:zse,LucideSkull:Bse,LucideSlack:$se,LucideSlash:qse,LucideSlashSquare:Lk,LucideSlice:Use,LucideSliders:UN,LucideSlidersHorizontal:W_,LucideSlidersVertical:UN,LucideSmartphone:v0,LucideSmartphoneCharging:Vse,LucideSmartphoneNfc:Hse,LucideSmile:Gse,LucideSmilePlus:Wse,LucideSnail:Kse,LucideSnowflake:a0,LucideSofa:Zse,LucideSortAsc:ej,LucideSortDesc:X2,LucideSoup:Yse,LucideSpace:Xse,LucideSpade:Qse,LucideSparkle:Jse,LucideSparkles:pn,LucideSpeaker:ere,LucideSpeech:tre,LucideSpellCheck:rre,LucideSpellCheck2:sre,LucideSpline:nre,LucideSplit:are,LucideSplitSquareHorizontal:Dk,LucideSplitSquareVertical:Ok,LucideSprayCan:ire,LucideSprout:ore,LucideSquare:b0,LucideSquareActivity:VN,LucideSquareArrowDown:GN,LucideSquareArrowDownLeft:HN,LucideSquareArrowDownRight:WN,LucideSquareArrowLeft:KN,LucideSquareArrowOutDownLeft:ZN,LucideSquareArrowOutDownRight:YN,LucideSquareArrowOutUpLeft:XN,LucideSquareArrowOutUpRight:QN,LucideSquareArrowRight:JN,LucideSquareArrowUp:sk,LucideSquareArrowUpLeft:ek,LucideSquareArrowUpRight:tk,LucideSquareAsterisk:rk,LucideSquareBottomDashedScissors:nk,LucideSquareChartGantt:Vy,LucideSquareCheck:ak,LucideSquareCheckBig:$v,LucideSquareChevronDown:ik,LucideSquareChevronLeft:ok,LucideSquareChevronRight:lk,LucideSquareChevronUp:ck,LucideSquareCode:dk,LucideSquareDashed:mk,LucideSquareDashedBottom:cre,LucideSquareDashedBottomCode:lre,LucideSquareDashedKanban:uk,LucideSquareDashedMousePointer:hk,LucideSquareDivide:pk,LucideSquareDot:fk,LucideSquareEqual:xk,LucideSquareFunction:gk,LucideSquareGanttChart:Vy,LucideSquareKanban:yk,LucideSquareLibrary:vk,LucideSquareM:bk,LucideSquareMenu:_k,LucideSquareMinus:wk,LucideSquareMousePointer:jk,LucideSquareParking:kk,LucideSquareParkingOff:Nk,LucideSquarePen:hd,LucideSquarePercent:Sk,LucideSquarePi:Ck,LucideSquarePilcrow:Mk,LucideSquarePlay:Tk,LucideSquarePlus:Ak,LucideSquarePower:Ek,LucideSquareRadical:dre,LucideSquareScissors:Pk,LucideSquareSigma:Ik,LucideSquareSlash:Lk,LucideSquareSplitHorizontal:Dk,LucideSquareSplitVertical:Ok,LucideSquareSquare:ure,LucideSquareStack:hre,LucideSquareTerminal:Rk,LucideSquareUser:zk,LucideSquareUserRound:Fk,LucideSquareX:Bk,LucideSquircle:mre,LucideSquirrel:pre,LucideStamp:fre,LucideStar:Jn,LucideStarHalf:xre,LucideStarOff:gre,LucideStars:pn,LucideStepBack:yre,LucideStepForward:vre,LucideStethoscope:bre,LucideSticker:_re,LucideStickyNote:wre,LucideStopCircle:Uj,LucideStore:$M,LucideStretchHorizontal:jre,LucideStretchVertical:Nre,LucideStrikethrough:EL,LucideSubscript:kre,LucideSubtitles:lj,LucideSun:p1,LucideSunDim:Sre,LucideSunMedium:Cre,LucideSunMoon:Mre,LucideSunSnow:Tre,LucideSunrise:Are,LucideSunset:Ere,LucideSuperscript:Pre,LucideSwatchBook:Ire,LucideSwissFranc:Lre,LucideSwitchCamera:Dre,LucideSword:Ore,LucideSwords:Rre,LucideSyringe:Fre,LucideTable:UM,LucideTable2:qM,LucideTableCellsMerge:zre,LucideTableCellsSplit:Bre,LucideTableColumnsSplit:$re,LucideTableOfContents:qre,LucideTableProperties:Ure,LucideTableRowsSplit:Vre,LucideTablet:Wre,LucideTabletSmartphone:Hre,LucideTablets:Gre,LucideTag:Fm,LucideTags:Kre,LucideTally1:Zre,LucideTally2:Yre,LucideTally3:Xre,LucideTally4:Qre,LucideTally5:Jre,LucideTangent:ene,LucideTarget:zm,LucideTelescope:tne,LucideTent:rne,LucideTentTree:sne,LucideTerminal:nne,LucideTerminalSquare:Rk,LucideTestTube:ane,LucideTestTube2:$k,LucideTestTubeDiagonal:$k,LucideTestTubes:ine,LucideText:une,LucideTextCursor:lne,LucideTextCursorInput:one,LucideTextQuote:cne,LucideTextSearch:dne,LucideTextSelect:qk,LucideTextSelection:qk,LucideTheater:hne,LucideThermometer:PL,LucideThermometerSnowflake:mne,LucideThermometerSun:pne,LucideThumbsDown:IL,LucideThumbsUp:sh,LucideTicket:LL,LucideTicketCheck:fne,LucideTicketMinus:xne,LucideTicketPercent:gne,LucideTicketPlus:yne,LucideTicketSlash:vne,LucideTicketX:bne,LucideTickets:wne,LucideTicketsPlane:_ne,LucideTimer:kne,LucideTimerOff:jne,LucideTimerReset:Nne,LucideToggleLeft:Sne,LucideToggleRight:Cne,LucideToilet:Mne,LucideTornado:Tne,LucideTorus:Ane,LucideTouchpad:Pne,LucideTouchpadOff:Ene,LucideTowerControl:Ine,LucideToyBrick:Lne,LucideTractor:Dne,LucideTrafficCone:One,LucideTrain:Uk,LucideTrainFront:Fne,LucideTrainFrontTunnel:Rne,LucideTrainTrack:zne,LucideTramFront:Uk,LucideTrash:Bne,LucideTrash2:Nr,LucideTreeDeciduous:$ne,LucideTreePalm:Vk,LucideTreePine:f1,LucideTrees:qne,LucideTrello:Une,LucideTrendingDown:fS,LucideTrendingUp:ul,LucideTrendingUpDown:Vne,LucideTriangle:Wne,LucideTriangleAlert:Ku,LucideTriangleRight:Hne,LucideTrophy:xo,LucideTruck:DL,LucideTurtle:Gne,LucideTv:Zne,LucideTv2:Hk,LucideTvMinimal:Hk,LucideTvMinimalPlay:Kne,LucideTwitch:Yne,LucideTwitter:Xne,LucideType:Jne,LucideTypeOutline:Qne,LucideUmbrella:tae,LucideUmbrellaOff:eae,LucideUnderline:OL,LucideUndo:xS,LucideUndo2:sae,LucideUndoDot:rae,LucideUnfoldHorizontal:nae,LucideUnfoldVertical:aae,LucideUngroup:iae,LucideUniversity:Wk,LucideUnlink:gS,LucideUnlink2:oae,LucideUnlock:wN,LucideUnlockKeyhole:_N,LucideUnplug:lae,LucideUpload:li,LucideUploadCloud:Zj,LucideUsb:cae,LucideUser:to,LucideUser2:Qk,LucideUserCheck:G_,LucideUserCheck2:Gk,LucideUserCircle:Hj,LucideUserCircle2:Vj,LucideUserCog:RL,LucideUserCog2:Kk,LucideUserMinus:FL,LucideUserMinus2:Zk,LucideUserPen:dae,LucideUserPlus:Tl,LucideUserPlus2:Yk,LucideUserRound:Qk,LucideUserRoundCheck:Gk,LucideUserRoundCog:Kk,LucideUserRoundMinus:Zk,LucideUserRoundPen:uae,LucideUserRoundPlus:Yk,LucideUserRoundSearch:hae,LucideUserRoundX:Xk,LucideUserSearch:mae,LucideUserSquare:zk,LucideUserSquare2:Fk,LucideUserX:pae,LucideUserX2:Xk,LucideUsers:pr,LucideUsers2:Jk,LucideUsersRound:Jk,LucideUtensils:t4,LucideUtensilsCrossed:e4,LucideUtilityPole:fae,LucideVariable:VM,LucideVault:xae,LucideVegan:gae,LucideVenetianMask:yae,LucideVerified:rj,LucideVibrate:bae,LucideVibrateOff:vae,LucideVideo:An,LucideVideoOff:_ae,LucideVideotape:wae,LucideView:jae,LucideVoicemail:Nae,LucideVolleyball:kae,LucideVolume:Aae,LucideVolume1:Sae,LucideVolume2:Cae,LucideVolumeOff:Mae,LucideVolumeX:Tae,LucideVote:Eae,LucideWallet:zL,LucideWallet2:s4,LucideWalletCards:Pae,LucideWalletMinimal:s4,LucideWallpaper:Iae,LucideWand:Lae,LucideWand2:qv,LucideWandSparkles:qv,LucideWarehouse:Dae,LucideWashingMachine:Oae,LucideWatch:Rae,LucideWaves:BL,LucideWaypoints:Fae,LucideWebcam:zae,LucideWebhook:$ae,LucideWebhookOff:Bae,LucideWeight:qae,LucideWheat:Vae,LucideWheatOff:Uae,LucideWholeWord:Hae,LucideWifi:Yae,LucideWifiHigh:Wae,LucideWifiLow:Gae,LucideWifiOff:Kae,LucideWifiZero:Zae,LucideWind:Qae,LucideWindArrowDown:Xae,LucideWine:eie,LucideWineOff:Jae,LucideWorkflow:tie,LucideWorm:sie,LucideWrapText:rie,LucideWrench:ty,LucideX:Rr,LucideXCircle:vc,LucideXOctagon:SN,LucideXSquare:Bk,LucideYoutube:nie,LucideZap:Zh,LucideZapOff:aie,LucideZoomIn:K_,LucideZoomOut:HM,Luggage:xX,LuggageIcon:xX,MSquare:bk,MSquareIcon:bk,Magnet:gX,MagnetIcon:gX,Mail:cr,MailCheck:yX,MailCheckIcon:yX,MailIcon:cr,MailMinus:vX,MailMinusIcon:vX,MailOpen:bX,MailOpenIcon:bX,MailPlus:mL,MailPlusIcon:mL,MailQuestion:_X,MailQuestionIcon:_X,MailSearch:wX,MailSearchIcon:wX,MailWarning:jX,MailWarningIcon:jX,MailX:pL,MailXIcon:pL,Mailbox:NX,MailboxIcon:NX,Mails:kX,MailsIcon:kX,Map:l1,MapIcon:l1,MapPin:ma,MapPinCheck:CX,MapPinCheckIcon:CX,MapPinCheckInside:SX,MapPinCheckInsideIcon:SX,MapPinHouse:MX,MapPinHouseIcon:MX,MapPinIcon:ma,MapPinMinus:AX,MapPinMinusIcon:AX,MapPinMinusInside:TX,MapPinMinusInsideIcon:TX,MapPinOff:EX,MapPinOffIcon:EX,MapPinPlus:IX,MapPinPlusIcon:IX,MapPinPlusInside:PX,MapPinPlusInsideIcon:PX,MapPinX:DX,MapPinXIcon:DX,MapPinXInside:LX,MapPinXInsideIcon:LX,MapPinned:OX,MapPinnedIcon:OX,Martini:RX,MartiniIcon:RX,Maximize:lS,Maximize2:FX,Maximize2Icon:FX,MaximizeIcon:lS,Medal:c1,MedalIcon:c1,Megaphone:Ah,MegaphoneIcon:Ah,MegaphoneOff:zX,MegaphoneOffIcon:zX,Meh:BX,MehIcon:BX,MemoryStick:$X,MemoryStickIcon:$X,Menu:RM,MenuIcon:RM,MenuSquare:_k,MenuSquareIcon:_k,Merge:qX,MergeIcon:qX,MessageCircle:$c,MessageCircleCode:UX,MessageCircleCodeIcon:UX,MessageCircleDashed:VX,MessageCircleDashedIcon:VX,MessageCircleHeart:FM,MessageCircleHeartIcon:FM,MessageCircleIcon:$c,MessageCircleMore:HX,MessageCircleMoreIcon:HX,MessageCircleOff:WX,MessageCircleOffIcon:WX,MessageCirclePlus:GX,MessageCirclePlusIcon:GX,MessageCircleQuestion:fL,MessageCircleQuestionIcon:fL,MessageCircleReply:KX,MessageCircleReplyIcon:KX,MessageCircleWarning:ZX,MessageCircleWarningIcon:ZX,MessageCircleX:YX,MessageCircleXIcon:YX,MessageSquare:so,MessageSquareCode:XX,MessageSquareCodeIcon:XX,MessageSquareDashed:QX,MessageSquareDashedIcon:QX,MessageSquareDiff:JX,MessageSquareDiffIcon:JX,MessageSquareDot:eQ,MessageSquareDotIcon:eQ,MessageSquareHeart:tQ,MessageSquareHeartIcon:tQ,MessageSquareIcon:so,MessageSquareLock:sQ,MessageSquareLockIcon:sQ,MessageSquareMore:xL,MessageSquareMoreIcon:xL,MessageSquareOff:rQ,MessageSquareOffIcon:rQ,MessageSquarePlus:zM,MessageSquarePlusIcon:zM,MessageSquareQuote:gL,MessageSquareQuoteIcon:gL,MessageSquareReply:nQ,MessageSquareReplyIcon:nQ,MessageSquareShare:aQ,MessageSquareShareIcon:aQ,MessageSquareText:iQ,MessageSquareTextIcon:iQ,MessageSquareWarning:oQ,MessageSquareWarningIcon:oQ,MessageSquareX:lQ,MessageSquareXIcon:lQ,MessagesSquare:cQ,MessagesSquareIcon:cQ,Mic:yL,Mic2:jN,Mic2Icon:jN,MicIcon:yL,MicOff:dQ,MicOffIcon:dQ,MicVocal:jN,MicVocalIcon:jN,Microchip:uQ,MicrochipIcon:uQ,Microscope:hQ,MicroscopeIcon:hQ,Microwave:mQ,MicrowaveIcon:mQ,Milestone:pQ,MilestoneIcon:pQ,Milk:xQ,MilkIcon:xQ,MilkOff:fQ,MilkOffIcon:fQ,Minimize:yQ,Minimize2:gQ,Minimize2Icon:gQ,MinimizeIcon:yQ,Minus:f0,MinusCircle:Dj,MinusCircleIcon:Dj,MinusIcon:f0,MinusSquare:wk,MinusSquareIcon:wk,Monitor:dS,MonitorCheck:vQ,MonitorCheckIcon:vQ,MonitorCog:bQ,MonitorCogIcon:bQ,MonitorDot:_Q,MonitorDotIcon:_Q,MonitorDown:wQ,MonitorDownIcon:wQ,MonitorIcon:dS,MonitorOff:jQ,MonitorOffIcon:jQ,MonitorPause:NQ,MonitorPauseIcon:NQ,MonitorPlay:kQ,MonitorPlayIcon:kQ,MonitorSmartphone:SQ,MonitorSmartphoneIcon:SQ,MonitorSpeaker:CQ,MonitorSpeakerIcon:CQ,MonitorStop:MQ,MonitorStopIcon:MQ,MonitorUp:cS,MonitorUpIcon:cS,MonitorX:TQ,MonitorXIcon:TQ,Moon:EQ,MoonIcon:EQ,MoonStar:AQ,MoonStarIcon:AQ,MoreHorizontal:fx,MoreHorizontalIcon:fx,MoreVertical:px,MoreVerticalIcon:px,Mountain:IQ,MountainIcon:IQ,MountainSnow:PQ,MountainSnowIcon:PQ,Mouse:RQ,MouseIcon:RQ,MouseOff:LQ,MouseOffIcon:LQ,MousePointer:wh,MousePointer2:DQ,MousePointer2Icon:DQ,MousePointerBan:OQ,MousePointerBanIcon:OQ,MousePointerClick:Jg,MousePointerClickIcon:Jg,MousePointerIcon:wh,MousePointerSquareDashed:hk,MousePointerSquareDashedIcon:hk,Move:YQ,Move3D:NN,Move3DIcon:NN,Move3d:NN,Move3dIcon:NN,MoveDiagonal:zQ,MoveDiagonal2:FQ,MoveDiagonal2Icon:FQ,MoveDiagonalIcon:zQ,MoveDown:qQ,MoveDownIcon:qQ,MoveDownLeft:BQ,MoveDownLeftIcon:BQ,MoveDownRight:$Q,MoveDownRightIcon:$Q,MoveHorizontal:UQ,MoveHorizontalIcon:UQ,MoveIcon:YQ,MoveLeft:VQ,MoveLeftIcon:VQ,MoveRight:HQ,MoveRightIcon:HQ,MoveUp:KQ,MoveUpIcon:KQ,MoveUpLeft:WQ,MoveUpLeftIcon:WQ,MoveUpRight:GQ,MoveUpRightIcon:GQ,MoveVertical:ZQ,MoveVerticalIcon:ZQ,Music:eJ,Music2:XQ,Music2Icon:XQ,Music3:QQ,Music3Icon:QQ,Music4:JQ,Music4Icon:JQ,MusicIcon:eJ,Navigation:nJ,Navigation2:sJ,Navigation2Icon:sJ,Navigation2Off:tJ,Navigation2OffIcon:tJ,NavigationIcon:nJ,NavigationOff:rJ,NavigationOffIcon:rJ,Network:aJ,NetworkIcon:aJ,Newspaper:d1,NewspaperIcon:d1,Nfc:iJ,NfcIcon:iJ,Notebook:dJ,NotebookIcon:dJ,NotebookPen:oJ,NotebookPenIcon:oJ,NotebookTabs:lJ,NotebookTabsIcon:lJ,NotebookText:cJ,NotebookTextIcon:cJ,NotepadText:hJ,NotepadTextDashed:uJ,NotepadTextDashedIcon:uJ,NotepadTextIcon:hJ,Nut:pJ,NutIcon:pJ,NutOff:mJ,NutOffIcon:mJ,Octagon:xJ,OctagonAlert:Fv,OctagonAlertIcon:Fv,OctagonIcon:xJ,OctagonMinus:fJ,OctagonMinusIcon:fJ,OctagonPause:kN,OctagonPauseIcon:kN,OctagonX:SN,OctagonXIcon:SN,Omega:gJ,OmegaIcon:gJ,Option:yJ,OptionIcon:yJ,Orbit:vJ,OrbitIcon:vJ,Origami:bJ,OrigamiIcon:bJ,Outdent:yN,OutdentIcon:yN,Package:Ml,Package2:_J,Package2Icon:_J,PackageCheck:wJ,PackageCheckIcon:wJ,PackageIcon:Ml,PackageMinus:jJ,PackageMinusIcon:jJ,PackageOpen:NJ,PackageOpenIcon:NJ,PackagePlus:kJ,PackagePlusIcon:kJ,PackageSearch:SJ,PackageSearchIcon:SJ,PackageX:CJ,PackageXIcon:CJ,PaintBucket:MJ,PaintBucketIcon:MJ,PaintRoller:TJ,PaintRollerIcon:TJ,Paintbrush:AJ,Paintbrush2:CN,Paintbrush2Icon:CN,PaintbrushIcon:AJ,PaintbrushVertical:CN,PaintbrushVerticalIcon:CN,Palette:ic,PaletteIcon:ic,Palmtree:Vk,PalmtreeIcon:Vk,PanelBottom:IJ,PanelBottomClose:EJ,PanelBottomCloseIcon:EJ,PanelBottomDashed:MN,PanelBottomDashedIcon:MN,PanelBottomIcon:IJ,PanelBottomInactive:MN,PanelBottomInactiveIcon:MN,PanelBottomOpen:PJ,PanelBottomOpenIcon:PJ,PanelLeft:PN,PanelLeftClose:TN,PanelLeftCloseIcon:TN,PanelLeftDashed:AN,PanelLeftDashedIcon:AN,PanelLeftIcon:PN,PanelLeftInactive:AN,PanelLeftInactiveIcon:AN,PanelLeftOpen:EN,PanelLeftOpenIcon:EN,PanelRight:OJ,PanelRightClose:LJ,PanelRightCloseIcon:LJ,PanelRightDashed:IN,PanelRightDashedIcon:IN,PanelRightIcon:OJ,PanelRightInactive:IN,PanelRightInactiveIcon:IN,PanelRightOpen:DJ,PanelRightOpenIcon:DJ,PanelTop:zJ,PanelTopClose:RJ,PanelTopCloseIcon:RJ,PanelTopDashed:LN,PanelTopDashedIcon:LN,PanelTopIcon:zJ,PanelTopInactive:LN,PanelTopInactiveIcon:LN,PanelTopOpen:FJ,PanelTopOpenIcon:FJ,PanelsLeftBottom:BJ,PanelsLeftBottomIcon:BJ,PanelsLeftRight:Qj,PanelsLeftRightIcon:Qj,PanelsRightBottom:$J,PanelsRightBottomIcon:$J,PanelsTopBottom:zN,PanelsTopBottomIcon:zN,PanelsTopLeft:zv,PanelsTopLeftIcon:zv,Paperclip:uS,PaperclipIcon:uS,Parentheses:qJ,ParenthesesIcon:qJ,ParkingCircle:Rj,ParkingCircleIcon:Rj,ParkingCircleOff:Oj,ParkingCircleOffIcon:Oj,ParkingMeter:UJ,ParkingMeterIcon:UJ,ParkingSquare:kk,ParkingSquareIcon:kk,ParkingSquareOff:Nk,ParkingSquareOffIcon:Nk,PartyPopper:ru,PartyPopperIcon:ru,Pause:Rm,PauseCircle:Fj,PauseCircleIcon:Fj,PauseIcon:Rm,PauseOctagon:kN,PauseOctagonIcon:kN,PawPrint:VJ,PawPrintIcon:VJ,PcCase:HJ,PcCaseIcon:HJ,Pen:e0,PenBox:hd,PenBoxIcon:hd,PenIcon:e0,PenLine:Bv,PenLineIcon:Bv,PenOff:WJ,PenOffIcon:WJ,PenSquare:hd,PenSquareIcon:hd,PenTool:U_,PenToolIcon:U_,Pencil:Ra,PencilIcon:Ra,PencilLine:GJ,PencilLineIcon:GJ,PencilOff:KJ,PencilOffIcon:KJ,PencilRuler:ZJ,PencilRulerIcon:ZJ,Pentagon:YJ,PentagonIcon:YJ,Percent:hS,PercentCircle:zj,PercentCircleIcon:zj,PercentDiamond:eN,PercentDiamondIcon:eN,PercentIcon:hS,PercentSquare:Sk,PercentSquareIcon:Sk,PersonStanding:XJ,PersonStandingIcon:XJ,PhilippinePeso:QJ,PhilippinePesoIcon:QJ,Phone:Un,PhoneCall:JJ,PhoneCallIcon:JJ,PhoneForwarded:eee,PhoneForwardedIcon:eee,PhoneIcon:Un,PhoneIncoming:tee,PhoneIncomingIcon:tee,PhoneMissed:see,PhoneMissedIcon:see,PhoneOff:ree,PhoneOffIcon:ree,PhoneOutgoing:nee,PhoneOutgoingIcon:nee,Pi:aee,PiIcon:aee,PiSquare:Ck,PiSquareIcon:Ck,Piano:iee,PianoIcon:iee,Pickaxe:oee,PickaxeIcon:oee,PictureInPicture:cee,PictureInPicture2:lee,PictureInPicture2Icon:lee,PictureInPictureIcon:cee,PieChart:vj,PieChartIcon:vj,PiggyBank:dee,PiggyBankIcon:dee,Pilcrow:mee,PilcrowIcon:mee,PilcrowLeft:uee,PilcrowLeftIcon:uee,PilcrowRight:hee,PilcrowRightIcon:hee,PilcrowSquare:Mk,PilcrowSquareIcon:Mk,Pill:fee,PillBottle:pee,PillBottleIcon:pee,PillIcon:fee,Pin:V_,PinIcon:V_,PinOff:vL,PinOffIcon:vL,Pipette:xee,PipetteIcon:xee,Pizza:gee,PizzaIcon:gee,Plane:bee,PlaneIcon:bee,PlaneLanding:yee,PlaneLandingIcon:yee,PlaneTakeoff:vee,PlaneTakeoffIcon:vee,Play:nl,PlayCircle:pp,PlayCircleIcon:pp,PlayIcon:nl,PlaySquare:Tk,PlaySquareIcon:Tk,Plug:bL,Plug2:_ee,Plug2Icon:_ee,PlugIcon:bL,PlugZap:DN,PlugZap2:DN,PlugZap2Icon:DN,PlugZapIcon:DN,Plus:$s,PlusCircle:Bj,PlusCircleIcon:Bj,PlusIcon:$s,PlusSquare:Ak,PlusSquareIcon:Ak,Pocket:jee,PocketIcon:jee,PocketKnife:wee,PocketKnifeIcon:wee,Podcast:Nee,PodcastIcon:Nee,Pointer:See,PointerIcon:See,PointerOff:kee,PointerOffIcon:kee,Popcorn:Cee,PopcornIcon:Cee,Popsicle:Mee,PopsicleIcon:Mee,PoundSterling:Tee,PoundSterlingIcon:Tee,Power:_L,PowerCircle:$j,PowerCircleIcon:$j,PowerIcon:_L,PowerOff:Aee,PowerOffIcon:Aee,PowerSquare:Ek,PowerSquareIcon:Ek,Presentation:ey,PresentationIcon:ey,Printer:wL,PrinterCheck:Eee,PrinterCheckIcon:Eee,PrinterIcon:wL,Projector:Pee,ProjectorIcon:Pee,Proportions:Iee,ProportionsIcon:Iee,Puzzle:Lee,PuzzleIcon:Lee,Pyramid:Dee,PyramidIcon:Dee,QrCode:u1,QrCodeIcon:u1,Quote:H_,QuoteIcon:H_,Rabbit:Oee,RabbitIcon:Oee,Radar:Ree,RadarIcon:Ree,Radiation:Fee,RadiationIcon:Fee,Radical:zee,RadicalIcon:zee,Radio:h1,RadioIcon:h1,RadioReceiver:Bee,RadioReceiverIcon:Bee,RadioTower:$ee,RadioTowerIcon:$ee,Radius:qee,RadiusIcon:qee,RailSymbol:Uee,RailSymbolIcon:Uee,Rainbow:Vee,RainbowIcon:Vee,Rat:Hee,RatIcon:Hee,Ratio:Wee,RatioIcon:Wee,Receipt:tte,ReceiptCent:Gee,ReceiptCentIcon:Gee,ReceiptEuro:Kee,ReceiptEuroIcon:Kee,ReceiptIcon:tte,ReceiptIndianRupee:Zee,ReceiptIndianRupeeIcon:Zee,ReceiptJapaneseYen:Yee,ReceiptJapaneseYenIcon:Yee,ReceiptPoundSterling:Xee,ReceiptPoundSterlingIcon:Xee,ReceiptRussianRuble:Qee,ReceiptRussianRubleIcon:Qee,ReceiptSwissFranc:Jee,ReceiptSwissFrancIcon:Jee,ReceiptText:ete,ReceiptTextIcon:ete,RectangleEllipsis:ON,RectangleEllipsisIcon:ON,RectangleHorizontal:ste,RectangleHorizontalIcon:ste,RectangleVertical:rte,RectangleVerticalIcon:rte,Recycle:nte,RecycleIcon:nte,Redo:mS,Redo2:ate,Redo2Icon:ate,RedoDot:ite,RedoDotIcon:ite,RedoIcon:mS,RefreshCcw:BM,RefreshCcwDot:ote,RefreshCcwDotIcon:ote,RefreshCcwIcon:BM,RefreshCw:Go,RefreshCwIcon:Go,RefreshCwOff:lte,RefreshCwOffIcon:lte,Refrigerator:cte,RefrigeratorIcon:cte,Regex:dte,RegexIcon:dte,RemoveFormatting:ute,RemoveFormattingIcon:ute,Repeat:jL,Repeat1:hte,Repeat1Icon:hte,Repeat2:mte,Repeat2Icon:mte,RepeatIcon:jL,Replace:fte,ReplaceAll:pte,ReplaceAllIcon:pte,ReplaceIcon:fte,Reply:NL,ReplyAll:xte,ReplyAllIcon:xte,ReplyIcon:NL,Rewind:gte,RewindIcon:gte,Ribbon:yte,RibbonIcon:yte,Rocket:x0,RocketIcon:x0,RockingChair:vte,RockingChairIcon:vte,RollerCoaster:bte,RollerCoasterIcon:bte,Rotate3D:RN,Rotate3DIcon:RN,Rotate3d:RN,Rotate3dIcon:RN,RotateCcw:m1,RotateCcwIcon:m1,RotateCcwSquare:_te,RotateCcwSquareIcon:_te,RotateCw:kL,RotateCwIcon:kL,RotateCwSquare:wte,RotateCwSquareIcon:wte,Route:Nte,RouteIcon:Nte,RouteOff:jte,RouteOffIcon:jte,Router:kte,RouterIcon:kte,Rows:FN,Rows2:FN,Rows2Icon:FN,Rows3:zN,Rows3Icon:zN,Rows4:Ste,Rows4Icon:Ste,RowsIcon:FN,Rss:Cte,RssIcon:Cte,Ruler:g0,RulerIcon:g0,RussianRuble:Mte,RussianRubleIcon:Mte,Sailboat:Tte,SailboatIcon:Tte,Salad:Ate,SaladIcon:Ate,Sandwich:Ete,SandwichIcon:Ete,Satellite:Ite,SatelliteDish:Pte,SatelliteDishIcon:Pte,SatelliteIcon:Ite,Save:qc,SaveAll:Lte,SaveAllIcon:Lte,SaveIcon:qc,SaveOff:Dte,SaveOffIcon:Dte,Scale:SL,Scale3D:BN,Scale3DIcon:BN,Scale3d:BN,Scale3dIcon:BN,ScaleIcon:SL,Scaling:Ote,ScalingIcon:Ote,Scan:Vte,ScanBarcode:Rte,ScanBarcodeIcon:Rte,ScanEye:Fte,ScanEyeIcon:Fte,ScanFace:zte,ScanFaceIcon:zte,ScanIcon:Vte,ScanLine:Bte,ScanLineIcon:Bte,ScanQrCode:$te,ScanQrCodeIcon:$te,ScanSearch:qte,ScanSearchIcon:qte,ScanText:Ute,ScanTextIcon:Ute,ScatterChart:bj,ScatterChartIcon:bj,School:Hte,School2:Wk,School2Icon:Wk,SchoolIcon:Hte,Scissors:Gte,ScissorsIcon:Gte,ScissorsLineDashed:Wte,ScissorsLineDashedIcon:Wte,ScissorsSquare:Pk,ScissorsSquareDashedBottom:nk,ScissorsSquareDashedBottomIcon:nk,ScissorsSquareIcon:Pk,ScreenShare:Zte,ScreenShareIcon:Zte,ScreenShareOff:Kte,ScreenShareOffIcon:Kte,Scroll:Xte,ScrollIcon:Xte,ScrollText:Yte,ScrollTextIcon:Yte,Search:cn,SearchCheck:Qte,SearchCheckIcon:Qte,SearchCode:Jte,SearchCodeIcon:Jte,SearchIcon:cn,SearchSlash:ese,SearchSlashIcon:ese,SearchX:CL,SearchXIcon:CL,Section:tse,SectionIcon:tse,Send:Bn,SendHorizonal:$N,SendHorizonalIcon:$N,SendHorizontal:$N,SendHorizontalIcon:$N,SendIcon:Bn,SendToBack:sse,SendToBackIcon:sse,SeparatorHorizontal:rse,SeparatorHorizontalIcon:rse,SeparatorVertical:nse,SeparatorVerticalIcon:nse,Server:lse,ServerCog:ase,ServerCogIcon:ase,ServerCrash:ise,ServerCrashIcon:ise,ServerIcon:lse,ServerOff:ose,ServerOffIcon:ose,Settings:Xo,Settings2:ML,Settings2Icon:ML,SettingsIcon:Xo,Shapes:cse,ShapesIcon:cse,Share:TL,Share2:wd,Share2Icon:wd,ShareIcon:TL,Sheet:dse,SheetIcon:dse,Shell:use,ShellIcon:use,Shield:th,ShieldAlert:hse,ShieldAlertIcon:hse,ShieldBan:mse,ShieldBanIcon:mse,ShieldCheck:AL,ShieldCheckIcon:AL,ShieldClose:qN,ShieldCloseIcon:qN,ShieldEllipsis:pse,ShieldEllipsisIcon:pse,ShieldHalf:fse,ShieldHalfIcon:fse,ShieldIcon:th,ShieldMinus:xse,ShieldMinusIcon:xse,ShieldOff:gse,ShieldOffIcon:gse,ShieldPlus:yse,ShieldPlusIcon:yse,ShieldQuestion:vse,ShieldQuestionIcon:vse,ShieldX:qN,ShieldXIcon:qN,Ship:_se,ShipIcon:_se,ShipWheel:bse,ShipWheelIcon:bse,Shirt:wse,ShirtIcon:wse,ShoppingBag:y0,ShoppingBagIcon:y0,ShoppingBasket:jse,ShoppingBasketIcon:jse,ShoppingCart:vp,ShoppingCartIcon:vp,Shovel:Nse,ShovelIcon:Nse,ShowerHead:kse,ShowerHeadIcon:kse,Shrink:Sse,ShrinkIcon:Sse,Shrub:Cse,ShrubIcon:Cse,Shuffle:pS,ShuffleIcon:pS,Sidebar:PN,SidebarClose:TN,SidebarCloseIcon:TN,SidebarIcon:PN,SidebarOpen:EN,SidebarOpenIcon:EN,Sigma:Mse,SigmaIcon:Mse,SigmaSquare:Ik,SigmaSquareIcon:Ik,Signal:Ise,SignalHigh:Tse,SignalHighIcon:Tse,SignalIcon:Ise,SignalLow:Ase,SignalLowIcon:Ase,SignalMedium:Ese,SignalMediumIcon:Ese,SignalZero:Pse,SignalZeroIcon:Pse,Signature:Lse,SignatureIcon:Lse,Signpost:Ose,SignpostBig:Dse,SignpostBigIcon:Dse,SignpostIcon:Ose,Siren:Rse,SirenIcon:Rse,SkipBack:Fse,SkipBackIcon:Fse,SkipForward:zse,SkipForwardIcon:zse,Skull:Bse,SkullIcon:Bse,Slack:$se,SlackIcon:$se,Slash:qse,SlashIcon:qse,SlashSquare:Lk,SlashSquareIcon:Lk,Slice:Use,SliceIcon:Use,Sliders:UN,SlidersHorizontal:W_,SlidersHorizontalIcon:W_,SlidersIcon:UN,SlidersVertical:UN,SlidersVerticalIcon:UN,Smartphone:v0,SmartphoneCharging:Vse,SmartphoneChargingIcon:Vse,SmartphoneIcon:v0,SmartphoneNfc:Hse,SmartphoneNfcIcon:Hse,Smile:Gse,SmileIcon:Gse,SmilePlus:Wse,SmilePlusIcon:Wse,Snail:Kse,SnailIcon:Kse,Snowflake:a0,SnowflakeIcon:a0,Sofa:Zse,SofaIcon:Zse,SortAsc:ej,SortAscIcon:ej,SortDesc:X2,SortDescIcon:X2,Soup:Yse,SoupIcon:Yse,Space:Xse,SpaceIcon:Xse,Spade:Qse,SpadeIcon:Qse,Sparkle:Jse,SparkleIcon:Jse,Sparkles:pn,SparklesIcon:pn,Speaker:ere,SpeakerIcon:ere,Speech:tre,SpeechIcon:tre,SpellCheck:rre,SpellCheck2:sre,SpellCheck2Icon:sre,SpellCheckIcon:rre,Spline:nre,SplineIcon:nre,Split:are,SplitIcon:are,SplitSquareHorizontal:Dk,SplitSquareHorizontalIcon:Dk,SplitSquareVertical:Ok,SplitSquareVerticalIcon:Ok,SprayCan:ire,SprayCanIcon:ire,Sprout:ore,SproutIcon:ore,Square:b0,SquareActivity:VN,SquareActivityIcon:VN,SquareArrowDown:GN,SquareArrowDownIcon:GN,SquareArrowDownLeft:HN,SquareArrowDownLeftIcon:HN,SquareArrowDownRight:WN,SquareArrowDownRightIcon:WN,SquareArrowLeft:KN,SquareArrowLeftIcon:KN,SquareArrowOutDownLeft:ZN,SquareArrowOutDownLeftIcon:ZN,SquareArrowOutDownRight:YN,SquareArrowOutDownRightIcon:YN,SquareArrowOutUpLeft:XN,SquareArrowOutUpLeftIcon:XN,SquareArrowOutUpRight:QN,SquareArrowOutUpRightIcon:QN,SquareArrowRight:JN,SquareArrowRightIcon:JN,SquareArrowUp:sk,SquareArrowUpIcon:sk,SquareArrowUpLeft:ek,SquareArrowUpLeftIcon:ek,SquareArrowUpRight:tk,SquareArrowUpRightIcon:tk,SquareAsterisk:rk,SquareAsteriskIcon:rk,SquareBottomDashedScissors:nk,SquareBottomDashedScissorsIcon:nk,SquareChartGantt:Vy,SquareChartGanttIcon:Vy,SquareCheck:ak,SquareCheckBig:$v,SquareCheckBigIcon:$v,SquareCheckIcon:ak,SquareChevronDown:ik,SquareChevronDownIcon:ik,SquareChevronLeft:ok,SquareChevronLeftIcon:ok,SquareChevronRight:lk,SquareChevronRightIcon:lk,SquareChevronUp:ck,SquareChevronUpIcon:ck,SquareCode:dk,SquareCodeIcon:dk,SquareDashed:mk,SquareDashedBottom:cre,SquareDashedBottomCode:lre,SquareDashedBottomCodeIcon:lre,SquareDashedBottomIcon:cre,SquareDashedIcon:mk,SquareDashedKanban:uk,SquareDashedKanbanIcon:uk,SquareDashedMousePointer:hk,SquareDashedMousePointerIcon:hk,SquareDivide:pk,SquareDivideIcon:pk,SquareDot:fk,SquareDotIcon:fk,SquareEqual:xk,SquareEqualIcon:xk,SquareFunction:gk,SquareFunctionIcon:gk,SquareGanttChart:Vy,SquareGanttChartIcon:Vy,SquareIcon:b0,SquareKanban:yk,SquareKanbanIcon:yk,SquareLibrary:vk,SquareLibraryIcon:vk,SquareM:bk,SquareMIcon:bk,SquareMenu:_k,SquareMenuIcon:_k,SquareMinus:wk,SquareMinusIcon:wk,SquareMousePointer:jk,SquareMousePointerIcon:jk,SquareParking:kk,SquareParkingIcon:kk,SquareParkingOff:Nk,SquareParkingOffIcon:Nk,SquarePen:hd,SquarePenIcon:hd,SquarePercent:Sk,SquarePercentIcon:Sk,SquarePi:Ck,SquarePiIcon:Ck,SquarePilcrow:Mk,SquarePilcrowIcon:Mk,SquarePlay:Tk,SquarePlayIcon:Tk,SquarePlus:Ak,SquarePlusIcon:Ak,SquarePower:Ek,SquarePowerIcon:Ek,SquareRadical:dre,SquareRadicalIcon:dre,SquareScissors:Pk,SquareScissorsIcon:Pk,SquareSigma:Ik,SquareSigmaIcon:Ik,SquareSlash:Lk,SquareSlashIcon:Lk,SquareSplitHorizontal:Dk,SquareSplitHorizontalIcon:Dk,SquareSplitVertical:Ok,SquareSplitVerticalIcon:Ok,SquareSquare:ure,SquareSquareIcon:ure,SquareStack:hre,SquareStackIcon:hre,SquareTerminal:Rk,SquareTerminalIcon:Rk,SquareUser:zk,SquareUserIcon:zk,SquareUserRound:Fk,SquareUserRoundIcon:Fk,SquareX:Bk,SquareXIcon:Bk,Squircle:mre,SquircleIcon:mre,Squirrel:pre,SquirrelIcon:pre,Stamp:fre,StampIcon:fre,Star:Jn,StarHalf:xre,StarHalfIcon:xre,StarIcon:Jn,StarOff:gre,StarOffIcon:gre,Stars:pn,StarsIcon:pn,StepBack:yre,StepBackIcon:yre,StepForward:vre,StepForwardIcon:vre,Stethoscope:bre,StethoscopeIcon:bre,Sticker:_re,StickerIcon:_re,StickyNote:wre,StickyNoteIcon:wre,StopCircle:Uj,StopCircleIcon:Uj,Store:$M,StoreIcon:$M,StretchHorizontal:jre,StretchHorizontalIcon:jre,StretchVertical:Nre,StretchVerticalIcon:Nre,Strikethrough:EL,StrikethroughIcon:EL,Subscript:kre,SubscriptIcon:kre,Subtitles:lj,SubtitlesIcon:lj,Sun:p1,SunDim:Sre,SunDimIcon:Sre,SunIcon:p1,SunMedium:Cre,SunMediumIcon:Cre,SunMoon:Mre,SunMoonIcon:Mre,SunSnow:Tre,SunSnowIcon:Tre,Sunrise:Are,SunriseIcon:Are,Sunset:Ere,SunsetIcon:Ere,Superscript:Pre,SuperscriptIcon:Pre,SwatchBook:Ire,SwatchBookIcon:Ire,SwissFranc:Lre,SwissFrancIcon:Lre,SwitchCamera:Dre,SwitchCameraIcon:Dre,Sword:Ore,SwordIcon:Ore,Swords:Rre,SwordsIcon:Rre,Syringe:Fre,SyringeIcon:Fre,Table:UM,Table2:qM,Table2Icon:qM,TableCellsMerge:zre,TableCellsMergeIcon:zre,TableCellsSplit:Bre,TableCellsSplitIcon:Bre,TableColumnsSplit:$re,TableColumnsSplitIcon:$re,TableIcon:UM,TableOfContents:qre,TableOfContentsIcon:qre,TableProperties:Ure,TablePropertiesIcon:Ure,TableRowsSplit:Vre,TableRowsSplitIcon:Vre,Tablet:Wre,TabletIcon:Wre,TabletSmartphone:Hre,TabletSmartphoneIcon:Hre,Tablets:Gre,TabletsIcon:Gre,Tag:Fm,TagIcon:Fm,Tags:Kre,TagsIcon:Kre,Tally1:Zre,Tally1Icon:Zre,Tally2:Yre,Tally2Icon:Yre,Tally3:Xre,Tally3Icon:Xre,Tally4:Qre,Tally4Icon:Qre,Tally5:Jre,Tally5Icon:Jre,Tangent:ene,TangentIcon:ene,Target:zm,TargetIcon:zm,Telescope:tne,TelescopeIcon:tne,Tent:rne,TentIcon:rne,TentTree:sne,TentTreeIcon:sne,Terminal:nne,TerminalIcon:nne,TerminalSquare:Rk,TerminalSquareIcon:Rk,TestTube:ane,TestTube2:$k,TestTube2Icon:$k,TestTubeDiagonal:$k,TestTubeDiagonalIcon:$k,TestTubeIcon:ane,TestTubes:ine,TestTubesIcon:ine,Text:une,TextCursor:lne,TextCursorIcon:lne,TextCursorInput:one,TextCursorInputIcon:one,TextIcon:une,TextQuote:cne,TextQuoteIcon:cne,TextSearch:dne,TextSearchIcon:dne,TextSelect:qk,TextSelectIcon:qk,TextSelection:qk,TextSelectionIcon:qk,Theater:hne,TheaterIcon:hne,Thermometer:PL,ThermometerIcon:PL,ThermometerSnowflake:mne,ThermometerSnowflakeIcon:mne,ThermometerSun:pne,ThermometerSunIcon:pne,ThumbsDown:IL,ThumbsDownIcon:IL,ThumbsUp:sh,ThumbsUpIcon:sh,Ticket:LL,TicketCheck:fne,TicketCheckIcon:fne,TicketIcon:LL,TicketMinus:xne,TicketMinusIcon:xne,TicketPercent:gne,TicketPercentIcon:gne,TicketPlus:yne,TicketPlusIcon:yne,TicketSlash:vne,TicketSlashIcon:vne,TicketX:bne,TicketXIcon:bne,Tickets:wne,TicketsIcon:wne,TicketsPlane:_ne,TicketsPlaneIcon:_ne,Timer:kne,TimerIcon:kne,TimerOff:jne,TimerOffIcon:jne,TimerReset:Nne,TimerResetIcon:Nne,ToggleLeft:Sne,ToggleLeftIcon:Sne,ToggleRight:Cne,ToggleRightIcon:Cne,Toilet:Mne,ToiletIcon:Mne,Tornado:Tne,TornadoIcon:Tne,Torus:Ane,TorusIcon:Ane,Touchpad:Pne,TouchpadIcon:Pne,TouchpadOff:Ene,TouchpadOffIcon:Ene,TowerControl:Ine,TowerControlIcon:Ine,ToyBrick:Lne,ToyBrickIcon:Lne,Tractor:Dne,TractorIcon:Dne,TrafficCone:One,TrafficConeIcon:One,Train:Uk,TrainFront:Fne,TrainFrontIcon:Fne,TrainFrontTunnel:Rne,TrainFrontTunnelIcon:Rne,TrainIcon:Uk,TrainTrack:zne,TrainTrackIcon:zne,TramFront:Uk,TramFrontIcon:Uk,Trash:Bne,Trash2:Nr,Trash2Icon:Nr,TrashIcon:Bne,TreeDeciduous:$ne,TreeDeciduousIcon:$ne,TreePalm:Vk,TreePalmIcon:Vk,TreePine:f1,TreePineIcon:f1,Trees:qne,TreesIcon:qne,Trello:Une,TrelloIcon:Une,TrendingDown:fS,TrendingDownIcon:fS,TrendingUp:ul,TrendingUpDown:Vne,TrendingUpDownIcon:Vne,TrendingUpIcon:ul,Triangle:Wne,TriangleAlert:Ku,TriangleAlertIcon:Ku,TriangleIcon:Wne,TriangleRight:Hne,TriangleRightIcon:Hne,Trophy:xo,TrophyIcon:xo,Truck:DL,TruckIcon:DL,Turtle:Gne,TurtleIcon:Gne,Tv:Zne,Tv2:Hk,Tv2Icon:Hk,TvIcon:Zne,TvMinimal:Hk,TvMinimalIcon:Hk,TvMinimalPlay:Kne,TvMinimalPlayIcon:Kne,Twitch:Yne,TwitchIcon:Yne,Twitter:Xne,TwitterIcon:Xne,Type:Jne,TypeIcon:Jne,TypeOutline:Qne,TypeOutlineIcon:Qne,Umbrella:tae,UmbrellaIcon:tae,UmbrellaOff:eae,UmbrellaOffIcon:eae,Underline:OL,UnderlineIcon:OL,Undo:xS,Undo2:sae,Undo2Icon:sae,UndoDot:rae,UndoDotIcon:rae,UndoIcon:xS,UnfoldHorizontal:nae,UnfoldHorizontalIcon:nae,UnfoldVertical:aae,UnfoldVerticalIcon:aae,Ungroup:iae,UngroupIcon:iae,University:Wk,UniversityIcon:Wk,Unlink:gS,Unlink2:oae,Unlink2Icon:oae,UnlinkIcon:gS,Unlock:wN,UnlockIcon:wN,UnlockKeyhole:_N,UnlockKeyholeIcon:_N,Unplug:lae,UnplugIcon:lae,Upload:li,UploadCloud:Zj,UploadCloudIcon:Zj,UploadIcon:li,Usb:cae,UsbIcon:cae,User:to,User2:Qk,User2Icon:Qk,UserCheck:G_,UserCheck2:Gk,UserCheck2Icon:Gk,UserCheckIcon:G_,UserCircle:Hj,UserCircle2:Vj,UserCircle2Icon:Vj,UserCircleIcon:Hj,UserCog:RL,UserCog2:Kk,UserCog2Icon:Kk,UserCogIcon:RL,UserIcon:to,UserMinus:FL,UserMinus2:Zk,UserMinus2Icon:Zk,UserMinusIcon:FL,UserPen:dae,UserPenIcon:dae,UserPlus:Tl,UserPlus2:Yk,UserPlus2Icon:Yk,UserPlusIcon:Tl,UserRound:Qk,UserRoundCheck:Gk,UserRoundCheckIcon:Gk,UserRoundCog:Kk,UserRoundCogIcon:Kk,UserRoundIcon:Qk,UserRoundMinus:Zk,UserRoundMinusIcon:Zk,UserRoundPen:uae,UserRoundPenIcon:uae,UserRoundPlus:Yk,UserRoundPlusIcon:Yk,UserRoundSearch:hae,UserRoundSearchIcon:hae,UserRoundX:Xk,UserRoundXIcon:Xk,UserSearch:mae,UserSearchIcon:mae,UserSquare:zk,UserSquare2:Fk,UserSquare2Icon:Fk,UserSquareIcon:zk,UserX:pae,UserX2:Xk,UserX2Icon:Xk,UserXIcon:pae,Users:pr,Users2:Jk,Users2Icon:Jk,UsersIcon:pr,UsersRound:Jk,UsersRoundIcon:Jk,Utensils:t4,UtensilsCrossed:e4,UtensilsCrossedIcon:e4,UtensilsIcon:t4,UtilityPole:fae,UtilityPoleIcon:fae,Variable:VM,VariableIcon:VM,Vault:xae,VaultIcon:xae,Vegan:gae,VeganIcon:gae,VenetianMask:yae,VenetianMaskIcon:yae,Verified:rj,VerifiedIcon:rj,Vibrate:bae,VibrateIcon:bae,VibrateOff:vae,VibrateOffIcon:vae,Video:An,VideoIcon:An,VideoOff:_ae,VideoOffIcon:_ae,Videotape:wae,VideotapeIcon:wae,View:jae,ViewIcon:jae,Voicemail:Nae,VoicemailIcon:Nae,Volleyball:kae,VolleyballIcon:kae,Volume:Aae,Volume1:Sae,Volume1Icon:Sae,Volume2:Cae,Volume2Icon:Cae,VolumeIcon:Aae,VolumeOff:Mae,VolumeOffIcon:Mae,VolumeX:Tae,VolumeXIcon:Tae,Vote:Eae,VoteIcon:Eae,Wallet:zL,Wallet2:s4,Wallet2Icon:s4,WalletCards:Pae,WalletCardsIcon:Pae,WalletIcon:zL,WalletMinimal:s4,WalletMinimalIcon:s4,Wallpaper:Iae,WallpaperIcon:Iae,Wand:Lae,Wand2:qv,Wand2Icon:qv,WandIcon:Lae,WandSparkles:qv,WandSparklesIcon:qv,Warehouse:Dae,WarehouseIcon:Dae,WashingMachine:Oae,WashingMachineIcon:Oae,Watch:Rae,WatchIcon:Rae,Waves:BL,WavesIcon:BL,Waypoints:Fae,WaypointsIcon:Fae,Webcam:zae,WebcamIcon:zae,Webhook:$ae,WebhookIcon:$ae,WebhookOff:Bae,WebhookOffIcon:Bae,Weight:qae,WeightIcon:qae,Wheat:Vae,WheatIcon:Vae,WheatOff:Uae,WheatOffIcon:Uae,WholeWord:Hae,WholeWordIcon:Hae,Wifi:Yae,WifiHigh:Wae,WifiHighIcon:Wae,WifiIcon:Yae,WifiLow:Gae,WifiLowIcon:Gae,WifiOff:Kae,WifiOffIcon:Kae,WifiZero:Zae,WifiZeroIcon:Zae,Wind:Qae,WindArrowDown:Xae,WindArrowDownIcon:Xae,WindIcon:Qae,Wine:eie,WineIcon:eie,WineOff:Jae,WineOffIcon:Jae,Workflow:tie,WorkflowIcon:tie,Worm:sie,WormIcon:sie,WrapText:rie,WrapTextIcon:rie,Wrench:ty,WrenchIcon:ty,X:Rr,XCircle:vc,XCircleIcon:vc,XIcon:Rr,XOctagon:SN,XOctagonIcon:SN,XSquare:Bk,XSquareIcon:Bk,Youtube:nie,YoutubeIcon:nie,Zap:Zh,ZapIcon:Zh,ZapOff:aie,ZapOffIcon:aie,ZoomIn:K_,ZoomInIcon:K_,ZoomOut:HM,ZoomOutIcon:HM,createLucideIcon:Z,icons:Bxt},Symbol.toStringTag,{value:"Module"})),y2e="-",$xt=t=>{const s=Uxt(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(y2e);return i[0]===""&&i.length!==1&&i.shift(),oqe(i,s)||qxt(l)},getConflictingClassGroupIds:(l,i)=>{const c=r[l]||[];return i&&n[l]?[...c,...n[l]]:c}}},oqe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?oqe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(y2e);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},PAe=/^\[(.+)\]$/,qxt=t=>{if(PAe.test(t)){const s=PAe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Uxt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return Hxt(Object.entries(t.classGroups),r).forEach(([o,l])=>{D0e(l,n,o,s)}),n},D0e=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:IAe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(Vxt(a)){D0e(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{D0e(l,IAe(s,o),r,n)})})},IAe=(t,s)=>{let r=t;return s.split(y2e).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},Vxt=t=>t.isThemeGetter,Hxt=(t,s)=>s?t.map(([r,n])=>{const a=n.map(o=>typeof o=="string"?s+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([l,i])=>[s+l,i])):o);return[r,a]}):t,Wxt=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,n=new Map;const a=(o,l)=>{r.set(o,l),s++,s>t&&(s=0,n=r,r=new Map)};return{get(o){let l=r.get(o);if(l!==void 0)return l;if((l=n.get(o))!==void 0)return a(o,l),l},set(o,l){r.has(o)?r.set(o,l):a(o,l)}}},lqe="!",Gxt=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const c=[];let u=0,p=0,f;for(let w=0;wp?f-p:void 0;return{modifiers:c,hasImportantModifier:b,baseClassName:_,maybePostfixModifierPosition:j}};return r?i=>r({className:i,parseClassName:l}):l},Kxt=t=>{if(t.length<=1)return t;const s=[];let r=[];return t.forEach(n=>{n[0]==="["?(s.push(...r.sort(),n),r=[]):r.push(n)}),s.push(...r.sort()),s},Zxt=t=>({cache:Wxt(t.cacheSize),parseClassName:Gxt(t),...$xt(t)}),Yxt=/\s+/,Xxt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(Yxt);let i="";for(let c=l.length-1;c>=0;c-=1){const u=l[c],{modifiers:p,hasImportantModifier:f,baseClassName:g,maybePostfixModifierPosition:b}=r(u);let _=!!b,j=n(_?g.substring(0,b):g);if(!j){if(!_){i=u+(i.length>0?" "+i:i);continue}if(j=n(g),!j){i=u+(i.length>0?" "+i:i);continue}_=!1}const w=Kxt(p).join(":"),N=f?w+lqe:w,S=N+j;if(o.includes(S))continue;o.push(S);const M=a(j,_);for(let L=0;L0?" "+i:i)}return i};function Qxt(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;nf(p),t());return r=Zxt(u),n=r.cache.get,a=r.cache.set,o=i,i(c)}function i(c){const u=n(c);if(u)return u;const p=Xxt(c,r);return a(c,p),p}return function(){return o(Qxt.apply(null,arguments))}}const hc=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},dqe=/^\[(?:([a-z-]+):)?(.+)\]$/i,egt=/^\d+\/\d+$/,tgt=new Set(["px","full","screen"]),sgt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,rgt=/\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$/,ngt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,agt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,igt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_v=t=>WM(t)||tgt.has(t)||egt.test(t),Ab=t=>zA(t,"length",pgt),WM=t=>!!t&&!Number.isNaN(Number(t)),Qfe=t=>zA(t,"number",WM),FP=t=>!!t&&Number.isInteger(Number(t)),ogt=t=>t.endsWith("%")&&WM(t.slice(0,-1)),Yi=t=>dqe.test(t),Eb=t=>sgt.test(t),lgt=new Set(["length","size","percentage"]),cgt=t=>zA(t,lgt,uqe),dgt=t=>zA(t,"position",uqe),ugt=new Set(["image","url"]),hgt=t=>zA(t,ugt,xgt),mgt=t=>zA(t,"",fgt),zP=()=>!0,zA=(t,s,r)=>{const n=dqe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},pgt=t=>rgt.test(t)&&!ngt.test(t),uqe=()=>!1,fgt=t=>agt.test(t),xgt=t=>igt.test(t),ggt=()=>{const t=hc("colors"),s=hc("spacing"),r=hc("blur"),n=hc("brightness"),a=hc("borderColor"),o=hc("borderRadius"),l=hc("borderSpacing"),i=hc("borderWidth"),c=hc("contrast"),u=hc("grayscale"),p=hc("hueRotate"),f=hc("invert"),g=hc("gap"),b=hc("gradientColorStops"),_=hc("gradientColorStopPositions"),j=hc("inset"),w=hc("margin"),N=hc("opacity"),S=hc("padding"),M=hc("saturate"),L=hc("scale"),I=hc("sepia"),O=hc("skew"),q=hc("space"),U=hc("translate"),B=()=>["auto","contain","none"],V=()=>["auto","hidden","clip","visible","scroll"],Y=()=>["auto",Yi,s],Q=()=>[Yi,s],ee=()=>["",_v,Ab],X=()=>["auto",WM,Yi],ie=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],re=()=>["solid","dashed","dotted","double","none"],oe=()=>["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",Yi],ye=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ue=()=>[WM,Yi];return{cacheSize:500,separator:":",theme:{colors:[zP],spacing:[_v,Ab],blur:["none","",Eb,Yi],brightness:ue(),borderColor:[t],borderRadius:["none","","full",Eb,Yi],borderSpacing:Q(),borderWidth:ee(),contrast:ue(),grayscale:ge(),hueRotate:ue(),invert:ge(),gap:Q(),gradientColorStops:[t],gradientColorStopPositions:[ogt,Ab],inset:Y(),margin:Y(),opacity:ue(),padding:Q(),saturate:ue(),scale:ue(),sepia:ge(),skew:ue(),space:Q(),translate:Q()},classGroups:{aspect:[{aspect:["auto","square","video",Yi]}],container:["container"],columns:[{columns:[Eb]}],"break-after":[{"break-after":ye()}],"break-before":[{"break-before":ye()}],"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:[...ie(),Yi]}],overflow:[{overflow:V()}],"overflow-x":[{"overflow-x":V()}],"overflow-y":[{"overflow-y":V()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[j]}],"inset-x":[{"inset-x":[j]}],"inset-y":[{"inset-y":[j]}],start:[{start:[j]}],end:[{end:[j]}],top:[{top:[j]}],right:[{right:[j]}],bottom:[{bottom:[j]}],left:[{left:[j]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",FP,Yi]}],basis:[{basis:Y()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Yi]}],grow:[{grow:ge()}],shrink:[{shrink:ge()}],order:[{order:["first","last","none",FP,Yi]}],"grid-cols":[{"grid-cols":[zP]}],"col-start-end":[{col:["auto",{span:["full",FP,Yi]},Yi]}],"col-start":[{"col-start":X()}],"col-end":[{"col-end":X()}],"grid-rows":[{"grid-rows":[zP]}],"row-start-end":[{row:["auto",{span:[FP,Yi]},Yi]}],"row-start":[{"row-start":X()}],"row-end":[{"row-end":X()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Yi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Yi]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...ce()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ce(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ce(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[q]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[q]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Yi,s]}],"min-w":[{"min-w":[Yi,s,"min","max","fit"]}],"max-w":[{"max-w":[Yi,s,"none","full","min","max","fit","prose",{screen:[Eb]},Eb]}],h:[{h:[Yi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Yi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Yi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Yi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Eb,Ab]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Qfe]}],"font-family":[{font:[zP]}],"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",Yi]}],"line-clamp":[{"line-clamp":["none",WM,Qfe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",_v,Yi]}],"list-image":[{"list-image":["none",Yi]}],"list-style-type":[{list:["none","disc","decimal",Yi]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",_v,Ab]}],"underline-offset":[{"underline-offset":["auto",_v,Yi]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Q()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Yi]}],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",Yi]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ie(),dgt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",cgt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},hgt]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[_]}],"gradient-via-pos":[{via:[_]}],"gradient-to-pos":[{to:[_]}],"gradient-from":[{from:[b]}],"gradient-via":[{via:[b]}],"gradient-to":[{to:[b]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[N]}],"border-style":[{border:[...re(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[N]}],"divide-style":[{divide:re()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...re()]}],"outline-offset":[{"outline-offset":[_v,Yi]}],"outline-w":[{outline:[_v,Ab]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[_v,Ab]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Eb,mgt]}],"shadow-color":[{shadow:[zP]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...oe(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":oe()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",Eb,Yi]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[f]}],saturate:[{saturate:[M]}],sepia:[{sepia:[I]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[M]}],"backdrop-sepia":[{"backdrop-sepia":[I]}],"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",Yi]}],duration:[{duration:ue()}],ease:[{ease:["linear","in","out","in-out",Yi]}],delay:[{delay:ue()}],animate:[{animate:["none","spin","ping","pulse","bounce",Yi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[L]}],"scale-x":[{"scale-x":[L]}],"scale-y":[{"scale-y":[L]}],rotate:[{rotate:[FP,Yi]}],"translate-x":[{"translate-x":[U]}],"translate-y":[{"translate-y":[U]}],"skew-x":[{"skew-x":[O]}],"skew-y":[{"skew-y":[O]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Yi]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Yi]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Q()}],"scroll-mx":[{"scroll-mx":Q()}],"scroll-my":[{"scroll-my":Q()}],"scroll-ms":[{"scroll-ms":Q()}],"scroll-me":[{"scroll-me":Q()}],"scroll-mt":[{"scroll-mt":Q()}],"scroll-mr":[{"scroll-mr":Q()}],"scroll-mb":[{"scroll-mb":Q()}],"scroll-ml":[{"scroll-ml":Q()}],"scroll-p":[{"scroll-p":Q()}],"scroll-px":[{"scroll-px":Q()}],"scroll-py":[{"scroll-py":Q()}],"scroll-ps":[{"scroll-ps":Q()}],"scroll-pe":[{"scroll-pe":Q()}],"scroll-pt":[{"scroll-pt":Q()}],"scroll-pr":[{"scroll-pr":Q()}],"scroll-pb":[{"scroll-pb":Q()}],"scroll-pl":[{"scroll-pl":Q()}],"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",Yi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[_v,Ab,Qfe]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},ygt=Jxt(ggt);function It(...t){return ygt(Vi(t))}function Zl(t,s=!1){return s&&t>=1e6?`$${(t/1e6).toFixed(1)}M`:s&&t>=1e3?`$${(t/1e3).toFixed(0)}K`:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(t)}function LAe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function jde(t){return t?t.replace(/<[^>]*>/g,""):""}const vgt=Rxt,hqe=k.forwardRef(({className:t,...s},r)=>e.jsx(Q$e,{ref:r,className:It("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));hqe.displayName=Q$e.displayName;const bgt=pC("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"}}),mqe=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(J$e,{ref:n,className:It(bgt({variant:s}),t),...r}));mqe.displayName=J$e.displayName;const _gt=k.forwardRef(({className:t,...s},r)=>e.jsx(sqe,{ref:r,className:It("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...s}));_gt.displayName=sqe.displayName;const pqe=k.forwardRef(({className:t,...s},r)=>e.jsx(rqe,{ref:r,className:It("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Rr,{className:"h-4 w-4"})}));pqe.displayName=rqe.displayName;const fqe=k.forwardRef(({className:t,...s},r)=>e.jsx(eqe,{ref:r,className:It("text-sm font-semibold",t),...s}));fqe.displayName=eqe.displayName;const xqe=k.forwardRef(({className:t,...s},r)=>e.jsx(tqe,{ref:r,className:It("text-sm opacity-90",t),...s}));xqe.displayName=tqe.displayName;function wgt(){const{toasts:t}=Ua();return e.jsxs(vgt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(mqe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(fqe,{children:r}),n&&e.jsx(xqe,{children:n})]}),a,e.jsx(pqe,{})]},s)}),e.jsx(hqe,{})]})}var DAe=["light","dark"],jgt="(prefers-color-scheme: dark)",Ngt=k.createContext(void 0),kgt={setTheme:t=>{},themes:[]},Sgt=()=>{var t;return(t=k.useContext(Ngt))!=null?t:kgt};k.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:c})=>{let u=o==="system",p=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(_=>`'${_}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,f=a?DAe.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",g=(_,j=!1,w=!0)=>{let N=l?l[_]:_,S=j?_+"|| ''":`'${N}'`,M="";return a&&w&&!j&&DAe.includes(_)&&(M+=`d.style.colorScheme = '${_}';`),r==="class"?j||N?M+=`c.add(${S})`:M+="null":N&&(M+=`d[s](n,${S})`),M},b=t?`!function(){${p}${g(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${jgt}',m=window.matchMedia(t);if(m.media!==t||m.matches){${g("dark")}}else{${g("light")}}}else if(e){${l?`var x=${JSON.stringify(l)};`:""}${g(l?"x[e]":"e",!0)}}${u?"":"else{"+g(o,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${s}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${g(l?"x[e]":"e",!0)}}else{${g(o,!1,!1)};}${f}}catch(t){}}();`;return k.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:b}})});var Cgt=t=>{switch(t){case"success":return Agt;case"info":return Pgt;case"warning":return Egt;case"error":return Igt;default:return null}},Mgt=Array(12).fill(0),Tgt=({visible:t,className:s})=>ht.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ht.createElement("div",{className:"sonner-spinner"},Mgt.map((r,n)=>ht.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Agt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Egt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Pgt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Igt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Lgt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ht.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ht.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Dgt=()=>{let[t,s]=ht.useState(document.hidden);return ht.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},O0e=1,Ogt=class{constructor(){this.subscribe=s=>(this.subscribers.push(s),()=>{let r=this.subscribers.indexOf(s);this.subscribers.splice(r,1)}),this.publish=s=>{this.subscribers.forEach(r=>r(s))},this.addToast=s=>{this.publish(s),this.toasts=[...this.toasts,s]},this.create=s=>{var r;let{message:n,...a}=s,o=typeof(s==null?void 0:s.id)=="number"||((r=s.id)==null?void 0:r.length)>0?s.id:O0e++,l=this.toasts.find(c=>c.id===o),i=s.dismissible===void 0?!0:s.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),l?this.toasts=this.toasts.map(c=>c.id===o?(this.publish({...c,...s,id:o,title:n}),{...c,...s,id:o,dismissible:i,title:n}):c):this.addToast({title:n,...a,dismissible:i,id:o}),o},this.dismiss=s=>(this.dismissedToasts.add(s),s||this.toasts.forEach(r=>{this.subscribers.forEach(n=>n({id:r.id,dismiss:!0}))}),this.subscribers.forEach(r=>r({id:s,dismiss:!0})),s),this.message=(s,r)=>this.create({...r,message:s}),this.error=(s,r)=>this.create({...r,message:s,type:"error"}),this.success=(s,r)=>this.create({...r,type:"success",message:s}),this.info=(s,r)=>this.create({...r,type:"info",message:s}),this.warning=(s,r)=>this.create({...r,type:"warning",message:s}),this.loading=(s,r)=>this.create({...r,type:"loading",message:s}),this.promise=(s,r)=>{if(!r)return;let n;r.loading!==void 0&&(n=this.create({...r,promise:s,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));let a=s instanceof Promise?s:s(),o=n!==void 0,l,i=a.then(async u=>{if(l=["resolve",u],ht.isValidElement(u))o=!1,this.create({id:n,type:"default",message:u});else if(Fgt(u)&&!u.ok){o=!1;let p=typeof r.error=="function"?await r.error(`HTTP error! status: ${u.status}`):r.error,f=typeof r.description=="function"?await r.description(`HTTP error! status: ${u.status}`):r.description;this.create({id:n,type:"error",message:p,description:f})}else if(r.success!==void 0){o=!1;let p=typeof r.success=="function"?await r.success(u):r.success,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"success",message:p,description:f})}}).catch(async u=>{if(l=["reject",u],r.error!==void 0){o=!1;let p=typeof r.error=="function"?await r.error(u):r.error,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"error",message:p,description:f})}}).finally(()=>{var u;o&&(this.dismiss(n),n=void 0),(u=r.finally)==null||u.call(r)}),c=()=>new Promise((u,p)=>i.then(()=>l[0]==="reject"?p(l[1]):u(l[1])).catch(p));return typeof n!="string"&&typeof n!="number"?{unwrap:c}:Object.assign(n,{unwrap:c})},this.custom=(s,r)=>{let n=(r==null?void 0:r.id)||O0e++;return this.create({jsx:s(n),id:n,...r}),n},this.getActiveToasts=()=>this.toasts.filter(s=>!this.dismissedToasts.has(s.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},up=new Ogt,Rgt=(t,s)=>{let r=(s==null?void 0:s.id)||O0e++;return up.addToast({title:t,...s,id:r}),r},Fgt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",zgt=Rgt,Bgt=()=>up.toasts,$gt=()=>up.getActiveToasts(),me=Object.assign(zgt,{success:up.success,info:up.info,warning:up.warning,error:up.error,custom:up.custom,message:up.message,promise:up.promise,dismiss:up.dismiss,loading:up.loading},{getHistory:Bgt,getToasts:$gt});function qgt(t,{insertAt:s}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",s==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}qgt(`: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 F7(t){return t.label!==void 0}var Ugt=3,Vgt="32px",Hgt="16px",OAe=4e3,Wgt=356,Ggt=14,Kgt=20,Zgt=200;function Ng(...t){return t.filter(Boolean).join(" ")}function Ygt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var Xgt=t=>{var s,r,n,a,o,l,i,c,u,p,f;let{invert:g,toast:b,unstyled:_,interacting:j,setHeights:w,visibleToasts:N,heights:S,index:M,toasts:L,expanded:I,removeToast:O,defaultRichColors:q,closeButton:U,style:B,cancelButtonStyle:V,actionButtonStyle:Y,className:Q="",descriptionClassName:ee="",duration:X,position:ie,gap:re,loadingIcon:oe,expandByDefault:ce,classNames:ge,icons:ye,closeButtonAriaLabel:ue="Close toast",pauseWhenPageIsHidden:pe}=t,[_e,$e]=ht.useState(null),[Ae,Ie]=ht.useState(null),[Ce,xe]=ht.useState(!1),[we,Le]=ht.useState(!1),[tt,Te]=ht.useState(!1),[pt,fe]=ht.useState(!1),[qe,at]=ht.useState(!1),[et,Me]=ht.useState(0),[rt,He]=ht.useState(0),ct=ht.useRef(b.duration||X||OAe),Ue=ht.useRef(null),Ze=ht.useRef(null),Qe=M===0,We=M+1<=N,Je=b.type,it=b.dismissible!==!1,Dt=b.className||"",Vt=b.descriptionClassName||"",hs=ht.useMemo(()=>S.findIndex(Wr=>Wr.toastId===b.id)||0,[S,b.id]),Ts=ht.useMemo(()=>{var Wr;return(Wr=b.closeButton)!=null?Wr:U},[b.closeButton,U]),Cs=ht.useMemo(()=>b.duration||X||OAe,[b.duration,X]),cs=ht.useRef(0),er=ht.useRef(0),xt=ht.useRef(0),Es=ht.useRef(null),[ur,Mr]=ie.split("-"),Lr=ht.useMemo(()=>S.reduce((Wr,dn,Yr)=>Yr>=hs?Wr:Wr+dn.height,0),[S,hs]),fn=Dgt(),ki=b.invert||g,Ea=Je==="loading";er.current=ht.useMemo(()=>hs*re+Lr,[hs,Lr]),ht.useEffect(()=>{ct.current=Cs},[Cs]),ht.useEffect(()=>{xe(!0)},[]),ht.useEffect(()=>{let Wr=Ze.current;if(Wr){let dn=Wr.getBoundingClientRect().height;return He(dn),w(Yr=>[{toastId:b.id,height:dn,position:b.position},...Yr]),()=>w(Yr=>Yr.filter(vi=>vi.toastId!==b.id))}},[w,b.id]),ht.useLayoutEffect(()=>{if(!Ce)return;let Wr=Ze.current,dn=Wr.style.height;Wr.style.height="auto";let Yr=Wr.getBoundingClientRect().height;Wr.style.height=dn,He(Yr),w(vi=>vi.find(ft=>ft.toastId===b.id)?vi.map(ft=>ft.toastId===b.id?{...ft,height:Yr}:ft):[{toastId:b.id,height:Yr,position:b.position},...vi])},[Ce,b.title,b.description,w,b.id]);let dr=ht.useCallback(()=>{Le(!0),Me(er.current),w(Wr=>Wr.filter(dn=>dn.toastId!==b.id)),setTimeout(()=>{O(b)},Zgt)},[b,O,w,er]);ht.useEffect(()=>{if(b.promise&&Je==="loading"||b.duration===1/0||b.type==="loading")return;let Wr;return I||j||pe&&fn?(()=>{if(xt.current{var dn;(dn=b.onAutoClose)==null||dn.call(b,b),dr()},ct.current)),()=>clearTimeout(Wr)},[I,j,b,Je,pe,fn,dr]),ht.useEffect(()=>{b.delete&&dr()},[dr,b.delete]);function Jr(){var Wr,dn,Yr;return ye!=null&&ye.loading?ht.createElement("div",{className:Ng(ge==null?void 0:ge.loader,(Wr=b==null?void 0:b.classNames)==null?void 0:Wr.loader,"sonner-loader"),"data-visible":Je==="loading"},ye.loading):oe?ht.createElement("div",{className:Ng(ge==null?void 0:ge.loader,(dn=b==null?void 0:b.classNames)==null?void 0:dn.loader,"sonner-loader"),"data-visible":Je==="loading"},oe):ht.createElement(Tgt,{className:Ng(ge==null?void 0:ge.loader,(Yr=b==null?void 0:b.classNames)==null?void 0:Yr.loader),visible:Je==="loading"})}return ht.createElement("li",{tabIndex:0,ref:Ze,className:Ng(Q,Dt,ge==null?void 0:ge.toast,(s=b==null?void 0:b.classNames)==null?void 0:s.toast,ge==null?void 0:ge.default,ge==null?void 0:ge[Je],(r=b==null?void 0:b.classNames)==null?void 0:r[Je]),"data-sonner-toast":"","data-rich-colors":(n=b.richColors)!=null?n:q,"data-styled":!(b.jsx||b.unstyled||_),"data-mounted":Ce,"data-promise":!!b.promise,"data-swiped":qe,"data-removed":we,"data-visible":We,"data-y-position":ur,"data-x-position":Mr,"data-index":M,"data-front":Qe,"data-swiping":tt,"data-dismissible":it,"data-type":Je,"data-invert":ki,"data-swipe-out":pt,"data-swipe-direction":Ae,"data-expanded":!!(I||ce&&Ce),style:{"--index":M,"--toasts-before":M,"--z-index":L.length-M,"--offset":`${we?et:er.current}px`,"--initial-height":ce?"auto":`${rt}px`,...B,...b.style},onDragEnd:()=>{Te(!1),$e(null),Es.current=null},onPointerDown:Wr=>{Ea||!it||(Ue.current=new Date,Me(er.current),Wr.target.setPointerCapture(Wr.pointerId),Wr.target.tagName!=="BUTTON"&&(Te(!0),Es.current={x:Wr.clientX,y:Wr.clientY}))},onPointerUp:()=>{var Wr,dn,Yr,vi;if(pt||!it)return;Es.current=null;let ft=Number(((Wr=Ze.current)==null?void 0:Wr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ir=Number(((dn=Ze.current)==null?void 0:dn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Vn=new Date().getTime()-((Yr=Ue.current)==null?void 0:Yr.getTime()),Sr=_e==="x"?ft:ir,jr=Math.abs(Sr)/Vn;if(Math.abs(Sr)>=Kgt||jr>.11){Me(er.current),(vi=b.onDismiss)==null||vi.call(b,b),Ie(_e==="x"?ft>0?"right":"left":ir>0?"down":"up"),dr(),fe(!0),at(!1);return}Te(!1),$e(null)},onPointerMove:Wr=>{var dn,Yr,vi,ft;if(!Es.current||!it||((dn=window.getSelection())==null?void 0:dn.toString().length)>0)return;let ir=Wr.clientY-Es.current.y,Vn=Wr.clientX-Es.current.x,Sr=(Yr=t.swipeDirections)!=null?Yr:Ygt(ie);!_e&&(Math.abs(Vn)>1||Math.abs(ir)>1)&&$e(Math.abs(Vn)>Math.abs(ir)?"x":"y");let jr={x:0,y:0};_e==="y"?(Sr.includes("top")||Sr.includes("bottom"))&&(Sr.includes("top")&&ir<0||Sr.includes("bottom")&&ir>0)&&(jr.y=ir):_e==="x"&&(Sr.includes("left")||Sr.includes("right"))&&(Sr.includes("left")&&Vn<0||Sr.includes("right")&&Vn>0)&&(jr.x=Vn),(Math.abs(jr.x)>0||Math.abs(jr.y)>0)&&at(!0),(vi=Ze.current)==null||vi.style.setProperty("--swipe-amount-x",`${jr.x}px`),(ft=Ze.current)==null||ft.style.setProperty("--swipe-amount-y",`${jr.y}px`)}},Ts&&!b.jsx?ht.createElement("button",{"aria-label":ue,"data-disabled":Ea,"data-close-button":!0,onClick:Ea||!it?()=>{}:()=>{var Wr;dr(),(Wr=b.onDismiss)==null||Wr.call(b,b)},className:Ng(ge==null?void 0:ge.closeButton,(a=b==null?void 0:b.classNames)==null?void 0:a.closeButton)},(o=ye==null?void 0:ye.close)!=null?o:Lgt):null,b.jsx||k.isValidElement(b.title)?b.jsx?b.jsx:typeof b.title=="function"?b.title():b.title:ht.createElement(ht.Fragment,null,Je||b.icon||b.promise?ht.createElement("div",{"data-icon":"",className:Ng(ge==null?void 0:ge.icon,(l=b==null?void 0:b.classNames)==null?void 0:l.icon)},b.promise||b.type==="loading"&&!b.icon?b.icon||Jr():null,b.type!=="loading"?b.icon||(ye==null?void 0:ye[Je])||Cgt(Je):null):null,ht.createElement("div",{"data-content":"",className:Ng(ge==null?void 0:ge.content,(i=b==null?void 0:b.classNames)==null?void 0:i.content)},ht.createElement("div",{"data-title":"",className:Ng(ge==null?void 0:ge.title,(c=b==null?void 0:b.classNames)==null?void 0:c.title)},typeof b.title=="function"?b.title():b.title),b.description?ht.createElement("div",{"data-description":"",className:Ng(ee,Vt,ge==null?void 0:ge.description,(u=b==null?void 0:b.classNames)==null?void 0:u.description)},typeof b.description=="function"?b.description():b.description):null),k.isValidElement(b.cancel)?b.cancel:b.cancel&&F7(b.cancel)?ht.createElement("button",{"data-button":!0,"data-cancel":!0,style:b.cancelButtonStyle||V,onClick:Wr=>{var dn,Yr;F7(b.cancel)&&it&&((Yr=(dn=b.cancel).onClick)==null||Yr.call(dn,Wr),dr())},className:Ng(ge==null?void 0:ge.cancelButton,(p=b==null?void 0:b.classNames)==null?void 0:p.cancelButton)},b.cancel.label):null,k.isValidElement(b.action)?b.action:b.action&&F7(b.action)?ht.createElement("button",{"data-button":!0,"data-action":!0,style:b.actionButtonStyle||Y,onClick:Wr=>{var dn,Yr;F7(b.action)&&((Yr=(dn=b.action).onClick)==null||Yr.call(dn,Wr),!Wr.defaultPrevented&&dr())},className:Ng(ge==null?void 0:ge.actionButton,(f=b==null?void 0:b.classNames)==null?void 0:f.actionButton)},b.action.label):null))};function RAe(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function Qgt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?Hgt:Vgt;function c(u){["top","right","bottom","left"].forEach(p=>{r[`${l}-${p}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?c(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${l}-${u}`]=i:r[`${l}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):c(i)}),r}var Jgt=k.forwardRef(function(t,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:c,mobileOffset:u,theme:p="light",richColors:f,duration:g,style:b,visibleToasts:_=Ugt,toastOptions:j,dir:w=RAe(),gap:N=Ggt,loadingIcon:S,icons:M,containerAriaLabel:L="Notifications",pauseWhenPageIsHidden:I}=t,[O,q]=ht.useState([]),U=ht.useMemo(()=>Array.from(new Set([n].concat(O.filter(pe=>pe.position).map(pe=>pe.position)))),[O,n]),[B,V]=ht.useState([]),[Y,Q]=ht.useState(!1),[ee,X]=ht.useState(!1),[ie,re]=ht.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),oe=ht.useRef(null),ce=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),ge=ht.useRef(null),ye=ht.useRef(!1),ue=ht.useCallback(pe=>{q(_e=>{var $e;return($e=_e.find(Ae=>Ae.id===pe.id))!=null&&$e.delete||up.dismiss(pe.id),_e.filter(({id:Ae})=>Ae!==pe.id)})},[]);return ht.useEffect(()=>up.subscribe(pe=>{if(pe.dismiss){q(_e=>_e.map($e=>$e.id===pe.id?{...$e,delete:!0}:$e));return}setTimeout(()=>{u2e.flushSync(()=>{q(_e=>{let $e=_e.findIndex(Ae=>Ae.id===pe.id);return $e!==-1?[..._e.slice(0,$e),{..._e[$e],...pe},..._e.slice($e+1)]:[pe,..._e]})})})}),[]),ht.useEffect(()=>{if(p!=="system"){re(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?re("dark"):re("light")),typeof window>"u")return;let pe=window.matchMedia("(prefers-color-scheme: dark)");try{pe.addEventListener("change",({matches:_e})=>{re(_e?"dark":"light")})}catch{pe.addListener(({matches:$e})=>{try{re($e?"dark":"light")}catch(Ae){console.error(Ae)}})}},[p]),ht.useEffect(()=>{O.length<=1&&Q(!1)},[O]),ht.useEffect(()=>{let pe=_e=>{var $e,Ae;a.every(Ie=>_e[Ie]||_e.code===Ie)&&(Q(!0),($e=oe.current)==null||$e.focus()),_e.code==="Escape"&&(document.activeElement===oe.current||(Ae=oe.current)!=null&&Ae.contains(document.activeElement))&&Q(!1)};return document.addEventListener("keydown",pe),()=>document.removeEventListener("keydown",pe)},[a]),ht.useEffect(()=>{if(oe.current)return()=>{ge.current&&(ge.current.focus({preventScroll:!0}),ge.current=null,ye.current=!1)}},[oe.current]),ht.createElement("section",{ref:s,"aria-label":`${L} ${ce}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},U.map((pe,_e)=>{var $e;let[Ae,Ie]=pe.split("-");return O.length?ht.createElement("ol",{key:pe,dir:w==="auto"?RAe():w,tabIndex:-1,ref:oe,className:i,"data-sonner-toaster":!0,"data-theme":ie,"data-y-position":Ae,"data-lifted":Y&&O.length>1&&!o,"data-x-position":Ie,style:{"--front-toast-height":`${(($e=B[0])==null?void 0:$e.height)||0}px`,"--width":`${Wgt}px`,"--gap":`${N}px`,...b,...Qgt(c,u)},onBlur:Ce=>{ye.current&&!Ce.currentTarget.contains(Ce.relatedTarget)&&(ye.current=!1,ge.current&&(ge.current.focus({preventScroll:!0}),ge.current=null))},onFocus:Ce=>{Ce.target instanceof HTMLElement&&Ce.target.dataset.dismissible==="false"||ye.current||(ye.current=!0,ge.current=Ce.relatedTarget)},onMouseEnter:()=>Q(!0),onMouseMove:()=>Q(!0),onMouseLeave:()=>{ee||Q(!1)},onDragEnd:()=>Q(!1),onPointerDown:Ce=>{Ce.target instanceof HTMLElement&&Ce.target.dataset.dismissible==="false"||X(!0)},onPointerUp:()=>X(!1)},O.filter(Ce=>!Ce.position&&_e===0||Ce.position===pe).map((Ce,xe)=>{var we,Le;return ht.createElement(Xgt,{key:Ce.id,icons:M,index:xe,toast:Ce,defaultRichColors:f,duration:(we=j==null?void 0:j.duration)!=null?we:g,className:j==null?void 0:j.className,descriptionClassName:j==null?void 0:j.descriptionClassName,invert:r,visibleToasts:_,closeButton:(Le=j==null?void 0:j.closeButton)!=null?Le:l,interacting:ee,position:pe,style:j==null?void 0:j.style,unstyled:j==null?void 0:j.unstyled,classNames:j==null?void 0:j.classNames,cancelButtonStyle:j==null?void 0:j.cancelButtonStyle,actionButtonStyle:j==null?void 0:j.actionButtonStyle,removeToast:ue,toasts:O.filter(tt=>tt.position==Ce.position),heights:B.filter(tt=>tt.position==Ce.position),setHeights:V,expandByDefault:o,gap:N,loadingIcon:S,expanded:Y,pauseWhenPageIsHidden:I,swipeDirections:t.swipeDirections})})):null}))});const eyt=({...t})=>{const{theme:s="system"}=Sgt();return e.jsx(Jgt,{theme:s,position:"top-center",className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})};var tyt=bwe[" useId ".trim().toString()]||(()=>{}),syt=0;function Tu(t){const[s,r]=k.useState(tyt());return jd(()=>{r(n=>n??String(syt++))},[t]),s?`radix-${s}`:""}const ryt=["top","right","bottom","left"],cw=Math.min,nf=Math.max,ooe=Math.round,z7=Math.floor,_0=t=>({x:t,y:t}),nyt={left:"right",right:"left",bottom:"top",top:"bottom"},ayt={start:"end",end:"start"};function R0e(t,s,r){return nf(t,cw(s,r))}function M1(t,s){return typeof t=="function"?t(s):t}function T1(t){return t.split("-")[0]}function BA(t){return t.split("-")[1]}function v2e(t){return t==="x"?"y":"x"}function b2e(t){return t==="y"?"height":"width"}const iyt=new Set(["top","bottom"]);function i0(t){return iyt.has(T1(t))?"y":"x"}function _2e(t){return v2e(i0(t))}function oyt(t,s,r){r===void 0&&(r=!1);const n=BA(t),a=_2e(t),o=b2e(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=loe(l)),[l,loe(l)]}function lyt(t){const s=loe(t);return[F0e(t),s,F0e(s)]}function F0e(t){return t.replace(/start|end/g,s=>ayt[s])}const FAe=["left","right"],zAe=["right","left"],cyt=["top","bottom"],dyt=["bottom","top"];function uyt(t,s,r){switch(t){case"top":case"bottom":return r?s?zAe:FAe:s?FAe:zAe;case"left":case"right":return s?cyt:dyt;default:return[]}}function hyt(t,s,r,n){const a=BA(t);let o=uyt(T1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(F0e)))),o}function loe(t){return t.replace(/left|right|bottom|top/g,s=>nyt[s])}function myt(t){return{top:0,right:0,bottom:0,left:0,...t}}function gqe(t){return typeof t!="number"?myt(t):{top:t,right:t,bottom:t,left:t}}function coe(t){const{x:s,y:r,width:n,height:a}=t;return{width:n,height:a,top:r,left:s,right:s+n,bottom:r+a,x:s,y:r}}function BAe(t,s,r){let{reference:n,floating:a}=t;const o=i0(s),l=_2e(s),i=b2e(l),c=T1(s),u=o==="y",p=n.x+n.width/2-a.width/2,f=n.y+n.height/2-a.height/2,g=n[i]/2-a[i]/2;let b;switch(c){case"top":b={x:p,y:n.y-a.height};break;case"bottom":b={x:p,y:n.y+n.height};break;case"right":b={x:n.x+n.width,y:f};break;case"left":b={x:n.x-a.width,y:f};break;default:b={x:n.x,y:n.y}}switch(BA(s)){case"start":b[l]-=g*(r&&u?-1:1);break;case"end":b[l]+=g*(r&&u?-1:1);break}return b}const pyt=async(t,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:l}=r,i=o.filter(Boolean),c=await(l.isRTL==null?void 0:l.isRTL(s));let u=await l.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:f}=BAe(u,n,c),g=n,b={},_=0;for(let j=0;j({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:c}=s,{element:u,padding:p=0}=M1(t,s)||{};if(u==null)return{};const f=gqe(p),g={x:r,y:n},b=_2e(a),_=b2e(b),j=await l.getDimensions(u),w=b==="y",N=w?"top":"left",S=w?"bottom":"right",M=w?"clientHeight":"clientWidth",L=o.reference[_]+o.reference[b]-g[b]-o.floating[_],I=g[b]-o.reference[b],O=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let q=O?O[M]:0;(!q||!await(l.isElement==null?void 0:l.isElement(O)))&&(q=i.floating[M]||o.floating[_]);const U=L/2-I/2,B=q/2-j[_]/2-1,V=cw(f[N],B),Y=cw(f[S],B),Q=V,ee=q-j[_]-Y,X=q/2-j[_]/2+U,ie=R0e(Q,X,ee),re=!c.arrow&&BA(a)!=null&&X!==ie&&o.reference[_]/2-(XX<=0)){var Y,Q;const X=(((Y=o.flip)==null?void 0:Y.index)||0)+1,ie=q[X];if(ie&&(!(f==="alignment"?S!==i0(ie):!1)||V.every(ce=>ce.overflows[0]>0&&i0(ce.placement)===S)))return{data:{index:X,overflows:V},reset:{placement:ie}};let re=(Q=V.filter(oe=>oe.overflows[0]<=0).sort((oe,ce)=>oe.overflows[1]-ce.overflows[1])[0])==null?void 0:Q.placement;if(!re)switch(b){case"bestFit":{var ee;const oe=(ee=V.filter(ce=>{if(O){const ge=i0(ce.placement);return ge===S||ge==="y"}return!0}).map(ce=>[ce.placement,ce.overflows.filter(ge=>ge>0).reduce((ge,ye)=>ge+ye,0)]).sort((ce,ge)=>ce[1]-ge[1])[0])==null?void 0:ee[0];oe&&(re=oe);break}case"initialPlacement":re=i;break}if(a!==re)return{reset:{placement:re}}}return{}}}};function $Ae(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function qAe(t){return ryt.some(s=>t[s]>=0)}const gyt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=M1(t,s);switch(n){case"referenceHidden":{const o=await q8(s,{...a,elementContext:"reference"}),l=$Ae(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:qAe(l)}}}case"escaped":{const o=await q8(s,{...a,altBoundary:!0}),l=$Ae(o,r.floating);return{data:{escapedOffsets:l,escaped:qAe(l)}}}default:return{}}}}},yqe=new Set(["left","top"]);async function yyt(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=T1(r),i=BA(r),c=i0(r)==="y",u=yqe.has(l)?-1:1,p=o&&c?-1:1,f=M1(s,t);let{mainAxis:g,crossAxis:b,alignmentAxis:_}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return i&&typeof _=="number"&&(b=i==="end"?_*-1:_),c?{x:b*p,y:g*u}:{x:g*u,y:b*p}}const vyt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var r,n;const{x:a,y:o,placement:l,middlewareData:i}=s,c=await yyt(s,t);return l===((r=i.offset)==null?void 0:r.placement)&&(n=i.arrow)!=null&&n.alignmentOffset?{}:{x:a+c.x,y:o+c.y,data:{...c,placement:l}}}}},byt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:w=>{let{x:N,y:S}=w;return{x:N,y:S}}},...c}=M1(t,s),u={x:r,y:n},p=await q8(s,c),f=i0(T1(a)),g=v2e(f);let b=u[g],_=u[f];if(o){const w=g==="y"?"top":"left",N=g==="y"?"bottom":"right",S=b+p[w],M=b-p[N];b=R0e(S,b,M)}if(l){const w=f==="y"?"top":"left",N=f==="y"?"bottom":"right",S=_+p[w],M=_-p[N];_=R0e(S,_,M)}const j=i.fn({...s,[g]:b,[f]:_});return{...j,data:{x:j.x-r,y:j.y-n,enabled:{[g]:o,[f]:l}}}}}},_yt=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:r,y:n,placement:a,rects:o,middlewareData:l}=s,{offset:i=0,mainAxis:c=!0,crossAxis:u=!0}=M1(t,s),p={x:r,y:n},f=i0(a),g=v2e(f);let b=p[g],_=p[f];const j=M1(i,s),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(c){const M=g==="y"?"height":"width",L=o.reference[g]-o.floating[M]+w.mainAxis,I=o.reference[g]+o.reference[M]-w.mainAxis;bI&&(b=I)}if(u){var N,S;const M=g==="y"?"width":"height",L=yqe.has(T1(a)),I=o.reference[f]-o.floating[M]+(L&&((N=l.offset)==null?void 0:N[f])||0)+(L?0:w.crossAxis),O=o.reference[f]+o.reference[M]+(L?0:((S=l.offset)==null?void 0:S[f])||0)-(L?w.crossAxis:0);_O&&(_=O)}return{[g]:b,[f]:_}}}},wyt=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var r,n;const{placement:a,rects:o,platform:l,elements:i}=s,{apply:c=()=>{},...u}=M1(t,s),p=await q8(s,u),f=T1(a),g=BA(a),b=i0(a)==="y",{width:_,height:j}=o.floating;let w,N;f==="top"||f==="bottom"?(w=f,N=g===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(N=f,w=g==="end"?"top":"bottom");const S=j-p.top-p.bottom,M=_-p.left-p.right,L=cw(j-p[w],S),I=cw(_-p[N],M),O=!s.middlewareData.shift;let q=L,U=I;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(U=M),(n=s.middlewareData.shift)!=null&&n.enabled.y&&(q=S),O&&!g){const V=nf(p.left,0),Y=nf(p.right,0),Q=nf(p.top,0),ee=nf(p.bottom,0);b?U=_-2*(V!==0||Y!==0?V+Y:nf(p.left,p.right)):q=j-2*(Q!==0||ee!==0?Q+ee:nf(p.top,p.bottom))}await c({...s,availableWidth:U,availableHeight:q});const B=await l.getDimensions(i.floating);return _!==B.width||j!==B.height?{reset:{rects:!0}}:{}}}};function Nde(){return typeof window<"u"}function $A(t){return vqe(t)?(t.nodeName||"").toLowerCase():"#document"}function xf(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function R0(t){var s;return(s=(vqe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function vqe(t){return Nde()?t instanceof Node||t instanceof xf(t).Node:!1}function iy(t){return Nde()?t instanceof Element||t instanceof xf(t).Element:!1}function M0(t){return Nde()?t instanceof HTMLElement||t instanceof xf(t).HTMLElement:!1}function UAe(t){return!Nde()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof xf(t).ShadowRoot}const jyt=new Set(["inline","contents"]);function bO(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=oy(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!jyt.has(a)}const Nyt=new Set(["table","td","th"]);function kyt(t){return Nyt.has($A(t))}const Syt=[":popover-open",":modal"];function kde(t){return Syt.some(s=>{try{return t.matches(s)}catch{return!1}})}const Cyt=["transform","translate","scale","rotate","perspective"],Myt=["transform","translate","scale","rotate","perspective","filter"],Tyt=["paint","layout","strict","content"];function w2e(t){const s=j2e(),r=iy(t)?oy(t):t;return Cyt.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!s&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!s&&(r.filter?r.filter!=="none":!1)||Myt.some(n=>(r.willChange||"").includes(n))||Tyt.some(n=>(r.contain||"").includes(n))}function Ayt(t){let s=dw(t);for(;M0(s)&&!ET(s);){if(w2e(s))return s;if(kde(s))return null;s=dw(s)}return null}function j2e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Eyt=new Set(["html","body","#document"]);function ET(t){return Eyt.has($A(t))}function oy(t){return xf(t).getComputedStyle(t)}function Sde(t){return iy(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function dw(t){if($A(t)==="html")return t;const s=t.assignedSlot||t.parentNode||UAe(t)&&t.host||R0(t);return UAe(s)?s.host:s}function bqe(t){const s=dw(t);return ET(s)?t.ownerDocument?t.ownerDocument.body:t.body:M0(s)&&bO(s)?s:bqe(s)}function U8(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=bqe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=xf(a);if(o){const i=z0e(l);return s.concat(l,l.visualViewport||[],bO(a)?a:[],i&&r?U8(i):[])}return s.concat(a,U8(a,[],r))}function z0e(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function _qe(t){const s=oy(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=M0(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=ooe(r)!==o||ooe(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function N2e(t){return iy(t)?t:t.contextElement}function GM(t){const s=N2e(t);if(!M0(s))return _0(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=_qe(s);let l=(o?ooe(r.width):r.width)/n,i=(o?ooe(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const Pyt=_0(0);function wqe(t){const s=xf(t);return!j2e()||!s.visualViewport?Pyt:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function Iyt(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==xf(t)?!1:s}function RS(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=N2e(t);let l=_0(1);s&&(n?iy(n)&&(l=GM(n)):l=GM(t));const i=Iyt(o,r,n)?wqe(o):_0(0);let c=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,p=a.width/l.x,f=a.height/l.y;if(o){const g=xf(o),b=n&&iy(n)?xf(n):n;let _=g,j=z0e(_);for(;j&&n&&b!==_;){const w=GM(j),N=j.getBoundingClientRect(),S=oy(j),M=N.left+(j.clientLeft+parseFloat(S.paddingLeft))*w.x,L=N.top+(j.clientTop+parseFloat(S.paddingTop))*w.y;c*=w.x,u*=w.y,p*=w.x,f*=w.y,c+=M,u+=L,_=xf(j),j=z0e(_)}}return coe({width:p,height:f,x:c,y:u})}function k2e(t,s){const r=Sde(t).scrollLeft;return s?s.left+r:RS(R0(t)).left+r}function jqe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:k2e(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function Lyt(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=R0(n),i=s?kde(s.floating):!1;if(n===l||i&&o)return r;let c={scrollLeft:0,scrollTop:0},u=_0(1);const p=_0(0),f=M0(n);if((f||!f&&!o)&&(($A(n)!=="body"||bO(l))&&(c=Sde(n)),M0(n))){const b=RS(n);u=GM(n),p.x=b.x+n.clientLeft,p.y=b.y+n.clientTop}const g=l&&!f&&!o?jqe(l,c,!0):_0(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+p.x+g.x,y:r.y*u.y-c.scrollTop*u.y+p.y+g.y}}function Dyt(t){return Array.from(t.getClientRects())}function Oyt(t){const s=R0(t),r=Sde(t),n=t.ownerDocument.body,a=nf(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=nf(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+k2e(t);const i=-r.scrollTop;return oy(n).direction==="rtl"&&(l+=nf(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function Ryt(t,s){const r=xf(t),n=R0(t),a=r.visualViewport;let o=n.clientWidth,l=n.clientHeight,i=0,c=0;if(a){o=a.width,l=a.height;const u=j2e();(!u||u&&s==="fixed")&&(i=a.offsetLeft,c=a.offsetTop)}return{width:o,height:l,x:i,y:c}}const Fyt=new Set(["absolute","fixed"]);function zyt(t,s){const r=RS(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=M0(t)?GM(t):_0(1),l=t.clientWidth*o.x,i=t.clientHeight*o.y,c=a*o.x,u=n*o.y;return{width:l,height:i,x:c,y:u}}function VAe(t,s,r){let n;if(s==="viewport")n=Ryt(t,r);else if(s==="document")n=Oyt(R0(t));else if(iy(s))n=zyt(s,r);else{const a=wqe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return coe(n)}function Nqe(t,s){const r=dw(t);return r===s||!iy(r)||ET(r)?!1:oy(r).position==="fixed"||Nqe(r,s)}function Byt(t,s){const r=s.get(t);if(r)return r;let n=U8(t,[],!1).filter(i=>iy(i)&&$A(i)!=="body"),a=null;const o=oy(t).position==="fixed";let l=o?dw(t):t;for(;iy(l)&&!ET(l);){const i=oy(l),c=w2e(l);!c&&i.position==="fixed"&&(a=null),(o?!c&&!a:!c&&i.position==="static"&&!!a&&Fyt.has(a.position)||bO(l)&&!c&&Nqe(t,l))?n=n.filter(p=>p!==l):a=i,l=dw(l)}return s.set(t,n),n}function $yt(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?kde(s)?[]:Byt(s,this._c):[].concat(r),n],i=l[0],c=l.reduce((u,p)=>{const f=VAe(s,p,a);return u.top=nf(f.top,u.top),u.right=cw(f.right,u.right),u.bottom=cw(f.bottom,u.bottom),u.left=nf(f.left,u.left),u},VAe(s,i,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function qyt(t){const{width:s,height:r}=_qe(t);return{width:s,height:r}}function Uyt(t,s,r){const n=M0(s),a=R0(s),o=r==="fixed",l=RS(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const c=_0(0);function u(){c.x=k2e(a)}if(n||!n&&!o)if(($A(s)!=="body"||bO(a))&&(i=Sde(s)),n){const b=RS(s,!0,o,s);c.x=b.x+s.clientLeft,c.y=b.y+s.clientTop}else a&&u();o&&!n&&a&&u();const p=a&&!n&&!o?jqe(a,i):_0(0),f=l.left+i.scrollLeft-c.x-p.x,g=l.top+i.scrollTop-c.y-p.y;return{x:f,y:g,width:l.width,height:l.height}}function Jfe(t){return oy(t).position==="static"}function HAe(t,s){if(!M0(t)||oy(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return R0(t)===r&&(r=r.ownerDocument.body),r}function kqe(t,s){const r=xf(t);if(kde(t))return r;if(!M0(t)){let a=dw(t);for(;a&&!ET(a);){if(iy(a)&&!Jfe(a))return a;a=dw(a)}return r}let n=HAe(t,s);for(;n&&kyt(n)&&Jfe(n);)n=HAe(n,s);return n&&ET(n)&&Jfe(n)&&!w2e(n)?r:n||Ayt(t)||r}const Vyt=async function(t){const s=this.getOffsetParent||kqe,r=this.getDimensions,n=await r(t.floating);return{reference:Uyt(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Hyt(t){return oy(t).direction==="rtl"}const Wyt={convertOffsetParentRelativeRectToViewportRelativeRect:Lyt,getDocumentElement:R0,getClippingRect:$yt,getOffsetParent:kqe,getElementRects:Vyt,getClientRects:Dyt,getDimensions:qyt,getScale:GM,isElement:iy,isRTL:Hyt};function Sqe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function Gyt(t,s){let r=null,n;const a=R0(t);function o(){var i;clearTimeout(n),(i=r)==null||i.disconnect(),r=null}function l(i,c){i===void 0&&(i=!1),c===void 0&&(c=1),o();const u=t.getBoundingClientRect(),{left:p,top:f,width:g,height:b}=u;if(i||s(),!g||!b)return;const _=z7(f),j=z7(a.clientWidth-(p+g)),w=z7(a.clientHeight-(f+b)),N=z7(p),M={rootMargin:-_+"px "+-j+"px "+-w+"px "+-N+"px",threshold:nf(0,cw(1,c))||1};let L=!0;function I(O){const q=O[0].intersectionRatio;if(q!==c){if(!L)return l();q?l(!1,q):n=setTimeout(()=>{l(!1,1e-7)},1e3)}q===1&&!Sqe(u,t.getBoundingClientRect())&&l(),L=!1}try{r=new IntersectionObserver(I,{...M,root:a.ownerDocument})}catch{r=new IntersectionObserver(I,M)}r.observe(t)}return l(!0),o}function Kyt(t,s,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=N2e(t),p=a||o?[...u?U8(u):[],...U8(s)]:[];p.forEach(N=>{a&&N.addEventListener("scroll",r,{passive:!0}),o&&N.addEventListener("resize",r)});const f=u&&i?Gyt(u,r):null;let g=-1,b=null;l&&(b=new ResizeObserver(N=>{let[S]=N;S&&S.target===u&&b&&(b.unobserve(s),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var M;(M=b)==null||M.observe(s)})),r()}),u&&!c&&b.observe(u),b.observe(s));let _,j=c?RS(t):null;c&&w();function w(){const N=RS(t);j&&!Sqe(j,N)&&r(),j=N,_=requestAnimationFrame(w)}return r(),()=>{var N;p.forEach(S=>{a&&S.removeEventListener("scroll",r),o&&S.removeEventListener("resize",r)}),f==null||f(),(N=b)==null||N.disconnect(),b=null,c&&cancelAnimationFrame(_)}}const Zyt=vyt,Yyt=byt,Xyt=xyt,Qyt=wyt,Jyt=gyt,WAe=fyt,e0t=_yt,t0t=(t,s,r)=>{const n=new Map,a={platform:Wyt,...r},o={...a.platform,_c:n};return pyt(t,s,{...a,platform:o})};var s0t=typeof document<"u",r0t=function(){},iie=s0t?k.useLayoutEffect:r0t;function doe(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let r,n,a;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(r=t.length,r!==s.length)return!1;for(n=r;n--!==0;)if(!doe(t[n],s[n]))return!1;return!0}if(a=Object.keys(t),r=a.length,r!==Object.keys(s).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(s,a[n]))return!1;for(n=r;n--!==0;){const o=a[n];if(!(o==="_owner"&&t.$$typeof)&&!doe(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function Cqe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function GAe(t,s){const r=Cqe(t);return Math.round(s*r)/r}function exe(t){const s=k.useRef(t);return iie(()=>{s.current=t}),s}function n0t(t){t===void 0&&(t={});const{placement:s="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:o,floating:l}={},transform:i=!0,whileElementsMounted:c,open:u}=t,[p,f]=k.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[g,b]=k.useState(n);doe(g,n)||b(n);const[_,j]=k.useState(null),[w,N]=k.useState(null),S=k.useCallback(ce=>{ce!==O.current&&(O.current=ce,j(ce))},[]),M=k.useCallback(ce=>{ce!==q.current&&(q.current=ce,N(ce))},[]),L=o||_,I=l||w,O=k.useRef(null),q=k.useRef(null),U=k.useRef(p),B=c!=null,V=exe(c),Y=exe(a),Q=exe(u),ee=k.useCallback(()=>{if(!O.current||!q.current)return;const ce={placement:s,strategy:r,middleware:g};Y.current&&(ce.platform=Y.current),t0t(O.current,q.current,ce).then(ge=>{const ye={...ge,isPositioned:Q.current!==!1};X.current&&!doe(U.current,ye)&&(U.current=ye,yp.flushSync(()=>{f(ye)}))})},[g,s,r,Y,Q]);iie(()=>{u===!1&&U.current.isPositioned&&(U.current.isPositioned=!1,f(ce=>({...ce,isPositioned:!1})))},[u]);const X=k.useRef(!1);iie(()=>(X.current=!0,()=>{X.current=!1}),[]),iie(()=>{if(L&&(O.current=L),I&&(q.current=I),L&&I){if(V.current)return V.current(L,I,ee);ee()}},[L,I,ee,V,B]);const ie=k.useMemo(()=>({reference:O,floating:q,setReference:S,setFloating:M}),[S,M]),re=k.useMemo(()=>({reference:L,floating:I}),[L,I]),oe=k.useMemo(()=>{const ce={position:r,left:0,top:0};if(!re.floating)return ce;const ge=GAe(re.floating,p.x),ye=GAe(re.floating,p.y);return i?{...ce,transform:"translate("+ge+"px, "+ye+"px)",...Cqe(re.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:ge,top:ye}},[r,i,re.floating,p.x,p.y]);return k.useMemo(()=>({...p,update:ee,refs:ie,elements:re,floatingStyles:oe}),[p,ee,ie,re,oe])}const a0t=t=>{function s(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:t,fn(r){const{element:n,padding:a}=typeof t=="function"?t(r):t;return n&&s(n)?n.current!=null?WAe({element:n.current,padding:a}).fn(r):{}:n?WAe({element:n,padding:a}).fn(r):{}}}},i0t=(t,s)=>({...Zyt(t),options:[t,s]}),o0t=(t,s)=>({...Yyt(t),options:[t,s]}),l0t=(t,s)=>({...e0t(t),options:[t,s]}),c0t=(t,s)=>({...Xyt(t),options:[t,s]}),d0t=(t,s)=>({...Qyt(t),options:[t,s]}),u0t=(t,s)=>({...Jyt(t),options:[t,s]}),h0t=(t,s)=>({...a0t(t),options:[t,s]});var m0t="Arrow",Mqe=k.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(nn.svg,{...o,ref:s,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});Mqe.displayName=m0t;var p0t=Mqe;function _O(t){const[s,r]=k.useState(void 0);return jd(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let l,i;if("borderBoxSize"in o){const c=o.borderBoxSize,u=Array.isArray(c)?c[0]:c;l=u.inlineSize,i=u.blockSize}else l=t.offsetWidth,i=t.offsetHeight;r({width:l,height:i})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),s}var S2e="Popper",[Tqe,F0]=ad(S2e),[f0t,Aqe]=Tqe(S2e),Eqe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=k.useState(null);return e.jsx(f0t,{scope:s,anchor:n,onAnchorChange:a,children:r})};Eqe.displayName=S2e;var Pqe="PopperAnchor",Iqe=k.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=Aqe(Pqe,r),l=k.useRef(null),i=qa(s,l);return k.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(nn.div,{...a,ref:i})});Iqe.displayName=Pqe;var C2e="PopperContent",[x0t,g0t]=Tqe(C2e),Lqe=k.forwardRef((t,s)=>{var Ce,xe,we,Le,tt,Te;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:g=!1,updatePositionStrategy:b="optimized",onPlaced:_,...j}=t,w=Aqe(C2e,r),[N,S]=k.useState(null),M=qa(s,pt=>S(pt)),[L,I]=k.useState(null),O=_O(L),q=(O==null?void 0:O.width)??0,U=(O==null?void 0:O.height)??0,B=n+(o!=="center"?"-"+o:""),V=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},Y=Array.isArray(u)?u:[u],Q=Y.length>0,ee={padding:V,boundary:Y.filter(v0t),altBoundary:Q},{refs:X,floatingStyles:ie,placement:re,isPositioned:oe,middlewareData:ce}=n0t({strategy:"fixed",placement:B,whileElementsMounted:(...pt)=>Kyt(...pt,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[i0t({mainAxis:a+U,alignmentAxis:l}),c&&o0t({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?l0t():void 0,...ee}),c&&c0t({...ee}),d0t({...ee,apply:({elements:pt,rects:fe,availableWidth:qe,availableHeight:at})=>{const{width:et,height:Me}=fe.reference,rt=pt.floating.style;rt.setProperty("--radix-popper-available-width",`${qe}px`),rt.setProperty("--radix-popper-available-height",`${at}px`),rt.setProperty("--radix-popper-anchor-width",`${et}px`),rt.setProperty("--radix-popper-anchor-height",`${Me}px`)}}),L&&h0t({element:L,padding:i}),b0t({arrowWidth:q,arrowHeight:U}),g&&u0t({strategy:"referenceHidden",...ee})]}),[ge,ye]=Rqe(re),ue=vd(_);jd(()=>{oe&&(ue==null||ue())},[oe,ue]);const pe=(Ce=ce.arrow)==null?void 0:Ce.x,_e=(xe=ce.arrow)==null?void 0:xe.y,$e=((we=ce.arrow)==null?void 0:we.centerOffset)!==0,[Ae,Ie]=k.useState();return jd(()=>{N&&Ie(window.getComputedStyle(N).zIndex)},[N]),e.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...ie,transform:oe?ie.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ae,"--radix-popper-transform-origin":[(Le=ce.transformOrigin)==null?void 0:Le.x,(tt=ce.transformOrigin)==null?void 0:tt.y].join(" "),...((Te=ce.hide)==null?void 0:Te.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(x0t,{scope:r,placedSide:ge,onArrowChange:I,arrowX:pe,arrowY:_e,shouldHideArrow:$e,children:e.jsx(nn.div,{"data-side":ge,"data-align":ye,...j,ref:M,style:{...j.style,animation:oe?void 0:"none"}})})})});Lqe.displayName=C2e;var Dqe="PopperArrow",y0t={top:"bottom",right:"left",bottom:"top",left:"right"},Oqe=k.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=g0t(Dqe,n),l=y0t[o.placedSide];return e.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:e.jsx(p0t,{...a,ref:r,style:{...a.style,display:"block"}})})});Oqe.displayName=Dqe;function v0t(t){return t!==null}var b0t=t=>({name:"transformOrigin",options:t,fn(s){var w,N,S;const{placement:r,rects:n,middlewareData:a}=s,l=((w=a.arrow)==null?void 0:w.centerOffset)!==0,i=l?0:t.arrowWidth,c=l?0:t.arrowHeight,[u,p]=Rqe(r),f={start:"0%",center:"50%",end:"100%"}[p],g=(((N=a.arrow)==null?void 0:N.x)??0)+i/2,b=(((S=a.arrow)==null?void 0:S.y)??0)+c/2;let _="",j="";return u==="bottom"?(_=l?f:`${g}px`,j=`${-c}px`):u==="top"?(_=l?f:`${g}px`,j=`${n.floating.height+c}px`):u==="right"?(_=`${-c}px`,j=l?f:`${b}px`):u==="left"&&(_=`${n.floating.width+c}px`,j=l?f:`${b}px`),{data:{x:_,y:j}}}});function Rqe(t){const[s,r="center"]=t.split("-");return[s,r]}var wO=Eqe,qA=Iqe,jO=Lqe,NO=Oqe,[Cde]=ad("Tooltip",[F0]),Mde=F0(),Fqe="TooltipProvider",_0t=700,B0e="tooltip.open",[w0t,M2e]=Cde(Fqe),zqe=t=>{const{__scopeTooltip:s,delayDuration:r=_0t,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=k.useRef(!0),i=k.useRef(!1),c=k.useRef(0);return k.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),e.jsx(w0t,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:k.useCallback(()=>{window.clearTimeout(c.current),l.current=!1},[]),onClose:k.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:k.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};zqe.displayName=Fqe;var V8="Tooltip",[j0t,Tde]=Cde(V8),Bqe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,c=M2e(V8,t.__scopeTooltip),u=Mde(s),[p,f]=k.useState(null),g=Tu(),b=k.useRef(0),_=l??c.disableHoverableContent,j=i??c.delayDuration,w=k.useRef(!1),[N,S]=ah({prop:n,defaultProp:a??!1,onChange:q=>{q?(c.onOpen(),document.dispatchEvent(new CustomEvent(B0e))):c.onClose(),o==null||o(q)},caller:V8}),M=k.useMemo(()=>N?w.current?"delayed-open":"instant-open":"closed",[N]),L=k.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,S(!0)},[S]),I=k.useCallback(()=>{window.clearTimeout(b.current),b.current=0,S(!1)},[S]),O=k.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,S(!0),b.current=0},j)},[j,S]);return k.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),e.jsx(wO,{...u,children:e.jsx(j0t,{scope:s,contentId:g,open:N,stateAttribute:M,trigger:p,onTriggerChange:f,onTriggerEnter:k.useCallback(()=>{c.isOpenDelayedRef.current?O():L()},[c.isOpenDelayedRef,O,L]),onTriggerLeave:k.useCallback(()=>{_?I():(window.clearTimeout(b.current),b.current=0)},[I,_]),onOpen:L,onClose:I,disableHoverableContent:_,children:r})})};Bqe.displayName=V8;var $0e="TooltipTrigger",$qe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=Tde($0e,r),o=M2e($0e,r),l=Mde(r),i=k.useRef(null),c=qa(s,i,a.onTriggerChange),u=k.useRef(!1),p=k.useRef(!1),f=k.useCallback(()=>u.current=!1,[]);return k.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx(qA,{asChild:!0,...l,children:e.jsx(nn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:c,onPointerMove:Ir(t.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ir(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Ir(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Ir(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Ir(t.onBlur,a.onClose),onClick:Ir(t.onClick,a.onClose)})})});$qe.displayName=$0e;var N0t="TooltipPortal",[DMs,k0t]=Cde(N0t,{forceMount:void 0}),PT="TooltipContent",qqe=k.forwardRef((t,s)=>{const r=k0t(PT,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=Tde(PT,t.__scopeTooltip);return e.jsx(zd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(Uqe,{side:a,...o,ref:s}):e.jsx(S0t,{side:a,...o,ref:s})})}),S0t=k.forwardRef((t,s)=>{const r=Tde(PT,t.__scopeTooltip),n=M2e(PT,t.__scopeTooltip),a=k.useRef(null),o=qa(s,a),[l,i]=k.useState(null),{trigger:c,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,g=k.useCallback(()=>{i(null),f(!1)},[f]),b=k.useCallback((_,j)=>{const w=_.currentTarget,N={x:_.clientX,y:_.clientY},S=E0t(N,w.getBoundingClientRect()),M=P0t(N,S),L=I0t(j.getBoundingClientRect()),I=D0t([...M,...L]);i(I),f(!0)},[f]);return k.useEffect(()=>()=>g(),[g]),k.useEffect(()=>{if(c&&p){const _=w=>b(w,p),j=w=>b(w,c);return c.addEventListener("pointerleave",_),p.addEventListener("pointerleave",j),()=>{c.removeEventListener("pointerleave",_),p.removeEventListener("pointerleave",j)}}},[c,p,b,g]),k.useEffect(()=>{if(l){const _=j=>{const w=j.target,N={x:j.clientX,y:j.clientY},S=(c==null?void 0:c.contains(w))||(p==null?void 0:p.contains(w)),M=!L0t(N,l);S?g():M&&(g(),u())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[c,p,l,u,g]),e.jsx(Uqe,{...t,ref:o})}),[C0t,M0t]=Cde(V8,{isInside:!1}),T0t=L$e("TooltipContent"),Uqe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,c=Tde(PT,r),u=Mde(r),{onClose:p}=c;return k.useEffect(()=>(document.addEventListener(B0e,p),()=>document.removeEventListener(B0e,p)),[p]),k.useEffect(()=>{if(c.trigger){const f=g=>{const b=g.target;b!=null&&b.contains(c.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,p]),e.jsx(kw,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:e.jsxs(jO,{"data-state":c.stateAttribute,...u,...i,ref:s,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(T0t,{children:n}),e.jsx(C0t,{scope:r,isInside:!0,children:e.jsx(vxt,{id:c.contentId,role:"tooltip",children:a||n})})]})})});qqe.displayName=PT;var Vqe="TooltipArrow",A0t=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=Mde(r);return M0t(Vqe,r).isInside?null:e.jsx(NO,{...a,...n,ref:s})});A0t.displayName=Vqe;function E0t(t,s){const r=Math.abs(s.top-t.y),n=Math.abs(s.bottom-t.y),a=Math.abs(s.right-t.x),o=Math.abs(s.left-t.x);switch(Math.min(r,n,a,o)){case o:return"left";case a:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function P0t(t,s,r=5){const n=[];switch(s){case"top":n.push({x:t.x-r,y:t.y+r},{x:t.x+r,y:t.y+r});break;case"bottom":n.push({x:t.x-r,y:t.y-r},{x:t.x+r,y:t.y-r});break;case"left":n.push({x:t.x+r,y:t.y-r},{x:t.x+r,y:t.y+r});break;case"right":n.push({x:t.x-r,y:t.y-r},{x:t.x-r,y:t.y+r});break}return n}function I0t(t){const{top:s,right:r,bottom:n,left:a}=t;return[{x:a,y:s},{x:r,y:s},{x:r,y:n},{x:a,y:n}]}function L0t(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=g>n&&r<(f-u)*(n-p)/(g-p)+u&&(a=!a)}return a}function D0t(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),O0t(s)}function O0t(t){if(t.length<=1)return t.slice();const s=[];for(let n=0;n=2;){const o=s[s.length-1],l=s[s.length-2];if((o.x-l.x)*(a.y-l.y)>=(o.y-l.y)*(a.x-l.x))s.pop();else break}s.push(a)}s.pop();const r=[];for(let n=t.length-1;n>=0;n--){const a=t[n];for(;r.length>=2;){const o=r[r.length-1],l=r[r.length-2];if((o.x-l.x)*(a.y-l.y)>=(o.y-l.y)*(a.x-l.x))r.pop();else break}r.push(a)}return r.pop(),s.length===1&&r.length===1&&s[0].x===r[0].x&&s[0].y===r[0].y?s:s.concat(r)}var R0t=zqe,F0t=Bqe,z0t=$qe,Hqe=qqe;const B1=R0t,bc=F0t,_c=z0t,Xl=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Hqe,{ref:n,sideOffset:s,className:It("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));Xl.displayName=Hqe.displayName;var UA=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},FS=typeof window>"u"||"Deno"in globalThis;function _m(){}function B0t(t,s){return typeof t=="function"?t(s):t}function q0e(t){return typeof t=="number"&&t>=0&&t!==1/0}function Wqe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function Z_(t,s){return typeof t=="function"?t(s):t}function lx(t,s){return typeof t=="function"?t(s):t}function KAe(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==T2e(l,s.options))return!1}else if(!H8(s.queryKey,l))return!1}if(r!=="all"){const c=s.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof i=="boolean"&&s.isStale()!==i||a&&a!==s.state.fetchStatus||o&&!o(s))}function ZAe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(zS(s.options.mutationKey)!==zS(o))return!1}else if(!H8(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function T2e(t,s){return((s==null?void 0:s.queryKeyHashFn)||zS)(t)}function zS(t){return JSON.stringify(t,(s,r)=>U0e(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function H8(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>H8(t[r],s[r])):!1}function Gqe(t,s){if(t===s)return t;const r=YAe(t)&&YAe(s);if(r||U0e(t)&&U0e(s)){const n=r?t:Object.keys(t),a=n.length,o=r?s:Object.keys(s),l=o.length,i=r?[]:{},c=new Set(n);let u=0;for(let p=0;p{setTimeout(s,t)})}function V0e(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?Gqe(t,s):s}function q0t(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function U0t(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var A2e=Symbol();function Kqe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===A2e?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Zqe(t,s){return typeof t=="function"?t(...s):!!t}var L4,d_,hT,l9e,V0t=(l9e=class extends UA{constructor(){super();Xa(this,L4);Xa(this,d_);Xa(this,hT);Yn(this,hT,s=>{if(!FS&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){is(this,d_)||this.setEventListener(is(this,hT))}onUnsubscribe(){var s;this.hasListeners()||((s=is(this,d_))==null||s.call(this),Yn(this,d_,void 0))}setEventListener(s){var r;Yn(this,hT,s),(r=is(this,d_))==null||r.call(this),Yn(this,d_,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){is(this,L4)!==s&&(Yn(this,L4,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof is(this,L4)=="boolean"?is(this,L4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},L4=new WeakMap,d_=new WeakMap,hT=new WeakMap,l9e),E2e=new V0t,mT,u_,pT,c9e,H0t=(c9e=class extends UA{constructor(){super();Xa(this,mT,!0);Xa(this,u_);Xa(this,pT);Yn(this,pT,s=>{if(!FS&&window.addEventListener){const r=()=>s(!0),n=()=>s(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){is(this,u_)||this.setEventListener(is(this,pT))}onUnsubscribe(){var s;this.hasListeners()||((s=is(this,u_))==null||s.call(this),Yn(this,u_,void 0))}setEventListener(s){var r;Yn(this,pT,s),(r=is(this,u_))==null||r.call(this),Yn(this,u_,s(this.setOnline.bind(this)))}setOnline(s){is(this,mT)!==s&&(Yn(this,mT,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return is(this,mT)}},mT=new WeakMap,u_=new WeakMap,pT=new WeakMap,c9e),hoe=new H0t;function H0e(){let t,s;const r=new Promise((a,o)=>{t=a,s=o});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),t(a)},r.reject=a=>{n({status:"rejected",reason:a}),s(a)},r}function W0t(t){return Math.min(1e3*2**t,3e4)}function Yqe(t){return(t??"online")==="online"?hoe.isOnline():!0}var Xqe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function txe(t){return t instanceof Xqe}function Qqe(t){let s=!1,r=0,n=!1,a;const o=H0e(),l=j=>{var w;n||(g(new Xqe(j)),(w=t.abort)==null||w.call(t))},i=()=>{s=!0},c=()=>{s=!1},u=()=>E2e.isFocused()&&(t.networkMode==="always"||hoe.isOnline())&&t.canRun(),p=()=>Yqe(t.networkMode)&&t.canRun(),f=j=>{var w;n||(n=!0,(w=t.onSuccess)==null||w.call(t,j),a==null||a(),o.resolve(j))},g=j=>{var w;n||(n=!0,(w=t.onError)==null||w.call(t,j),a==null||a(),o.reject(j))},b=()=>new Promise(j=>{var w;a=N=>{(n||u())&&j(N)},(w=t.onPause)==null||w.call(t)}).then(()=>{var j;a=void 0,n||(j=t.onContinue)==null||j.call(t)}),_=()=>{if(n)return;let j;const w=r===0?t.initialPromise:void 0;try{j=w??t.fn()}catch(N){j=Promise.reject(N)}Promise.resolve(j).then(f).catch(N=>{var O;if(n)return;const S=t.retry??(FS?0:3),M=t.retryDelay??W0t,L=typeof M=="function"?M(r,N):M,I=S===!0||typeof S=="number"&&ru()?void 0:b()).then(()=>{s?g(N):_()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:c,canStart:p,start:()=>(p()?_():b().then(_),o)}}var G0t=t=>setTimeout(t,0);function K0t(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=G0t;const o=i=>{s?t.push(i):a(()=>{r(i)})},l=()=>{const i=t;t=[],i.length&&a(()=>{n(()=>{i.forEach(c=>{r(c)})})})};return{batch:i=>{let c;s++;try{c=i()}finally{s--,s||l()}return c},batchCalls:i=>(...c)=>{o(()=>{i(...c)})},schedule:o,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{a=i}}}var vu=K0t(),D4,d9e,Jqe=(d9e=class{constructor(){Xa(this,D4)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),q0e(this.gcTime)&&Yn(this,D4,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(FS?1/0:5*60*1e3))}clearGcTimeout(){is(this,D4)&&(clearTimeout(is(this,D4)),Yn(this,D4,void 0))}},D4=new WeakMap,d9e),fT,O4,ox,R4,zh,cO,F4,Lg,Tv,u9e,Z0t=(u9e=class extends Jqe{constructor(s){super();Xa(this,Lg);Xa(this,fT);Xa(this,O4);Xa(this,ox);Xa(this,R4);Xa(this,zh);Xa(this,cO);Xa(this,F4);Yn(this,F4,!1),Yn(this,cO,s.defaultOptions),this.setOptions(s.options),this.observers=[],Yn(this,R4,s.client),Yn(this,ox,is(this,R4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,Yn(this,fT,Y0t(this.options)),this.state=s.state??is(this,fT),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=is(this,zh))==null?void 0:s.promise}setOptions(s){this.options={...is(this,cO),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&is(this,ox).remove(this)}setData(s,r){const n=V0e(this.state.data,s,this.options);return Qi(this,Lg,Tv).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Qi(this,Lg,Tv).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=is(this,zh))==null?void 0:n.promise;return(a=is(this,zh))==null||a.cancel(s),r?r.then(_m).catch(_m):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(is(this,fT))}isActive(){return this.observers.some(s=>lx(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===A2e||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>Z_(s.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(s=>s.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(s=0){return this.state.data===void 0?!0:s==="static"?!1:this.state.isInvalidated?!0:!Wqe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=is(this,zh))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=is(this,zh))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),is(this,ox).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(is(this,zh)&&(is(this,F4)?is(this,zh).cancel({revert:!0}):is(this,zh).cancelRetry()),this.scheduleGc()),is(this,ox).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Qi(this,Lg,Tv).call(this,{type:"invalidate"})}fetch(s,r){var u,p,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(is(this,zh))return is(this,zh).continueRetry(),is(this,zh).promise}if(s&&this.setOptions(s),!this.options.queryFn){const g=this.observers.find(b=>b.options.queryFn);g&&this.setOptions(g.options)}const n=new AbortController,a=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(Yn(this,F4,!0),n.signal)})},o=()=>{const g=Kqe(this.options,r),_=(()=>{const j={client:is(this,R4),queryKey:this.queryKey,meta:this.meta};return a(j),j})();return Yn(this,F4,!1),this.options.persister?this.options.persister(g,_,this):g(_)},i=(()=>{const g={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:is(this,R4),state:this.state,fetchFn:o};return a(g),g})();(u=this.options.behavior)==null||u.onFetch(i,this),Yn(this,O4,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Qi(this,Lg,Tv).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta});const c=g=>{var b,_,j,w;txe(g)&&g.silent||Qi(this,Lg,Tv).call(this,{type:"error",error:g}),txe(g)||((_=(b=is(this,ox).config).onError)==null||_.call(b,g,this),(w=(j=is(this,ox).config).onSettled)==null||w.call(j,this.state.data,g,this)),this.scheduleGc()};return Yn(this,zh,Qqe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:g=>{var b,_,j,w;if(g===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(g)}catch(N){c(N);return}(_=(b=is(this,ox).config).onSuccess)==null||_.call(b,g,this),(w=(j=is(this,ox).config).onSettled)==null||w.call(j,g,this.state.error,this),this.scheduleGc()},onError:c,onFail:(g,b)=>{Qi(this,Lg,Tv).call(this,{type:"failed",failureCount:g,error:b})},onPause:()=>{Qi(this,Lg,Tv).call(this,{type:"pause"})},onContinue:()=>{Qi(this,Lg,Tv).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),is(this,zh).start()}},fT=new WeakMap,O4=new WeakMap,ox=new WeakMap,R4=new WeakMap,zh=new WeakMap,cO=new WeakMap,F4=new WeakMap,Lg=new WeakSet,Tv=function(s){const r=n=>{switch(s.type){case"failed":return{...n,fetchFailureCount:s.failureCount,fetchFailureReason:s.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...eUe(n.data,this.options),fetchMeta:s.meta??null};case"success":return Yn(this,O4,void 0),{...n,data:s.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:s.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!s.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=s.error;return txe(a)&&a.revert&&is(this,O4)?{...is(this,O4),fetchStatus:"idle"}:{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...s.state}}};this.state=r(this.state),vu.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),is(this,ox).notify({query:this,type:"updated",action:s})})},u9e);function eUe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Yqe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Y0t(t){const s=typeof t.initialData=="function"?t.initialData():t.initialData,r=s!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:s,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Xy,h9e,X0t=(h9e=class extends UA{constructor(s={}){super();Xa(this,Xy);this.config=s,Yn(this,Xy,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??T2e(a,r);let l=this.get(o);return l||(l=new Z0t({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){is(this,Xy).has(s.queryHash)||(is(this,Xy).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=is(this,Xy).get(s.queryHash);r&&(s.destroy(),r===s&&is(this,Xy).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){vu.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return is(this,Xy).get(s)}getAll(){return[...is(this,Xy).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>KAe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>KAe(s,n)):r}notify(s){vu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){vu.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){vu.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Xy=new WeakMap,h9e),Qy,ym,z4,Jy,zb,m9e,Q0t=(m9e=class extends Jqe{constructor(s){super();Xa(this,Jy);Xa(this,Qy);Xa(this,ym);Xa(this,z4);this.mutationId=s.mutationId,Yn(this,ym,s.mutationCache),Yn(this,Qy,[]),this.state=s.state||tUe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){is(this,Qy).includes(s)||(is(this,Qy).push(s),this.clearGcTimeout(),is(this,ym).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){Yn(this,Qy,is(this,Qy).filter(r=>r!==s)),this.scheduleGc(),is(this,ym).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){is(this,Qy).length||(this.state.status==="pending"?this.scheduleGc():is(this,ym).remove(this))}continue(){var s;return((s=is(this,z4))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,c,u,p,f,g,b,_,j,w,N,S,M,L,I,O,q,U;const r=()=>{Qi(this,Jy,zb).call(this,{type:"continue"})};Yn(this,z4,Qqe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(B,V)=>{Qi(this,Jy,zb).call(this,{type:"failed",failureCount:B,error:V})},onPause:()=>{Qi(this,Jy,zb).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>is(this,ym).canRun(this)}));const n=this.state.status==="pending",a=!is(this,z4).canStart();try{if(n)r();else{Qi(this,Jy,zb).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=is(this,ym).config).onMutate)==null?void 0:l.call(o,s,this));const V=await((c=(i=this.options).onMutate)==null?void 0:c.call(i,s));V!==this.state.context&&Qi(this,Jy,zb).call(this,{type:"pending",context:V,variables:s,isPaused:a})}const B=await is(this,z4).start();return await((p=(u=is(this,ym).config).onSuccess)==null?void 0:p.call(u,B,s,this.state.context,this)),await((g=(f=this.options).onSuccess)==null?void 0:g.call(f,B,s,this.state.context)),await((_=(b=is(this,ym).config).onSettled)==null?void 0:_.call(b,B,null,this.state.variables,this.state.context,this)),await((w=(j=this.options).onSettled)==null?void 0:w.call(j,B,null,s,this.state.context)),Qi(this,Jy,zb).call(this,{type:"success",data:B}),B}catch(B){try{throw await((S=(N=is(this,ym).config).onError)==null?void 0:S.call(N,B,s,this.state.context,this)),await((L=(M=this.options).onError)==null?void 0:L.call(M,B,s,this.state.context)),await((O=(I=is(this,ym).config).onSettled)==null?void 0:O.call(I,void 0,B,this.state.variables,this.state.context,this)),await((U=(q=this.options).onSettled)==null?void 0:U.call(q,void 0,B,s,this.state.context)),B}finally{Qi(this,Jy,zb).call(this,{type:"error",error:B})}}finally{is(this,ym).runNext(this)}}},Qy=new WeakMap,ym=new WeakMap,z4=new WeakMap,Jy=new WeakSet,zb=function(s){const r=n=>{switch(s.type){case"failed":return{...n,failureCount:s.failureCount,failureReason:s.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:s.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:s.isPaused,status:"pending",variables:s.variables,submittedAt:Date.now()};case"success":return{...n,data:s.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:s.error,failureCount:n.failureCount+1,failureReason:s.error,isPaused:!1,status:"error"}}};this.state=r(this.state),vu.batch(()=>{is(this,Qy).forEach(n=>{n.onMutationUpdate(s)}),is(this,ym).notify({mutation:this,type:"updated",action:s})})},m9e);function tUe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Uv,Dg,dO,p9e,J0t=(p9e=class extends UA{constructor(s={}){super();Xa(this,Uv);Xa(this,Dg);Xa(this,dO);this.config=s,Yn(this,Uv,new Set),Yn(this,Dg,new Map),Yn(this,dO,0)}build(s,r,n){const a=new Q0t({mutationCache:this,mutationId:++y7(this,dO)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){is(this,Uv).add(s);const r=B7(s);if(typeof r=="string"){const n=is(this,Dg).get(r);n?n.push(s):is(this,Dg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(is(this,Uv).delete(s)){const r=B7(s);if(typeof r=="string"){const n=is(this,Dg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&is(this,Dg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=B7(s);if(typeof r=="string"){const n=is(this,Dg).get(r),a=n==null?void 0:n.find(o=>o.state.status==="pending");return!a||a===s}else return!0}runNext(s){var n;const r=B7(s);if(typeof r=="string"){const a=(n=is(this,Dg).get(r))==null?void 0:n.find(o=>o!==s&&o.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){vu.batch(()=>{is(this,Uv).forEach(s=>{this.notify({type:"removed",mutation:s})}),is(this,Uv).clear(),is(this,Dg).clear()})}getAll(){return Array.from(is(this,Uv))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>ZAe(r,n))}findAll(s={}){return this.getAll().filter(r=>ZAe(s,r))}notify(s){vu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return vu.batch(()=>Promise.all(s.map(r=>r.continue().catch(_m))))}},Uv=new WeakMap,Dg=new WeakMap,dO=new WeakMap,p9e);function B7(t){var s;return(s=t.options.scope)==null?void 0:s.id}function moe(t){return{onFetch:(s,r)=>{var p,f,g,b,_;const n=s.options,a=(g=(f=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:f.fetchMore)==null?void 0:g.direction,o=((b=s.state.data)==null?void 0:b.pages)||[],l=((_=s.state.data)==null?void 0:_.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const u=async()=>{let j=!1;const w=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(s.signal.aborted?j=!0:s.signal.addEventListener("abort",()=>{j=!0}),s.signal)})},N=Kqe(s.options,s.fetchOptions),S=async(M,L,I)=>{if(j)return Promise.reject();if(L==null&&M.pages.length)return Promise.resolve(M);const q=(()=>{const Y={client:s.client,queryKey:s.queryKey,pageParam:L,direction:I?"backward":"forward",meta:s.options.meta};return w(Y),Y})(),U=await N(q),{maxPages:B}=s.options,V=I?U0t:q0t;return{pages:V(M.pages,U,B),pageParams:V(M.pageParams,L,B)}};if(a&&o.length){const M=a==="backward",L=M?sUe:W0e,I={pages:o,pageParams:l},O=L(n,I);i=await S(I,O,M)}else{const M=t??o.length;do{const L=c===0?l[0]??n.initialPageParam:W0e(n,i);if(c>0&&L==null)break;i=await S(i,L),c++}while(c{var j,w;return(w=(j=s.options).persister)==null?void 0:w.call(j,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function W0e(t,{pages:s,pageParams:r}){const n=s.length-1;return s.length>0?t.getNextPageParam(s[n],s,r[n],r):void 0}function sUe(t,{pages:s,pageParams:r}){var n;return s.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,s[0],s,r[0],r):void 0}function evt(t,s){return s?W0e(t,s)!=null:!1}function tvt(t,s){return!s||!t.getPreviousPageParam?!1:sUe(t,s)!=null}var ud,h_,m_,xT,gT,p_,yT,vT,f9e,svt=(f9e=class{constructor(t={}){Xa(this,ud);Xa(this,h_);Xa(this,m_);Xa(this,xT);Xa(this,gT);Xa(this,p_);Xa(this,yT);Xa(this,vT);Yn(this,ud,t.queryCache||new X0t),Yn(this,h_,t.mutationCache||new J0t),Yn(this,m_,t.defaultOptions||{}),Yn(this,xT,new Map),Yn(this,gT,new Map),Yn(this,p_,0)}mount(){y7(this,p_)._++,is(this,p_)===1&&(Yn(this,yT,E2e.subscribe(async t=>{t&&(await this.resumePausedMutations(),is(this,ud).onFocus())})),Yn(this,vT,hoe.subscribe(async t=>{t&&(await this.resumePausedMutations(),is(this,ud).onOnline())})))}unmount(){var t,s;y7(this,p_)._--,is(this,p_)===0&&((t=is(this,yT))==null||t.call(this),Yn(this,yT,void 0),(s=is(this,vT))==null||s.call(this),Yn(this,vT,void 0))}isFetching(t){return is(this,ud).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return is(this,h_).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=is(this,ud).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=is(this,ud).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Z_(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return is(this,ud).findAll(t).map(({queryKey:s,state:r})=>{const n=r.data;return[s,n]})}setQueryData(t,s,r){const n=this.defaultQueryOptions({queryKey:t}),a=is(this,ud).get(n.queryHash),o=a==null?void 0:a.state.data,l=B0t(s,o);if(l!==void 0)return is(this,ud).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return vu.batch(()=>is(this,ud).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=is(this,ud).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=is(this,ud);vu.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=is(this,ud);return vu.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=vu.batch(()=>is(this,ud).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(_m).catch(_m)}invalidateQueries(t,s={}){return vu.batch(()=>(is(this,ud).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},s)))}refetchQueries(t,s={}){const r={...s,cancelRefetch:s.cancelRefetch??!0},n=vu.batch(()=>is(this,ud).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(_m)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(_m)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=is(this,ud).build(this,s);return r.isStaleByTime(Z_(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(_m).catch(_m)}fetchInfiniteQuery(t){return t.behavior=moe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(_m).catch(_m)}ensureInfiniteQueryData(t){return t.behavior=moe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return hoe.isOnline()?is(this,h_).resumePausedMutations():Promise.resolve()}getQueryCache(){return is(this,ud)}getMutationCache(){return is(this,h_)}getDefaultOptions(){return is(this,m_)}setDefaultOptions(t){Yn(this,m_,t)}setQueryDefaults(t,s){is(this,xT).set(zS(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...is(this,xT).values()],r={};return s.forEach(n=>{H8(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){is(this,gT).set(zS(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...is(this,gT).values()],r={};return s.forEach(n=>{H8(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...is(this,m_).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=T2e(s.queryKey,s)),s.refetchOnReconnect===void 0&&(s.refetchOnReconnect=s.networkMode!=="always"),s.throwOnError===void 0&&(s.throwOnError=!!s.suspense),!s.networkMode&&s.persister&&(s.networkMode="offlineFirst"),s.queryFn===A2e&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...is(this,m_).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){is(this,ud).clear(),is(this,h_).clear()}},ud=new WeakMap,h_=new WeakMap,m_=new WeakMap,xT=new WeakMap,gT=new WeakMap,p_=new WeakMap,yT=new WeakMap,vT=new WeakMap,f9e),lp,Mo,uO,vm,B4,bT,f_,x_,hO,_T,wT,$4,q4,g_,jT,ll,vI,G0e,K0e,Z0e,Y0e,X0e,Q0e,J0e,nUe,x9e,rUe=(x9e=class extends UA{constructor(s,r){super();Xa(this,ll);Xa(this,lp);Xa(this,Mo);Xa(this,uO);Xa(this,vm);Xa(this,B4);Xa(this,bT);Xa(this,f_);Xa(this,x_);Xa(this,hO);Xa(this,_T);Xa(this,wT);Xa(this,$4);Xa(this,q4);Xa(this,g_);Xa(this,jT,new Set);this.options=r,Yn(this,lp,s),Yn(this,x_,null),Yn(this,f_,H0e()),this.options.experimental_prefetchInRender||is(this,f_).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(is(this,Mo).addObserver(this),QAe(is(this,Mo),this.options)?Qi(this,ll,vI).call(this):this.updateResult(),Qi(this,ll,Y0e).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return eve(is(this,Mo),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return eve(is(this,Mo),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Qi(this,ll,X0e).call(this),Qi(this,ll,Q0e).call(this),is(this,Mo).removeObserver(this)}setOptions(s){const r=this.options,n=is(this,Mo);if(this.options=is(this,lp).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof lx(this.options.enabled,is(this,Mo))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Qi(this,ll,J0e).call(this),is(this,Mo).setOptions(this.options),r._defaulted&&!uoe(this.options,r)&&is(this,lp).getQueryCache().notify({type:"observerOptionsUpdated",query:is(this,Mo),observer:this});const a=this.hasListeners();a&&JAe(is(this,Mo),n,this.options,r)&&Qi(this,ll,vI).call(this),this.updateResult(),a&&(is(this,Mo)!==n||lx(this.options.enabled,is(this,Mo))!==lx(r.enabled,is(this,Mo))||Z_(this.options.staleTime,is(this,Mo))!==Z_(r.staleTime,is(this,Mo)))&&Qi(this,ll,G0e).call(this);const o=Qi(this,ll,K0e).call(this);a&&(is(this,Mo)!==n||lx(this.options.enabled,is(this,Mo))!==lx(r.enabled,is(this,Mo))||o!==is(this,g_))&&Qi(this,ll,Z0e).call(this,o)}getOptimisticResult(s){const r=is(this,lp).getQueryCache().build(is(this,lp),s),n=this.createResult(r,s);return nvt(this,n)&&(Yn(this,vm,n),Yn(this,bT,this.options),Yn(this,B4,is(this,Mo).state)),n}getCurrentResult(){return is(this,vm)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){is(this,jT).add(s)}getCurrentQuery(){return is(this,Mo)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=is(this,lp).defaultQueryOptions(s),n=is(this,lp).getQueryCache().build(is(this,lp),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Qi(this,ll,vI).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),is(this,vm)))}createResult(s,r){var B;const n=is(this,Mo),a=this.options,o=is(this,vm),l=is(this,B4),i=is(this,bT),u=s!==n?s.state:is(this,uO),{state:p}=s;let f={...p},g=!1,b;if(r._optimisticResults){const V=this.hasListeners(),Y=!V&&QAe(s,r),Q=V&&JAe(s,n,r,a);(Y||Q)&&(f={...f,...eUe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:_,errorUpdatedAt:j,status:w}=f;b=f.data;let N=!1;if(r.placeholderData!==void 0&&b===void 0&&w==="pending"){let V;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(V=o.data,N=!0):V=typeof r.placeholderData=="function"?r.placeholderData((B=is(this,wT))==null?void 0:B.state.data,is(this,wT)):r.placeholderData,V!==void 0&&(w="success",b=V0e(o==null?void 0:o.data,V,r),g=!0)}if(r.select&&b!==void 0&&!N)if(o&&b===(l==null?void 0:l.data)&&r.select===is(this,hO))b=is(this,_T);else try{Yn(this,hO,r.select),b=r.select(b),b=V0e(o==null?void 0:o.data,b,r),Yn(this,_T,b),Yn(this,x_,null)}catch(V){Yn(this,x_,V)}is(this,x_)&&(_=is(this,x_),b=is(this,_T),j=Date.now(),w="error");const S=f.fetchStatus==="fetching",M=w==="pending",L=w==="error",I=M&&S,O=b!==void 0,U={status:w,fetchStatus:f.fetchStatus,isPending:M,isSuccess:w==="success",isError:L,isInitialLoading:I,isLoading:I,data:b,dataUpdatedAt:f.dataUpdatedAt,error:_,errorUpdatedAt:j,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!M,isLoadingError:L&&!O,isPaused:f.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:L&&O,isStale:P2e(s,r),refetch:this.refetch,promise:is(this,f_),isEnabled:lx(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const V=ee=>{U.status==="error"?ee.reject(U.error):U.data!==void 0&&ee.resolve(U.data)},Y=()=>{const ee=Yn(this,f_,U.promise=H0e());V(ee)},Q=is(this,f_);switch(Q.status){case"pending":s.queryHash===n.queryHash&&V(Q);break;case"fulfilled":(U.status==="error"||U.data!==Q.value)&&Y();break;case"rejected":(U.status!=="error"||U.error!==Q.reason)&&Y();break}}return U}updateResult(){const s=is(this,vm),r=this.createResult(is(this,Mo),this.options);if(Yn(this,B4,is(this,Mo).state),Yn(this,bT,this.options),is(this,B4).data!==void 0&&Yn(this,wT,is(this,Mo)),uoe(r,s))return;Yn(this,vm,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!is(this,jT).size)return!0;const l=new Set(o??is(this,jT));return this.options.throwOnError&&l.add("error"),Object.keys(is(this,vm)).some(i=>{const c=i;return is(this,vm)[c]!==s[c]&&l.has(c)})};Qi(this,ll,nUe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Qi(this,ll,Y0e).call(this)}},lp=new WeakMap,Mo=new WeakMap,uO=new WeakMap,vm=new WeakMap,B4=new WeakMap,bT=new WeakMap,f_=new WeakMap,x_=new WeakMap,hO=new WeakMap,_T=new WeakMap,wT=new WeakMap,$4=new WeakMap,q4=new WeakMap,g_=new WeakMap,jT=new WeakMap,ll=new WeakSet,vI=function(s){Qi(this,ll,J0e).call(this);let r=is(this,Mo).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(_m)),r},G0e=function(){Qi(this,ll,X0e).call(this);const s=Z_(this.options.staleTime,is(this,Mo));if(FS||is(this,vm).isStale||!q0e(s))return;const n=Wqe(is(this,vm).dataUpdatedAt,s)+1;Yn(this,$4,setTimeout(()=>{is(this,vm).isStale||this.updateResult()},n))},K0e=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(is(this,Mo)):this.options.refetchInterval)??!1},Z0e=function(s){Qi(this,ll,Q0e).call(this),Yn(this,g_,s),!(FS||lx(this.options.enabled,is(this,Mo))===!1||!q0e(is(this,g_))||is(this,g_)===0)&&Yn(this,q4,setInterval(()=>{(this.options.refetchIntervalInBackground||E2e.isFocused())&&Qi(this,ll,vI).call(this)},is(this,g_)))},Y0e=function(){Qi(this,ll,G0e).call(this),Qi(this,ll,Z0e).call(this,Qi(this,ll,K0e).call(this))},X0e=function(){is(this,$4)&&(clearTimeout(is(this,$4)),Yn(this,$4,void 0))},Q0e=function(){is(this,q4)&&(clearInterval(is(this,q4)),Yn(this,q4,void 0))},J0e=function(){const s=is(this,lp).getQueryCache().build(is(this,lp),this.options);if(s===is(this,Mo))return;const r=is(this,Mo);Yn(this,Mo,s),Yn(this,uO,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},nUe=function(s){vu.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(is(this,vm))}),is(this,lp).getQueryCache().notify({query:is(this,Mo),type:"observerResultsUpdated"})})},x9e);function rvt(t,s){return lx(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function QAe(t,s){return rvt(t,s)||t.state.data!==void 0&&eve(t,s,s.refetchOnMount)}function eve(t,s,r){if(lx(s.enabled,t)!==!1&&Z_(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&P2e(t,s)}return!1}function JAe(t,s,r,n){return(t!==s||lx(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&P2e(t,r)}function P2e(t,s){return lx(s.enabled,t)!==!1&&t.isStaleByTime(Z_(s.staleTime,t))}function nvt(t,s){return!uoe(t.getCurrentResult(),s)}var avt=class extends rUe{constructor(t,s){super(t,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:moe()})}getOptimisticResult(t){return t.behavior=moe(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,s){var _,j;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,c=(j=(_=r.fetchMeta)==null?void 0:_.fetchMore)==null?void 0:j.direction,u=l&&c==="forward",p=a&&c==="forward",f=l&&c==="backward",g=a&&c==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:evt(s,r.data),hasPreviousPage:tvt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:g,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!g}}},y_,v_,cp,Vv,w1,oie,tve,g9e,ivt=(g9e=class extends UA{constructor(r,n){super();Xa(this,w1);Xa(this,y_);Xa(this,v_);Xa(this,cp);Xa(this,Vv);Yn(this,y_,r),this.setOptions(n),this.bindMethods(),Qi(this,w1,oie).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const n=this.options;this.options=is(this,y_).defaultMutationOptions(r),uoe(this.options,n)||is(this,y_).getMutationCache().notify({type:"observerOptionsUpdated",mutation:is(this,cp),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&zS(n.mutationKey)!==zS(this.options.mutationKey)?this.reset():((a=is(this,cp))==null?void 0:a.state.status)==="pending"&&is(this,cp).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=is(this,cp))==null||r.removeObserver(this)}onMutationUpdate(r){Qi(this,w1,oie).call(this),Qi(this,w1,tve).call(this,r)}getCurrentResult(){return is(this,v_)}reset(){var r;(r=is(this,cp))==null||r.removeObserver(this),Yn(this,cp,void 0),Qi(this,w1,oie).call(this),Qi(this,w1,tve).call(this)}mutate(r,n){var a;return Yn(this,Vv,n),(a=is(this,cp))==null||a.removeObserver(this),Yn(this,cp,is(this,y_).getMutationCache().build(is(this,y_),this.options)),is(this,cp).addObserver(this),is(this,cp).execute(r)}},y_=new WeakMap,v_=new WeakMap,cp=new WeakMap,Vv=new WeakMap,w1=new WeakSet,oie=function(){var n;const r=((n=is(this,cp))==null?void 0:n.state)??tUe();Yn(this,v_,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},tve=function(r){vu.batch(()=>{var n,a,o,l,i,c,u,p;if(is(this,Vv)&&this.hasListeners()){const f=is(this,v_).variables,g=is(this,v_).context;(r==null?void 0:r.type)==="success"?((a=(n=is(this,Vv)).onSuccess)==null||a.call(n,r.data,f,g),(l=(o=is(this,Vv)).onSettled)==null||l.call(o,r.data,null,f,g)):(r==null?void 0:r.type)==="error"&&((c=(i=is(this,Vv)).onError)==null||c.call(i,r.error,f,g),(p=(u=is(this,Vv)).onSettled)==null||p.call(u,void 0,r.error,f,g))}this.listeners.forEach(f=>{f(is(this,v_))})})},g9e),aUe=k.createContext(void 0),Qt=t=>{const s=k.useContext(aUe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},ovt=({client:t,children:s})=>(k.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(aUe.Provider,{value:t,children:s})),iUe=k.createContext(!1),lvt=()=>k.useContext(iUe);iUe.Provider;function cvt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var dvt=k.createContext(cvt()),uvt=()=>k.useContext(dvt),hvt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},mvt=t=>{k.useEffect(()=>{t.clearReset()},[t])},pvt=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||Zqe(r,[t.error,n])),fvt=t=>{if(t.suspense){const s=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>s(r(...n)):s(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},xvt=(t,s)=>t.isLoading&&t.isFetching&&!s,gvt=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,eEe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function oUe(t,s,r){var f,g,b,_,j;const n=lvt(),a=uvt(),o=Qt(),l=o.defaultQueryOptions(t);(g=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||g.call(f,l),l._optimisticResults=n?"isRestoring":"optimistic",fvt(l),hvt(l,a),mvt(a);const i=!o.getQueryCache().get(l.queryHash),[c]=k.useState(()=>new s(o,l)),u=c.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(w=>{const N=p?c.subscribe(vu.batchCalls(w)):_m;return c.updateResult(),N},[c,p]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),k.useEffect(()=>{c.setOptions(l)},[l,c]),gvt(l,u))throw eEe(l,c,a);if(pvt({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw u.error;if((_=(b=o.getDefaultOptions().queries)==null?void 0:b._experimental_afterQuery)==null||_.call(b,l,u),l.experimental_prefetchInRender&&!FS&&xvt(u,n)){const w=i?eEe(l,c,a):(j=o.getQueryCache().get(l.queryHash))==null?void 0:j.promise;w==null||w.catch(_m).finally(()=>{c.updateResult()})}return l.notifyOnChangeProps?u:c.trackResult(u)}function mt(t,s){return oUe(t,rUe)}function Lt(t,s){const r=Qt(),[n]=k.useState(()=>new ivt(r,t));k.useEffect(()=>{n.setOptions(t)},[n,t]);const a=k.useSyncExternalStore(k.useCallback(l=>n.subscribe(vu.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=k.useCallback((l,i)=>{n.mutate(l,i).catch(_m)},[n]);if(a.error&&Zqe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function lUe(t,s){return oUe(t,avt)}/** * @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 W8(){return W8=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function cUe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function vvt(){return Math.random().toString(36).substr(2,8)}function sEe(t,s){return{usr:t.state,key:t.key,idx:s}}function sve(t,s,r,n){return r===void 0&&(r=null),W8({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?VA(s):s,{state:r,key:s&&s.key||n||vvt()})}function poe(t){let{pathname:s="/",search:r="",hash:n=""}=t;return r&&r!=="?"&&(s+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(s+=n.charAt(0)==="#"?n:"#"+n),s}function VA(t){let s={};if(t){let r=t.indexOf("#");r>=0&&(s.hash=t.substr(r),t=t.substr(0,r));let n=t.indexOf("?");n>=0&&(s.search=t.substr(n),t=t.substr(0,n)),t&&(s.pathname=t)}return s}function bvt(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=w_.Pop,c=null,u=p();u==null&&(u=0,l.replaceState(W8({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function f(){i=w_.Pop;let w=p(),N=w==null?null:w-u;u=w,c&&c({action:i,location:j.location,delta:N})}function g(w,N){i=w_.Push;let S=sve(j.location,w,N);u=p()+1;let M=sEe(S,u),L=j.createHref(S);try{l.pushState(M,"",L)}catch(I){if(I instanceof DOMException&&I.name==="DataCloneError")throw I;a.location.assign(L)}o&&c&&c({action:i,location:j.location,delta:1})}function b(w,N){i=w_.Replace;let S=sve(j.location,w,N);u=p();let M=sEe(S,u),L=j.createHref(S);l.replaceState(M,"",L),o&&c&&c({action:i,location:j.location,delta:0})}function _(w){let N=a.location.origin!=="null"?a.location.origin:a.location.href,S=typeof w=="string"?w:poe(w);return S=S.replace(/ $/,"%20"),Rd(N,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,N)}let j={get action(){return i},get location(){return t(a,l)},listen(w){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(tEe,f),c=w,()=>{a.removeEventListener(tEe,f),c=null}},createHref(w){return s(a,w)},createURL:_,encodeLocation(w){let N=_(w);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:g,replace:b,go(w){return l.go(w)}};return j}var rEe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(rEe||(rEe={}));function _vt(t,s,r){return r===void 0&&(r="/"),wvt(t,s,r)}function wvt(t,s,r,n){let a=typeof s=="string"?VA(s):s,o=I2e(a.pathname||"/",r);if(o==null)return null;let l=dUe(t);jvt(l);let i=null;for(let c=0;i==null&&c{let c={relativePath:i===void 0?o.path||"":i,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};c.relativePath.startsWith("/")&&(Rd(c.relativePath.startsWith(n),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(n.length));let u=Y_([n,c.relativePath]),p=r.concat(c);o.children&&o.children.length>0&&(Rd(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),dUe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:Avt(u,o.index),routesMeta:p})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let c of uUe(o.path))a(o,l,c)}),s}function uUe(t){let s=t.split("/");if(s.length===0)return[];let[r,...n]=s,a=r.endsWith("?"),o=r.replace(/\?$/,"");if(n.length===0)return a?[o,""]:[o];let l=uUe(n.join("/")),i=[];return i.push(...l.map(c=>c===""?o:[o,c].join("/"))),a&&i.push(...l),i.map(c=>t.startsWith("/")&&c===""?"/":c)}function jvt(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:Evt(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Nvt=/^:[\w-]+$/,kvt=3,Svt=2,Cvt=1,Mvt=10,Tvt=-2,nEe=t=>t==="*";function Avt(t,s){let r=t.split("/"),n=r.length;return r.some(nEe)&&(n+=Tvt),s&&(n+=Svt),r.filter(a=>!nEe(a)).reduce((a,o)=>a+(Nvt.test(o)?kvt:o===""?Cvt:Mvt),n)}function Evt(t,s){return t.length===s.length&&t.slice(0,-1).every((n,a)=>n===s[a])?t[t.length-1]-s[s.length-1]:0}function Pvt(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:g,isOptional:b}=p;if(g==="*"){let j=i[f]||"";l=o.slice(0,o.length-j.length).replace(/(.)\/+$/,"$1")}const _=i[f];return b&&!_?u[g]=void 0:u[g]=(_||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function Lvt(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),cUe(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,i,c)=>(n.push({paramName:i,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),n]}function Dvt(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return cUe(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+s+").")),t}}function I2e(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let r=s.endsWith("/")?s.length-1:s.length,n=t.charAt(r);return n&&n!=="/"?null:t.slice(r)||"/"}function Ovt(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?VA(t):t;return{pathname:r?r.startsWith("/")?r:Rvt(r,s):s,search:Bvt(n),hash:$vt(a)}}function Rvt(t,s){let r=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function sxe(t,s,r,n){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+s+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Fvt(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function L2e(t,s){let r=Fvt(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function D2e(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=VA(t):(a=W8({},t),Rd(!a.pathname||!a.pathname.includes("?"),sxe("?","pathname","search",a)),Rd(!a.pathname||!a.pathname.includes("#"),sxe("#","pathname","hash",a)),Rd(!a.search||!a.search.includes("#"),sxe("#","search","hash",a)));let o=t===""||a.pathname==="",l=o?"/":a.pathname,i;if(l==null)i=r;else{let f=s.length-1;if(!n&&l.startsWith("..")){let g=l.split("/");for(;g[0]==="..";)g.shift(),f-=1;a.pathname=g.join("/")}i=f>=0?s[f]:"/"}let c=Ovt(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}const Y_=t=>t.join("/").replace(/\/\/+/g,"/"),zvt=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Bvt=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,$vt=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function qvt(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const hUe=["post","put","patch","delete"];new Set(hUe);const Uvt=["get",...hUe];new Set(Uvt);/** * 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 G8(){return G8=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),k.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=D2e(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:Y_([s,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[s,n,l,o,t])}const Gvt=k.createContext(null);function Kvt(t){let s=k.useContext(z0).outlet;return s&&k.createElement(Gvt.Provider,{value:t},s)}function yo(){let{matches:t}=k.useContext(z0),s=t[t.length-1];return s?s.params:{}}function fUe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=k.useContext(Sw),{matches:a}=k.useContext(z0),{pathname:o}=id(),l=JSON.stringify(L2e(a,n.v7_relativeSplatPath));return k.useMemo(()=>D2e(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function Zvt(t,s){return Yvt(t,s)}function Yvt(t,s,r,n){HA()||Rd(!1);let{navigator:a}=k.useContext(Sw),{matches:o}=k.useContext(z0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=id(),p;if(s){var f;let w=typeof s=="string"?VA(s):s;c==="/"||(f=w.pathname)!=null&&f.startsWith(c)||Rd(!1),p=w}else p=u;let g=p.pathname||"/",b=g;if(c!=="/"){let w=c.replace(/^\//,"").split("/");b="/"+g.replace(/^\//,"").split("/").slice(w.length).join("/")}let _=_vt(t,{pathname:b}),j=t1t(_&&_.map(w=>Object.assign({},w,{params:Object.assign({},i,w.params),pathname:Y_([c,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?c:Y_([c,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),o,r,n);return s&&j?k.createElement(Ade.Provider,{value:{location:G8({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:w_.Pop}},j):j}function Xvt(){let t=a1t(),s=qvt(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return k.createElement(k.Fragment,null,k.createElement("h2",null,"Unexpected Application Error!"),k.createElement("h3",{style:{fontStyle:"italic"}},s),r?k.createElement("pre",{style:a},r):null,null)}const Qvt=k.createElement(Xvt,null);class Jvt extends k.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,r){return r.location!==s.location||r.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:r.error,location:r.location,revalidation:s.revalidation||r.revalidation}}componentDidCatch(s,r){console.error("React Router caught the following error during render",s,r)}render(){return this.state.error!==void 0?k.createElement(z0.Provider,{value:this.props.routeContext},k.createElement(mUe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function e1t(t){let{routeContext:s,match:r,children:n}=t,a=k.useContext(O2e);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),k.createElement(z0.Provider,{value:s},n)}function t1t(t,s,r,n){var a;if(s===void 0&&(s=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var o;if(!r)return null;if(r.errors)t=r.matches;else if((o=n)!=null&&o.v7_partialHydration&&s.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let l=t,i=(a=r)==null?void 0:a.errors;if(i!=null){let p=l.findIndex(f=>f.route.id&&(i==null?void 0:i[f.route.id])!==void 0);p>=0||Rd(!1),l=l.slice(0,Math.min(l.length,p+1))}let c=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let p=0;p=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((p,f,g)=>{let b,_=!1,j=null,w=null;r&&(b=i&&f.route.id?i[f.route.id]:void 0,j=f.route.errorElement||Qvt,c&&(u<0&&g===0?(o1t("route-fallback"),_=!0,w=null):u===g&&(_=!0,w=f.route.hydrateFallbackElement||null)));let N=s.concat(l.slice(0,g+1)),S=()=>{let M;return b?M=j:_?M=w:f.route.Component?M=k.createElement(f.route.Component,null):f.route.element?M=f.route.element:M=p,k.createElement(e1t,{match:f,routeContext:{outlet:p,matches:N,isDataRoute:r!=null},children:M})};return r&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?k.createElement(Jvt,{location:r.location,revalidation:r.revalidation,component:j,error:b,children:S(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):S()},null)}var xUe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(xUe||{}),gUe=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(gUe||{});function s1t(t){let s=k.useContext(O2e);return s||Rd(!1),s}function r1t(t){let s=k.useContext(Vvt);return s||Rd(!1),s}function n1t(t){let s=k.useContext(z0);return s||Rd(!1),s}function yUe(t){let s=n1t(),r=s.matches[s.matches.length-1];return r.route.id||Rd(!1),r.route.id}function a1t(){var t;let s=k.useContext(mUe),r=r1t(),n=yUe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function i1t(){let{router:t}=s1t(xUe.UseNavigateStable),s=yUe(gUe.UseNavigateStable),r=k.useRef(!1);return pUe(()=>{r.current=!0}),k.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,G8({fromRouteId:s},o)))},[t,s])}const aEe={};function o1t(t,s,r){aEe[t]||(aEe[t]=!0)}function l1t(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function rxe(t){let{to:s,replace:r,state:n,relative:a}=t;HA()||Rd(!1);let{future:o,static:l}=k.useContext(Sw),{matches:i}=k.useContext(z0),{pathname:c}=id(),u=fr(),p=D2e(s,L2e(i,o.v7_relativeSplatPath),c,a==="path"),f=JSON.stringify(p);return k.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function c1t(t){return Kvt(t.context)}function ks(t){Rd(!1)}function d1t(t){let{basename:s="/",children:r=null,location:n,navigationType:a=w_.Pop,navigator:o,static:l=!1,future:i}=t;HA()&&Rd(!1);let c=s.replace(/^\/*/,"/"),u=k.useMemo(()=>({basename:c,navigator:o,static:l,future:G8({v7_relativeSplatPath:!1},i)}),[c,i,o,l]);typeof n=="string"&&(n=VA(n));let{pathname:p="/",search:f="",hash:g="",state:b=null,key:_="default"}=n,j=k.useMemo(()=>{let w=I2e(p,c);return w==null?null:{location:{pathname:w,search:f,hash:g,state:b,key:_},navigationType:a}},[c,p,f,g,b,_,a]);return j==null?null:k.createElement(Sw.Provider,{value:u},k.createElement(Ade.Provider,{children:r,value:j}))}function R2e(t){let{children:s,location:r}=t;return Zvt(rve(s),r)}new Promise(()=>{});function rve(t,s){s===void 0&&(s=[]);let r=[];return k.Children.forEach(t,(n,a)=>{if(!k.isValidElement(n))return;let o=[...s,a];if(n.type===k.Fragment){r.push.apply(r,rve(n.props.children,o));return}n.type!==ks&&Rd(!1),!n.props.index||!n.props.children||Rd(!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=rve(n.props.children,o)),r.push(l)}),r}/** * React Router DOM v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function nve(){return nve=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function h1t(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function m1t(t,s){return t.button===0&&(!s||s==="_self")&&!h1t(t)}function ave(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,r)=>{let n=t[r];return s.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function p1t(t,s){let r=ave(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const f1t=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],x1t="6";try{window.__reactRouterVersion=x1t}catch{}const g1t="startTransition",iEe=bwe[g1t];function y1t(t){let{basename:s,children:r,future:n,window:a}=t,o=k.useRef();o.current==null&&(o.current=yvt({window:a,v5Compat:!0}));let l=o.current,[i,c]=k.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=k.useCallback(f=>{u&&iEe?iEe(()=>c(f)):c(f)},[c,u]);return k.useLayoutEffect(()=>l.listen(p),[l,p]),k.useEffect(()=>l1t(n),[n]),k.createElement(d1t,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const v1t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",b1t=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pi=k.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:c,to:u,preventScrollReset:p,viewTransition:f}=s,g=u1t(s,f1t),{basename:b}=k.useContext(Sw),_,j=!1;if(typeof u=="string"&&b1t.test(u)&&(_=u,v1t))try{let M=new URL(window.location.href),L=u.startsWith("//")?new URL(M.protocol+u):new URL(u),I=I2e(L.pathname,b);L.origin===M.origin&&I!=null?u=I+L.search+L.hash:j=!0}catch{}let w=Hvt(u,{relative:a}),N=_1t(u,{replace:l,state:i,target:c,preventScrollReset:p,relative:a,viewTransition:f});function S(M){n&&n(M),M.defaultPrevented||N(M)}return k.createElement("a",nve({},g,{href:_||w,onClick:j||o?n:S,ref:r,target:c}))});var oEe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(oEe||(oEe={}));var lEe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(lEe||(lEe={}));function _1t(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,c=fr(),u=id(),p=fUe(t,{relative:l});return k.useCallback(f=>{if(m1t(f,r)){f.preventDefault();let g=n!==void 0?n:poe(u)===poe(p);c(t,{replace:g,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,c,p,n,a,r,t,o,l,i])}function Cc(t){let s=k.useRef(ave(t)),r=k.useRef(!1),n=id(),a=k.useMemo(()=>p1t(n.search,r.current?null:s.current),[n.search]),o=fr(),l=k.useCallback((i,c)=>{const u=ave(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,c)},[o,a]);return[a,l]}var w1t=typeof Element<"u",j1t=typeof Map=="function",N1t=typeof Set=="function",k1t=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function lie(t,s){if(t===s)return!0;if(t&&s&&typeof t=="object"&&typeof s=="object"){if(t.constructor!==s.constructor)return!1;var r,n,a;if(Array.isArray(t)){if(r=t.length,r!=s.length)return!1;for(n=r;n--!==0;)if(!lie(t[n],s[n]))return!1;return!0}var o;if(j1t&&t instanceof Map&&s instanceof Map){if(t.size!==s.size)return!1;for(o=t.entries();!(n=o.next()).done;)if(!s.has(n.value[0]))return!1;for(o=t.entries();!(n=o.next()).done;)if(!lie(n.value[1],s.get(n.value[0])))return!1;return!0}if(N1t&&t instanceof Set&&s instanceof Set){if(t.size!==s.size)return!1;for(o=t.entries();!(n=o.next()).done;)if(!s.has(n.value[0]))return!1;return!0}if(k1t&&ArrayBuffer.isView(t)&&ArrayBuffer.isView(s)){if(r=t.length,r!=s.length)return!1;for(n=r;n--!==0;)if(t[n]!==s[n])return!1;return!0}if(t.constructor===RegExp)return t.source===s.source&&t.flags===s.flags;if(t.valueOf!==Object.prototype.valueOf&&typeof t.valueOf=="function"&&typeof s.valueOf=="function")return t.valueOf()===s.valueOf();if(t.toString!==Object.prototype.toString&&typeof t.toString=="function"&&typeof s.toString=="function")return t.toString()===s.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(s).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(s,a[n]))return!1;if(w1t&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!lie(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var S1t=function(s,r){try{return lie(s,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const C1t=Po(S1t);var M1t=function(t,s,r,n,a,o,l,i){if(!t){var c;if(s===void 0)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,a,o,l,i],p=0;c=new Error(s.replace(/%s/g,function(){return u[p++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}},T1t=M1t;const cEe=Po(T1t);var A1t=function(s,r,n,a){var o=n?n.call(a,s,r):void 0;if(o!==void 0)return!!o;if(s===r)return!0;if(typeof s!="object"||!s||typeof r!="object"||!r)return!1;var l=Object.keys(s),i=Object.keys(r);if(l.length!==i.length)return!1;for(var c=Object.prototype.hasOwnProperty.bind(r),u=0;u(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(vUe||{}),nxe={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"]}},dEe=Object.values(vUe),F2e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},P1t=Object.entries(F2e).reduce((t,[s,r])=>(t[r]=s,t),{}),Gg="data-rh",KM={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},ZM=(t,s)=>{for(let r=t.length-1;r>=0;r-=1){const n=t[r];if(Object.prototype.hasOwnProperty.call(n,s))return n[s]}return null},I1t=t=>{let s=ZM(t,"title");const r=ZM(t,KM.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=ZM(t,KM.DEFAULT_TITLE);return s||n||void 0},L1t=t=>ZM(t,KM.ON_CHANGE_CLIENT_STATE)||(()=>{}),axe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),D1t=(t,s)=>s.filter(r=>typeof r.base<"u").map(r=>r.base).reverse().reduce((r,n)=>{if(!r.length){const a=Object.keys(n);for(let o=0;oconsole&&typeof console.warn=="function"&&console.warn(t),BP=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&O1t(`Helmet: ${t} should be of type "Array". Instead found type "${typeof a[t]}"`),!1)).map(a=>a[t]).reverse().reduce((a,o)=>{const l={};o.filter(c=>{let u;const p=Object.keys(c);for(let g=0;ga.push(c));const i=Object.keys(l);for(let c=0;c{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:D1t(["href"],t),bodyAttributes:axe("bodyAttributes",t),defer:ZM(t,KM.DEFER),encode:ZM(t,KM.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:axe("htmlAttributes",t),linkTags:BP("link",["rel","href"],t),metaTags:BP("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:BP("noscript",["innerHTML"],t),onChangeClientState:L1t(t),scriptTags:BP("script",["src","innerHTML"],t),styleTags:BP("style",["cssText"],t),title:I1t(t),titleAttributes:axe("titleAttributes",t),prioritizeSeoTags:R1t(t,KM.PRIORITIZE_SEO_TAGS)}),bUe=t=>Array.isArray(t)?t.join(""):t,z1t=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(z1t(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},uEe=(t,s)=>({...t,[s]:void 0}),B1t=["noscript","script","style"],ive=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),_Ue=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),$1t=(t,s,r,n)=>{const a=_Ue(r),o=bUe(s);return a?`<${t} ${Gg}="true" ${a}>${ive(o,n)}`:`<${t} ${Gg}="true">${ive(o,n)}`},q1t=(t,s,r=!0)=>s.reduce((n,a)=>{const o=a,l=Object.keys(o).filter(u=>!(u==="innerHTML"||u==="cssText")).reduce((u,p)=>{const f=typeof o[p]>"u"?p:`${p}="${ive(o[p],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",c=B1t.indexOf(t)===-1;return`${n}<${t} ${Gg}="true" ${l}${c?"/>":`>${i}`}`},""),wUe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=F2e[n];return r[a||n]=t[n],r},s),U1t=(t,s,r)=>{const n={key:s,[Gg]:!0},a=wUe(r,n);return[ht.createElement("title",a,s)]},cie=(t,s)=>s.map((r,n)=>{const a={key:n,[Gg]:!0};return Object.keys(r).forEach(o=>{const i=F2e[o]||o;if(i==="innerHTML"||i==="cssText"){const c=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:c}}else a[i]=r[o]}),ht.createElement(t,a)}),ix=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>U1t(t,s.title,s.titleAttributes),toString:()=>$1t(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>wUe(s),toString:()=>_Ue(s)};default:return{toComponent:()=>cie(t,s),toString:()=>q1t(t,s,r)}}},V1t=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=ixe(t,nxe.meta),o=ixe(s,nxe.link),l=ixe(r,nxe.script);return{priorityMethods:{toComponent:()=>[...cie("meta",a.priority),...cie("link",o.priority),...cie("script",l.priority)],toString:()=>`${ix("meta",a.priority,n)} ${ix("link",o.priority,n)} ${ix("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},H1t=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:c,prioritizeSeoTags:u}=t;let{linkTags:p,metaTags:f,scriptTags:g}=t,b={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:b,linkTags:p,metaTags:f,scriptTags:g}=V1t(t)),{priority:b,base:ix("base",s,n),bodyAttributes:ix("bodyAttributes",r,n),htmlAttributes:ix("htmlAttributes",a,n),link:ix("link",p,n),meta:ix("meta",f,n),noscript:ix("noscript",o,n),script:ix("script",g,n),style:ix("style",l,n),title:ix("title",{title:i,titleAttributes:c},n)}},ove=H1t,$7=[],jUe=!!(typeof window<"u"&&window.document&&window.document.createElement),lve=class{constructor(t,s){Mn(this,"instances",[]);Mn(this,"canUseDOM",jUe);Mn(this,"context");Mn(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?$7:this.instances,add:t=>{(this.canUseDOM?$7:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?$7:this.instances).indexOf(t);(this.canUseDOM?$7:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=ove({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},W1t={},NUe=ht.createContext(W1t),U4,kUe=(U4=class extends k.Component{constructor(r){super(r);Mn(this,"helmetData");this.helmetData=new lve(this.props.context||{},U4.canUseDOM)}render(){return ht.createElement(NUe.Provider,{value:this.helmetData.value},this.props.children)}},Mn(U4,"canUseDOM",jUe),U4),u5=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Gg}]`),a=[].slice.call(n),o=[];let l;return s&&s.length&&s.forEach(i=>{const c=document.createElement(t);for(const u in i)if(Object.prototype.hasOwnProperty.call(i,u))if(u==="innerHTML")c.innerHTML=i.innerHTML;else if(u==="cssText")c.styleSheet?c.styleSheet.cssText=i.cssText:c.appendChild(document.createTextNode(i.cssText));else{const p=u,f=typeof i[p]>"u"?"":i[p];c.setAttribute(u,f)}c.setAttribute(Gg,"true"),a.some((u,p)=>(l=p,c.isEqualNode(u)))?a.splice(l,1):o.push(c)}),a.forEach(i=>{var c;return(c=i.parentNode)==null?void 0:c.removeChild(i)}),o.forEach(i=>r.appendChild(i)),{oldTags:a,newTags:o}},cve=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Gg),a=n?n.split(","):[],o=[...a],l=Object.keys(s);for(const i of l){const c=s[i]||"";r.getAttribute(i)!==c&&r.setAttribute(i,c),a.indexOf(i)===-1&&a.push(i);const u=o.indexOf(i);u!==-1&&o.splice(u,1)}for(let i=o.length-1;i>=0;i-=1)r.removeAttribute(o[i]);a.length===o.length?r.removeAttribute(Gg):r.getAttribute(Gg)!==l.join(",")&&r.setAttribute(Gg,l.join(","))},G1t=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=bUe(t)),cve("title",s)},hEe=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:c,scriptTags:u,styleTags:p,title:f,titleAttributes:g}=t;cve("body",n),cve("html",a),G1t(f,g);const b={baseTag:u5("base",r),linkTags:u5("link",o),metaTags:u5("meta",l),noscriptTags:u5("noscript",i),scriptTags:u5("script",u),styleTags:u5("style",p)},_={},j={};Object.keys(b).forEach(w=>{const{newTags:N,oldTags:S}=b[w];N.length&&(_[w]=N),S.length&&(j[w]=b[w].oldTags)}),s&&s(),c(t,_,j)},$P=null,K1t=t=>{$P&&cancelAnimationFrame($P),t.defer?$P=requestAnimationFrame(()=>{hEe(t,()=>{$P=null})}):(hEe(t),$P=null)},Z1t=K1t,mEe=class extends k.Component{constructor(){super(...arguments);Mn(this,"rendered",!1)}shouldComponentUpdate(s){return!E1t(s,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:s}=this.props.context;s.remove(this),this.emitChange()}emitChange(){const{helmetInstances:s,setHelmet:r}=this.props.context;let n=null;const a=F1t(s.get().map(o=>{const l={...o.props};return delete l.context,l}));kUe.canUseDOM?Z1t(a):ove&&(n=ove(a)),r(n)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:s}=this.props.context;s.add(this),this.emitChange()}render(){return this.init(),null}},Fye,Sc=(Fye=class extends k.Component{shouldComponentUpdate(t){return!C1t(uEe(this.props,"helmetData"),uEe(t,"helmetData"))}mapNestedChildrenToProps(t,s){if(!s)return null;switch(t.type){case"script":case"noscript":return{innerHTML:s};case"style":return{cssText:s};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,s,r,n){return{...s,[t.type]:[...s[t.type]||[],{...r,...this.mapNestedChildrenToProps(t,n)}]}}mapObjectTypeChildren(t,s,r,n){switch(t.type){case"title":return{...s,[t.type]:n,titleAttributes:{...r}};case"body":return{...s,bodyAttributes:{...r}};case"html":return{...s,htmlAttributes:{...r}};default:return{...s,[t.type]:{...r}}}}mapArrayTypeChildrenToProps(t,s){let r={...s};return Object.keys(t).forEach(n=>{r={...r,[n]:t[n]}}),r}warnOnInvalidChildren(t,s){return cEe(dEe.some(r=>t.type===r),typeof t.type=="function"?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${dEe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),cEe(!s||typeof s=="string"||Array.isArray(s)&&!s.some(r=>typeof r!="string"),`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`),!0}mapChildrenToProps(t,s){let r={};return ht.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((c,u)=>(c[P1t[u]||u]=o[u],c),{});let{type:i}=n;switch(typeof i=="symbol"?i=i.toString():this.warnOnInvalidChildren(n,a),i){case"Symbol(react.fragment)":s=this.mapChildrenToProps(a,s);break;case"link":case"meta":case"noscript":case"script":case"style":r=this.flattenArrayTypeChildren(n,r,l,a);break;default:s=this.mapObjectTypeChildren(n,s,l,a);break}}),this.mapArrayTypeChildrenToProps(r,s)}render(){const{children:t,...s}=this.props;let r={...s},{helmetData:n}=s;if(t&&(r=this.mapChildrenToProps(t,r)),n&&!(n instanceof lve)){const a=n;n=new lve(a.context,!0),delete r.helmetData}return n?ht.createElement(mEe,{...r,context:n.value}):ht.createElement(NUe.Consumer,null,a=>ht.createElement(mEe,{...r,context:a}))}},Mn(Fye,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),Fye),dve=function(t,s){return dve=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])},dve(t,s)};function SUe(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");dve(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var xx=function(){return xx=Object.assign||function(s){for(var r,n=1,a=arguments.length;n=0;i--)(l=t[i])&&(o=(a<3?l(o):a>3?l(s,r,o):l(s,r))||o);return a>3&&o&&Object.defineProperty(s,r,o),o}function MUe(t,s){return function(r,n){s(r,n,t)}}function TUe(t,s,r,n,a,o){function l(N){if(N!==void 0&&typeof N!="function")throw new TypeError("Function expected");return N}for(var i=n.kind,c=i==="getter"?"get":i==="setter"?"set":"value",u=!s&&t?n.static?t:t.prototype:null,p=s||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f,g=!1,b=r.length-1;b>=0;b--){var _={};for(var j in n)_[j]=j==="access"?{}:n[j];for(var j in n.access)_.access[j]=n.access[j];_.addInitializer=function(N){if(g)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(N||null))};var w=(0,r[b])(i==="accessor"?{get:p.get,set:p.set}:p[c],_);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(f=l(w.get))&&(p.get=f),(f=l(w.set))&&(p.set=f),(f=l(w.init))&&a.unshift(f)}else(f=l(w))&&(i==="field"?a.unshift(f):p[c]=f)}u&&Object.defineProperty(u,n.name,p),g=!0}function AUe(t,s,r){for(var n=arguments.length>2,a=0;a0&&o[o.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function z2e(t,s){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,o=[],l;try{for(;(s===void 0||s-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(i){l={error:i}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(l)throw l.error}}return o}function OUe(){for(var t=[],s=0;s1||c(b,j)})},_&&(a[b]=_(a[b])))}function c(b,_){try{u(n[b](_))}catch(j){g(o[0][3],j)}}function u(b){b.value instanceof IT?Promise.resolve(b.value.v).then(p,f):g(o[0][2],b)}function p(b){c("next",b)}function f(b){c("throw",b)}function g(b,_){b(_),o.shift(),o.length&&c(o[0][0],o[0][1])}}function zUe(t){var s,r;return s={},n("next"),n("throw",function(a){throw a}),n("return"),s[Symbol.iterator]=function(){return this},s;function n(a,o){s[a]=t[a]?function(l){return(r=!r)?{value:IT(t[a](l)),done:!1}:o?o(l):l}:o}}function BUe(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t[Symbol.asyncIterator],r;return s?s.call(t):(t=typeof foe=="function"?foe(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(l){return new Promise(function(i,c){l=t[o](l),a(i,c,l.done,l.value)})}}function a(o,l,i,c){Promise.resolve(c).then(function(u){o({value:u,done:i})},l)}}function $Ue(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var Y1t=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},uve=function(t){return uve=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},uve(t)};function qUe(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=uve(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Al(async()=>{const{default:n}=await Promise.resolve().then(()=>fC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class $2e extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class pEe extends $2e{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class fEe extends $2e{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class xEe extends $2e{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var hve;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(hve||(hve={}));class tbt{constructor(s,{headers:r={},customFetch:n,region:a=hve.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=ebt(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return ya(this,arguments,void 0,function*(r,n={}){var a;try{const{headers:o,method:l,body:i,signal:c}=n;let u={},{region:p}=n;p||(p=this.region);const f=new URL(`${this.url}/${r}`);p&&p!=="any"&&(u["x-region"]=p,f.searchParams.set("forceFunctionRegion",p));let g;i&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)?typeof Blob<"u"&&i instanceof Blob||i instanceof ArrayBuffer?(u["Content-Type"]="application/octet-stream",g=i):typeof i=="string"?(u["Content-Type"]="text/plain",g=i):typeof FormData<"u"&&i instanceof FormData?g=i:(u["Content-Type"]="application/json",g=JSON.stringify(i)):g=i;const b=yield this.fetch(f.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),o),body:g,signal:c}).catch(N=>{throw N.name==="AbortError"?N:new pEe(N)}),_=b.headers.get("x-relay-error");if(_&&_==="true")throw new fEe(b);if(!b.ok)throw new xEe(b);let j=((a=b.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),w;return j==="application/json"?w=yield b.json():j==="application/octet-stream"||j==="application/pdf"?w=yield b.blob():j==="text/event-stream"?w=b:j==="multipart/form-data"?w=yield b.formData():w=yield b.text(),{data:w,error:null,response:b}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new pEe(o)}:{data:null,error:o,response:o instanceof xEe||o instanceof fEe?o.context:void 0}}})}}var fp={};const WA=v9e(J1t);var q7={},U7={},V7={},H7={},W7={},sbt=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")},LT=sbt();const rbt=LT.fetch,YUe=LT.fetch.bind(LT),XUe=LT.Headers,nbt=LT.Request,abt=LT.Response,fC=Object.freeze(Object.defineProperty({__proto__:null,Headers:XUe,Request:nbt,Response:abt,default:YUe,fetch:rbt},Symbol.toStringTag,{value:"Module"})),ibt=v9e(fC);var G7={},gEe;function QUe(){if(gEe)return G7;gEe=1,Object.defineProperty(G7,"__esModule",{value:!0});class t extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}}return G7.default=t,G7}var yEe;function JUe(){if(yEe)return W7;yEe=1,Object.defineProperty(W7,"__esModule",{value:!0});const t=WA,s=t.__importDefault(ibt),r=t.__importDefault(QUe());class n{constructor(o){var l,i;this.shouldThrowOnError=!1,this.method=o.method,this.url=o.url,this.headers=new Headers(o.headers),this.schema=o.schema,this.body=o.body,this.shouldThrowOnError=(l=o.shouldThrowOnError)!==null&&l!==void 0?l:!1,this.signal=o.signal,this.isMaybeSingle=(i=o.isMaybeSingle)!==null&&i!==void 0?i:!1,o.fetch?this.fetch=o.fetch:typeof fetch>"u"?this.fetch=s.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,l){return this.headers=new Headers(this.headers),this.headers.set(o,l),this}then(o,l){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const i=this.fetch;let c=i(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var p,f,g,b;let _=null,j=null,w=null,N=u.status,S=u.statusText;if(u.ok){if(this.method!=="HEAD"){const O=await u.text();O===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((p=this.headers.get("Accept"))===null||p===void 0)&&p.includes("application/vnd.pgrst.plan+text"))?j=O:j=JSON.parse(O))}const L=(f=this.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),I=(g=u.headers.get("content-range"))===null||g===void 0?void 0:g.split("/");L&&I&&I.length>1&&(w=parseInt(I[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(j)&&(j.length>1?(_={code:"PGRST116",details:`Results contain ${j.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},j=null,w=null,N=406,S="Not Acceptable"):j.length===1?j=j[0]:j=null)}else{const L=await u.text();try{_=JSON.parse(L),Array.isArray(_)&&u.status===404&&(j=[],_=null,N=200,S="OK")}catch{u.status===404&&L===""?(N=204,S="No Content"):_={message:L}}if(_&&this.isMaybeSingle&&(!((b=_==null?void 0:_.details)===null||b===void 0)&&b.includes("0 rows"))&&(_=null,N=200,S="OK"),_&&this.shouldThrowOnError)throw new r.default(_)}return{error:_,data:j,count:w,status:N,statusText:S}});return this.shouldThrowOnError||(c=c.catch(u=>{var p,f,g;return{error:{message:`${(p=u==null?void 0:u.name)!==null&&p!==void 0?p:"FetchError"}: ${u==null?void 0:u.message}`,details:`${(f=u==null?void 0:u.stack)!==null&&f!==void 0?f:""}`,hint:"",code:`${(g=u==null?void 0:u.code)!==null&&g!==void 0?g:""}`},data:null,count:null,status:0,statusText:""}})),c.then(o,l)}returns(){return this}overrideTypes(){return this}}return W7.default=n,W7}var vEe;function eVe(){if(vEe)return H7;vEe=1,Object.defineProperty(H7,"__esModule",{value:!0});const s=WA.__importDefault(JUe());class r extends s.default{select(a){let o=!1;const l=(a??"*").split("").map(i=>/\s/.test(i)&&!o?"":(i==='"'&&(o=!o),i)).join("");return this.url.searchParams.set("select",l),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:o=!0,nullsFirst:l,foreignTable:i,referencedTable:c=i}={}){const u=c?`${c}.order`:"order",p=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${p?`${p},`:""}${a}.${o?"asc":"desc"}${l===void 0?"":l?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:o,referencedTable:l=o}={}){const i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(i,`${a}`),this}range(a,o,{foreignTable:l,referencedTable:i=l}={}){const c=typeof i>"u"?"offset":`${i}.offset`,u=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${a}`),this.url.searchParams.set(u,`${o-a+1}`),this}abortSignal(a){return this.signal=a,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:a=!1,verbose:o=!1,settings:l=!1,buffers:i=!1,wal:c=!1,format:u="text"}={}){var p;const f=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),g=(p=this.headers.get("Accept"))!==null&&p!==void 0?p:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${g}"; options=${f};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}}return H7.default=r,H7}var bEe;function q2e(){if(bEe)return V7;bEe=1,Object.defineProperty(V7,"__esModule",{value:!0});const s=WA.__importDefault(eVe()),r=new RegExp("[,()]");class n extends s.default{eq(o,l){return this.url.searchParams.append(o,`eq.${l}`),this}neq(o,l){return this.url.searchParams.append(o,`neq.${l}`),this}gt(o,l){return this.url.searchParams.append(o,`gt.${l}`),this}gte(o,l){return this.url.searchParams.append(o,`gte.${l}`),this}lt(o,l){return this.url.searchParams.append(o,`lt.${l}`),this}lte(o,l){return this.url.searchParams.append(o,`lte.${l}`),this}like(o,l){return this.url.searchParams.append(o,`like.${l}`),this}likeAllOf(o,l){return this.url.searchParams.append(o,`like(all).{${l.join(",")}}`),this}likeAnyOf(o,l){return this.url.searchParams.append(o,`like(any).{${l.join(",")}}`),this}ilike(o,l){return this.url.searchParams.append(o,`ilike.${l}`),this}ilikeAllOf(o,l){return this.url.searchParams.append(o,`ilike(all).{${l.join(",")}}`),this}ilikeAnyOf(o,l){return this.url.searchParams.append(o,`ilike(any).{${l.join(",")}}`),this}is(o,l){return this.url.searchParams.append(o,`is.${l}`),this}in(o,l){const i=Array.from(new Set(l)).map(c=>typeof c=="string"&&r.test(c)?`"${c}"`:`${c}`).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:c}={}){let u="";c==="plain"?u="pl":c==="phrase"?u="ph":c==="websearch"&&(u="w");const p=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${u}fts${p}.${l}`),this}match(o){return Object.entries(o).forEach(([l,i])=>{this.url.searchParams.append(l,`eq.${i}`)}),this}not(o,l,i){return this.url.searchParams.append(o,`not.${l}.${i}`),this}or(o,{foreignTable:l,referencedTable:i=l}={}){const c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${o})`),this}filter(o,l,i){return this.url.searchParams.append(o,`${l}.${i}`),this}}return V7.default=n,V7}var _Ee;function tVe(){if(_Ee)return U7;_Ee=1,Object.defineProperty(U7,"__esModule",{value:!0});const s=WA.__importDefault(q2e());class r{constructor(a,{headers:o={},schema:l,fetch:i}){this.url=a,this.headers=new Headers(o),this.schema=l,this.fetch=i}select(a,o){const{head:l=!1,count:i}=o??{},c=l?"HEAD":"GET";let u=!1;const p=(a??"*").split("").map(f=>/\s/.test(f)&&!u?"":(f==='"'&&(u=!u),f)).join("");return this.url.searchParams.set("select",p),i&&this.headers.append("Prefer",`count=${i}`),new s.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:o,defaultToNull:l=!0}={}){var i;const c="POST";if(o&&this.headers.append("Prefer",`count=${o}`),l||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const u=a.reduce((p,f)=>p.concat(Object.keys(f)),[]);if(u.length>0){const p=[...new Set(u)].map(f=>`"${f}"`);this.url.searchParams.set("columns",p.join(","))}}return new s.default({method:c,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:c=!0}={}){var u;const p="POST";if(this.headers.append("Prefer",`resolution=${l?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),i&&this.headers.append("Prefer",`count=${i}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const f=a.reduce((g,b)=>g.concat(Object.keys(b)),[]);if(f.length>0){const g=[...new Set(f)].map(b=>`"${b}"`);this.url.searchParams.set("columns",g.join(","))}}return new s.default({method:p,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}update(a,{count:o}={}){var l;const i="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new s.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}delete({count:a}={}){var o;const l="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new s.default({method:l,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}}return U7.default=r,U7}var wEe;function obt(){if(wEe)return q7;wEe=1,Object.defineProperty(q7,"__esModule",{value:!0});const t=WA,s=t.__importDefault(tVe()),r=t.__importDefault(q2e());class n{constructor(o,{headers:l={},schema:i,fetch:c}={}){this.url=o,this.headers=new Headers(l),this.schemaName=i,this.fetch=c}from(o){const l=new URL(`${this.url}/${o}`);return new s.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new n(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,l={},{head:i=!1,get:c=!1,count:u}={}){var p;let f;const g=new URL(`${this.url}/rpc/${o}`);let b;i||c?(f=i?"HEAD":"GET",Object.entries(l).filter(([j,w])=>w!==void 0).map(([j,w])=>[j,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([j,w])=>{g.searchParams.append(j,w)})):(f="POST",b=l);const _=new Headers(this.headers);return u&&_.set("Prefer",`count=${u}`),new r.default({method:f,url:g,headers:_,schema:this.schemaName,body:b,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return q7.default=n,q7}Object.defineProperty(fp,"__esModule",{value:!0});var sVe=fp.PostgrestError=hVe=fp.PostgrestBuilder=dVe=fp.PostgrestTransformBuilder=lVe=fp.PostgrestFilterBuilder=iVe=fp.PostgrestQueryBuilder=nVe=fp.PostgrestClient=void 0;const GA=WA,rVe=GA.__importDefault(obt());var nVe=fp.PostgrestClient=rVe.default;const aVe=GA.__importDefault(tVe());var iVe=fp.PostgrestQueryBuilder=aVe.default;const oVe=GA.__importDefault(q2e());var lVe=fp.PostgrestFilterBuilder=oVe.default;const cVe=GA.__importDefault(eVe());var dVe=fp.PostgrestTransformBuilder=cVe.default;const uVe=GA.__importDefault(JUe());var hVe=fp.PostgrestBuilder=uVe.default;const mVe=GA.__importDefault(QUe());sVe=fp.PostgrestError=mVe.default;var pVe=fp.default={PostgrestClient:rVe.default,PostgrestQueryBuilder:aVe.default,PostgrestFilterBuilder:oVe.default,PostgrestTransformBuilder:cVe.default,PostgrestBuilder:uVe.default,PostgrestError:mVe.default};const lbt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return hVe},get PostgrestClient(){return nVe},get PostgrestError(){return sVe},get PostgrestFilterBuilder(){return lVe},get PostgrestQueryBuilder(){return iVe},get PostgrestTransformBuilder(){return dVe},default:pVe},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:cbt,PostgrestQueryBuilder:RMs,PostgrestFilterBuilder:FMs,PostgrestTransformBuilder:zMs,PostgrestBuilder:BMs,PostgrestError:$Ms}=pVe||lbt;class dbt{static detectEnvironment(){var s;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((s=navigator.userAgent)===null||s===void 0)&&s.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const r=process.versions;if(r&&r.node){const n=r.node,a=parseInt(n.replace(/^v/,"").split(".")[0]);return a>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${a} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${a} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: import ws from "ws" new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const s=this.detectEnvironment();if(s.constructor)return s.constructor;let r=s.error||"WebSocket not supported in this environment.";throw s.workaround&&(r+=` Suggested solution: ${s.workaround}`),new Error(r)}static createWebSocket(s,r){const n=this.getWebSocketConstructor();return new n(s,r)}static isWebSocketSupported(){try{const s=this.detectEnvironment();return s.type==="native"||s.type==="ws"}catch{return!1}}}const ubt="2.78.0",hbt=`realtime-js/${ubt}`,mbt="1.0.0",mve=1e4,pbt=1e3,fbt=100;var $L;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})($L||($L={}));var mu;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(mu||(mu={}));var Rg;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(Rg||(Rg={}));var pve;(function(t){t.websocket="websocket"})(pve||(pve={}));var c4;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(c4||(c4={}));class xbt{constructor(){this.HEADER_LENGTH=1}decode(s,r){return s.constructor===ArrayBuffer?r(this._binaryDecode(s)):r(typeof s=="string"?JSON.parse(s):{})}_binaryDecode(s){const r=new DataView(s),n=new TextDecoder;return this._decodeBroadcast(s,r,n)}_decodeBroadcast(s,r,n){const a=r.getUint8(1),o=r.getUint8(2);let l=this.HEADER_LENGTH+2;const i=n.decode(s.slice(l,l+a));l=l+a;const c=n.decode(s.slice(l,l+o));l=l+o;const u=JSON.parse(n.decode(s.slice(l,s.byteLength)));return{ref:null,topic:i,event:c,payload:u}}}class fVe{constructor(s,r){this.callback=s,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=s,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var Wl;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(Wl||(Wl={}));const jEe=(t,s,r={})=>{var n;const a=(n=r.skipTypes)!==null&&n!==void 0?n:[];return s?Object.keys(s).reduce((o,l)=>(o[l]=gbt(l,t,s,a),o),{}):{}},gbt=(t,s,r,n)=>{const a=s.find(i=>i.name===t),o=a==null?void 0:a.type,l=r[t];return o&&!n.includes(o)?xVe(o,l):fve(l)},xVe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return _bt(s,r)}switch(t){case Wl.bool:return ybt(s);case Wl.float4:case Wl.float8:case Wl.int2:case Wl.int4:case Wl.int8:case Wl.numeric:case Wl.oid:return vbt(s);case Wl.json:case Wl.jsonb:return bbt(s);case Wl.timestamp:return wbt(s);case Wl.abstime:case Wl.date:case Wl.daterange:case Wl.int4range:case Wl.int8range:case Wl.money:case Wl.reltime:case Wl.text:case Wl.time:case Wl.timestamptz:case Wl.timetz:case Wl.tsrange:case Wl.tstzrange:return fve(s);default:return fve(s)}},fve=t=>t,ybt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},vbt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},bbt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},_bt=(t,s)=>{if(typeof t!="string")return t;const r=t.length-1,n=t[r];if(t[0]==="{"&&n==="}"){let o;const l=t.slice(1,r);try{o=JSON.parse("["+l+"]")}catch{o=l?l.split(","):[]}return o.map(i=>xVe(s,i))}return t},wbt=t=>typeof t=="string"?t.replace(" ","T"):t,gVe=t=>{const s=new URL(t);return s.protocol=s.protocol.replace(/^ws/i,"http"),s.pathname=s.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),s.pathname===""||s.pathname==="/"?s.pathname="/api/broadcast":s.pathname=s.pathname+"/api/broadcast",s.href};class oxe{constructor(s,r,n={},a=mve){this.channel=s,this.event=r,this.payload=n,this.timeout=a,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(s){this.timeout=s,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(s){this.payload=Object.assign(Object.assign({},this.payload),s)}receive(s,r){var n;return this._hasReceived(s)&&r((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:s,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const s=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},s),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(s,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:s,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:s,response:r}){this.recHooks.filter(n=>n.status===s).forEach(n=>n.callback(r))}_hasReceived(s){return this.receivedResp&&this.receivedResp.status===s}}var NEe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(NEe||(NEe={}));class qL{constructor(s,r){this.channel=s,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},a=>{const{onJoin:o,onLeave:l,onSync:i}=this.caller;this.joinRef=this.channel._joinRef(),this.state=qL.syncState(this.state,a,o,l),this.pendingDiffs.forEach(c=>{this.state=qL.syncDiff(this.state,c,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=qL.syncDiff(this.state,a,o,l),i())}),this.onJoin((a,o,l)=>{this.channel._trigger("presence",{event:"join",key:a,currentPresences:o,newPresences:l})}),this.onLeave((a,o,l)=>{this.channel._trigger("presence",{event:"leave",key:a,currentPresences:o,leftPresences:l})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(s,r,n,a){const o=this.cloneDeep(s),l=this.transformState(r),i={},c={};return this.map(o,(u,p)=>{l[u]||(c[u]=p)}),this.map(l,(u,p)=>{const f=o[u];if(f){const g=p.map(w=>w.presence_ref),b=f.map(w=>w.presence_ref),_=p.filter(w=>b.indexOf(w.presence_ref)<0),j=f.filter(w=>g.indexOf(w.presence_ref)<0);_.length>0&&(i[u]=_),j.length>0&&(c[u]=j)}else i[u]=p}),this.syncDiff(o,{joins:i,leaves:c},n,a)}static syncDiff(s,r,n,a){const{joins:o,leaves:l}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),a||(a=()=>{}),this.map(o,(i,c)=>{var u;const p=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(c),p.length>0){const f=s[i].map(b=>b.presence_ref),g=p.filter(b=>f.indexOf(b.presence_ref)<0);s[i].unshift(...g)}n(i,p,c)}),this.map(l,(i,c)=>{let u=s[i];if(!u)return;const p=c.map(f=>f.presence_ref);u=u.filter(f=>p.indexOf(f.presence_ref)<0),s[i]=u,a(i,u,c),u.length===0&&delete s[i]}),s}static map(s,r){return Object.getOwnPropertyNames(s).map(n=>r(n,s[n]))}static transformState(s){return s=this.cloneDeep(s),Object.getOwnPropertyNames(s).reduce((r,n)=>{const a=s[n];return"metas"in a?r[n]=a.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):r[n]=a,r},{})}static cloneDeep(s){return JSON.parse(JSON.stringify(s))}onJoin(s){this.caller.onJoin=s}onLeave(s){this.caller.onLeave=s}onSync(s){this.caller.onSync=s}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var kEe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(kEe||(kEe={}));var UL;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(UL||(UL={}));var Iv;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Iv||(Iv={}));class U2e{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=mu.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=s.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new oxe(this,Rg.join,this.params,this.timeout),this.rejoinTimer=new fVe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=mu.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=mu.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=mu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=mu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=mu.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Rg.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new qL(this),this.broadcastEndpointURL=gVe(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((o=(a=this.params.config)===null||a===void 0?void 0:a.broadcast)===null||o===void 0)&&o.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(s,r=this.timeout){var n,a,o;if(this.socket.isConnected()||this.socket.connect(),this.state==mu.closed){const{config:{broadcast:l,presence:i,private:c}}=this.params,u=(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(b=>b.filter))!==null&&a!==void 0?a:[],p=!!this.bindings[UL.PRESENCE]&&this.bindings[UL.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,f={},g={broadcast:l,presence:Object.assign(Object.assign({},i),{enabled:p}),postgres_changes:u,private:c};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(b=>s==null?void 0:s(Iv.CHANNEL_ERROR,b)),this._onClose(()=>s==null?void 0:s(Iv.CLOSED)),this.updateJoinPayload(Object.assign({config:g},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:b})=>{var _;if(this.socket.setAuth(),b===void 0){s==null||s(Iv.SUBSCRIBED);return}else{const j=this.bindings.postgres_changes,w=(_=j==null?void 0:j.length)!==null&&_!==void 0?_:0,N=[];for(let S=0;S{this.state=mu.errored,s==null||s(Iv.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(b).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(Iv.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(s,r={}){return await this.send({type:"presence",event:"track",payload:s},r.timeout||this.timeout)}async untrack(s={}){return await this.send({type:"presence",event:"untrack"},s)}on(s,r,n){return this.state===mu.joined&&s===UL.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(s,r,n)}async httpSend(s,r,n={}){var a;const o=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(r==null)return Promise.reject("Payload is required for httpSend()");const l={method:"POST",headers:{Authorization:o,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:r,private:this.private}]})},i=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(a=n.timeout)!==null&&a!==void 0?a:this.timeout);if(i.status===202)return{success:!0};let c=i.statusText;try{const u=await i.json();c=u.error||u.message||c}catch{}return Promise.reject(new Error(c))}async send(s,r={}){var n,a;if(!this._canPush()&&s.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:o,payload:l}=s,c={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:l,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((a=u.body)===null||a===void 0?void 0:a.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var l,i,c;const u=this._push(s.type,s,r.timeout||this.timeout);s.type==="broadcast"&&!(!((c=(i=(l=this.params)===null||l===void 0?void 0:l.config)===null||i===void 0?void 0:i.broadcast)===null||c===void 0)&&c.ack)&&o("ok"),u.receive("ok",()=>o("ok")),u.receive("error",()=>o("error")),u.receive("timeout",()=>o("timed out"))})}updateJoinPayload(s){this.joinPush.updatePayload(s)}unsubscribe(s=this.timeout){this.state=mu.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Rg.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new oxe(this,Rg.leave,{},s),n.receive("ok",()=>{r(),a("ok")}).receive("timeout",()=>{r(),a("timed out")}).receive("error",()=>{a("error")}),n.send(),this._canPush()||n.trigger("ok",{})}).finally(()=>{n==null||n.destroy()})}teardown(){this.pushBuffer.forEach(s=>s.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=mu.closed,this.bindings={}}async _fetchWithTimeout(s,r,n){const a=new AbortController,o=setTimeout(()=>a.abort(),n),l=await this.socket.fetch(s,Object.assign(Object.assign({},r),{signal:a.signal}));return clearTimeout(o),l}_push(s,r,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${s}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let a=new oxe(this,s,r,n);return this._canPush()?a.send():this._addToPushBuffer(a),a}_addToPushBuffer(s){if(s.startTimeout(),this.pushBuffer.push(s),this.pushBuffer.length>fbt){const r=this.pushBuffer.shift();r&&(r.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${r.event}`,r.payload))}}_onMessage(s,r,n){return r}_isMember(s){return this.topic===s}_joinRef(){return this.joinPush.ref}_trigger(s,r,n){var a,o;const l=s.toLocaleLowerCase(),{close:i,error:c,leave:u,join:p}=Rg;if(n&&[i,c,u,p].indexOf(l)>=0&&n!==this._joinRef())return;let g=this._onMessage(l,r,n);if(r&&!g)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(b=>{var _,j,w;return((_=b.filter)===null||_===void 0?void 0:_.event)==="*"||((w=(j=b.filter)===null||j===void 0?void 0:j.event)===null||w===void 0?void 0:w.toLocaleLowerCase())===l}).map(b=>b.callback(g,n)):(o=this.bindings[l])===null||o===void 0||o.filter(b=>{var _,j,w,N,S,M;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in b){const L=b.id,I=(_=b.filter)===null||_===void 0?void 0:_.event;return L&&((j=r.ids)===null||j===void 0?void 0:j.includes(L))&&(I==="*"||(I==null?void 0:I.toLocaleLowerCase())===((w=r.data)===null||w===void 0?void 0:w.type.toLocaleLowerCase()))}else{const L=(S=(N=b==null?void 0:b.filter)===null||N===void 0?void 0:N.event)===null||S===void 0?void 0:S.toLocaleLowerCase();return L==="*"||L===((M=r==null?void 0:r.event)===null||M===void 0?void 0:M.toLocaleLowerCase())}else return b.type.toLocaleLowerCase()===l}).map(b=>{if(typeof g=="object"&&"ids"in g){const _=g.data,{schema:j,table:w,commit_timestamp:N,type:S,errors:M}=_;g=Object.assign(Object.assign({},{schema:j,table:w,commit_timestamp:N,eventType:S,new:{},old:{},errors:M}),this._getPayloadRecords(_))}b.callback(g,n)})}_isClosed(){return this.state===mu.closed}_isJoined(){return this.state===mu.joined}_isJoining(){return this.state===mu.joining}_isLeaving(){return this.state===mu.leaving}_replyEventName(s){return`chan_reply_${s}`}_on(s,r,n){const a=s.toLocaleLowerCase(),o={type:a,filter:r,callback:n};return this.bindings[a]?this.bindings[a].push(o):this.bindings[a]=[o],this}_off(s,r){const n=s.toLocaleLowerCase();return this.bindings[n]&&(this.bindings[n]=this.bindings[n].filter(a=>{var o;return!(((o=a.type)===null||o===void 0?void 0:o.toLocaleLowerCase())===n&&U2e.isEqual(a.filter,r))})),this}static isEqual(s,r){if(Object.keys(s).length!==Object.keys(r).length)return!1;for(const n in s)if(s[n]!==r[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(s){this._on(Rg.close,{},s)}_onError(s){this._on(Rg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=mu.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=jEe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=jEe(s.columns,s.old_record)),r}}const lxe=()=>{},K7={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},jbt=[1e3,2e3,5e3,1e4],Nbt=1e4,kbt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class Sbt{constructor(s,r){var n;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=mve,this.transport=null,this.heartbeatIntervalMs=K7.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=lxe,this.ref=0,this.reconnectTimer=null,this.logger=lxe,this.conn=null,this.sendBuffer=[],this.serializer=new xbt,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)=>Al(async()=>{const{default:i}=await Promise.resolve().then(()=>fC);return{default:i}},void 0).then(({default:i})=>i(...l)).catch(i=>{throw new Error(`Failed to load @supabase/node-fetch: ${i.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):o=fetch,(...l)=>o(...l)},!(!((n=r==null?void 0:r.params)===null||n===void 0)&&n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey,this.endPoint=`${s}/${pve.websocket}`,this.httpEndpoint=gVe(s),this._initializeOptions(r),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(r==null?void 0:r.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=dbt.createWebSocket(this.endpointURL())}catch(s){this._setConnectionState("disconnected");const r=s.message;throw r.includes("Node.js")?new Error(`${r} To use Realtime in Node.js, you need to provide a WebSocket implementation: Option 1: Use Node.js 22+ which has native WebSocket support Option 2: Install and provide the "ws" package: npm install ws import ws from "ws" const client = new RealtimeClient(url, { ...options, transport: ws })`):new Error(`WebSocket not available: ${r}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:mbt}))}disconnect(s,r){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const n=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(n),this._setConnectionState("disconnected")},s?this.conn.close(s,r??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(s){const r=await s.unsubscribe();return this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const s=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),s}log(s,r,n){this.logger(s,r,n)}connectionState(){switch(this.conn&&this.conn.readyState){case $L.connecting:return c4.Connecting;case $L.open:return c4.Open;case $L.closing:return c4.Closing;default:return c4.Closed}}isConnected(){return this.connectionState()===c4.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(s,r={config:{}}){const n=`realtime:${s}`,a=this.getChannels().find(o=>o.topic===n);if(a)return a;{const o=new U2e(`realtime:${s}`,r,this);return this.channels.push(o),o}}push(s){const{topic:r,event:n,payload:a,ref:o}=s,l=()=>{this.encode(s,i=>{var c;(c=this.conn)===null||c===void 0||c.send(i)})};this.log("push",`${r} ${n} (${o})`,a),this.isConnected()?l():this.sendBuffer.push(l)}async setAuth(s=null){this._authPromise=this._performAuth(s);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var s;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(r){this.log("error","error in heartbeat callback",r)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(r){this.log("error","error in heartbeat callback",r)}this._wasManualDisconnect=!1,(s=this.conn)===null||s===void 0||s.close(pbt,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},K7.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(r){this.log("error","error in heartbeat callback",r)}this._setAuthSafely("heartbeat")}onHeartbeat(s){this.heartbeatCallback=s}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(s=>s()),this.sendBuffer=[])}_makeRef(){let s=this.ref+1;return s===this.ref?this.ref=0:this.ref=s,this.ref.toString()}_leaveOpenTopic(s){let r=this.channels.find(n=>n.topic===s&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${s}"`),r.unsubscribe())}_remove(s){this.channels=this.channels.filter(r=>r.topic!==s.topic)}_onConnMessage(s){this.decode(s.data,r=>{if(r.topic==="phoenix"&&r.event==="phx_reply")try{this.heartbeatCallback(r.payload.status==="ok"?"ok":"error")}catch(u){this.log("error","error in heartbeat callback",u)}r.ref&&r.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:a,payload:o,ref:l}=r,i=l?`(${l})`:"",c=o.status||"";this.log("receive",`${c} ${n} ${a} ${i}`.trim(),o),this.channels.filter(u=>u._isMember(n)).forEach(u=>u._trigger(a,o,l)),this._triggerStateCallbacks("message",r)})}_clearTimer(s){var r;s==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):s==="reconnect"&&((r=this.reconnectTimer)===null||r===void 0||r.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=s=>this._onConnError(s),this.conn.onmessage=s=>this._onConnMessage(s),this.conn.onclose=s=>this._onConnClose(s))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(s=>s.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const s=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(s),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(s){var r;this._setConnectionState("disconnected"),this.log("transport","close",s),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout(),this._triggerStateCallbacks("close",s)}_onConnError(s){this._setConnectionState("disconnected"),this.log("transport",`${s}`),this._triggerChanError(),this._triggerStateCallbacks("error",s)}_triggerChanError(){this.channels.forEach(s=>s._trigger(Rg.error))}_appendParams(s,r){if(Object.keys(r).length===0)return s;const n=s.match(/\?/)?"&":"?",a=new URLSearchParams(r);return`${s}${n}${a}`}_workerObjectUrl(s){let r;if(s)r=s;else{const n=new Blob([kbt],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}_setConnectionState(s,r=!1){this._connectionState=s,s==="connecting"?this._wasManualDisconnect=!1:s==="disconnecting"&&(this._wasManualDisconnect=r)}async _performAuth(s=null){let r;s?r=s:this.accessToken?r=await this.accessToken():r=this.accessTokenValue,this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{const a={access_token:r,version:hbt};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(Rg.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(s="general"){this.setAuth().catch(r=>{this.log("error",`error setting auth in ${s}`,r)})}_triggerStateCallbacks(s,r){try{this.stateChangeCallbacks[s].forEach(n=>{try{n(r)}catch(a){this.log("error",`error in ${s} callback`,a)}})}catch(n){this.log("error",`error triggering ${s} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new fVe(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},K7.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(s){var r,n,a,o,l,i,c,u,p;if(this.transport=(r=s==null?void 0:s.transport)!==null&&r!==void 0?r:null,this.timeout=(n=s==null?void 0:s.timeout)!==null&&n!==void 0?n:mve,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:K7.HEARTBEAT_INTERVAL,this.worker=(o=s==null?void 0:s.worker)!==null&&o!==void 0?o:!1,this.accessToken=(l=s==null?void 0:s.accessToken)!==null&&l!==void 0?l:null,this.heartbeatCallback=(i=s==null?void 0:s.heartbeatCallback)!==null&&i!==void 0?i:lxe,s!=null&&s.params&&(this.params=s.params),s!=null&&s.logger&&(this.logger=s.logger),(s!=null&&s.logLevel||s!=null&&s.log_level)&&(this.logLevel=s.logLevel||s.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(c=s==null?void 0:s.reconnectAfterMs)!==null&&c!==void 0?c:f=>jbt[f-1]||Nbt,this.encode=(u=s==null?void 0:s.encode)!==null&&u!==void 0?u:(f,g)=>g(JSON.stringify(f)),this.decode=(p=s==null?void 0:s.decode)!==null&&p!==void 0?p:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=s==null?void 0:s.workerUrl}}}class V2e extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function Yc(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class Cbt extends V2e{constructor(s,r,n){super(s),this.name="StorageApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class xve extends V2e{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const H2e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Al(async()=>{const{default:n}=await Promise.resolve().then(()=>fC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Mbt=()=>ya(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Al(()=>Promise.resolve().then(()=>fC),void 0)).Response:Response}),gve=t=>{if(Array.isArray(t))return t.map(r=>gve(r));if(typeof t=="function"||t!==Object(t))return t;const s={};return Object.entries(t).forEach(([r,n])=>{const a=r.replace(/([-_][a-z])/gi,o=>o.toUpperCase().replace(/[-_]/g,""));s[a]=gve(n)}),s},Tbt=t=>{if(typeof t!="object"||t===null)return!1;const s=Object.getPrototypeOf(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},cxe=t=>{var s;return t.msg||t.message||t.error_description||(typeof t.error=="string"?t.error:(s=t.error)===null||s===void 0?void 0:s.message)||JSON.stringify(t)},Abt=(t,s,r)=>ya(void 0,void 0,void 0,function*(){const n=yield Mbt();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(a=>{const o=t.status||500,l=(a==null?void 0:a.statusCode)||o+"";s(new Cbt(cxe(a),o,l))}).catch(a=>{s(new xve(cxe(a),a))}):s(new xve(cxe(t),t))}),Ebt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(Tbt(n)?(a.headers=Object.assign({"Content-Type":"application/json"},s==null?void 0:s.headers),a.body=JSON.stringify(n)):a.body=n,s!=null&&s.duplex&&(a.duplex=s.duplex),Object.assign(Object.assign({},a),r))};function kO(t,s,r,n,a,o){return ya(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Ebt(s,n,a,o)).then(c=>{if(!c.ok)throw c;return n!=null&&n.noResolveJson?c:c.json()}).then(c=>l(c)).catch(c=>Abt(c,i,n))})})}function K8(t,s,r,n){return ya(this,void 0,void 0,function*(){return kO(t,"GET",s,r,n)})}function Ig(t,s,r,n,a){return ya(this,void 0,void 0,function*(){return kO(t,"POST",s,n,a,r)})}function yve(t,s,r,n,a){return ya(this,void 0,void 0,function*(){return kO(t,"PUT",s,n,a,r)})}function Pbt(t,s,r,n){return ya(this,void 0,void 0,function*(){return kO(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function W2e(t,s,r,n,a){return ya(this,void 0,void 0,function*(){return kO(t,"DELETE",s,n,a,r)})}class Ibt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return ya(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Yc(s))return{data:null,error:s};throw s}})}}var yVe;class Lbt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[yVe]="BlobDownloadBuilder",this.promise=null}asStream(){return new Ibt(this.downloadFn,this.shouldThrowOnError)}then(s,r){return this.getPromise().then(s,r)}catch(s){return this.getPromise().catch(s)}finally(s){return this.getPromise().finally(s)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}execute(){return ya(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Yc(s))return{data:null,error:s};throw s}})}}yVe=Symbol.toStringTag;const Dbt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},SEe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Obt{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=H2e(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return ya(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},SEe),a);let i=Object.assign(Object.assign({},this.headers),s==="POST"&&{"x-upsert":String(l.upsert)});const c=l.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",l.cacheControl),c&&o.append("metadata",this.encodeMetadata(c)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",l.cacheControl),c&&o.append("metadata",this.encodeMetadata(c))):(o=n,i["cache-control"]=`max-age=${l.cacheControl}`,i["content-type"]=l.contentType,c&&(i["x-metadata"]=this.toBase64(this.encodeMetadata(c)))),a!=null&&a.headers&&(i=Object.assign(Object.assign({},i),a.headers));const u=this._removeEmptyFolders(r),p=this._getFinalPath(u),f=yield(s=="PUT"?yve:Ig)(this.fetch,`${this.url}/object/${p}`,o,Object.assign({headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{}));return{data:{path:u,id:f.Id,fullPath:f.Key},error:null}}catch(o){if(this.shouldThrowOnError)throw o;if(Yc(o))return{data:null,error:o};throw o}})}upload(s,r,n){return ya(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return ya(this,void 0,void 0,function*(){const o=this._removeEmptyFolders(s),l=this._getFinalPath(o),i=new URL(this.url+`/object/upload/sign/${l}`);i.searchParams.set("token",r);try{let c;const u=Object.assign({upsert:SEe.upsert},a),p=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&n instanceof Blob?(c=new FormData,c.append("cacheControl",u.cacheControl),c.append("",n)):typeof FormData<"u"&&n instanceof FormData?(c=n,c.append("cacheControl",u.cacheControl)):(c=n,p["cache-control"]=`max-age=${u.cacheControl}`,p["content-type"]=u.contentType);const f=yield yve(this.fetch,i.toString(),c,{headers:p});return{data:{path:o,fullPath:f.Key},error:null}}catch(c){if(this.shouldThrowOnError)throw c;if(Yc(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(s,r){return ya(this,void 0,void 0,function*(){try{let n=this._getFinalPath(s);const a=Object.assign({},this.headers);r!=null&&r.upsert&&(a["x-upsert"]="true");const o=yield Ig(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 V2e("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Yc(n))return{data:null,error:n};throw n}})}update(s,r,n){return ya(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return ya(this,void 0,void 0,function*(){try{return{data:yield Ig(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:s,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Yc(a))return{data:null,error:a};throw a}})}copy(s,r,n){return ya(this,void 0,void 0,function*(){try{return{data:{path:(yield Ig(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:s,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Yc(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return ya(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield Ig(this.fetch,`${this.url}/object/sign/${a}`,Object.assign({expiresIn:r},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers});const l=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return o={signedUrl:encodeURI(`${this.url}${o.signedURL}${l}`)},{data:o,error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Yc(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return ya(this,void 0,void 0,function*(){try{const a=yield Ig(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:s},{headers:this.headers}),o=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:a.map(l=>Object.assign(Object.assign({},l),{signedUrl:l.signedURL?encodeURI(`${this.url}${l.signedURL}${o}`):null})),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Yc(a))return{data:null,error:a};throw a}})}download(s,r){const a=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",o=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),l=o?`?${o}`:"",i=this._getFinalPath(s),c=()=>K8(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new Lbt(c,this.shouldThrowOnError)}info(s){return ya(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield K8(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:gve(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Yc(n))return{data:null,error:n};throw n}})}exists(s){return ya(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield Pbt(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Yc(n)&&n instanceof xve){const a=n.originalError;if([400,404].includes(a==null?void 0:a.status))return{data:!1,error:n}}throw n}})}getPublicUrl(s,r){const n=this._getFinalPath(s),a=[],o=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";o!==""&&a.push(o);const i=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",c=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});c!==""&&a.push(c);let u=a.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${u}`)}}}remove(s){return ya(this,void 0,void 0,function*(){try{return{data:yield W2e(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}list(s,r,n){return ya(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},Dbt),r),{prefix:s||""});return{data:yield Ig(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Yc(a))return{data:null,error:a};throw a}})}listV2(s,r){return ya(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield Ig(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Yc(n))return{data:null,error:n};throw n}})}encodeMetadata(s){return JSON.stringify(s)}toBase64(s){return typeof Buffer<"u"?Buffer.from(s).toString("base64"):btoa(s)}_getFinalPath(s){return`${this.bucketId}/${s.replace(/^\/+/,"")}`}_removeEmptyFolders(s){return s.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(s){const r=[];return s.width&&r.push(`width=${s.width}`),s.height&&r.push(`height=${s.height}`),s.resize&&r.push(`resize=${s.resize}`),s.format&&r.push(`format=${s.format}`),s.quality&&r.push(`quality=${s.quality}`),r.join("&")}}const vVe="2.78.0",bVe={"X-Client-Info":`storage-js/${vVe}`};class Rbt{constructor(s,r={},n,a){this.shouldThrowOnError=!1;const o=new URL(s);a!=null&&a.useNewHostname&&/supabase\.(co|in|red)$/.test(o.hostname)&&!o.hostname.includes("storage.supabase.")&&(o.hostname=o.hostname.replace("supabase.","storage.supabase.")),this.url=o.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},bVe),r),this.fetch=H2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return ya(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield K8(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}getBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield K8(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}createBucket(s){return ya(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield Ig(this.fetch,`${this.url}/bucket`,{id:r,name:r,type:n.type,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Yc(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return ya(this,void 0,void 0,function*(){try{return{data:yield yve(this.fetch,`${this.url}/bucket/${s}`,{id:s,name:s,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Yc(n))return{data:null,error:n};throw n}})}emptyBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield Ig(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield W2e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}listBucketOptionsToQueryString(s){const r={};return s&&("limit"in s&&(r.limit=String(s.limit)),"offset"in s&&(r.offset=String(s.offset)),s.search&&(r.search=s.search),s.sortColumn&&(r.sortColumn=s.sortColumn),s.sortOrder&&(r.sortOrder=s.sortOrder)),Object.keys(r).length>0?"?"+new URLSearchParams(r).toString():""}}class Fbt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},bVe),r),this.fetch=H2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield Ig(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}listBuckets(s){return ya(this,void 0,void 0,function*(){try{const r=new URLSearchParams;(s==null?void 0:s.limit)!==void 0&&r.set("limit",s.limit.toString()),(s==null?void 0:s.offset)!==void 0&&r.set("offset",s.offset.toString()),s!=null&&s.sortColumn&&r.set("sortColumn",s.sortColumn),s!=null&&s.sortOrder&&r.set("sortOrder",s.sortOrder),s!=null&&s.search&&r.set("search",s.search);const n=r.toString(),a=n?`${this.url}/bucket?${n}`:`${this.url}/bucket`;return{data:yield K8(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield W2e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Yc(r))return{data:null,error:r};throw r}})}}const G2e={"X-Client-Info":`storage-js/${vVe}`,"Content-Type":"application/json"};class _Ve extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function of(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class dxe extends _Ve{constructor(s,r,n){super(s),this.name="StorageVectorsApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class zbt extends _Ve{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var CEe;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(CEe||(CEe={}));const K2e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Al(async()=>{const{default:n}=await Promise.resolve().then(()=>fC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Bbt=t=>{if(typeof t!="object"||t===null)return!1;const s=Object.getPrototypeOf(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},MEe=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),$bt=(t,s,r)=>ya(void 0,void 0,void 0,function*(){if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!(r!=null&&r.noResolveJson)){const a=t.status||500,o=t;if(typeof o.json=="function")o.json().then(l=>{const i=(l==null?void 0:l.statusCode)||(l==null?void 0:l.code)||a+"";s(new dxe(MEe(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new dxe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new dxe(i,a,l))}}else s(new zbt(MEe(t),t))}),qbt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(Bbt(n)?(a.headers=Object.assign({"Content-Type":"application/json"},s==null?void 0:s.headers),a.body=JSON.stringify(n)):a.body=n,Object.assign(Object.assign({},a),r)):a};function Ubt(t,s,r,n,a,o){return ya(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,qbt(s,n,a,o)).then(c=>{if(!c.ok)throw c;if(n!=null&&n.noResolveJson)return c;const u=c.headers.get("content-type");return!u||!u.includes("application/json")?{}:c.json()}).then(c=>l(c)).catch(c=>$bt(c,i,n))})})}function lf(t,s,r,n,a){return ya(this,void 0,void 0,function*(){return Ubt(t,"POST",s,n,a,r)})}class Vbt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},G2e),r),this.fetch=K2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return ya(this,void 0,void 0,function*(){try{return{data:(yield lf(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}getIndex(s,r){return ya(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(of(n))return{data:null,error:n};throw n}})}listIndexes(s){return ya(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return ya(this,void 0,void 0,function*(){try{return{data:(yield lf(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(of(n))return{data:null,error:n};throw n}})}}class Hbt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},G2e),r),this.fetch=K2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return ya(this,void 0,void 0,function*(){try{if(s.vectors.length<1||s.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:(yield lf(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}getVectors(s){return ya(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}listVectors(s){return ya(this,void 0,void 0,function*(){try{if(s.segmentCount!==void 0){if(s.segmentCount<1||s.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(s.segmentIndex!==void 0&&(s.segmentIndex<0||s.segmentIndex>=s.segmentCount))throw new Error(`segmentIndex must be between 0 and ${s.segmentCount-1}`)}return{data:yield lf(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}queryVectors(s){return ya(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}deleteVectors(s){return ya(this,void 0,void 0,function*(){try{if(s.keys.length<1||s.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:(yield lf(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}}class Wbt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},G2e),r),this.fetch=K2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:(yield lf(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}getBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}listBuckets(){return ya(this,arguments,void 0,function*(s={}){try{return{data:yield lf(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ya(this,void 0,void 0,function*(){try{return{data:(yield lf(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}}class Gbt extends Wbt{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new Kbt(this.url,this.headers,s,this.fetch)}}class Kbt extends Vbt{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return ya(this,void 0,void 0,function*(){return r.createIndex.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName}))})}listIndexes(){const s=Object.create(null,{listIndexes:{get:()=>super.listIndexes}});return ya(this,arguments,void 0,function*(r={}){return s.listIndexes.call(this,Object.assign(Object.assign({},r),{vectorBucketName:this.vectorBucketName}))})}getIndex(s){const r=Object.create(null,{getIndex:{get:()=>super.getIndex}});return ya(this,void 0,void 0,function*(){return r.getIndex.call(this,this.vectorBucketName,s)})}deleteIndex(s){const r=Object.create(null,{deleteIndex:{get:()=>super.deleteIndex}});return ya(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new Zbt(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class Zbt extends Hbt{constructor(s,r,n,a,o){super(s,r,o),this.vectorBucketName=n,this.indexName=a}putVectors(s){const r=Object.create(null,{putVectors:{get:()=>super.putVectors}});return ya(this,void 0,void 0,function*(){return r.putVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}getVectors(s){const r=Object.create(null,{getVectors:{get:()=>super.getVectors}});return ya(this,void 0,void 0,function*(){return r.getVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}listVectors(){const s=Object.create(null,{listVectors:{get:()=>super.listVectors}});return ya(this,arguments,void 0,function*(r={}){return s.listVectors.call(this,Object.assign(Object.assign({},r),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}queryVectors(s){const r=Object.create(null,{queryVectors:{get:()=>super.queryVectors}});return ya(this,void 0,void 0,function*(){return r.queryVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}deleteVectors(s){const r=Object.create(null,{deleteVectors:{get:()=>super.deleteVectors}});return ya(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class Ybt extends Rbt{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new Obt(this.url,this.headers,s,this.fetch)}get vectors(){return new Gbt(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Fbt(this.url+"/iceberg",this.headers,this.fetch)}}const Xbt="2.78.0";let bI="";typeof Deno<"u"?bI="deno":typeof document<"u"?bI="web":typeof navigator<"u"&&navigator.product==="ReactNative"?bI="react-native":bI="node";const Qbt={"X-Client-Info":`supabase-js-${bI}/${Xbt}`},Jbt={headers:Qbt},e_t={schema:"public"},t_t={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},s_t={},r_t=t=>{let s;return t?s=t:typeof fetch>"u"?s=YUe:s=fetch,(...r)=>s(...r)},n_t=()=>typeof Headers>"u"?XUe:Headers,a_t=(t,s,r)=>{const n=r_t(r),a=n_t();return async(o,l)=>{var i;const c=(i=await s())!==null&&i!==void 0?i:t;let u=new a(l==null?void 0:l.headers);return u.has("apikey")||u.set("apikey",t),u.has("Authorization")||u.set("Authorization",`Bearer ${c}`),n(o,Object.assign(Object.assign({},l),{headers:u}))}};function i_t(t){return t.endsWith("/")?t:t+"/"}function o_t(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:c,auth:u,realtime:p,global:f}=s,g={db:Object.assign(Object.assign({},c),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},p),l),storage:{},global:Object.assign(Object.assign(Object.assign({},f),i),{headers:Object.assign(Object.assign({},(r=f==null?void 0:f.headers)!==null&&r!==void 0?r:{}),(n=i==null?void 0:i.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?g.accessToken=t.accessToken:delete g.accessToken,g}function l_t(t){const s=t==null?void 0:t.trim();if(!s)throw new Error("supabaseUrl is required.");if(!s.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(i_t(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const wVe="2.78.0",R5=30*1e3,vve=3,uxe=vve*R5,c_t="http://localhost:9999",d_t="supabase.auth.token",u_t={"X-Client-Info":`gotrue-js/${wVe}`},bve="X-Supabase-Api-Version",jVe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},h_t=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,m_t=10*60*1e3;class Z8 extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Ba(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class p_t extends Z8{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function f_t(t){return Ba(t)&&t.name==="AuthApiError"}class d4 extends Z8{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class Mw extends Z8{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class Cg extends Mw{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function x_t(t){return Ba(t)&&t.name==="AuthSessionMissingError"}class h5 extends Mw{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Z7 extends Mw{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class Y7 extends Mw{constructor(s,r=null){super(s,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function g_t(t){return Ba(t)&&t.name==="AuthImplicitGrantRedirectError"}class TEe extends Mw{constructor(s,r=null){super(s,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class _ve extends Mw{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function hxe(t){return Ba(t)&&t.name==="AuthRetryableFetchError"}class AEe extends Mw{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class wve extends Mw{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const xoe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),EEe=` \r=`.split(""),y_t=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(xoe[n]),s.queuedBits-=6}else if(s.queuedBits>0)for(s.queue=s.queue<<6-s.queuedBits,s.queuedBits=6;s.queuedBits>=6;){const n=s.queue>>s.queuedBits-6&63;r(xoe[n]),s.queuedBits-=6}}function NVe(t,s,r){const n=y_t[t];if(n>-1)for(s.queue=s.queue<<6|n,s.queuedBits+=6;s.queuedBits>=8;)r(s.queue>>s.queuedBits-8&255),s.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function IEe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{__t(l,n,r)};for(let l=0;l>6),s(128|t&63);return}else if(t<=65535){s(224|t>>12),s(128|t>>6&63),s(128|t&63);return}else if(t<=1114111){s(240|t>>18),s(128|t>>12&63),s(128|t>>6&63),s(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function b_t(t,s){for(let r=0;r55295&&n<=56319){const a=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|a)+65536,r+=1}v_t(n,s)}}function __t(t,s,r){if(s.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){s.utf8seq=n;break}if(s.utf8seq===2)s.codepoint=t&31;else if(s.utf8seq===3)s.codepoint=t&15;else if(s.utf8seq===4)s.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");s.utf8seq-=1}else if(s.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");s.codepoint=s.codepoint<<6|t&63,s.utf8seq-=1,s.utf8seq===0&&r(s.codepoint)}}function YM(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function g4(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>PEe(a,r,n)),PEe(null,r,n),s.join("")}function j_t(t){return Math.round(Date.now()/1e3)+t}function N_t(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const s=Math.random()*16|0;return(t=="x"?s:s&3|8).toString(16)})}const gm=()=>typeof window<"u"&&typeof document<"u",O2={tested:!1,writable:!1},kVe=()=>{if(!gm())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(O2.tested)return O2.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),O2.tested=!0,O2.writable=!0}catch{O2.tested=!0,O2.writable=!1}return O2.writable};function k_t(t){const s={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((a,o)=>{s[o]=a})}catch{}return r.searchParams.forEach((n,a)=>{s[a]=n}),s}const SVe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Al(async()=>{const{default:n}=await Promise.resolve().then(()=>fC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},S_t=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",F5=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},R2=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Pb=async(t,s)=>{await t.removeItem(s)};class Pde{constructor(){this.promise=new Pde.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}Pde.promiseConstructor=Promise;function mxe(t){const s=t.split(".");if(s.length!==3)throw new wve("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function M_t(t,s){return new Promise((n,a)=>{(async()=>{for(let o=0;o<1/0;o++)try{const l=await t(o);if(!s(o,null,l)){n(l);return}}catch(l){if(!s(o,l)){a(l);return}}})()})}function T_t(t){return("0"+t.toString(16)).substr(-2)}function A_t(){const s=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let a="";for(let o=0;o<56;o++)a+=r.charAt(Math.floor(Math.random()*n));return a}return crypto.getRandomValues(s),Array.from(s,T_t).join("")}async function E_t(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),a=new Uint8Array(n);return Array.from(a).map(o=>String.fromCharCode(o)).join("")}async function P_t(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await E_t(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function m5(t,s,r=!1){const n=A_t();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await F5(t,`${s}-code-verifier`,a);const o=await P_t(n);return[o,n===o?"plain":"s256"]}const I_t=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function L_t(t){const s=t.headers.get(bve);if(!s||!s.match(I_t))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function D_t(t){if(!t)throw new Error("Missing exp claim");const s=Math.floor(Date.now()/1e3);if(t<=s)throw new Error("JWT has expired")}function O_t(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const R_t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function p5(t){if(!R_t.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function pxe(){const t={};return new Proxy(t,{get:(s,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(s,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(s,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function F_t(t,s){return new Proxy(t,{get:(r,n,a)=>{if(n==="__isInsecureUserWarningProxy")return!0;if(typeof n=="symbol"){const o=n.toString();if(o==="Symbol(Symbol.toPrimitive)"||o==="Symbol(Symbol.toStringTag)"||o==="Symbol(util.inspect.custom)"||o==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,n,a)}return!s.value&&typeof n=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),s.value=!0),Reflect.get(r,n,a)}})}function LEe(t){return JSON.parse(JSON.stringify(t))}const r4=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),z_t=[502,503,504];async function DEe(t){var s;if(!S_t(t))throw new _ve(r4(t),0);if(z_t.includes(t.status))throw new _ve(r4(t),t.status);let r;try{r=await t.json()}catch(o){throw new d4(r4(o),o)}let n;const a=L_t(t);if(a&&a.getTime()>=jVe["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new AEe(r4(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new Cg}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((o,l)=>o&&typeof l=="string",!0))throw new AEe(r4(r),t.status,r.weak_password.reasons);throw new p_t(r4(r),t.status||500,n)}const B_t=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},s==null?void 0:s.headers),a.body=JSON.stringify(n),Object.assign(Object.assign({},a),r))};async function ji(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[bve]||(o[bve]=jVe["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():"",c=await $_t(t,s,r+i,{headers:o,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(c):{data:Object.assign({},c),error:null}}async function $_t(t,s,r,n,a,o){const l=B_t(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(c){throw console.error(c),new _ve(r4(c),0)}if(i.ok||await DEe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(c){await DEe(c)}}function Mg(t){var s;let r=null;V_t(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=j_t(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function OEe(t){const s=Mg(t);return!s.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(s.data.weak_password=t.weak_password),s}function n_(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function q_t(t){return{data:t,error:null}}function U_t(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=Cw(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),i={action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o},c=Object.assign({},l);return{data:{properties:i,user:c},error:null}}function REe(t){return t}function V_t(t){return t.access_token&&t.refresh_token&&t.expires_in}const fxe=["global","local","others"];class H_t{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=SVe(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(s,r=fxe[0]){if(fxe.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${fxe.join(", ")}`);try{return await ji(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Ba(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await ji(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:n_})}catch(n){if(Ba(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=Cw(s,["options"]),a=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(a.new_email=n==null?void 0:n.newEmail,delete a.newEmail),await ji(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:U_t,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Ba(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await ji(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:n_})}catch(r){if(Ba(r))return{data:{user:null},error:r};throw r}}async listUsers(s){var r,n,a,o,l,i,c;try{const u={nextPage:null,lastPage:0,total:0},p=await ji(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=s==null?void 0:s.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=s==null?void 0:s.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:REe});if(p.error)throw p.error;const f=await p.json(),g=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,b=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return b.length>0&&(b.forEach(_=>{const j=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(_.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ba(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){p5(s);try{return await ji(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:n_})}catch(r){if(Ba(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){p5(s);try{return await ji(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:n_})}catch(n){if(Ba(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){p5(s);try{return await ji(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:n_})}catch(n){if(Ba(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){p5(s.userId);try{const{data:r,error:n}=await ji(this.fetch,"GET",`${this.url}/admin/users/${s.userId}/factors`,{headers:this.headers,xform:a=>({data:{factors:a},error:null})});return{data:r,error:n}}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _deleteFactor(s){p5(s.userId),p5(s.id);try{return{data:await ji(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _listOAuthClients(s){var r,n,a,o,l,i,c;try{const u={nextPage:null,lastPage:0,total:0},p=await ji(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=s==null?void 0:s.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=s==null?void 0:s.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:REe});if(p.error)throw p.error;const f=await p.json(),g=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,b=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return b.length>0&&(b.forEach(_=>{const j=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(_.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ba(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await ji(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await ji(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await ji(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ba(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await ji(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await ji(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}}function FEe(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const f5={debug:!!(globalThis&&kVe()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class CVe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class W_t extends CVe{}async function G_t(t,s,r){f5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),f5.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},s),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,s===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async a=>{if(a){f5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{f5.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw f5.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new W_t(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(f5.debug)try{const o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}function K_t(){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 MVe(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Z_t(t){return parseInt(t,16)}function Y_t(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function X_t(t){var s;const{chainId:r,domain:n,expirationTime:a,issuedAt:o=new Date,nonce:l,notBefore:i,requestId:c,resources:u,scheme:p,uri:f,version:g}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!n)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(l&&l.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${l}`);if(!f)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(g!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${g}`);if(!((s=t.statement)===null||s===void 0)&&s.includes(` `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const b=MVe(t.address),_=p?`${p}://${n}`:n,j=t.statement?`${t.statement} `:"",w=`${_} wants you to sign in with your Ethereum account: ${b} ${j}`;let N=`URI: ${f} Version: ${g} Chain ID: ${r}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(N+=` Expiration Time: ${a.toISOString()}`),i&&(N+=` Not Before: ${i.toISOString()}`),c&&(N+=` Request ID: ${c}`),u){let S=` Resources:`;for(const M of u){if(!M||typeof M!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${M}`);S+=` - ${M}`}N+=S}return`${w} ${N}`}class Zd extends Error{constructor({message:s,code:r,cause:n,name:a}){var o;super(s,{cause:n}),this.__isWebAuthnError=!0,this.name=(o=a??(n instanceof Error?n.name:void 0))!==null&&o!==void 0?o:"Unknown Error",this.code=r}}class goe extends Zd{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function Q_t({error:t,options:s}){var r,n,a;const{publicKey:o}=s;if(!o)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new Zd({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=o.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new Zd({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(s.mediation==="conditional"&&((n=o.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new Zd({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((a=o.authenticatorSelection)===null||a===void 0?void 0:a.userVerification)==="required")return new Zd({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Zd({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Zd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return o.pubKeyCredParams.filter(i=>i.type==="public-key").length===0?new Zd({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Zd({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const l=window.location.hostname;if(TVe(l)){if(o.rp.id!==l)return new Zd({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Zd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(o.user.id.byteLength<1||o.user.id.byteLength>64)return new Zd({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Zd({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Zd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function J_t({error:t,options:s}){const{publicKey:r}=s;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new Zd({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Zd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(TVe(n)){if(r.rpId!==n)return new Zd({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Zd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Zd({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Zd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class ewt{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const s=new AbortController;return this.controller=s,s.signal}cancelCeremony(){if(this.controller){const s=new Error("Manually cancelling existing WebAuthn API call");s.name="AbortError",this.controller.abort(s),this.controller=void 0}}}const twt=new ewt;function swt(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:s,user:r,excludeCredentials:n}=t,a=Cw(t,["challenge","user","excludeCredentials"]),o=YM(s).buffer,l=Object.assign(Object.assign({},r),{id:YM(r.id).buffer}),i=Object.assign(Object.assign({},a),{challenge:o,user:l});if(n&&n.length>0){i.excludeCredentials=new Array(n.length);for(let c=0;c0){o.allowCredentials=new Array(r.length);for(let l=0;la!==null&&typeof a=="object"&&!Array.isArray(a),r=a=>a instanceof ArrayBuffer||ArrayBuffer.isView(a),n={};for(const a of t)if(a)for(const o in a){const l=a[o];if(l!==void 0)if(Array.isArray(l))n[o]=l;else if(r(l))n[o]=l;else if(s(l)){const i=n[o];s(i)?n[o]=yoe(i,l):n[o]=yoe(l)}else n[o]=l}return n}function dwt(t,s){return yoe(lwt,t,s||{})}function uwt(t,s){return yoe(cwt,t,s||{})}class hwt{constructor(s){this.client=s,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(s){return this.client.mfa.enroll(Object.assign(Object.assign({},s),{factorType:"webauthn"}))}async _challenge({factorId:s,webauthn:r,friendlyName:n,signal:a},o){try{const{data:l,error:i}=await this.client.mfa.challenge({factorId:s,webauthn:r});if(!l)return{data:null,error:i};const c=a??twt.createNewAbortSignal();if(l.webauthn.type==="create"){const{user:u}=l.webauthn.credential_options.publicKey;u.name||(u.name=`${u.id}:${n}`),u.displayName||(u.displayName=u.name)}switch(l.webauthn.type){case"create":{const u=dwt(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:p,error:f}=await iwt({publicKey:u,signal:c});return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}case"request":{const u=uwt(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:p,error:f}=await owt(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:u,signal:c}));return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}}}catch(l){return Ba(l)?{data:null,error:l}:{data:null,error:new d4("Unexpected error in challenge",l)}}}async _verify({challengeId:s,factorId:r,webauthn:n}){return this.client.mfa.verify({factorId:r,challengeId:s,webauthn:n})}async _authenticate({factorId:s,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:a}},o){if(!r)return{data:null,error:new Z8("rpId is required for WebAuthn authentication")};try{if(!zEe())return{data:null,error:new d4("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this.challenge({factorId:s,webauthn:{rpId:r,rpOrigins:n},signal:a},{request:o});if(!l)return{data:null,error:i};const{webauthn:c}=l;return this._verify({factorId:s,challengeId:l.challengeId,webauthn:{type:c.type,rpId:r,rpOrigins:n,credential_response:c.credential_response}})}catch(l){return Ba(l)?{data:null,error:l}:{data:null,error:new d4("Unexpected error in authenticate",l)}}}async _register({friendlyName:s,rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:a},o){if(!r)return{data:null,error:new Z8("rpId is required for WebAuthn registration")};try{if(!zEe())return{data:null,error:new d4("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this._enroll({friendlyName:s});if(!l)return await this.client.mfa.listFactors().then(p=>{var f;return(f=p.data)===null||f===void 0?void 0:f.all.find(g=>g.factor_type==="webauthn"&&g.friendly_name===s&&g.status!=="unverified")}).then(p=>p?this.client.mfa.unenroll({factorId:p==null?void 0:p.id}):void 0),{data:null,error:i};const{data:c,error:u}=await this._challenge({factorId:l.id,friendlyName:l.friendly_name,webauthn:{rpId:r,rpOrigins:n},signal:a},{create:o});return c?this._verify({factorId:l.id,challengeId:c.challengeId,webauthn:{rpId:r,rpOrigins:n,type:c.webauthn.type,credential_response:c.webauthn.credential_response}}):{data:null,error:u}}catch(l){return Ba(l)?{data:null,error:l}:{data:null,error:new d4("Unexpected error in register",l)}}}}K_t();const mwt={url:c_t,storageKey:d_t,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:u_t,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function BEe(t,s,r){return await r()}const x5={};class Y8{get jwks(){var s,r;return(r=(s=x5[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){x5[this.storageKey]=Object.assign(Object.assign({},x5[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=x5[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){x5[this.storageKey]=Object.assign(Object.assign({},x5[this.storageKey]),{cachedAt:s})}constructor(s){var r,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Y8.nextInstanceID,Y8.nextInstanceID+=1,this.instanceID>0&&gm()&&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({},mwt),s);if(this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.persistSession=a.persistSession,this.storageKey=a.storageKey,this.autoRefreshToken=a.autoRefreshToken,this.admin=new H_t({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=SVe(a.fetch),this.lock=a.lock||BEe,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:gm()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=G_t:this.lock=BEe,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 hwt(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:kVe()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=FEe(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=FEe(this.memoryStorage)),gm()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o),await this._notifyAllSubscribers(o.data.event,o.data.session,!1)})}this.initialize()}_debug(...s){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${wVe}) ${new Date().toISOString()}`,...s),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var s;try{const r=k_t(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),gm()&&this.detectSessionInUrl&&n!=="none"){const{data:a,error:o}=await this._getSessionFromURL(r,n);if(o){if(this._debug("#_initialize()","error detecting session from URL",o),g_t(o)){const c=(s=o.details)===null||s===void 0?void 0:s.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:o}}return await this._removeSession(),{error:o}}const{session:l,redirectType:i}=a;return this._debug("#_initialize()","detected session in URL",l,"redirect type",i),await this._saveSession(l),setTimeout(async()=>{i==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",l):await this._notifyAllSubscribers("SIGNED_IN",l)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return Ba(r)?{error:r}:{error:new d4("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await ji(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=s==null?void 0:s.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(a=s==null?void 0:s.options)===null||a===void 0?void 0:a.captchaToken}},xform:Mg}),{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const c=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(o){if(Ba(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(s){var r,n,a;try{let o;if("email"in s){const{email:p,password:f,options:g}=s;let b=null,_=null;this.flowType==="pkce"&&([b,_]=await m5(this.storage,this.storageKey)),o=await ji(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:g==null?void 0:g.emailRedirectTo,body:{email:p,password:f,data:(r=g==null?void 0:g.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:g==null?void 0:g.captchaToken},code_challenge:b,code_challenge_method:_},xform:Mg})}else if("phone"in s){const{phone:p,password:f,options:g}=s;o=await ji(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:f,data:(n=g==null?void 0:g.data)!==null&&n!==void 0?n:{},channel:(a=g==null?void 0:g.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:g==null?void 0:g.captchaToken}},xform:Mg})}else throw new Z7("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 c=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(o){if(Ba(o))return{data:{user:null,session:null},error:o};throw o}}async signInWithPassword(s){try{let r;if("email"in s){const{email:o,password:l,options:i}=s;r=await ji(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:OEe})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await ji(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:OEe})}else throw new Z7("You must provide either an email or phone number and a password");const{data:n,error:a}=r;return a?{data:{user:null,session:null},error:a}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new h5}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:a})}catch(r){if(Ba(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(s){var r,n,a,o;return await this._handleProviderSignIn(s.provider,{redirectTo:(r=s.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=s.options)===null||n===void 0?void 0:n.scopes,queryParams:(a=s.options)===null||a===void 0?void 0:a.queryParams,skipBrowserRedirect:(o=s.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(s){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(s))}async signInWithWeb3(s){const{chain:r}=s;switch(r){case"ethereum":return await this.signInWithEthereum(s);case"solana":return await this.signInWithSolana(s);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(s){var r,n,a,o,l,i,c,u,p,f,g;let b,_;if("message"in s)b=s.message,_=s.signature;else{const{chain:j,wallet:w,statement:N,options:S}=s;let M;if(gm())if(typeof w=="object")M=w;else{const B=window;if("ethereum"in B&&typeof B.ethereum=="object"&&"request"in B.ethereum&&typeof B.ethereum.request=="function")M=B.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof w!="object"||!(S!=null&&S.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");M=w}const L=new URL((r=S==null?void 0:S.url)!==null&&r!==void 0?r:window.location.href),I=await M.request({method:"eth_requestAccounts"}).then(B=>B).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!I||I.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const O=MVe(I[0]);let q=(n=S==null?void 0:S.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!q){const B=await M.request({method:"eth_chainId"});q=Z_t(B)}const U={domain:L.host,address:O,statement:N,uri:L.href,version:"1",chainId:q,nonce:(a=S==null?void 0:S.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=S==null?void 0:S.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=S==null?void 0:S.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(c=S==null?void 0:S.signInWithEthereum)===null||c===void 0?void 0:c.notBefore,requestId:(u=S==null?void 0:S.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(p=S==null?void 0:S.signInWithEthereum)===null||p===void 0?void 0:p.resources};b=X_t(U),_=await M.request({method:"personal_sign",params:[Y_t(b),O]})}try{const{data:j,error:w}=await ji(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:b,signature:_},!((f=s.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(g=s.options)===null||g===void 0?void 0:g.captchaToken}}:null),xform:Mg});if(w)throw w;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new h5}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:w})}catch(j){if(Ba(j))return{data:{user:null,session:null},error:j};throw j}}async signInWithSolana(s){var r,n,a,o,l,i,c,u,p,f,g,b;let _,j;if("message"in s)_=s.message,j=s.signature;else{const{chain:w,wallet:N,statement:S,options:M}=s;let L;if(gm())if(typeof N=="object")L=N;else{const O=window;if("solana"in O&&typeof O.solana=="object"&&("signIn"in O.solana&&typeof O.solana.signIn=="function"||"signMessage"in O.solana&&typeof O.solana.signMessage=="function"))L=O.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof N!="object"||!(M!=null&&M.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");L=N}const I=new URL((r=M==null?void 0:M.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in L&&L.signIn){const O=await L.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},M==null?void 0:M.signInWithSolana),{version:"1",domain:I.host,uri:I.href}),S?{statement:S}:null));let q;if(Array.isArray(O)&&O[0]&&typeof O[0]=="object")q=O[0];else if(O&&typeof O=="object"&&"signedMessage"in O&&"signature"in O)q=O;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in q&&"signature"in q&&(typeof q.signedMessage=="string"||q.signedMessage instanceof Uint8Array)&&q.signature instanceof Uint8Array)_=typeof q.signedMessage=="string"?q.signedMessage:new TextDecoder().decode(q.signedMessage),j=q.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in L)||typeof L.signMessage!="function"||!("publicKey"in L)||typeof L!="object"||!L.publicKey||!("toBase58"in L.publicKey)||typeof L.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");_=[`${I.host} wants you to sign in with your Solana account:`,L.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${I.href}`,`Issued At: ${(a=(n=M==null?void 0:M.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((o=M==null?void 0:M.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${M.signInWithSolana.notBefore}`]:[],...!((l=M==null?void 0:M.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${M.signInWithSolana.expirationTime}`]:[],...!((i=M==null?void 0:M.signInWithSolana)===null||i===void 0)&&i.chainId?[`Chain ID: ${M.signInWithSolana.chainId}`]:[],...!((c=M==null?void 0:M.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${M.signInWithSolana.nonce}`]:[],...!((u=M==null?void 0:M.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${M.signInWithSolana.requestId}`]:[],...!((f=(p=M==null?void 0:M.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||f===void 0)&&f.length?["Resources",...M.signInWithSolana.resources.map(q=>`- ${q}`)]:[]].join(` `);const O=await L.signMessage(new TextEncoder().encode(_),"utf8");if(!O||!(O instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");j=O}}try{const{data:w,error:N}=await ji(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:_,signature:g4(j)},!((g=s.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(b=s.options)===null||b===void 0?void 0:b.captchaToken}}:null),xform:Mg});if(N)throw N;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new h5}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:N})}catch(w){if(Ba(w))return{data:{user:null,session:null},error:w};throw w}}async _exchangeCodeForSession(s){const r=await R2(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await ji(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:Mg});if(await Pb(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new h5}:(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(Ba(o))return{data:{user:null,session:null,redirectType:null},error:o};throw o}}async signInWithIdToken(s){try{const{options:r,provider:n,token:a,access_token:o,nonce:l}=s,i=await ji(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:a,access_token:o,nonce:l,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Mg}),{data:c,error:u}=i;return u?{data:{user:null,session:null},error:u}:!c||!c.session||!c.user?{data:{user:null,session:null},error:new h5}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:u})}catch(r){if(Ba(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(s){var r,n,a,o,l;try{if("email"in s){const{email:i,options:c}=s;let u=null,p=null;this.flowType==="pkce"&&([u,p]=await m5(this.storage,this.storageKey));const{error:f}=await ji(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:i,data:(r=c==null?void 0:c.data)!==null&&r!==void 0?r:{},create_user:(n=c==null?void 0:c.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},code_challenge:u,code_challenge_method:p},redirectTo:c==null?void 0:c.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in s){const{phone:i,options:c}=s,{data:u,error:p}=await ji(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:i,data:(a=c==null?void 0:c.data)!==null&&a!==void 0?a:{},create_user:(o=c==null?void 0:c.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(l=c==null?void 0:c.channel)!==null&&l!==void 0?l:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:p}}throw new Z7("You must provide either an email or phone number.")}catch(i){if(Ba(i))return{data:{user:null,session:null},error:i};throw i}}async verifyOtp(s){var r,n;try{let a,o;"options"in s&&(a=(r=s.options)===null||r===void 0?void 0:r.redirectTo,o=(n=s.options)===null||n===void 0?void 0:n.captchaToken);const{data:l,error:i}=await ji(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:Mg});if(i)throw i;if(!l)throw new Error("An error occurred on token verification.");const c=l.session,u=l.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(s.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(a){if(Ba(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithSSO(s){var r,n,a;try{let o=null,l=null;return this.flowType==="pkce"&&([o,l]=await m5(this.storage,this.storageKey)),await ji(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in s?{provider_id:s.providerId}:null),"domain"in s?{domain:s.domain}:null),{redirect_to:(n=(r=s.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((a=s==null?void 0:s.options)===null||a===void 0)&&a.captchaToken?{gotrue_meta_security:{captcha_token:s.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:l}),headers:this.headers,xform:q_t})}catch(o){if(Ba(o))return{data:null,error:o};throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)throw n;if(!r)throw new Cg;const{error:a}=await ji(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Ba(s))return{data:{user:null,session:null},error:s};throw s}}async resend(s){try{const r=`${this.url}/resend`;if("email"in s){const{email:n,type:a,options:o}=s,{error:l}=await ji(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},redirectTo:o==null?void 0:o.emailRedirectTo});return{data:{user:null,session:null},error:l}}else if("phone"in s){const{phone:n,type:a,options:o}=s,{data:l,error:i}=await ji(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}}});return{data:{user:null,session:null,messageId:l==null?void 0:l.message_id},error:i}}throw new Z7("You must provide either an email or phone number and a type")}catch(r){if(Ba(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(s,r){this._debug("#_acquireLock","begin",s);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),a=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await a}catch{}})()),a}return await this.lock(`lock:${this.storageKey}`,s,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const a=[...this.pendingInLock];await Promise.all(a),this.pendingInLock.splice(0,a.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(s){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await s(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let s=null;const r=await R2(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?s=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!s)return{data:{session:null},error:null};const n=s.expires_at?s.expires_at*1e3-Date.now()await this._getUser()))}async _getUser(s){try{return s?await ji(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:n_}):await this._useSession(async r=>{var n,a,o;const{data:l,error:i}=r;if(i)throw i;return!(!((n=l.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Cg}:await ji(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:n_})})}catch(r){if(Ba(r))return x_t(r)&&(await this._removeSession(),await Pb(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(s,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(s,r))}async _updateUser(s,r={}){try{return await this._useSession(async n=>{const{data:a,error:o}=n;if(o)throw o;if(!a.session)throw new Cg;const l=a.session;let i=null,c=null;this.flowType==="pkce"&&s.email!=null&&([i,c]=await m5(this.storage,this.storageKey));const{data:u,error:p}=await ji(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},s),{code_challenge:i,code_challenge_method:c}),jwt:l.access_token,xform:n_});if(p)throw p;return l.user=u.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(n){if(Ba(n))return{data:{user:null},error:n};throw n}}async setSession(s){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(s))}async _setSession(s){try{if(!s.access_token||!s.refresh_token)throw new Cg;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=mxe(s.access_token);if(l.exp&&(n=l.exp,a=n<=r),a){const{data:i,error:c}=await this._callRefreshToken(s.refresh_token);if(c)return{data:{user:null,session:null},error:c};if(!i)return{data:{user:null,session:null},error:null};o=i}else{const{data:i,error:c}=await this._getUser(s.access_token);if(c)throw c;o={access_token:s.access_token,refresh_token:s.refresh_token,user:i.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(r){if(Ba(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(s){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(s))}async _refreshSession(s){try{return await this._useSession(async r=>{var n;if(!s){const{data:l,error:i}=r;if(i)throw i;s=(n=l.session)!==null&&n!==void 0?n:void 0}if(!(s!=null&&s.refresh_token))throw new Cg;const{data:a,error:o}=await this._callRefreshToken(s.refresh_token);return o?{data:{user:null,session:null},error:o}:a?{data:{user:a.user,session:a},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(Ba(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!gm())throw new Y7("No browser detected.");if(s.error||s.error_description||s.error_code)throw new Y7(s.error_description||"Error in URL with unspecified error_description",{error:s.error||"unspecified_error",code:s.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new TEe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Y7("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!s.code)throw new TEe("No code detected.");const{data:S,error:M}=await this._exchangeCodeForSession(s.code);if(M)throw M;const L=new URL(window.location.href);return L.searchParams.delete("code"),window.history.replaceState(window.history.state,"",L.toString()),{data:{session:S.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:c,token_type:u}=s;if(!o||!i||!l||!u)throw new Y7("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(i);let g=p+f;c&&(g=parseInt(c));const b=g-p;b*1e3<=R5&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${b}s, should have been closer to ${f}s`);const _=g-f;p-_>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",_,g,p):p-_<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",_,g,p);const{data:j,error:w}=await this._getUser(o);if(w)throw w;const N={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:f,expires_at:g,refresh_token:l,token_type:u,user:j.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:N,redirectType:s.type},error:null}}catch(n){if(Ba(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(s){return!!(s.access_token||s.error_description)}async _isPKCECallback(s){const r=await R2(this.storage,`${this.storageKey}-code-verifier`);return!!(s.code&&r)}async signOut(s={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(s))}async _signOut({scope:s}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{error:o};const l=(n=a.session)===null||n===void 0?void 0:n.access_token;if(l){const{error:i}=await this.admin.signOut(l,s);if(i&&!(f_t(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await Pb(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=N_t(),n={id:r,callback:s,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(s){return await this._useSession(async r=>{var n,a;try{const{data:{session:o},error:l}=r;if(l)throw l;await((n=this.stateChangeEmitters.get(s))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",s,"session",o)}catch(o){await((a=this.stateChangeEmitters.get(s))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",s,"error",o),console.error(o)}})}async resetPasswordForEmail(s,r={}){let n=null,a=null;this.flowType==="pkce"&&([n,a]=await m5(this.storage,this.storageKey,!0));try{return await ji(this.fetch,"POST",`${this.url}/recover`,{body:{email:s,code_challenge:n,code_challenge_method:a,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(o){if(Ba(o))return{data:null,error:o};throw o}}async getUserIdentities(){var s;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(s=r.user.identities)!==null&&s!==void 0?s:[]},error:null}}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async linkIdentity(s){return"token"in s?this.linkIdentityIdToken(s):this.linkIdentityOAuth(s)}async linkIdentityOAuth(s){var r;try{const{data:n,error:a}=await this._useSession(async o=>{var l,i,c,u,p;const{data:f,error:g}=o;if(g)throw g;const b=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,s.provider,{redirectTo:(l=s.options)===null||l===void 0?void 0:l.redirectTo,scopes:(i=s.options)===null||i===void 0?void 0:i.scopes,queryParams:(c=s.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await ji(this.fetch,"GET",b,{headers:this.headers,jwt:(p=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return gm()&&!(!((r=s.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:s.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(Ba(n))return{data:{provider:s.provider,url:null},error:n};throw n}}async linkIdentityIdToken(s){return await this._useSession(async r=>{var n;try{const{error:a,data:{session:o}}=r;if(a)throw a;const{options:l,provider:i,token:c,access_token:u,nonce:p}=s,f=await ji(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:c,access_token:u,nonce:p,link_identity:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:Mg}),{data:g,error:b}=f;return b?{data:{user:null,session:null},error:b}:!g||!g.session||!g.user?{data:{user:null,session:null},error:new h5}:(g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("USER_UPDATED",g.session)),{data:g,error:b})}catch(a){if(Ba(a))return{data:{user:null,session:null},error:a};throw a}})}async unlinkIdentity(s){try{return await this._useSession(async r=>{var n,a;const{data:o,error:l}=r;if(l)throw l;return await ji(this.fetch,"DELETE",`${this.url}/user/identities/${s.identity_id}`,{headers:this.headers,jwt:(a=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&a!==void 0?a:void 0})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _refreshAccessToken(s){const r=`#_refreshAccessToken(${s.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await M_t(async a=>(a>0&&await C_t(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await ji(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:Mg})),(a,o)=>{const l=200*Math.pow(2,a);return o&&hxe(o)&&Date.now()+l-n{try{await i.callback(s,r)}catch(c){o.push(c)}});if(await Promise.all(l),o.length>0){for(let i=0;ithis._autoRefreshTokenTick(),R5);this.autoRefreshTicker=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const s=this.autoRefreshTicker;this.autoRefreshTicker=null,s&&clearInterval(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const s=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const a=Math.floor((n.expires_at*1e3-s)/R5);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${R5}ms, refresh threshold is ${vve} ticks`),a<=vve&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(s){if(s.isAcquireTimeout||s instanceof CVe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!gm()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(s){console.error("_handleVisibilityChange",s)}}async _onVisibilityChanged(s){const r=`#_onVisibilityChanged(${s})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),s||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(s,r,n){const a=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&a.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&a.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[o,l]=await m5(this.storage,this.storageKey),i=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(l)}`});a.push(i.toString())}if(n!=null&&n.queryParams){const o=new URLSearchParams(n.queryParams);a.push(o.toString())}return n!=null&&n.skipBrowserRedirect&&a.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${s}?${a.join("&")}`}async _unenroll(s){try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;return o?{data:null,error:o}:await ji(this.fetch,"DELETE",`${this.url}/factors/${s.factorId}`,{headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _enroll(s){try{return await this._useSession(async r=>{var n,a;const{data:o,error:l}=r;if(l)return{data:null,error:l};const i=Object.assign({friendly_name:s.friendlyName,factor_type:s.factorType},s.factorType==="phone"?{phone:s.phone}:s.factorType==="totp"?{issuer:s.issuer}:{}),{data:c,error:u}=await ji(this.fetch,"POST",`${this.url}/factors`,{body:i,headers:this.headers,jwt:(n=o==null?void 0:o.session)===null||n===void 0?void 0:n.access_token});return u?{data:null,error:u}:(s.factorType==="totp"&&c.type==="totp"&&(!((a=c==null?void 0:c.totp)===null||a===void 0)&&a.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),{data:c,error:null})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _verify(s){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{data:null,error:o};const l=Object.assign({challenge_id:s.challengeId},"webauthn"in s?{webauthn:Object.assign(Object.assign({},s.webauthn),{credential_response:s.webauthn.type==="create"?nwt(s.webauthn.credential_response):awt(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:c}=await ji(this.fetch,"POST",`${this.url}/factors/${s.factorId}/verify`,{body:l,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return c?{data:null,error:c}:(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:c})})}catch(r){if(Ba(r))return{data:null,error:r};throw r}})}async _challenge(s){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{data:null,error:o};const l=await ji(this.fetch,"POST",`${this.url}/factors/${s.factorId}/challenge`,{body:s,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});if(l.error)return l;const{data:i}=l;if(i.type!=="webauthn")return{data:i,error:null};switch(i.webauthn.type){case"create":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:swt(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:rwt(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(Ba(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(s){const{data:r,error:n}=await this._challenge({factorId:s.factorId});return n?{data:null,error:n}:await this._verify({factorId:s.factorId,challengeId:r.id,code:s.code})}async _listFactors(){var s;const{data:{user:r},error:n}=await this.getUser();if(n)return{data:null,error:n};const a={all:[],phone:[],totp:[],webauthn:[]};for(const o of(s=r==null?void 0:r.factors)!==null&&s!==void 0?s:[])a.all.push(o),o.status==="verified"&&a[o.factor_type].push(o);return{data:a,error:null}}async _getAuthenticatorAssuranceLevel(){var s,r;const{data:{session:n},error:a}=await this.getSession();if(a)return{data:null,error:a};if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=mxe(n.access_token);let l=null;o.aal&&(l=o.aal);let i=l;((r=(s=n.user.factors)===null||s===void 0?void 0:s.filter(p=>p.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(i="aal2");const u=o.amr||[];return{data:{currentLevel:l,nextLevel:i,currentAuthenticationMethods:u},error:null}}async _getAuthorizationDetails(s){try{return await this._useSession(async r=>{const{data:{session:n},error:a}=r;return a?{data:null,error:a}:n?await ji(this.fetch,"GET",`${this.url}/oauth/authorizations/${s}`,{headers:this.headers,jwt:n.access_token,xform:o=>({data:o,error:null})}):{data:null,error:new Cg}})}catch(r){if(Ba(r))return{data:null,error:r};throw r}}async _approveAuthorization(s,r){try{return await this._useSession(async n=>{const{data:{session:a},error:o}=n;if(o)return{data:null,error:o};if(!a)return{data:null,error:new Cg};const l=await ji(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"approve"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&gm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ba(n))return{data:null,error:n};throw n}}async _denyAuthorization(s,r){try{return await this._useSession(async n=>{const{data:{session:a},error:o}=n;if(o)return{data:null,error:o};if(!a)return{data:null,error:new Cg};const l=await ji(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"deny"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&gm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ba(n))return{data:null,error:n};throw n}}async fetchJwk(s,r={keys:[]}){let n=r.keys.find(i=>i.kid===s);if(n)return n;const a=Date.now();if(n=this.jwks.keys.find(i=>i.kid===s),n&&this.jwks_cached_at+m_t>a)return n;const{data:o,error:l}=await ji(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(l)throw l;return!o.keys||o.keys.length===0||(this.jwks=o,this.jwks_cached_at=a,n=o.keys.find(i=>i.kid===s),!n)?null:n}async getClaims(s,r={}){try{let n=s;if(!n){const{data:b,error:_}=await this.getSession();if(_||!b.session)return{data:null,error:_};n=b.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:c}}=mxe(n);r!=null&&r.allowExpired||D_t(o.exp);const u=!a.alg||a.alg.startsWith("HS")||!a.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(a.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!u){const{error:b}=await this.getUser(n);if(b)throw b;return{data:{claims:o,header:a,signature:l},error:null}}const p=O_t(a.alg),f=await crypto.subtle.importKey("jwk",u,p,!0,["verify"]);if(!await crypto.subtle.verify(p,f,l,w_t(`${i}.${c}`)))throw new wve("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Ba(n))return{data:null,error:n};throw n}}}Y8.nextInstanceID=0;const pwt=Y8;class fwt extends pwt{constructor(s){super(s)}}class xwt{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=l_t(s);if(!r)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const c=`sb-${i.hostname.split(".")[0]}-auth-token`,u={db:e_t,realtime:s_t,auth:Object.assign(Object.assign({},t_t),{storageKey:c}),global:Jbt},p=o_t(n??{},u);this.storageKey=(a=p.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=p.global.headers)!==null&&o!==void 0?o:{},p.accessToken?(this.accessToken=p.accessToken,this.auth=new Proxy({},{get:(f,g)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(g)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=p.auth)!==null&&l!==void 0?l:{},this.headers,p.global.fetch),this.fetch=a_t(r,this._getAccessToken.bind(this),p.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},p.realtime)),this.rest=new cbt(new URL("rest/v1",i).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new Ybt(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new tbt(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(s){return this.rest.from(s)}schema(s){return this.rest.schema(s)}rpc(s,r={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(s,r,n)}channel(s,r={config:{}}){return this.realtime.channel(s,r)}getChannels(){return this.realtime.getChannels()}removeChannel(s){return this.realtime.removeChannel(s)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var s,r;if(this.accessToken)return await this.accessToken();const{data:n}=await this.auth.getSession();return(r=(s=n.session)===null||s===void 0?void 0:s.access_token)!==null&&r!==void 0?r:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,storageKey:l,flowType:i,lock:c,debug:u},p,f){const g={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new fwt({url:this.authUrl.href,headers:Object.assign(Object.assign({},g),p),storageKey:l,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,flowType:i,lock:c,debug:u,fetch:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(b=>b.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new Sbt(this.realtimeUrl.href,Object.assign(Object.assign({},s),{params:Object.assign({apikey:this.supabaseKey},s==null?void 0:s.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(s,r,n){(s==="TOKEN_REFRESHED"||s==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):s==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const gwt=(t,s,r)=>new xwt(t,s,r);function ywt(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const s=t.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}ywt()&&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 vwt="https://relzejiswnotikjgvjhz.supabase.co",bwt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",H=gwt(vwt,bwt,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),AVe=k.createContext(void 0),_wt=({children:t})=>{const[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(!0),[i,c]=k.useState(!0),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState(null),[j,w]=k.useState([]),[N,S]=k.useState(null),M=k.useRef(null),L=k.useRef(!1),I=fr(),O=()=>{p(!1),g(!1),_(null),w([]),S(null),M.current=null,L.current=!1},q=async Y=>{if(!(L.current&&M.current===Y)){c(!0);try{console.log("Checking roles via RPC for user:",Y);const[{data:Q,error:ee},{data:X,error:ie}]=await Promise.all([H.rpc("has_role",{_user_id:Y,_role:"admin"}),H.rpc("has_role",{_user_id:Y,_role:"brokerage_manager"})]);if(ee||ie)console.error("Role RPC errors:",{isAdminError:ee,isBrokerError:ie}),p(!1),g(!1);else{const ce=!!Q,ge=!!X;console.log("RPC roles result:",{adminValue:ce,brokerValue:ge}),p(ce),g(ge)}const{data:re,error:oe}=await H.from("profiles").select("brokerage_id").eq("id",Y).single();if(_(!oe&&re?re.brokerage_id:null),X){console.log("Fetching managed brokerages for user:",Y);const{data:ce,error:ge}=await H.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Y);if(console.log("Managed brokerage assignments result:",{assignments:ce,assignmentsError:ge}),ge||!ce){console.error("Error fetching managed brokerage assignments:",ge),w([]);return}const ye=Array.from(new Set(ce.map($e=>$e.brokerage_id).filter(Boolean)));if(ye.length===0){w([]);return}const{data:ue,error:pe}=await H.from("brokerages").select("id, name").in("id",ye);if(console.log("Managed brokerages details result:",{brokeragesData:ue,brokeragesError:pe}),pe||!ue){console.error("Error fetching managed brokerages details:",pe),w([]);return}const _e=ue.map($e=>({id:$e.id,name:$e.name})).sort(($e,Ae)=>ye.indexOf($e.id)-ye.indexOf(Ae.id));console.log("Parsed managed brokerages:",_e),w(_e),_e.length>0&&S($e=>$e??_e[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),w([]);M.current=Y,L.current=!0}catch(Q){console.error("Unexpected error in checkRoles:",Q),O()}finally{c(!1)}}};k.useEffect(()=>{let Y=!0,Q=!1;const ee=()=>{!Y||Q||(Q=!0,l(!1))},{data:{subscription:X}}=H.auth.onAuthStateChange((oe,ce)=>{console.log("Auth event:",oe),Y&&(a(ce),r((ce==null?void 0:ce.user)??null),ee(),oe==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{I("/profile?reset=true")},100)),ce!=null&&ce.user?(!L.current||M.current!==ce.user.id)&&setTimeout(()=>{q(ce.user.id)},0):(O(),c(!1)))}),ie=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),ee()},4e3);return(async()=>{try{const{data:{session:oe}}=await H.auth.getSession();if(!Y)return;a(oe),r((oe==null?void 0:oe.user)??null),oe!=null&&oe.user?await q(oe.user.id):O()}catch(oe){console.error("Error restoring auth session:",oe),Y&&(a(null),r(null),O())}finally{ee()}})(),()=>{Y=!1,window.clearTimeout(ie),X.unsubscribe()}},[]);const U=async(Y,Q)=>{const{error:ee}=await H.auth.signInWithPassword({email:Y,password:Q});if(ee)throw me.error(ee.message),ee;me.success("Welcome back!");const X=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),I(X)},B=async(Y,Q,ee)=>{const X=`${window.location.origin}/dashboard`,{error:ie}=await H.auth.signUp({email:Y,password:Q,options:{emailRedirectTo:X,data:{name:ee}}});if(ie)throw me.error(ie.message),ie;me.success("Account created! Welcome to LevelUp."),I("/dashboard")},V=async()=>{try{const{data:{session:Y}}=await H.auth.getSession();if(Y){const{error:Q}=await H.auth.signOut();Q?Q.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",Q.message):(console.error("Sign out error:",Q),me.error(Q.message)):me.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),p(!1),g(!1),_(null),w([]),S(null),I("/auth")}catch(Y){console.error("Unexpected sign out error:",Y),I("/auth")}};return e.jsx(AVe.Provider,{value:{user:s,session:n,loading:o,rolesLoading:i,signIn:U,signUp:B,signOut:V,isAdmin:u,isBrokerageManager:f,brokerageId:b,managedBrokerages:j,selectedBrokerageId:N,setSelectedBrokerageId:S},children:t})},Ds=()=>{const t=k.useContext(AVe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},EVe=k.createContext(void 0),F2="levelup_admin_session",Ib="levelup_impersonation",xxe="levelup_impersonation_return",wwt=({children:t})=>{const[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1);k.useEffect(()=>{const u=sessionStorage.getItem(Ib);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(Ib)}},[]);const i=async(u,p)=>{l(!0);try{const{data:{session:f}}=await H.auth.getSession();if(!f)return me.error("No active session found"),!1;const g={access_token:f.access_token,refresh_token:f.refresh_token};sessionStorage.setItem(F2,JSON.stringify(g)),p&&sessionStorage.setItem(xxe,p);const b=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.access_token}`},body:JSON.stringify({targetUserId:u})}),_=await b.json();if(!b.ok)throw new Error(_.error||"Failed to impersonate user");const j={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem(Ib,JSON.stringify(j)),_.method==="session"){const{error:w}=await H.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(w)throw console.error("Set session error:",w),sessionStorage.removeItem(F2),sessionStorage.removeItem(Ib),new Error("Failed to establish impersonation session")}else{const w=_.type||"recovery",{error:N}=await H.auth.verifyOtp({token_hash:_.token_hash,type:w});if(N)throw console.error("Verify OTP error:",N),sessionStorage.removeItem(F2),sessionStorage.removeItem(Ib),new Error("Failed to establish impersonation session")}return r(!0),a(j),me.success(`Now viewing as ${j.name}`),window.location.href="/dashboard",!0}catch(f){return console.error("Impersonation error:",f),me.error(f.message||"Failed to impersonate user"),sessionStorage.removeItem(F2),sessionStorage.removeItem(Ib),!1}finally{l(!1)}},c=async()=>{l(!0);try{const u=sessionStorage.getItem(F2);if(!u){await H.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(u);await H.auth.signOut();const{error:f}=await H.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(F2),sessionStorage.removeItem(Ib),f){console.error("Failed to restore admin session:",f),me.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),me.success("Returned to your account");const g=sessionStorage.getItem(xxe)||"/admin/members";sessionStorage.removeItem(xxe),window.location.href=g}catch(u){console.error("Stop impersonation error:",u),me.error("Failed to restore admin session"),sessionStorage.removeItem(F2),sessionStorage.removeItem(Ib),window.location.href="/auth"}finally{l(!1)}};return e.jsx(EVe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:c,isLoading:o},children:t})},Ide=()=>{const t=k.useContext(EVe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},X8=pC("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-full px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),K=k.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?h2e:"button";return e.jsx(l,{className:It(X8({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const jwt=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=Ide();return!t||!s?null:e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[100] bg-amber-500 text-amber-950 px-4 py-2 shadow-lg",children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ku,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("span",{className:"font-medium text-sm md:text-base",children:[e.jsx("span",{className:"hidden sm:inline",children:"You are viewing as "}),e.jsx("strong",{children:s.name}),e.jsxs("span",{className:"hidden md:inline text-amber-800",children:[" (",s.email,")"]})]})]}),e.jsx(K,{size:"sm",variant:"secondary",onClick:r,disabled:n,className:"bg-amber-100 hover:bg-amber-200 text-amber-950 border-0",children:n?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Rr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Exit Impersonation"}),e.jsx("span",{className:"sm:hidden",children:"Exit"})]})})]})})},PVe=k.createContext(void 0),g5="levelup_acting_as",X7="levelup_acting_as_self",Nwt=({children:t})=>{const{user:s}=Ds(),[r,n]=k.useState(!1),[a,o]=k.useState([]),[l,i]=k.useState(null),[c,u]=k.useState({}),[p,f]=k.useState(!0),[g,b]=k.useState(()=>sessionStorage.getItem(X7)==="true");k.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),f(!1);return}(async()=>{f(!0);try{const{data:M}=await H.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!M){n(!1),o([]),i(null),u({}),f(!1);return}n(!0);const{data:L,error:I}=await H.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(I||!L||L.length===0){o([]),f(!1);return}const O=L.map(B=>B.agent_id),{data:q}=await H.from("profiles").select("id, name, email, avatar_url").in("id",O),U=(q||[]).map(B=>({id:B.id,name:B.name||B.email||"Unknown",email:B.email||"",avatar_url:B.avatar_url}));if(o(U),sessionStorage.getItem(X7)==="true")b(!0),i(null),u({});else{const B=sessionStorage.getItem(g5);if(B){const V=U.find(Y=>Y.id===B);if(V){i(V);const Y=L.find(Q=>Q.agent_id===B);u((Y==null?void 0:Y.permissions)||{})}else if(U.length>0){i(U[0]);const Y=L.find(Q=>Q.agent_id===U[0].id);u((Y==null?void 0:Y.permissions)||{}),sessionStorage.setItem(g5,U[0].id)}}else if(U.length>0){i(U[0]);const V=L.find(Y=>Y.agent_id===U[0].id);u((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(g5,U[0].id)}}}catch(M){console.error("Error loading assistant data:",M)}finally{f(!1)}})()},[s==null?void 0:s.id]);const _=S=>{i(S),b(!1),sessionStorage.removeItem(X7),S?(sessionStorage.setItem(g5,S.id),H.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",S.id).single().then(({data:M})=>{u((M==null?void 0:M.permissions)||{})})):(sessionStorage.removeItem(g5),u({}))},j=()=>{b(!0),i(null),u({}),sessionStorage.setItem(X7,"true"),sessionStorage.removeItem(g5)},w=S=>!r||g?!0:c[S]===!0,N=r&&l&&!g?l.id:(s==null?void 0:s.id)||null;return e.jsx(PVe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:_,effectiveUserId:N,permissions:c,hasPermission:w,isLoading:p,isActingAsSelf:g,setActingAsSelf:j},children:t})},Z2e=()=>{const t=k.useContext(PVe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},ci=()=>{const{effectiveUserId:t}=Z2e();return t};var IVe={exports:{}},LVe={};/** * @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 DT=k;function kwt(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Swt=typeof Object.is=="function"?Object.is:kwt,Cwt=DT.useState,Mwt=DT.useEffect,Twt=DT.useLayoutEffect,Awt=DT.useDebugValue;function Ewt(t,s){var r=s(),n=Cwt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return Twt(function(){a.value=r,a.getSnapshot=s,gxe(a)&&o({inst:a})},[t,r,s]),Mwt(function(){return gxe(a)&&o({inst:a}),t(function(){gxe(a)&&o({inst:a})})},[t]),Awt(r),r}function gxe(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!Swt(t,r)}catch{return!0}}function Pwt(t,s){return s()}var Iwt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Pwt:Ewt;LVe.useSyncExternalStore=DT.useSyncExternalStore!==void 0?DT.useSyncExternalStore:Iwt;IVe.exports=LVe;var Lwt=IVe.exports;function Dwt(){return Lwt.useSyncExternalStore(Owt,()=>!0,()=>!1)}function Owt(){return()=>{}}var Y2e="Avatar",[Rwt]=ad(Y2e),[Fwt,DVe]=Rwt(Y2e),OVe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=k.useState("idle");return e.jsx(Fwt,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(nn.span,{...n,ref:s})})});OVe.displayName=Y2e;var RVe="AvatarImage",FVe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=DVe(RVe,r),i=zwt(n,o),c=vd(u=>{a(u),l.onImageLoadingStatusChange(u)});return jd(()=>{i!=="idle"&&c(i)},[i,c]),i==="loaded"?e.jsx(nn.img,{...o,ref:s,src:n}):null});FVe.displayName=RVe;var zVe="AvatarFallback",BVe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=DVe(zVe,r),[l,i]=k.useState(n===void 0);return k.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(c)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(nn.span,{...a,ref:s}):null});BVe.displayName=zVe;function $Ee(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function zwt(t,{referrerPolicy:s,crossOrigin:r}){const n=Dwt(),a=k.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=k.useState(()=>$Ee(o,t));return jd(()=>{i($Ee(o,t))},[o,t]),jd(()=>{const c=f=>()=>{i(f)};if(!o)return;const u=c("loaded"),p=c("error");return o.addEventListener("load",u),o.addEventListener("error",p),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",u),o.removeEventListener("error",p)}},[o,r,s]),l}var $Ve=OVe,qVe=FVe,UVe=BVe;const Nn=k.forwardRef(({className:t,...s},r)=>e.jsx($Ve,{ref:r,className:It("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));Nn.displayName=$Ve.displayName;const $a=k.forwardRef(({className:t,...s},r)=>e.jsx(qVe,{ref:r,className:It("aspect-square h-full w-full",t),...s}));$a.displayName=qVe.displayName;const kn=k.forwardRef(({className:t,...s},r)=>e.jsx(UVe,{ref:r,className:It("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));kn.displayName=UVe.displayName;const Bwt=pC("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 st({className:t,variant:s,...r}){return e.jsx("div",{className:It(Bwt({variant:s}),t),...r})}var $wt=k.createContext(void 0);function Tw(t){const s=k.useContext($wt);return t||s||"ltr"}var yxe=0;function Lde(){k.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??qEe()),document.body.insertAdjacentElement("beforeend",t[1]??qEe()),yxe++,()=>{yxe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),yxe--}},[])}function qEe(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var vxe="focusScope.autoFocusOnMount",bxe="focusScope.autoFocusOnUnmount",UEe={bubbles:!1,cancelable:!0},qwt="FocusScope",SO=k.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,c]=k.useState(null),u=vd(a),p=vd(o),f=k.useRef(null),g=qa(s,j=>c(j)),b=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(n){let j=function(M){if(b.paused||!i)return;const L=M.target;i.contains(L)?f.current=L:Bb(f.current,{select:!0})},w=function(M){if(b.paused||!i)return;const L=M.relatedTarget;L!==null&&(i.contains(L)||Bb(f.current,{select:!0}))},N=function(M){if(document.activeElement===document.body)for(const I of M)I.removedNodes.length>0&&Bb(i)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const S=new MutationObserver(N);return i&&S.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),S.disconnect()}}},[n,i,b.paused]),k.useEffect(()=>{if(i){HEe.add(b);const j=document.activeElement;if(!i.contains(j)){const N=new CustomEvent(vxe,UEe);i.addEventListener(vxe,u),i.dispatchEvent(N),N.defaultPrevented||(Uwt(Kwt(VVe(i)),{select:!0}),document.activeElement===j&&Bb(i))}return()=>{i.removeEventListener(vxe,u),setTimeout(()=>{const N=new CustomEvent(bxe,UEe);i.addEventListener(bxe,p),i.dispatchEvent(N),N.defaultPrevented||Bb(j??document.body,{select:!0}),i.removeEventListener(bxe,p),HEe.remove(b)},0)}}},[i,u,p,b]);const _=k.useCallback(j=>{if(!r&&!n||b.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(w&&N){const S=j.currentTarget,[M,L]=Vwt(S);M&&L?!j.shiftKey&&N===L?(j.preventDefault(),r&&Bb(M,{select:!0})):j.shiftKey&&N===M&&(j.preventDefault(),r&&Bb(L,{select:!0})):N===S&&j.preventDefault()}},[r,n,b.paused]);return e.jsx(nn.div,{tabIndex:-1,...l,ref:g,onKeyDown:_})});SO.displayName=qwt;function Uwt(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(Bb(n,{select:s}),document.activeElement!==r)return}function Vwt(t){const s=VVe(t),r=VEe(s,t),n=VEe(s.reverse(),t);return[r,n]}function VVe(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function VEe(t,s){for(const r of t)if(!Hwt(r,{upTo:s}))return r}function Hwt(t,{upTo:s}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(s!==void 0&&t===s)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Wwt(t){return t instanceof HTMLInputElement&&"select"in t}function Bb(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&Wwt(t)&&s&&t.select()}}var HEe=Gwt();function Gwt(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=WEe(t,s),t.unshift(s)},remove(s){var r;t=WEe(t,s),(r=t[0])==null||r.resume()}}}function WEe(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function Kwt(t){return t.filter(s=>s.tagName!=="A")}var _xe="rovingFocusGroup.onEntryFocus",Zwt={bubbles:!1,cancelable:!0},CO="RovingFocusGroup",[jve,HVe,Ywt]=yO(CO),[Xwt,Aw]=ad(CO,[Ywt]),[Qwt,Jwt]=Xwt(CO),WVe=k.forwardRef((t,s)=>e.jsx(jve.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(jve.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(e2t,{...t,ref:s})})}));WVe.displayName=CO;var e2t=k.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...f}=t,g=k.useRef(null),b=qa(s,g),_=Tw(o),[j,w]=ah({prop:l,defaultProp:i??null,onChange:c,caller:CO}),[N,S]=k.useState(!1),M=vd(u),L=HVe(r),I=k.useRef(!1),[O,q]=k.useState(0);return k.useEffect(()=>{const U=g.current;if(U)return U.addEventListener(_xe,M),()=>U.removeEventListener(_xe,M)},[M]),e.jsx(Qwt,{scope:r,orientation:n,dir:_,loop:a,currentTabStopId:j,onItemFocus:k.useCallback(U=>w(U),[w]),onItemShiftTab:k.useCallback(()=>S(!0),[]),onFocusableItemAdd:k.useCallback(()=>q(U=>U+1),[]),onFocusableItemRemove:k.useCallback(()=>q(U=>U-1),[]),children:e.jsx(nn.div,{tabIndex:N||O===0?-1:0,"data-orientation":n,...f,ref:b,style:{outline:"none",...t.style},onMouseDown:Ir(t.onMouseDown,()=>{I.current=!0}),onFocus:Ir(t.onFocus,U=>{const B=!I.current;if(U.target===U.currentTarget&&B&&!N){const V=new CustomEvent(_xe,Zwt);if(U.currentTarget.dispatchEvent(V),!V.defaultPrevented){const Y=L().filter(re=>re.focusable),Q=Y.find(re=>re.active),ee=Y.find(re=>re.id===j),ie=[Q,ee,...Y].filter(Boolean).map(re=>re.ref.current);ZVe(ie,p)}}I.current=!1}),onBlur:Ir(t.onBlur,()=>S(!1))})})}),GVe="RovingFocusGroupItem",KVe=k.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,c=Tu(),u=o||c,p=Jwt(GVe,r),f=p.currentTabStopId===u,g=HVe(r),{onFocusableItemAdd:b,onFocusableItemRemove:_,currentTabStopId:j}=p;return k.useEffect(()=>{if(n)return b(),()=>_()},[n,b,_]),e.jsx(jve.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(nn.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Ir(t.onMouseDown,w=>{n?p.onItemFocus(u):w.preventDefault()}),onFocus:Ir(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Ir(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const N=r2t(w,p.orientation,p.dir);if(N!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let M=g().filter(L=>L.focusable).map(L=>L.ref.current);if(N==="last")M.reverse();else if(N==="prev"||N==="next"){N==="prev"&&M.reverse();const L=M.indexOf(w.currentTarget);M=p.loop?n2t(M,L+1):M.slice(L+1)}setTimeout(()=>ZVe(M))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:j!=null}):l})})});KVe.displayName=GVe;var t2t={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function s2t(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function r2t(t,s,r){const n=s2t(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return t2t[n]}function ZVe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function n2t(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Dde=WVe,Ode=KVe,a2t=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},y5=new WeakMap,Q7=new WeakMap,J7={},wxe=0,YVe=function(t){return t&&(t.host||YVe(t.parentNode))},i2t=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=YVe(r);return n&&t.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",t,". Doing nothing"),null)}).filter(function(r){return!!r})},o2t=function(t,s,r,n){var a=i2t(s,Array.isArray(t)?t:[t]);J7[r]||(J7[r]=new WeakMap);var o=J7[r],l=[],i=new Set,c=new Set(a),u=function(f){!f||i.has(f)||(i.add(f),u(f.parentNode))};a.forEach(u);var p=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(g){if(i.has(g))p(g);else try{var b=g.getAttribute(n),_=b!==null&&b!=="false",j=(y5.get(g)||0)+1,w=(o.get(g)||0)+1;y5.set(g,j),o.set(g,w),l.push(g),j===1&&_&&Q7.set(g,!0),w===1&&g.setAttribute(r,"true"),_||g.setAttribute(n,"true")}catch(N){console.error("aria-hidden: cannot operate on ",g,N)}})};return p(s),i.clear(),wxe++,function(){l.forEach(function(f){var g=y5.get(f)-1,b=o.get(f)-1;y5.set(f,g),o.set(f,b),g||(Q7.has(f)||f.removeAttribute(n),Q7.delete(f)),b||f.removeAttribute(r)}),wxe--,wxe||(y5=new WeakMap,y5=new WeakMap,Q7=new WeakMap,J7={})}},Rde=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=a2t(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),o2t(n,a,r,"aria-hidden")):function(){return null}},die="right-scroll-bar-position",uie="width-before-scroll-bar",l2t="with-scroll-bars-hidden",c2t="--removed-body-scroll-bar-size";function jxe(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function d2t(t,s){var r=k.useState(function(){return{value:t,callback:s,facade:{get current(){return r.value},set current(n){var a=r.value;a!==n&&(r.value=n,r.callback(n,a))}}}})[0];return r.callback=s,r.facade}var u2t=typeof window<"u"?k.useLayoutEffect:k.useEffect,GEe=new WeakMap;function h2t(t,s){var r=d2t(null,function(n){return t.forEach(function(a){return jxe(a,n)})});return u2t(function(){var n=GEe.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||jxe(i,null)}),o.forEach(function(i){a.has(i)||jxe(i,l)})}GEe.set(r,t)},[t]),r}function m2t(t){return t}function p2t(t,s){s===void 0&&(s=m2t);var r=[],n=!1,a={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:t},useMedium:function(o){var l=s(o,n);return r.push(l),function(){r=r.filter(function(i){return i!==l})}},assignSyncMedium:function(o){for(n=!0;r.length;){var l=r;r=[],l.forEach(o)}r={push:function(i){return o(i)},filter:function(){return r}}},assignMedium:function(o){n=!0;var l=[];if(r.length){var i=r;r=[],i.forEach(o),l=r}var c=function(){var p=l;l=[],p.forEach(o)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(p){l.push(p),u()},filter:function(p){return l=l.filter(p),r}}}};return a}function f2t(t){t===void 0&&(t={});var s=p2t(null);return s.options=xx({async:!0,ssr:!1},t),s}var XVe=function(t){var s=t.sideCar,r=Cw(t,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=s.read();if(!n)throw new Error("Sidecar medium not found");return k.createElement(n,xx({},r))};XVe.isSideCarExport=!0;function x2t(t,s){return t.useMedium(s),XVe}var QVe=f2t(),Nxe=function(){},Fde=k.forwardRef(function(t,s){var r=k.useRef(null),n=k.useState({onScrollCapture:Nxe,onWheelCapture:Nxe,onTouchMoveCapture:Nxe}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,c=t.className,u=t.removeScrollBar,p=t.enabled,f=t.shards,g=t.sideCar,b=t.noRelative,_=t.noIsolation,j=t.inert,w=t.allowPinchZoom,N=t.as,S=N===void 0?"div":N,M=t.gapMode,L=Cw(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),I=g,O=h2t([r,s]),q=xx(xx({},L),a);return k.createElement(k.Fragment,null,p&&k.createElement(I,{sideCar:QVe,removeScrollBar:u,shards:f,noRelative:b,noIsolation:_,inert:j,setCallbacks:o,allowPinchZoom:!!w,lockRef:r,gapMode:M}),l?k.cloneElement(k.Children.only(i),xx(xx({},q),{ref:O})):k.createElement(S,xx({},q,{className:c,ref:O}),i))});Fde.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Fde.classNames={fullWidth:uie,zeroRight:die};var g2t=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function y2t(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=g2t();return s&&t.setAttribute("nonce",s),t}function v2t(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function b2t(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var _2t=function(){var t=0,s=null;return{add:function(r){t==0&&(s=y2t())&&(v2t(s,r),b2t(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},w2t=function(){var t=_2t();return function(s,r){k.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},JVe=function(){var t=w2t(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},j2t={left:0,top:0,right:0,gap:0},kxe=function(t){return parseInt(t||"",10)||0},N2t=function(t){var s=window.getComputedStyle(document.body),r=s[t==="padding"?"paddingLeft":"marginLeft"],n=s[t==="padding"?"paddingTop":"marginTop"],a=s[t==="padding"?"paddingRight":"marginRight"];return[kxe(r),kxe(n),kxe(a)]},k2t=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return j2t;var s=N2t(t),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:s[0],top:s[1],right:s[2],gap:Math.max(0,n-r+s[2]-s[0])}},S2t=JVe(),XM="data-scroll-locked",C2t=function(t,s,r,n){var a=t.left,o=t.top,l=t.right,i=t.gap;return r===void 0&&(r="margin"),` .`.concat(l2t,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(XM,`] { overflow: hidden `).concat(n,`; overscroll-behavior: contain; `).concat([s&&"position: relative ".concat(n,";"),r==="margin"&&` padding-left: `.concat(a,`px; padding-top: `).concat(o,`px; padding-right: `).concat(l,`px; margin-left:0; margin-top:0; margin-right: `).concat(i,"px ").concat(n,`; `),r==="padding"&&"padding-right: ".concat(i,"px ").concat(n,";")].filter(Boolean).join(""),` } .`).concat(die,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(uie,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(die," .").concat(die,` { right: 0 `).concat(n,`; } .`).concat(uie," .").concat(uie,` { margin-right: 0 `).concat(n,`; } body[`).concat(XM,`] { `).concat(c2t,": ").concat(i,`px; } `)},KEe=function(){var t=parseInt(document.body.getAttribute(XM)||"0",10);return isFinite(t)?t:0},M2t=function(){k.useEffect(function(){return document.body.setAttribute(XM,(KEe()+1).toString()),function(){var t=KEe()-1;t<=0?document.body.removeAttribute(XM):document.body.setAttribute(XM,t.toString())}},[])},T2t=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;M2t();var o=k.useMemo(function(){return k2t(a)},[a]);return k.createElement(S2t,{styles:C2t(o,!s,a,r?"":"!important")})},Nve=!1;if(typeof window<"u")try{var ez=Object.defineProperty({},"passive",{get:function(){return Nve=!0,!0}});window.addEventListener("test",ez,ez),window.removeEventListener("test",ez,ez)}catch{Nve=!1}var v5=Nve?{passive:!1}:!1,A2t=function(t){return t.tagName==="TEXTAREA"},eHe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!A2t(t)&&r[s]==="visible")},E2t=function(t){return eHe(t,"overflowY")},P2t=function(t){return eHe(t,"overflowX")},ZEe=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=tHe(t,n);if(a){var o=sHe(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},I2t=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},L2t=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},tHe=function(t,s){return t==="v"?E2t(s):P2t(s)},sHe=function(t,s){return t==="v"?I2t(s):L2t(s)},D2t=function(t,s){return t==="h"&&s==="rtl"?-1:1},O2t=function(t,s,r,n,a){var o=D2t(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,c=s.contains(i),u=!1,p=l>0,f=0,g=0;do{if(!i)break;var b=sHe(t,i),_=b[0],j=b[1],w=b[2],N=j-w-o*_;(_||N)&&tHe(t,i)&&(f+=N,g+=_);var S=i.parentNode;i=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!c&&i!==document.body||c&&(s.contains(i)||s===i));return(p&&Math.abs(f)<1||!p&&Math.abs(g)<1)&&(u=!0),u},tz=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},YEe=function(t){return[t.deltaX,t.deltaY]},XEe=function(t){return t&&"current"in t?t.current:t},R2t=function(t,s){return t[0]===s[0]&&t[1]===s[1]},F2t=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},z2t=0,b5=[];function B2t(t){var s=k.useRef([]),r=k.useRef([0,0]),n=k.useRef(),a=k.useState(z2t++)[0],o=k.useState(JVe)[0],l=k.useRef(t);k.useEffect(function(){l.current=t},[t]),k.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var j=B2e([t.lockRef.current],(t.shards||[]).map(XEe),!0).filter(Boolean);return j.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),j.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=k.useCallback(function(j,w){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!l.current.allowPinchZoom;var N=tz(j),S=r.current,M="deltaX"in j?j.deltaX:S[0]-N[0],L="deltaY"in j?j.deltaY:S[1]-N[1],I,O=j.target,q=Math.abs(M)>Math.abs(L)?"h":"v";if("touches"in j&&q==="h"&&O.type==="range")return!1;var U=ZEe(q,O);if(!U)return!0;if(U?I=q:(I=q==="v"?"h":"v",U=ZEe(q,O)),!U)return!1;if(!n.current&&"changedTouches"in j&&(M||L)&&(n.current=I),!I)return!0;var B=n.current||I;return O2t(B,w,j,B==="h"?M:L)},[]),c=k.useCallback(function(j){var w=j;if(!(!b5.length||b5[b5.length-1]!==o)){var N="deltaY"in w?YEe(w):tz(w),S=s.current.filter(function(I){return I.name===w.type&&(I.target===w.target||w.target===I.shadowParent)&&R2t(I.delta,N)})[0];if(S&&S.should){w.cancelable&&w.preventDefault();return}if(!S){var M=(l.current.shards||[]).map(XEe).filter(Boolean).filter(function(I){return I.contains(w.target)}),L=M.length>0?i(w,M[0]):!l.current.noIsolation;L&&w.cancelable&&w.preventDefault()}}},[]),u=k.useCallback(function(j,w,N,S){var M={name:j,delta:w,target:N,should:S,shadowParent:$2t(N)};s.current.push(M),setTimeout(function(){s.current=s.current.filter(function(L){return L!==M})},1)},[]),p=k.useCallback(function(j){r.current=tz(j),n.current=void 0},[]),f=k.useCallback(function(j){u(j.type,YEe(j),j.target,i(j,t.lockRef.current))},[]),g=k.useCallback(function(j){u(j.type,tz(j),j.target,i(j,t.lockRef.current))},[]);k.useEffect(function(){return b5.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:g}),document.addEventListener("wheel",c,v5),document.addEventListener("touchmove",c,v5),document.addEventListener("touchstart",p,v5),function(){b5=b5.filter(function(j){return j!==o}),document.removeEventListener("wheel",c,v5),document.removeEventListener("touchmove",c,v5),document.removeEventListener("touchstart",p,v5)}},[]);var b=t.removeScrollBar,_=t.inert;return k.createElement(k.Fragment,null,_?k.createElement(o,{styles:F2t(a)}):null,b?k.createElement(T2t,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function $2t(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const q2t=x2t(QVe,B2t);var MO=k.forwardRef(function(t,s){return k.createElement(Fde,xx({},t,{ref:s,sideCar:q2t}))});MO.classNames=Fde.classNames;var kve=["Enter"," "],U2t=["ArrowDown","PageUp","Home"],rHe=["ArrowUp","PageDown","End"],V2t=[...U2t,...rHe],H2t={ltr:[...kve,"ArrowRight"],rtl:[...kve,"ArrowLeft"]},W2t={ltr:["ArrowLeft"],rtl:["ArrowRight"]},TO="Menu",[Q8,G2t,K2t]=yO(TO),[xC,nHe]=ad(TO,[K2t,F0,Aw]),zde=F0(),aHe=Aw(),[Z2t,gC]=xC(TO),[Y2t,AO]=xC(TO),iHe=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=zde(s),[c,u]=k.useState(null),p=k.useRef(!1),f=vd(o),g=Tw(a);return k.useEffect(()=>{const b=()=>{p.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>p.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),e.jsx(wO,{...i,children:e.jsx(Z2t,{scope:s,open:r,onOpenChange:f,content:c,onContentChange:u,children:e.jsx(Y2t,{scope:s,onClose:k.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:g,modal:l,children:n})})})};iHe.displayName=TO;var X2t="MenuAnchor",X2e=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=zde(r);return e.jsx(qA,{...a,...n,ref:s})});X2e.displayName=X2t;var Q2e="MenuPortal",[Q2t,oHe]=xC(Q2e,{forceMount:void 0}),lHe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=gC(Q2e,s);return e.jsx(Q2t,{scope:s,forceMount:r,children:e.jsx(zd,{present:r||o.open,children:e.jsx(FA,{asChild:!0,container:a,children:n})})})};lHe.displayName=Q2e;var Tx="MenuContent",[J2t,J2e]=xC(Tx),cHe=k.forwardRef((t,s)=>{const r=oHe(Tx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=gC(Tx,t.__scopeMenu),l=AO(Tx,t.__scopeMenu);return e.jsx(Q8.Provider,{scope:t.__scopeMenu,children:e.jsx(zd,{present:n||o.open,children:e.jsx(Q8.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(ejt,{...a,ref:s}):e.jsx(tjt,{...a,ref:s})})})})}),ejt=k.forwardRef((t,s)=>{const r=gC(Tx,t.__scopeMenu),n=k.useRef(null),a=qa(s,n);return k.useEffect(()=>{const o=n.current;if(o)return Rde(o)},[]),e.jsx(eje,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Ir(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),tjt=k.forwardRef((t,s)=>{const r=gC(Tx,t.__scopeMenu);return e.jsx(eje,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),sjt=lw("MenuContent.ScrollLock"),eje=k.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:g,onDismiss:b,disableOutsideScroll:_,...j}=t,w=gC(Tx,r),N=AO(Tx,r),S=zde(r),M=aHe(r),L=G2t(r),[I,O]=k.useState(null),q=k.useRef(null),U=qa(s,q,w.onContentChange),B=k.useRef(0),V=k.useRef(""),Y=k.useRef(0),Q=k.useRef(null),ee=k.useRef("right"),X=k.useRef(0),ie=_?MO:k.Fragment,re=_?{as:sjt,allowPinchZoom:!0}:void 0,oe=ge=>{var Ce,xe;const ye=V.current+ge,ue=L().filter(we=>!we.disabled),pe=document.activeElement,_e=(Ce=ue.find(we=>we.ref.current===pe))==null?void 0:Ce.textValue,$e=ue.map(we=>we.textValue),Ae=pjt($e,ye,_e),Ie=(xe=ue.find(we=>we.textValue===Ae))==null?void 0:xe.ref.current;(function we(Le){V.current=Le,window.clearTimeout(B.current),Le!==""&&(B.current=window.setTimeout(()=>we(""),1e3))})(ye),Ie&&setTimeout(()=>Ie.focus())};k.useEffect(()=>()=>window.clearTimeout(B.current),[]),Lde();const ce=k.useCallback(ge=>{var ue,pe;return ee.current===((ue=Q.current)==null?void 0:ue.side)&&xjt(ge,(pe=Q.current)==null?void 0:pe.area)},[]);return e.jsx(J2t,{scope:r,searchRef:V,onItemEnter:k.useCallback(ge=>{ce(ge)&&ge.preventDefault()},[ce]),onItemLeave:k.useCallback(ge=>{var ye;ce(ge)||((ye=q.current)==null||ye.focus(),O(null))},[ce]),onTriggerLeave:k.useCallback(ge=>{ce(ge)&&ge.preventDefault()},[ce]),pointerGraceTimerRef:Y,onPointerGraceIntentChange:k.useCallback(ge=>{Q.current=ge},[]),children:e.jsx(ie,{...re,children:e.jsx(SO,{asChild:!0,trapped:a,onMountAutoFocus:Ir(o,ge=>{var ye;ge.preventDefault(),(ye=q.current)==null||ye.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(kw,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:g,onDismiss:b,children:e.jsx(Dde,{asChild:!0,...M,dir:N.dir,orientation:"vertical",loop:n,currentTabStopId:I,onCurrentTabStopIdChange:O,onEntryFocus:Ir(c,ge=>{N.isUsingKeyboardRef.current||ge.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(jO,{role:"menu","aria-orientation":"vertical","data-state":kHe(w.open),"data-radix-menu-content":"",dir:N.dir,...S,...j,ref:U,style:{outline:"none",...j.style},onKeyDown:Ir(j.onKeyDown,ge=>{const ue=ge.target.closest("[data-radix-menu-content]")===ge.currentTarget,pe=ge.ctrlKey||ge.altKey||ge.metaKey,_e=ge.key.length===1;ue&&(ge.key==="Tab"&&ge.preventDefault(),!pe&&_e&&oe(ge.key));const $e=q.current;if(ge.target!==$e||!V2t.includes(ge.key))return;ge.preventDefault();const Ie=L().filter(Ce=>!Ce.disabled).map(Ce=>Ce.ref.current);rHe.includes(ge.key)&&Ie.reverse(),hjt(Ie)}),onBlur:Ir(t.onBlur,ge=>{ge.currentTarget.contains(ge.target)||(window.clearTimeout(B.current),V.current="")}),onPointerMove:Ir(t.onPointerMove,J8(ge=>{const ye=ge.target,ue=X.current!==ge.clientX;if(ge.currentTarget.contains(ye)&&ue){const pe=ge.clientX>X.current?"right":"left";ee.current=pe,X.current=ge.clientX}}))})})})})})})});cHe.displayName=Tx;var rjt="MenuGroup",tje=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(nn.div,{role:"group",...n,ref:s})});tje.displayName=rjt;var njt="MenuLabel",dHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(nn.div,{...n,ref:s})});dHe.displayName=njt;var voe="MenuItem",QEe="menu.itemSelect",Bde=k.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=k.useRef(null),l=AO(voe,t.__scopeMenu),i=J2e(voe,t.__scopeMenu),c=qa(s,o),u=k.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const g=new CustomEvent(QEe,{bubbles:!0,cancelable:!0});f.addEventListener(QEe,b=>n==null?void 0:n(b),{once:!0}),m2e(f,g),g.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(uHe,{...a,ref:c,disabled:r,onClick:Ir(t.onClick,p),onPointerDown:f=>{var g;(g=t.onPointerDown)==null||g.call(t,f),u.current=!0},onPointerUp:Ir(t.onPointerUp,f=>{var g;u.current||(g=f.currentTarget)==null||g.click()}),onKeyDown:Ir(t.onKeyDown,f=>{const g=i.searchRef.current!=="";r||g&&f.key===" "||kve.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Bde.displayName=voe;var uHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=J2e(voe,r),i=aHe(r),c=k.useRef(null),u=qa(s,c),[p,f]=k.useState(!1),[g,b]=k.useState("");return k.useEffect(()=>{const _=c.current;_&&b((_.textContent??"").trim())},[o.children]),e.jsx(Q8.ItemSlot,{scope:r,disabled:n,textValue:a??g,children:e.jsx(Ode,{asChild:!0,...i,focusable:!n,children:e.jsx(nn.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Ir(t.onPointerMove,J8(_=>{n?l.onItemLeave(_):(l.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ir(t.onPointerLeave,J8(_=>l.onItemLeave(_))),onFocus:Ir(t.onFocus,()=>f(!0)),onBlur:Ir(t.onBlur,()=>f(!1))})})})}),ajt="MenuCheckboxItem",hHe=k.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(gHe,{scope:t.__scopeMenu,checked:r,children:e.jsx(Bde,{role:"menuitemcheckbox","aria-checked":boe(r)?"mixed":r,...a,ref:s,"data-state":rje(r),onSelect:Ir(a.onSelect,()=>n==null?void 0:n(boe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});hHe.displayName=ajt;var mHe="MenuRadioGroup",[ijt,ojt]=xC(mHe,{value:void 0,onValueChange:()=>{}}),pHe=k.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=vd(n);return e.jsx(ijt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(tje,{...a,ref:s})})});pHe.displayName=mHe;var fHe="MenuRadioItem",xHe=k.forwardRef((t,s)=>{const{value:r,...n}=t,a=ojt(fHe,t.__scopeMenu),o=r===a.value;return e.jsx(gHe,{scope:t.__scopeMenu,checked:o,children:e.jsx(Bde,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":rje(o),onSelect:Ir(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});xHe.displayName=fHe;var sje="MenuItemIndicator",[gHe,ljt]=xC(sje,{checked:!1}),yHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=ljt(sje,r);return e.jsx(zd,{present:n||boe(o.checked)||o.checked===!0,children:e.jsx(nn.span,{...a,ref:s,"data-state":rje(o.checked)})})});yHe.displayName=sje;var cjt="MenuSeparator",vHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(nn.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});vHe.displayName=cjt;var djt="MenuArrow",bHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=zde(r);return e.jsx(NO,{...a,...n,ref:s})});bHe.displayName=djt;var ujt="MenuSub",[qMs,_He]=xC(ujt),_I="MenuSubTrigger",wHe=k.forwardRef((t,s)=>{const r=gC(_I,t.__scopeMenu),n=AO(_I,t.__scopeMenu),a=_He(_I,t.__scopeMenu),o=J2e(_I,t.__scopeMenu),l=k.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:c}=o,u={__scopeMenu:t.__scopeMenu},p=k.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return k.useEffect(()=>p,[p]),k.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),c(null)}},[i,c]),e.jsx(X2e,{asChild:!0,...u,children:e.jsx(uHe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":kHe(r.open),...t,ref:C1(s,a.onTriggerChange),onClick:f=>{var g;(g=t.onClick)==null||g.call(t,f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Ir(t.onPointerMove,J8(f=>{o.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:Ir(t.onPointerLeave,J8(f=>{var b,_;p();const g=(b=r.content)==null?void 0:b.getBoundingClientRect();if(g){const j=(_=r.content)==null?void 0:_.dataset.side,w=j==="right",N=w?-5:5,S=g[w?"left":"right"],M=g[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+N,y:f.clientY},{x:S,y:g.top},{x:M,y:g.top},{x:M,y:g.bottom},{x:S,y:g.bottom}],side:j}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Ir(t.onKeyDown,f=>{var b;const g=o.searchRef.current!=="";t.disabled||g&&f.key===" "||H2t[n.dir].includes(f.key)&&(r.onOpenChange(!0),(b=r.content)==null||b.focus(),f.preventDefault())})})})});wHe.displayName=_I;var jHe="MenuSubContent",NHe=k.forwardRef((t,s)=>{const r=oHe(Tx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=gC(Tx,t.__scopeMenu),l=AO(Tx,t.__scopeMenu),i=_He(jHe,t.__scopeMenu),c=k.useRef(null),u=qa(s,c);return e.jsx(Q8.Provider,{scope:t.__scopeMenu,children:e.jsx(zd,{present:n||o.open,children:e.jsx(Q8.Slot,{scope:t.__scopeMenu,children:e.jsx(eje,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var f;l.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Ir(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Ir(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Ir(t.onKeyDown,p=>{var b;const f=p.currentTarget.contains(p.target),g=W2t[l.dir].includes(p.key);f&&g&&(o.onOpenChange(!1),(b=i.trigger)==null||b.focus(),p.preventDefault())})})})})})});NHe.displayName=jHe;function kHe(t){return t?"open":"closed"}function boe(t){return t==="indeterminate"}function rje(t){return boe(t)?"indeterminate":t?"checked":"unchecked"}function hjt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function mjt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function pjt(t,s,r){const a=s.length>1&&Array.from(s).every(u=>u===s[0])?s[0]:s,o=r?t.indexOf(r):-1;let l=mjt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const c=l.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function fjt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=g>n&&r<(f-u)*(n-p)/(g-p)+u&&(a=!a)}return a}function xjt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return fjt(r,s)}function J8(t){return s=>s.pointerType==="mouse"?t(s):void 0}var gjt=iHe,yjt=X2e,vjt=lHe,bjt=cHe,_jt=tje,wjt=dHe,jjt=Bde,Njt=hHe,kjt=pHe,Sjt=xHe,Cjt=yHe,Mjt=vHe,Tjt=bHe,Ajt=wHe,Ejt=NHe,$de="DropdownMenu",[Pjt]=ad($de,[nHe]),Wm=nHe(),[Ijt,SHe]=Pjt($de),CHe=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,c=Wm(s),u=k.useRef(null),[p,f]=ah({prop:a,defaultProp:o??!1,onChange:l,caller:$de});return e.jsx(Ijt,{scope:s,triggerId:Tu(),triggerRef:u,contentId:Tu(),open:p,onOpenChange:f,onOpenToggle:k.useCallback(()=>f(g=>!g),[f]),modal:i,children:e.jsx(gjt,{...c,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};CHe.displayName=$de;var MHe="DropdownMenuTrigger",THe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=SHe(MHe,r),l=Wm(r);return e.jsx(yjt,{asChild:!0,...l,children:e.jsx(nn.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:C1(s,o.triggerRef),onPointerDown:Ir(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Ir(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});THe.displayName=MHe;var Ljt="DropdownMenuPortal",AHe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Wm(s);return e.jsx(vjt,{...n,...r})};AHe.displayName=Ljt;var EHe="DropdownMenuContent",PHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=SHe(EHe,r),o=Wm(r),l=k.useRef(!1);return e.jsx(bjt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Ir(t.onCloseAutoFocus,i=>{var c;l.current||(c=a.triggerRef.current)==null||c.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Ir(t.onInteractOutside,i=>{const c=i.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,p=c.button===2||u;(!a.modal||p)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});PHe.displayName=EHe;var Djt="DropdownMenuGroup",Ojt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(_jt,{...a,...n,ref:s})});Ojt.displayName=Djt;var Rjt="DropdownMenuLabel",IHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(wjt,{...a,...n,ref:s})});IHe.displayName=Rjt;var Fjt="DropdownMenuItem",LHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(jjt,{...a,...n,ref:s})});LHe.displayName=Fjt;var zjt="DropdownMenuCheckboxItem",DHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Njt,{...a,...n,ref:s})});DHe.displayName=zjt;var Bjt="DropdownMenuRadioGroup",$jt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(kjt,{...a,...n,ref:s})});$jt.displayName=Bjt;var qjt="DropdownMenuRadioItem",OHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Sjt,{...a,...n,ref:s})});OHe.displayName=qjt;var Ujt="DropdownMenuItemIndicator",RHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Cjt,{...a,...n,ref:s})});RHe.displayName=Ujt;var Vjt="DropdownMenuSeparator",FHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Mjt,{...a,...n,ref:s})});FHe.displayName=Vjt;var Hjt="DropdownMenuArrow",Wjt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Tjt,{...a,...n,ref:s})});Wjt.displayName=Hjt;var Gjt="DropdownMenuSubTrigger",zHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Ajt,{...a,...n,ref:s})});zHe.displayName=Gjt;var Kjt="DropdownMenuSubContent",BHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Wm(r);return e.jsx(Ejt,{...a,...n,ref:s,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});BHe.displayName=Kjt;var Zjt=CHe,Yjt=THe,Xjt=AHe,$He=PHe,qHe=IHe,UHe=LHe,VHe=DHe,HHe=OHe,WHe=RHe,GHe=FHe,KHe=zHe,ZHe=BHe;const iu=Zjt,ou=Yjt,Qjt=k.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(KHe,{ref:a,className:It("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",s&&"pl-8",t),...n,children:[r,e.jsx(da,{className:"ml-auto h-4 w-4"})]}));Qjt.displayName=KHe.displayName;const Jjt=k.forwardRef(({className:t,...s},r)=>e.jsx(ZHe,{ref:r,className:It("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));Jjt.displayName=ZHe.displayName;const Bd=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Xjt,{children:e.jsx($He,{ref:n,sideOffset:s,className:It("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));Bd.displayName=$He.displayName;const Ma=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(UHe,{ref:n,className:It("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",s&&"pl-8",t),...r}));Ma.displayName=UHe.displayName;const eNt=k.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(VHe,{ref:a,className:It("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:r,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(WHe,{children:e.jsx(va,{className:"h-4 w-4"})})}),s]}));eNt.displayName=VHe.displayName;const tNt=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(HHe,{ref:n,className:It("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(WHe,{children:e.jsx(_d,{className:"h-2 w-2 fill-current"})})}),s]}));tNt.displayName=HHe.displayName;const Sve=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(qHe,{ref:n,className:It("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));Sve.displayName=qHe.displayName;const uw=k.forwardRef(({className:t,...s},r)=>e.jsx(GHe,{ref:r,className:It("-mx-1 my-1 h-px bg-muted",t),...s}));uw.displayName=GHe.displayName;const sNt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=Z2e();if(!t)return null;const l=i=>i.split(" ").map(c=>c[0]).join("").toUpperCase().slice(0,2);return e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[2147483647] bg-primary text-primary-foreground px-4 py-1.5 shadow-lg",style:{height:"40px"},children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4 h-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(to,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"My Account"})]}):e.jsxs(e.Fragment,{children:[e.jsx(pr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"secondary",size:"sm",className:"gap-2 bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground border-0",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(to,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(Nn,{className:"h-5 w-5",children:[e.jsx($a,{src:s.avatar_url||void 0}),e.jsx(kn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(Eo,{className:"h-3 w-3"})]})}),e.jsxs(Bd,{align:"start",className:"z-[2147483647]",children:[e.jsxs(Ma,{onClick:o,className:"gap-2",children:[e.jsx(to,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(st,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(uw,{}),r.map(i=>e.jsxs(Ma,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:i.avatar_url||void 0}),e.jsx(kn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(st,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(st,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},nr=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,rolesLoading:o,isAdmin:l,isBrokerageManager:i}=Ds(),c=id();if(a||(s||r)&&o)return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})});if(!n){const u=c.pathname+c.search+c.hash;return u&&u!=="/auth"&&sessionStorage.setItem("redirectAfterLogin",u),e.jsx(rxe,{to:"/auth",replace:!0})}return s&&!l?e.jsx(rxe,{to:"/dashboard",replace:!0}):r&&!i&&!l?e.jsx(rxe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t})};var nje={};(function t(s,r,n,a){var o=!!(s.Worker&&s.Blob&&s.Promise&&s.OffscreenCanvas&&s.OffscreenCanvasRenderingContext2D&&s.HTMLCanvasElement&&s.HTMLCanvasElement.prototype.transferControlToOffscreen&&s.URL&&s.URL.createObjectURL),l=typeof Path2D=="function"&&typeof DOMMatrix=="function",i=function(){if(!s.OffscreenCanvas)return!1;try{var ye=new OffscreenCanvas(1,1),ue=ye.getContext("2d");ue.fillRect(0,0,1,1);var pe=ye.transferToImageBitmap();ue.createPattern(pe,"no-repeat")}catch{return!1}return!0}();function c(){}function u(ye){var ue=r.exports.Promise,pe=ue!==void 0?ue:s.Promise;return typeof pe=="function"?new pe(ye):(ye(c,c),null)}var p=function(ye,ue){return{transform:function(pe){if(ye)return pe;if(ue.has(pe))return ue.get(pe);var _e=new OffscreenCanvas(pe.width,pe.height),$e=_e.getContext("2d");return $e.drawImage(pe,0,0),ue.set(pe,_e),_e},clear:function(){ue.clear()}}}(i,new Map),f=function(){var ye=Math.floor(16.666666666666668),ue,pe,_e={},$e=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(ue=function(Ae){var Ie=Math.random();return _e[Ie]=requestAnimationFrame(function Ce(xe){$e===xe||$e+ye-1{const{data:s,error:r}=await H.from("celebration_queue").select("*").eq("user_id",t.id).is("seen_at",null).order("created_at",{ascending:!0});if(r)throw r;return s},enabled:!!(t!=null&&t.id),refetchOnWindowFocus:!0,staleTime:0})}function nNt(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function aNt(){const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{const{error:n}=await H.from("celebration_queue").insert({user_id:r.user_id,celebration_type:r.celebration_type,title:r.title,message:r.message||null,points_amount:r.points_amount||null,created_by:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}var qde="Dialog",[YHe,XHe]=ad(qde),[iNt,hy]=YHe(qde),QHe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=k.useRef(null),c=k.useRef(null),[u,p]=ah({prop:n,defaultProp:a??!1,onChange:o,caller:qde});return e.jsx(iNt,{scope:s,triggerRef:i,contentRef:c,contentId:Tu(),titleId:Tu(),descriptionId:Tu(),open:u,onOpenChange:p,onOpenToggle:k.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};QHe.displayName=qde;var JHe="DialogTrigger",eWe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=hy(JHe,r),o=qa(s,a.triggerRef);return e.jsx(nn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":oje(a.open),...n,ref:o,onClick:Ir(t.onClick,a.onOpenToggle)})});eWe.displayName=JHe;var aje="DialogPortal",[oNt,tWe]=YHe(aje,{forceMount:void 0}),sWe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=hy(aje,s);return e.jsx(oNt,{scope:s,forceMount:r,children:k.Children.map(n,l=>e.jsx(zd,{present:r||o.open,children:e.jsx(FA,{asChild:!0,container:a,children:l})}))})};sWe.displayName=aje;var _oe="DialogOverlay",rWe=k.forwardRef((t,s)=>{const r=tWe(_oe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=hy(_oe,t.__scopeDialog);return o.modal?e.jsx(zd,{present:n||o.open,children:e.jsx(cNt,{...a,ref:s})}):null});rWe.displayName=_oe;var lNt=lw("DialogOverlay.RemoveScroll"),cNt=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=hy(_oe,r);return e.jsx(MO,{as:lNt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(nn.div,{"data-state":oje(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),BS="DialogContent",nWe=k.forwardRef((t,s)=>{const r=tWe(BS,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=hy(BS,t.__scopeDialog);return e.jsx(zd,{present:n||o.open,children:o.modal?e.jsx(dNt,{...a,ref:s}):e.jsx(uNt,{...a,ref:s})})});nWe.displayName=BS;var dNt=k.forwardRef((t,s)=>{const r=hy(BS,t.__scopeDialog),n=k.useRef(null),a=qa(s,r.contentRef,n);return k.useEffect(()=>{const o=n.current;if(o)return Rde(o)},[]),e.jsx(aWe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ir(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Ir(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Ir(t.onFocusOutside,o=>o.preventDefault())})}),uNt=k.forwardRef((t,s)=>{const r=hy(BS,t.__scopeDialog),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(aWe,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var c,u;(c=t.onInteractOutside)==null||c.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),aWe=k.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=hy(BS,r),c=k.useRef(null),u=qa(s,c);return Lde(),e.jsxs(e.Fragment,{children:[e.jsx(SO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(kw,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":oje(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(mNt,{titleId:i.titleId}),e.jsx(fNt,{contentRef:c,descriptionId:i.descriptionId})]})]})}),ije="DialogTitle",iWe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=hy(ije,r);return e.jsx(nn.h2,{id:a.titleId,...n,ref:s})});iWe.displayName=ije;var oWe="DialogDescription",lWe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=hy(oWe,r);return e.jsx(nn.p,{id:a.descriptionId,...n,ref:s})});lWe.displayName=oWe;var cWe="DialogClose",dWe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=hy(cWe,r);return e.jsx(nn.button,{type:"button",...n,ref:s,onClick:Ir(t.onClick,()=>a.onOpenChange(!1))})});dWe.displayName=cWe;function oje(t){return t?"open":"closed"}var uWe="DialogTitleWarning",[hNt,hWe]=Zft(uWe,{contentName:BS,titleName:ije,docsSlug:"dialog"}),mNt=({titleId:t})=>{const s=hWe(uWe),r=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return k.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},pNt="DialogDescriptionWarning",fNt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${hWe(pNt).contentName}}.`;return k.useEffect(()=>{var o;const a=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(n))},[n,t,s]),null},Ude=QHe,lje=eWe,Vde=sWe,KA=rWe,ZA=nWe,EO=iWe,PO=lWe,IO=dWe;const fs=Ude,qi=lje,xNt=Vde,UMs=IO,mWe=k.forwardRef(({className:t,...s},r)=>e.jsx(KA,{ref:r,className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));mWe.displayName=KA.displayName;const ps=k.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(xNt,{children:[e.jsx(mWe,{className:r}),e.jsxs(ZA,{ref:a,className:It("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[s,e.jsxs(IO,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Rr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ps.displayName=ZA.displayName;const _s=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});_s.displayName="DialogHeader";const qn=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});qn.displayName="DialogFooter";const vs=k.forwardRef(({className:t,...s},r)=>e.jsx(EO,{ref:r,className:It("text-lg font-semibold leading-none tracking-tight",t),...s}));vs.displayName=EO.displayName;const Gr=k.forwardRef(({className:t,...s},r)=>e.jsx(PO,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));Gr.displayName=PO.displayName;const gNt={points_earned:xo,listing_created:bn,deal_closed:ac,custom:Jn},e6e={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"},t6e=()=>{const t=window.location.hostname;return t.startsWith("cards.")||t.startsWith("cardstudio.")||t.startsWith("listings.")||t.startsWith("presentations.")||t.startsWith("guestbook.")||t.startsWith("clients.")||t.startsWith("booking.")||t.startsWith("contacts.")};function yNt(){const{user:t}=Ds(),s=Qt(),{data:r}=rNt(),n=nNt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),c=k.useCallback(()=>{const b=Date.now()+3e3,_={startVelocity:30,spread:360,ticks:60,zIndex:9999},j=(N,S)=>Math.random()*(S-N)+N,w=setInterval(()=>{const N=b-Date.now();if(N<=0){clearInterval(w);return}const S=50*(N/3e3);JEe({..._,particleCount:S,origin:{x:j(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),JEe({..._,particleCount:S,origin:{x:j(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);k.useEffect(()=>{t6e()||r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(c,100))},[r,a,c]);const u=async()=>{if(a){const g=a.id;i(!1),o(null),s.setQueryData(["celebrations","pending",t==null?void 0:t.id],b=>(b==null?void 0:b.filter(_=>_.id!==g))??[]),await n.mutateAsync(g)}};if(t6e()||!a)return null;const p=gNt[a.celebration_type]||Jn,f=e6e[a.celebration_type]||e6e.custom;return e.jsx(fs,{open:l,onOpenChange:g=>!g&&u(),children:e.jsxs(ps,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${f} opacity-10`}),e.jsxs("div",{className:"relative z-10 py-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:`w-20 h-20 rounded-full bg-gradient-to-br ${f} flex items-center justify-center animate-bounce`,children:e.jsx(p,{className:"w-10 h-10 text-white"})})}),e.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[e.jsx(pn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(pn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(pn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-150"})]}),e.jsxs("h2",{className:"text-2xl font-bold mb-2 bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent",children:["🎉 ",a.title]}),a.points_amount&&a.points_amount>0&&e.jsxs("div",{className:"text-4xl font-bold text-primary mb-2",children:["+",a.points_amount," points!"]}),a.message&&e.jsx("p",{className:"text-muted-foreground mb-6",children:a.message}),e.jsx(K,{onClick:u,className:"w-full",size:"lg",children:"Awesome! 🙌"}),r&&r.length>1&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-3",children:["+",r.length-1," more celebration",r.length>2?"s":""," waiting"]})]})]})})}const pWe="/assets/levelup-logo-horizontal-DEFNc0ms.png",cje="/assets/levelup-logo-white-C2RAgAoG.png",vNt="/assets/listings-hero-BI9Ki9Dq.jpg",ze=k.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:It("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));ze.displayName="Input";var fWe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(Gv,function(){var r,n,a;function o(i,c){if(!r)r=c;else if(!n)n=c;else{var u="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+r+")(sharedChunk); ("+n+")(sharedChunk); self.onerror = null;",p={};r(p),a=c(p),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(a.workerUrl=window.URL.createObjectURL(new Blob([u],{type:"text/javascript"})))}}o(["exports"],function(i){var c=1e-6,u=typeof Float32Array<"u"?Float32Array:Array;function p(x,d){var m=d[0],v=d[1],C=d[2],E=d[3],P=m*E-C*v;return P?(x[0]=E*(P=1/P),x[1]=-v*P,x[2]=-C*P,x[3]=m*P,x):null}function f(){var x=new u(9);return u!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[5]=0,x[6]=0,x[7]=0),x[0]=1,x[4]=1,x[8]=1,x}function g(x,d){var m=d[0],v=d[1],C=d[2],E=d[3],P=d[4],R=d[5],$=d[6],G=d[7],te=d[8];return x[0]=P*te-R*G,x[1]=C*G-v*te,x[2]=v*R-C*P,x[3]=R*$-E*te,x[4]=m*te-C*$,x[5]=C*E-m*R,x[6]=E*G-P*$,x[7]=v*$-m*G,x[8]=m*P-v*E,x}function b(x,d,m){var v=d[0],C=d[1],E=d[2],P=d[3],R=d[4],$=d[5],G=d[6],te=d[7],se=d[8],ae=m[0],de=m[1],he=m[2],Se=m[3],Fe=m[4],Re=m[5],Ke=m[6],Xe=m[7],lt=m[8];return x[0]=ae*v+de*P+he*G,x[1]=ae*C+de*R+he*te,x[2]=ae*E+de*$+he*se,x[3]=Se*v+Fe*P+Re*G,x[4]=Se*C+Fe*R+Re*te,x[5]=Se*E+Fe*$+Re*se,x[6]=Ke*v+Xe*P+lt*G,x[7]=Ke*C+Xe*R+lt*te,x[8]=Ke*E+Xe*$+lt*se,x}function _(){var x=new u(16);return u!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[11]=0,x[12]=0,x[13]=0,x[14]=0),x[0]=1,x[5]=1,x[10]=1,x[15]=1,x}function j(x){var d=new u(16);return d[0]=x[0],d[1]=x[1],d[2]=x[2],d[3]=x[3],d[4]=x[4],d[5]=x[5],d[6]=x[6],d[7]=x[7],d[8]=x[8],d[9]=x[9],d[10]=x[10],d[11]=x[11],d[12]=x[12],d[13]=x[13],d[14]=x[14],d[15]=x[15],d}function w(x){return x[0]=1,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=1,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=1,x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function N(x,d){var m=d[0],v=d[1],C=d[2],E=d[3],P=d[4],R=d[5],$=d[6],G=d[7],te=d[8],se=d[9],ae=d[10],de=d[11],he=d[12],Se=d[13],Fe=d[14],Re=d[15],Ke=m*R-v*P,Xe=m*$-C*P,lt=m*G-E*P,kt=v*$-C*R,vt=v*G-E*R,At=C*G-E*$,zt=te*Se-se*he,qt=te*Fe-ae*he,ss=te*Re-de*he,Gt=se*Fe-ae*Se,ds=se*Re-de*Se,js=ae*Re-de*Fe,Ns=Ke*js-Xe*ds+lt*Gt+kt*ss-vt*qt+At*zt;return Ns?(x[0]=(R*js-$*ds+G*Gt)*(Ns=1/Ns),x[1]=(C*ds-v*js-E*Gt)*Ns,x[2]=(Se*At-Fe*vt+Re*kt)*Ns,x[3]=(ae*vt-se*At-de*kt)*Ns,x[4]=($*ss-P*js-G*qt)*Ns,x[5]=(m*js-C*ss+E*qt)*Ns,x[6]=(Fe*lt-he*At-Re*Xe)*Ns,x[7]=(te*At-ae*lt+de*Xe)*Ns,x[8]=(P*ds-R*ss+G*zt)*Ns,x[9]=(v*ss-m*ds-E*zt)*Ns,x[10]=(he*vt-Se*lt+Re*Ke)*Ns,x[11]=(se*lt-te*vt-de*Ke)*Ns,x[12]=(R*qt-P*Gt-$*zt)*Ns,x[13]=(m*Gt-v*qt+C*zt)*Ns,x[14]=(Se*Xe-he*kt-Fe*Ke)*Ns,x[15]=(te*kt-se*Xe+ae*Ke)*Ns,x):null}function S(x,d,m){var v=d[0],C=d[1],E=d[2],P=d[3],R=d[4],$=d[5],G=d[6],te=d[7],se=d[8],ae=d[9],de=d[10],he=d[11],Se=d[12],Fe=d[13],Re=d[14],Ke=d[15],Xe=m[0],lt=m[1],kt=m[2],vt=m[3];return x[0]=Xe*v+lt*R+kt*se+vt*Se,x[1]=Xe*C+lt*$+kt*ae+vt*Fe,x[2]=Xe*E+lt*G+kt*de+vt*Re,x[3]=Xe*P+lt*te+kt*he+vt*Ke,x[4]=(Xe=m[4])*v+(lt=m[5])*R+(kt=m[6])*se+(vt=m[7])*Se,x[5]=Xe*C+lt*$+kt*ae+vt*Fe,x[6]=Xe*E+lt*G+kt*de+vt*Re,x[7]=Xe*P+lt*te+kt*he+vt*Ke,x[8]=(Xe=m[8])*v+(lt=m[9])*R+(kt=m[10])*se+(vt=m[11])*Se,x[9]=Xe*C+lt*$+kt*ae+vt*Fe,x[10]=Xe*E+lt*G+kt*de+vt*Re,x[11]=Xe*P+lt*te+kt*he+vt*Ke,x[12]=(Xe=m[12])*v+(lt=m[13])*R+(kt=m[14])*se+(vt=m[15])*Se,x[13]=Xe*C+lt*$+kt*ae+vt*Fe,x[14]=Xe*E+lt*G+kt*de+vt*Re,x[15]=Xe*P+lt*te+kt*he+vt*Ke,x}function M(x,d,m){var v,C,E,P,R,$,G,te,se,ae,de,he,Se=m[0],Fe=m[1],Re=m[2];return d===x?(x[12]=d[0]*Se+d[4]*Fe+d[8]*Re+d[12],x[13]=d[1]*Se+d[5]*Fe+d[9]*Re+d[13],x[14]=d[2]*Se+d[6]*Fe+d[10]*Re+d[14],x[15]=d[3]*Se+d[7]*Fe+d[11]*Re+d[15]):(C=d[1],E=d[2],P=d[3],R=d[4],$=d[5],G=d[6],te=d[7],se=d[8],ae=d[9],de=d[10],he=d[11],x[0]=v=d[0],x[1]=C,x[2]=E,x[3]=P,x[4]=R,x[5]=$,x[6]=G,x[7]=te,x[8]=se,x[9]=ae,x[10]=de,x[11]=he,x[12]=v*Se+R*Fe+se*Re+d[12],x[13]=C*Se+$*Fe+ae*Re+d[13],x[14]=E*Se+G*Fe+de*Re+d[14],x[15]=P*Se+te*Fe+he*Re+d[15]),x}function L(x,d,m){var v=m[0],C=m[1],E=m[2];return x[0]=d[0]*v,x[1]=d[1]*v,x[2]=d[2]*v,x[3]=d[3]*v,x[4]=d[4]*C,x[5]=d[5]*C,x[6]=d[6]*C,x[7]=d[7]*C,x[8]=d[8]*E,x[9]=d[9]*E,x[10]=d[10]*E,x[11]=d[11]*E,x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15],x}function I(x,d,m){var v=Math.sin(m),C=Math.cos(m),E=d[4],P=d[5],R=d[6],$=d[7],G=d[8],te=d[9],se=d[10],ae=d[11];return d!==x&&(x[0]=d[0],x[1]=d[1],x[2]=d[2],x[3]=d[3],x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15]),x[4]=E*C+G*v,x[5]=P*C+te*v,x[6]=R*C+se*v,x[7]=$*C+ae*v,x[8]=G*C-E*v,x[9]=te*C-P*v,x[10]=se*C-R*v,x[11]=ae*C-$*v,x}function O(x,d,m){var v=Math.sin(m),C=Math.cos(m),E=d[0],P=d[1],R=d[2],$=d[3],G=d[8],te=d[9],se=d[10],ae=d[11];return d!==x&&(x[4]=d[4],x[5]=d[5],x[6]=d[6],x[7]=d[7],x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15]),x[0]=E*C-G*v,x[1]=P*C-te*v,x[2]=R*C-se*v,x[3]=$*C-ae*v,x[8]=E*v+G*C,x[9]=P*v+te*C,x[10]=R*v+se*C,x[11]=$*v+ae*C,x}function q(x,d,m){var v=Math.sin(m),C=Math.cos(m),E=d[0],P=d[1],R=d[2],$=d[3],G=d[4],te=d[5],se=d[6],ae=d[7];return d!==x&&(x[8]=d[8],x[9]=d[9],x[10]=d[10],x[11]=d[11],x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15]),x[0]=E*C+G*v,x[1]=P*C+te*v,x[2]=R*C+se*v,x[3]=$*C+ae*v,x[4]=G*C-E*v,x[5]=te*C-P*v,x[6]=se*C-R*v,x[7]=ae*C-$*v,x}function U(x,d){return x[0]=d[0],x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=d[1],x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=d[2],x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function B(x,d,m){var v,C,E,P=m[0],R=m[1],$=m[2],G=Math.sqrt(P*P+R*R+$*$);return G0&&(E=1/Math.sqrt(E)),x[0]=d[0]*E,x[1]=d[1]*E,x[2]=d[2]*E,x}function Le(x,d){return x[0]*d[0]+x[1]*d[1]+x[2]*d[2]}function tt(x,d,m){var v=d[0],C=d[1],E=d[2],P=m[0],R=m[1],$=m[2];return x[0]=C*$-E*R,x[1]=E*P-v*$,x[2]=v*R-C*P,x}function Te(x,d,m,v){var C=d[0],E=d[1],P=d[2];return x[0]=C+v*(m[0]-C),x[1]=E+v*(m[1]-E),x[2]=P+v*(m[2]-P),x}function pt(x,d,m){var v=d[0],C=d[1],E=d[2],P=m[3]*v+m[7]*C+m[11]*E+m[15];return x[0]=(m[0]*v+m[4]*C+m[8]*E+m[12])/(P=P||1),x[1]=(m[1]*v+m[5]*C+m[9]*E+m[13])/P,x[2]=(m[2]*v+m[6]*C+m[10]*E+m[14])/P,x}function fe(x,d,m){var v=d[0],C=d[1],E=d[2];return x[0]=v*m[0]+C*m[3]+E*m[6],x[1]=v*m[1]+C*m[4]+E*m[7],x[2]=v*m[2]+C*m[5]+E*m[8],x}function qe(x,d,m){var v=m[0],C=m[1],E=m[2],P=m[3],R=d[0],$=d[1],G=d[2],te=C*G-E*$,se=E*R-v*G,ae=v*$-C*R;return x[0]=R+P*(te+=te)+C*(ae+=ae)-E*(se+=se),x[1]=$+P*se+E*te-v*ae,x[2]=G+P*ae+v*se-C*te,x}function at(x){return x[0]=0,x[1]=0,x[2]=0,x}function et(x,d){return x[0]===d[0]&&x[1]===d[1]&&x[2]===d[2]}var Me=ge,rt=ye,He=ie;function ct(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),x}function Ue(x,d,m){return x[0]=d[0]*m,x[1]=d[1]*m,x[2]=d[2]*m,x[3]=d[3]*m,x}function Ze(x,d){var m=d[0],v=d[1],C=d[2],E=d[3],P=m*m+v*v+C*C+E*E;return P>0&&(P=1/Math.sqrt(P)),x[0]=m*P,x[1]=v*P,x[2]=C*P,x[3]=E*P,x}function Qe(x,d,m){var v=d[0],C=d[1],E=d[2],P=d[3];return x[0]=m[0]*v+m[4]*C+m[8]*E+m[12]*P,x[1]=m[1]*v+m[5]*C+m[9]*E+m[13]*P,x[2]=m[2]*v+m[6]*C+m[10]*E+m[14]*P,x[3]=m[3]*v+m[7]*C+m[11]*E+m[15]*P,x}function We(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0),x[3]=1,x}function Je(x){return x[0]=0,x[1]=0,x[2]=0,x[3]=1,x}function it(x,d,m){m*=.5;var v=d[0],C=d[1],E=d[2],P=d[3],R=Math.sin(m),$=Math.cos(m);return x[0]=v*$+P*R,x[1]=C*$+E*R,x[2]=E*$-C*R,x[3]=P*$-v*R,x}function Dt(x,d,m){m*=.5;var v=d[0],C=d[1],E=d[2],P=d[3],R=Math.sin(m),$=Math.cos(m);return x[0]=v*$-E*R,x[1]=C*$+P*R,x[2]=E*$+v*R,x[3]=P*$-C*R,x}ee(),ct();var Vt,hs,Ts,Cs=Ze,cs=(Vt=ee(),hs=re(1,0,0),Ts=re(0,1,0),function(x,d,m){var v=Le(d,m);return v<-.999999?(tt(Vt,hs,d),He(Vt)<1e-6&&tt(Vt,Ts,d),we(Vt,Vt),function(C,E,P){P*=.5;var R=Math.sin(P);C[0]=R*E[0],C[1]=R*E[1],C[2]=R*E[2],C[3]=Math.cos(P)}(x,Vt,Math.PI),x):v>.999999?(x[0]=0,x[1]=0,x[2]=0,x[3]=1,x):(tt(Vt,d,m),x[0]=Vt[0],x[1]=Vt[1],x[2]=Vt[2],x[3]=1+v,Cs(x,x))});function er(){var x=new u(2);return u!=Float32Array&&(x[0]=0,x[1]=0),x}function xt(x,d){var m=new u(2);return m[0]=x,m[1]=d,m}function Es(x,d,m){return x[0]=d,x[1]=m,x}function ur(x,d,m){return x[0]=d[0]+m[0],x[1]=d[1]+m[1],x}function Mr(x,d,m){return x[0]=d[0]-m[0],x[1]=d[1]-m[1],x}function Lr(x,d,m){return x[0]=d[0]*m,x[1]=d[1]*m,x}function fn(x){var d=x[0],m=x[1];return Math.sqrt(d*d+m*m)}function ki(x,d){var m=d[0],v=d[1],C=m*m+v*v;return C>0&&(C=1/Math.sqrt(C)),x[0]=d[0]*C,x[1]=d[1]*C,x}function Ea(x,d){return x[0]*d[0]+x[1]*d[1]}We(),We(),f();var dr,Jr,Wr=Mr;function dn(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}er();var Yr=function(){if(Jr)return dr;function x(d,m,v,C){this.cx=3*d,this.bx=3*(v-d)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*m,this.by=3*(C-m)-this.cy,this.ay=1-this.cy-this.by,this.p1x=d,this.p1y=m,this.p2x=v,this.p2y=C}return Jr=1,dr=x,x.prototype={sampleCurveX:function(d){return((this.ax*d+this.bx)*d+this.cx)*d},sampleCurveY:function(d){return((this.ay*d+this.by)*d+this.cy)*d},sampleCurveDerivativeX:function(d){return(3*this.ax*d+2*this.bx)*d+this.cx},solveCurveX:function(d,m){if(m===void 0&&(m=1e-6),d<0)return 0;if(d>1)return 1;for(var v=d,C=0;C<8;C++){var E=this.sampleCurveX(v)-d;if(Math.abs(E)E?R=v:$=v,v=.5*($-R)+R;return v},solve:function(d,m){return this.sampleCurveY(this.solveCurveX(d,m))}},dr}(),vi=dn(Yr);function ft(x,d){this.x=x,this.y=d}function ir(x,d){if(Array.isArray(x)){if(!Array.isArray(d)||x.length!==d.length)return!1;for(let m=0;m=1)return 1;const d=x*x,m=d*x;return 4*(x<.5?m:3*(x-d)+m-.75)}function Fo(x,d,m,v){const C=new vi(x,d,m,v);return function(E){return C.solve(E)}}const $t=Fo(.25,.1,.25,1);function ke(x,d,m){return Math.min(m,Math.max(d,x))}function Be(x,d,m){return(m=ke((m-x)/(d-x),0,1))*m*(3-2*m)}function Ye(x,d,m){const v=m-d,C=((x-d)%v+v)%v+d;return C===d?m:C}function bt(x,d,m){if(!x.length)return m(null,[]);let v=x.length;const C=new Array(x.length);let E=null;x.forEach((P,R)=>{d(P,($,G)=>{$&&(E=$),C[R]=G,--v==0&&m(E,C)})})}let gt=1;function Ft(){return gt++}function Zt(x){return x<=1?1:Math.pow(2,Math.ceil(Math.log2(x)))}function Ut(x,d){x.forEach(m=>{d[m]&&(d[m]=d[m].bind(d))})}function Xt(x,d,m){const v={};for(const C in x)v[C]=d.call(this,x[C],C,x);return v}function Ps(x,d,m){const v={};for(const C in x)d.call(this,x[C],C,x)&&(v[C]=x[C]);return v}function gs(x){return Array.isArray(x)?x.map(gs):typeof x=="object"&&x?Xt(x,gs):x}function vr(x,d){for(let m=0;m=0)return!0;return!1}const Hr={};function xr(x){Hr[x]||(typeof console<"u"&&console.warn(x),Hr[x]=!0)}function Dn(x,d,m){return(m.y-x.y)*(d.x-x.x)>(d.y-x.y)*(m.x-x.x)}function On(x){let d=0;for(let m,v,C=0,E=x.length,P=E-1;C@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,v,C,E)=>{const P=C||E;return d[v]=!P||P.toLowerCase(),""}),d["max-age"]){const m=parseInt(d["max-age"],10);isNaN(m)?delete d["max-age"]:d["max-age"]=m}return d}let il=null;function ti(x,d){return[x[4*d],x[4*d+1],x[4*d+2],x[4*d+3]]}function hl(x,d,m,v){for(;d>1;x[C]>1;x[C]<=v?d=C+1:m=C}return d}function Ia(x){return x>0?1/(1.001-x):1+x}function lo(x){return x>0?1-1/(1.001-x):-x}function Ti(x,d,m){return(x-d.min)*(m.max-m.min)/(d.max-d.min)+m.min}const ua={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(!ua.API_URL)return null;try{const x=new URL(ua.API_URL);return x.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":x.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 co(x){return ua.API_URL_REGEX.test(x)}function Mc(x){return ua.API_SPRITE_REGEX.test(x)}let Wc,lu,Of,zl,ch,Sd;function Km(){return Wc==null&&(Wc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Wc}const Bl={now:()=>zl!==void 0?zl:performance.now(),setNow(x){zl=x},restoreNow(){zl=void 0},frame(x){const d=requestAnimationFrame(x);return{cancel:()=>cancelAnimationFrame(d)}},getImageData(x,d=0){const{width:m,height:v}=x;ch||(ch=document.createElement("canvas"));const C=ch.getContext("2d",{willReadFrequently:!0});if(!C)throw new Error("failed to create canvas 2d context");return(m>ch.width||v>ch.height)&&(ch.width=m,ch.height=v),C.clearRect(-d,-d,m+2*d,v+2*d),C.drawImage(x,0,0,m,v),C.getImageData(-d,-d,m+2*d,v+2*d)},resolveURL:x=>(lu||(lu=document.createElement("a")),lu.href=x,lu.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Of==null&&(Of=window.matchMedia("(prefers-reduced-motion: reduce)")),Of.matches)},hasCanvasFingerprintNoise(){if(Sd!==void 0)return Sd;if(!Km())return Sd=!1,!1;const x=new OffscreenCanvas(85,1),d=x.getContext("2d",{willReadFrequently:!0});let m=0;for(let C=0;C0?`?${E}`:""}`}const H1="mapbox-tiles";let W1=500,G1=50;const Dp=["language","worldview","jobid"];let am,cu;function im(){try{return caches}catch{}}function $d(){const x=im();x&&am==null&&(am=x.open(H1))}let Cd=1/0;const du={supported:!1,testSupport:function(x){!Zm&&Ff&&(Ym?Y0(x):Rf=x)}};let Rf,Ff,Zm=!1,Ym=!1;const Md=typeof self<"u"?self:{};function Y0(x){const d=x.createTexture();x.bindTexture(x.TEXTURE_2D,d);try{if(x.texImage2D(x.TEXTURE_2D,0,x.RGBA,x.RGBA,x.UNSIGNED_BYTE,Ff),x.isContextLost())return;du.supported=!0}catch{}x.deleteTexture(d),Zm=!0}Md.document&&(Ff=Md.document.createElement("img"),Ff.onload=function(){Rf&&Y0(Rf),Rf=null,Ym=!0},Ff.onerror=function(){Zm=!0,Rf=null},Ff.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Xx={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(Xx);class El extends Error{constructor(d,m,v){m===401&&co(v)&&(d+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(d),this.status=m,this.url=v}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const K1=_a()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Qx=function(x,d){if(!(/^file:/.test(m=x.url)||/^file:/.test(K1())&&!/^\w+:/.test(m))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(v,C){const E=new AbortController,P=new Request(v.url,{method:v.method||"GET",body:v.body,credentials:v.credentials,headers:v.headers,referrer:K1(),referrerPolicy:v.referrerPolicy,signal:E.signal});let R=!1,$=!1;const G=(te=P.url).indexOf("sku=")>0&&co(te);var te;v.type==="json"&&P.headers.set("Accept","application/json");const se=(de,he,Se)=>{if($)return;if(de&&de.message!=="SecurityError"&&xr(de.toString()),he&&Se)return ae(he);const Fe=Date.now();fetch(P).then(Re=>{if(Re.ok){const Ke=G?Re.clone():null;return ae(Re,Ke,Fe)}return C(new El(Re.statusText,Re.status,v.url))}).catch(Re=>{Re.name!=="AbortError"&&C(new Error(`${Re.message} ${v.url}`))})},ae=(de,he,Se)=>{(v.type==="arrayBuffer"?de.arrayBuffer():v.type==="json"?de.json():de.text()).then(Fe=>{$||(he&&Se&&function(Re,Ke,Xe){if($d(),am==null)return;const lt=vo(Ke.headers.get("Cache-Control")||"");if(lt["no-store"])return;const kt={status:Ke.status,statusText:Ke.statusText,headers:new Headers};Ke.headers.forEach((zt,qt)=>kt.headers.set(qt,zt)),lt["max-age"]&&kt.headers.set("Expires",new Date(Xe+1e3*lt["max-age"]).toUTCString());const vt=kt.headers.get("Expires");if(!vt||new Date(vt).getTime()-Xe<42e4)return;let At=vy(Re.url,{persistentParams:Dp});if(Ke.status===206){const zt=Re.headers.get("Range");if(!zt)return;kt.status=200,At=Yx(At,{range:zt})}(function(zt,qt){if(cu===void 0)try{new Response(new ReadableStream),cu=!0}catch{cu=!1}cu?qt(zt.body):zt.blob().then(qt).catch(ss=>xr(ss.message))})(Ke,zt=>{const qt=new Response((ss=Ke.status)!==200&&ss!==404&&[101,103,204,205,304].includes(ss)?null:zt,kt);var ss;$d(),am!=null&&am.then(Gt=>Gt.put(At,qt)).catch(Gt=>xr(Gt.message))})}(P,he,Se),R=!0,C(null,Fe,de.headers))}).catch(Fe=>{$||C(new Error(Fe.message))})};return G?function(de,he){if($d(),am==null)return he(null);am.then(Se=>{let Fe=vy(de.url,{persistentParams:Dp});const Re=de.headers.get("Range");Re&&(Fe=Yx(Fe,{range:Re})),Se.match(Fe).then(Ke=>{const Xe=function(lt){if(!lt)return!1;const kt=new Date(lt.headers.get("Expires")||0),vt=vo(lt.headers.get("Cache-Control")||"");return Number(kt)>Date.now()&&!vt["no-cache"]}(Ke);Se.delete(Fe).catch(he),Xe&&Se.put(Fe,Ke.clone()).catch(he),he(null,Ke,Xe)}).catch(he)}).catch(he)}(P,se):se(null,null),{cancel:()=>{$=!0,R||E.abort()}}}(x,d);if(_a(self)&&self.worker.actor)return self.worker.actor.send("getResource",x,d,void 0,!0)}var m;return function(v,C){const E=new XMLHttpRequest;E.open(v.method||"GET",v.url,!0),v.type==="arrayBuffer"&&(E.responseType="arraybuffer");for(const P in v.headers)E.setRequestHeader(P,v.headers[P]);return v.type==="json"&&(E.responseType="text",E.setRequestHeader("Accept","application/json")),E.withCredentials=v.credentials==="include",E.onerror=()=>{C(new Error(E.statusText))},E.onload=()=>{if((E.status>=200&&E.status<300||E.status===0)&&E.response!==null){let P=E.response;if(v.type==="json")try{P=JSON.parse(E.response)}catch($){return C($)}const R=new Headers;E.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach($=>{const G=$.split(": "),te=G.shift(),se=G.join(": ");R.append(te,se)}),C(null,P,R)}else C(new El(E.statusText,E.status,v.url))},E.send(v.body),{cancel:()=>E.abort()}}(x,d)},Lh=function(x,d){return Qx(Object.assign(x,{type:"arrayBuffer"}),d)};function Ww(x){const d=document.createElement("a");return d.href=x,d.protocol===location.protocol&&d.host===location.host}const EC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let X0,La;X0=[],La=0;const by=function(x,d){if(du.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),La>=ua.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:x,callback:d,cancelled:!1,cancel(){this.cancelled=!0}};return X0.push(E),E}La++;let m=!1;const v=()=>{if(!m)for(m=!0,La--;X0.length&&La{v(),E?d(E):P&&(self.createImageBitmap?function($,G){const te=new Blob([new Uint8Array($)],{type:"image/png"});createImageBitmap(te).then(se=>{G(null,se)}).catch(se=>{G(new Error(`Could not load image because of ${se.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(P,($,G)=>d($,G,R)):function($,G){const te=new Image;te.onload=()=>{G(null,te),URL.revokeObjectURL(te.src),te.onload=null,requestAnimationFrame(()=>{te.src=EC})},te.onerror=()=>G(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 se=new Blob([new Uint8Array($)],{type:"image/png"});te.src=$.byteLength?URL.createObjectURL(se):EC}(P,($,G)=>d($,G,R)))});return{cancel:()=>{C.cancel(),v()}}};var Gw,PC,IC,om={exports:{}},Q0={exports:{}},J0={exports:{}},Kw=function(){if(IC)return om.exports;IC=1;var x=(Gw||(Gw=1,Q0.exports=function(m,v){var C,E,P,R,$,G,te,se;for(E=m.length-(C=3&m.length),P=v,$=3432918353,G=461845907,se=0;se>>16)*$&65535)<<16)&4294967295)<<15|te>>>17))*G+(((te>>>16)*G&65535)<<16)&4294967295)<<13|P>>>19))+((5*(P>>>16)&65535)<<16)&4294967295))+((58964+(R>>>16)&65535)<<16);switch(te=0,C){case 3:te^=(255&m.charCodeAt(se+2))<<16;case 2:te^=(255&m.charCodeAt(se+1))<<8;case 1:P^=te=(65535&(te=(te=(65535&(te^=255&m.charCodeAt(se)))*$+(((te>>>16)*$&65535)<<16)&4294967295)<<15|te>>>17))*G+(((te>>>16)*G&65535)<<16)&4294967295}return P^=m.length,P=2246822507*(65535&(P^=P>>>16))+((2246822507*(P>>>16)&65535)<<16)&4294967295,P=3266489909*(65535&(P^=P>>>13))+((3266489909*(P>>>16)&65535)<<16)&4294967295,(P^=P>>>16)>>>0}),Q0.exports),d=(PC||(PC=1,J0.exports=function(m,v){for(var C,E=m.length,P=v^E,R=0;E>=4;)C=1540483477*(65535&(C=255&m.charCodeAt(R)|(255&m.charCodeAt(++R))<<8|(255&m.charCodeAt(++R))<<16|(255&m.charCodeAt(++R))<<24))+((1540483477*(C>>>16)&65535)<<16),P=1540483477*(65535&P)+((1540483477*(P>>>16)&65535)<<16)^(C=1540483477*(65535&(C^=C>>>24))+((1540483477*(C>>>16)&65535)<<16)),E-=4,++R;switch(E){case 3:P^=(255&m.charCodeAt(R+2))<<16;case 2:P^=(255&m.charCodeAt(R+1))<<8;case 1:P=1540483477*(65535&(P^=255&m.charCodeAt(R)))+((1540483477*(P>>>16)&65535)<<16)}return P=1540483477*(65535&(P^=P>>>13))+((1540483477*(P>>>16)&65535)<<16),(P^=P>>>15)>>>0}),J0.exports);return om.exports=x,om.exports.murmur3=x,om.exports.murmur2=d,om.exports}(),Z1=dn(Kw);class Xm{constructor(d,...m){Object.assign(this,m[0]||{}),this.type=d}}class _y extends Xm{constructor(d,m={}){super("error",Object.assign({error:d},m))}}function Zw(x,d,m){m[x]&&m[x].indexOf(d)!==-1||(m[x]=m[x]||[],m[x].push(d))}function jt(x,d,m){if(m&&m[x]){const v=m[x].indexOf(d);v!==-1&&m[x].splice(v,1)}}class As{on(d,m){return this._listeners=this._listeners||{},Zw(d,m,this._listeners),this}off(d,m){return jt(d,m,this._listeners),jt(d,m,this._oneTimeListeners),this}once(d,m){return m?(this._oneTimeListeners=this._oneTimeListeners||{},Zw(d,m,this._oneTimeListeners),this):new Promise(v=>{this.once(d,v)})}fire(d,m){const v=typeof d=="string"?new Xm(d,m):d,C=v.type;if(this.listens(C)){v.target=this;const E=this._listeners&&this._listeners[C]?this._listeners[C].slice():[];for(const $ of E)$.call(this,v);const P=this._oneTimeListeners&&this._oneTimeListeners[C]?this._oneTimeListeners[C].slice():[];for(const $ of P)jt(C,$,this._oneTimeListeners),$.call(this,v);const R=this._eventedParent;if(R){const $=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(v,$),R.fire(v)}}else v instanceof _y&&console.error(v.error);return this}listens(d){return!!(this._listeners&&this._listeners[d]&&this._listeners[d].length>0||this._oneTimeListeners&&this._oneTimeListeners[d]&&this._oneTimeListeners[d].length>0||this._eventedParent&&this._eventedParent.listens(d))}setEventedParent(d,m){return this._eventedParent=d,this._eventedParentData=m,this}}class Qs{constructor(d){typeof d=="string"?this.name=d:(this.name=d.name,this.iconsetId=d.iconsetId)}static from(d){return new Qs(d)}static toString(d){return d.iconsetId?`${d.name}${d.iconsetId}`:d.name}static parse(d){const[m,v]=d.split("");return new Qs({name:m,iconsetId:v})}static isEqual(d,m){return d.name===m.name&&d.iconsetId===m.iconsetId}toString(){return Qs.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var xn,gn={},ca=function(){if(xn)return gn;xn=1;var x={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 d(E){return(E=Math.round(E))<0?0:E>255?255:E}function m(E){return d(E[E.length-1]==="%"?parseFloat(E)/100*255:parseInt(E))}function v(E){return(P=E[E.length-1]==="%"?parseFloat(E)/100:parseFloat(E))<0?0:P>1?1:P;var P}function C(E,P,R){return R<0?R+=1:R>1&&(R-=1),6*R<1?E+(P-E)*R*6:2*R<1?P:3*R<2?E+(P-E)*(2/3-R)*6:E}try{gn.parseCSSColor=function(E){var P,R=E.replace(/ /g,"").toLowerCase();if(R in x)return x[R].slice();if(R[0]==="#")return R.length===4?(P=parseInt(R.substr(1),16))>=0&&P<=4095?[(3840&P)>>4|(3840&P)>>8,240&P|(240&P)>>4,15&P|(15&P)<<4,1]:null:R.length===7&&(P=parseInt(R.substr(1),16))>=0&&P<=16777215?[(16711680&P)>>16,(65280&P)>>8,255&P,1]:null;var $=R.indexOf("("),G=R.indexOf(")");if($!==-1&&G+1===R.length){var te=R.substr(0,$),se=R.substr($+1,G-($+1)).split(","),ae=1;switch(te){case"rgba":if(se.length!==4)return null;ae=v(se.pop());case"rgb":return se.length!==3?null:[m(se[0]),m(se[1]),m(se[2]),ae];case"hsla":if(se.length!==4)return null;ae=v(se.pop());case"hsl":if(se.length!==3)return null;var de=(parseFloat(se[0])%360+360)%360/360,he=v(se[1]),Se=v(se[2]),Fe=Se<=.5?Se*(he+1):Se+he-Se*he,Re=2*Se-Fe;return[d(255*C(Re,Fe,de+1/3)),d(255*C(Re,Fe,de)),d(255*C(Re,Fe,de-1/3)),ae];default:return null}}return null}}catch{}return gn}();class Ur{constructor(d,m,v,C=1){this.r=d,this.g=m,this.b=v,this.a=C}static parse(d){if(!d)return;if(d instanceof Ur)return d;if(typeof d!="string")return;const m=ca.parseCSSColor(d);return m?new Ur(m[0]/255,m[1]/255,m[2]/255,m[3]):void 0}toString(){const[d,m,v,C]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*d)},${Math.round(255*m)},${Math.round(255*v)},${C})`}toNonPremultipliedRenderColor(d){const{r:m,g:v,b:C,a:E}=this;return new Jx(d,m,v,C,E)}toPremultipliedRenderColor(d){const{r:m,g:v,b:C,a:E}=this;return new Op(d,m*E,v*E,C*E,E)}clone(){return new Ur(this.r,this.g,this.b,this.a)}}class uo{constructor(d,m,v,C,E,P=!1){if(this.premultiplied=!1,this.premultiplied=P,d){const R=d.image.height,$=R*R;this.premultiplied?(m=E===0?0:m/E*(R-1),v=E===0?0:v/E*(R-1),C=E===0?0:C/E*(R-1)):(m*=R-1,v*=R-1,C*=R-1);const G=Math.floor(m),te=Math.floor(v),se=Math.floor(C),ae=Math.ceil(m),de=Math.ceil(v),he=Math.ceil(C),Se=m-G,Fe=v-te,Re=C-se,Ke=d.image.data,Xe=4*(G+te*$+se*R),lt=4*(G+te*$+he*R),kt=4*(G+de*$+se*R),vt=4*(G+de*$+he*R),At=4*(ae+te*$+se*R),zt=4*(ae+te*$+he*R),qt=4*(ae+de*$+se*R),ss=4*(ae+de*$+he*R);if(Xe<0||ss>=Ke.length)throw new Error("out of range");this.r=Zr(Zr(Zr(Ke[Xe],Ke[lt],Re),Zr(Ke[kt],Ke[vt],Re),Fe),Zr(Zr(Ke[At],Ke[zt],Re),Zr(Ke[qt],Ke[ss],Re),Fe),Se)/255*(this.premultiplied?E:1),this.g=Zr(Zr(Zr(Ke[Xe+1],Ke[lt+1],Re),Zr(Ke[kt+1],Ke[vt+1],Re),Fe),Zr(Zr(Ke[At+1],Ke[zt+1],Re),Zr(Ke[qt+1],Ke[ss+1],Re),Fe),Se)/255*(this.premultiplied?E:1),this.b=Zr(Zr(Zr(Ke[Xe+2],Ke[lt+2],Re),Zr(Ke[kt+2],Ke[vt+2],Re),Fe),Zr(Zr(Ke[At+2],Ke[zt+2],Re),Zr(Ke[qt+2],Ke[ss+2],Re),Fe),Se)/255*(this.premultiplied?E:1),this.a=E}else this.r=m,this.g=v,this.b=C,this.a=E}toArray(){const{r:d,g:m,b:v,a:C}=this;return[255*d,255*m,255*v,C]}toHslaArray(){let{r:d,g:m,b:v,a:C}=this;if(this.premultiplied){if(C===0)return[0,0,0,0];const he=1/C;d*=he,m*=he,v*=he}const E=Math.min(Math.max(d,0),1),P=Math.min(Math.max(m,0),1),R=Math.min(Math.max(v,0),1),$=Math.min(E,P,R),G=Math.max(E,P,R),te=G-$,se=.5*($+G);if(te===0)return[0,0,100*se,C];const ae=se>.5?te/(2-G-$):te/(G+$);let de;switch(G){case E:de=60*((P-R)/te+(PZr(v,d[C],m))}Ur.black=new Ur(0,0,0,1),Ur.white=new Ur(1,1,1,1),Ur.transparent=new Ur(0,0,0,0),Ur.red=new Ur(1,0,0,1),Ur.blue=new Ur(0,0,1,1);var tv=Object.freeze({__proto__:null,array:ev,color:function(x,d,m){return new Ur(Zr(x.r,d.r,m),Zr(x.g,d.g,m),Zr(x.b,d.b,m),Zr(x.a,d.a,m))},number:Zr});class Qm extends Error{constructor(d,m){super(m),this.message=m,this.key=d}}class Y1{constructor(d,m=[]){this.parent=d,this.bindings={};for(const[v,C]of m)this.bindings[v]=C}concat(d){return new Y1(this,d)}get(d){if(this.bindings[d])return this.bindings[d];if(this.parent)return this.parent.get(d);throw new Error(`${d} not found in scope.`)}has(d){return!!this.bindings[d]||!!this.parent&&this.parent.has(d)}}const Rp={kind:"null"},$r={kind:"number"},Da={kind:"string"},Si={kind:"boolean"},dh={kind:"color"},zf={kind:"object"},pi={kind:"value"},LC={kind:"collator"},Yw={kind:"formatted"},Xw={kind:"resolvedImage"};function qd(x,d){return{kind:"array",itemType:x,N:d}}function _l(x){if(x.kind==="array"){const d=_l(x.itemType);return typeof x.N=="number"?`array<${d}, ${x.N}>`:x.itemType.kind==="value"?"array":`array<${d}>`}return x.kind}const Nme=[Rp,$r,Da,Si,dh,Yw,zf,qd(pi),Xw];function wy(x,d){if(d.kind==="error")return null;if(x.kind==="array"){if(d.kind==="array"&&(d.N===0&&d.itemType.kind==="value"||!wy(x.itemType,d.itemType))&&(typeof x.N!="number"||x.N===d.N))return null}else{if(x.kind===d.kind)return null;if(x.kind==="value"){for(const m of Nme)if(!wy(m,d))return null}}return`Expected ${_l(x)} but found ${_l(d)} instead.`}function BE(x,d){return d.some(m=>m.kind===x.kind)}function Qw(x,d){return d.some(m=>m==="null"?x===null:m==="array"?Array.isArray(x):m==="object"?x&&!Array.isArray(x)&&typeof x=="object":m===typeof x)}function DC(x,d){return x.kind==="array"&&d.kind==="array"?x.N===d.N&&DC(x.itemType,d.itemType):x.kind===d.kind}class $E{constructor(d,m,v){this.sensitivity=d?m?"variant":"case":m?"accent":"base",this.locale=v,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(d,m){return this.collator.compare(d,m)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class OC{constructor(d,m,v,C,E){this.text=d.normalize?d.normalize():d,this.image=m,this.scale=v,this.fontStack=C,this.textColor=E}}class Du{constructor(d){this.sections=d}static fromString(d){return new Du([new OC(d,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(d=>d.text.length!==0||!!d.image&&d.image.hasPrimary())}static factory(d){return d instanceof Du?d:Du.fromString(d)}toString(){return this.sections.length===0?"":this.sections.map(d=>d.text).join("")}serialize(){const d=["format"];for(const m of this.sections){if(m.image){const C=m.image.getPrimary().id.toString();d.push(["image",C]);continue}d.push(m.text);const v={};m.fontStack&&(v["text-font"]=["literal",m.fontStack.split(",")]),m.scale&&(v["font-scale"]=m.scale),m.textColor&&(v["text-color"]=["rgba"].concat(m.textColor.toNonPremultipliedRenderColor(null).toArray())),d.push(v)}return d}}class eg{constructor(d,m={}){this.id=Qs.from(d),this.params=m.params,this.sx=m.sx||1,this.sy=m.sy||1}toString(){return JSON.stringify(this)}static parse(d){let m,v,C,E;try{({id:m,params:v,sx:C,sy:E}=JSON.parse(d)||{})}catch{return null}return m?new eg(m,{params:v,sx:C,sy:E}):null}scaleSelf(d,m=d){return this.sx*=d,this.sy*=m,this}}class Ou{constructor(d,m,v,C,E=!1){this.primaryId=Qs.from(d),this.primaryOptions=m,v&&(this.secondaryId=Qs.from(v)),this.secondaryOptions=C,this.available=E}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new eg(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new eg(this.secondaryId,this.secondaryOptions):null}static from(d){return typeof d=="string"?Ou.build({name:d}):d}static build(d,m,v,C){return!d||typeof d=="object"&&!("name"in d)?null:new Ou(d,v,m,C)}}function sv(x,d,m,v){return typeof x=="number"&&x>=0&&x<=255&&typeof d=="number"&&d>=0&&d<=255&&typeof m=="number"&&m>=0&&m<=255?v===void 0||typeof v=="number"&&v>=0&&v<=1?null:`Invalid rgba value [${[x,d,m,v].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof v=="number"?[x,d,m,v]:[x,d,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function X1(x){if(x===null||typeof x=="string"||typeof x=="boolean"||typeof x=="number"||x instanceof Ur||x instanceof $E||x instanceof Du||x instanceof Ou)return!0;if(Array.isArray(x)){for(const d of x)if(!X1(d))return!1;return!0}if(typeof x=="object"){for(const d in x)if(!X1(x[d]))return!1;return!0}return!1}function Tc(x){if(x===null)return Rp;if(typeof x=="string")return Da;if(typeof x=="boolean")return Si;if(typeof x=="number")return $r;if(x instanceof Ur)return dh;if(x instanceof $E)return LC;if(x instanceof Du)return Yw;if(x instanceof Ou)return Xw;if(Array.isArray(x)){const d=x.length;let m;for(const v of x){const C=Tc(v);if(m){if(m===C)continue;m=pi;break}m=C}return qd(m||pi,d)}return zf}function Jm(x){const d=typeof x;return x===null?"":d==="string"||d==="number"||d==="boolean"?String(x):x instanceof Du||x instanceof Ou||x instanceof Ur?x.toString():JSON.stringify(x)}class tg{constructor(d,m){this.type=d,this.value=m}static parse(d,m){if(d.length!==2)return m.error(`'literal' expression requires exactly one argument, but found ${d.length-1} instead.`);if(!X1(d[1]))return m.error("invalid value");const v=d[1];let C=Tc(v);const E=m.expectedType;return C.kind!=="array"||C.N!==0||!E||E.kind!=="array"||typeof E.N=="number"&&E.N!==0||(C=E),new tg(C,v)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Ur?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Du?this.value.serialize():this.value}}class cc{constructor(d){this.name="ExpressionEvaluationError",this.message=d}toJSON(){return this.message}}const qE={string:Da,number:$r,boolean:Si,object:zf};class Fp{constructor(d,m){this.type=d,this.args=m}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");let v,C=1;const E=d[0];if(E==="array"){let R,$;if(d.length>2){const G=d[1];if(typeof G!="string"||!(G in qE)||G==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);R=qE[G],C++}else R=pi;if(d.length>3){if(d[2]!==null&&(typeof d[2]!="number"||d[2]<0||d[2]!==Math.floor(d[2])))return m.error('The length argument to "array" must be a positive integer literal',2);$=d[2],C++}v=qd(R,$)}else v=qE[E];const P=[];for(;Cd.outputDefined())}serialize(){const d=this.type,m=[d.kind];if(d.kind==="array"){const v=d.itemType;if(v.kind==="string"||v.kind==="number"||v.kind==="boolean"){m.push(v.kind);const C=d.N;(typeof C=="number"||this.args.length>1)&&m.push(C)}}return m.concat(this.args.map(v=>v.serialize()))}}class Bf{constructor(d){this.type=Yw,this.sections=d}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");const v=d[1];if(!Array.isArray(v)&&typeof v=="object")return m.error("First argument must be an image or text section.");const C=[];let E=!1;for(let P=1;P<=d.length-1;++P){const R=d[P];if(E&&typeof R=="object"&&!Array.isArray(R)){E=!1;let $=null;if(R["font-scale"]&&($=m.parseObjectValue(R["font-scale"],P,"font-scale",$r),!$))return null;let G=null;if(R["text-font"]&&(G=m.parseObjectValue(R["text-font"],P,"text-font",qd(Da)),!G))return null;let te=null;if(R["text-color"]&&(te=m.parseObjectValue(R["text-color"],P,"text-color",dh),!te))return null;const se=C[C.length-1];se.scale=$,se.font=G,se.textColor=te}else{const $=m.parse(d[P],P,pi);if(!$)return null;const G=$.type.kind;if(G!=="string"&&G!=="value"&&G!=="null"&&G!=="resolvedImage")return m.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");E=!0,C.push({content:$,scale:null,font:null,textColor:null})}}return new Bf(C)}evaluate(d){return new Du(this.sections.map(m=>{const v=m.content.evaluate(d);return DC(Tc(v),Xw)?new OC("",v,null,null,null):new OC(Jm(v),null,m.scale?m.scale.evaluate(d):null,m.font?m.font.evaluate(d).join(","):null,m.textColor?m.textColor.evaluate(d):null)}))}eachChild(d){for(const m of this.sections)d(m.content),m.scale&&d(m.scale),m.font&&d(m.font),m.textColor&&d(m.textColor)}outputDefined(){return!1}serialize(){const d=["format"];for(const m of this.sections){d.push(m.content.serialize());const v={};m.scale&&(v["font-scale"]=m.scale.serialize()),m.font&&(v["text-font"]=m.font.serialize()),m.textColor&&(v["text-color"]=m.textColor.serialize()),d.push(v)}return d}}class Hn{constructor(d,m,v,C){this._imageWarnHistory={},this.type=Xw,this.namePrimary=d,this.nameSecondary=m,v&&(this.paramsPrimary=v.params,this.iconsetIdPrimary=v.iconset?v.iconset.id:void 0),C&&(this.paramsSecondary=C.params,this.iconsetIdSecondary=C.iconset?C.iconset.id:void 0)}static parse(d,m){if(d.length<2)return m.error("Expected two or more arguments.");let v=1;const C=[];function E(){if(vQs.isEqual(P,E)),C.available){const P=C.getSecondary()?C.getSecondary().id:null;P&&(C.available=d.availableImages.some(R=>Qs.isEqual(R,P)))}}return C}eachChild(d){if(d(this.namePrimary),this.paramsPrimary)for(const m in this.paramsPrimary)this.paramsPrimary[m]&&d(this.paramsPrimary[m]);if(this.nameSecondary&&(d(this.nameSecondary),this.paramsSecondary))for(const m in this.paramsSecondary)this.paramsSecondary[m]&&d(this.paramsSecondary[m])}outputDefined(){return!1}serializeOptions(d,m){const v={};if(m&&(v.iconset={id:m}),d){v.params={};for(const C in d)d[C]&&(v.params[C]=d[C].serialize())}return Object.keys(v).length>0?v:void 0}serialize(){const d=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const m=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);m&&d.push(m)}if(this.nameSecondary&&(d.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const m=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);m&&d.push(m)}return d}}function Fr(x){return yn(x)?"string":Q1(x)?"number":FC(x)?"boolean":Array.isArray(x)?"array":x===null?"null":RC(x)?"object":typeof x}function RC(x){return x!=null&&!Array.isArray(x)&&typeof x!="function"&&!(x instanceof String||x instanceof Number||x instanceof Boolean)&&typeof x=="object"}function yn(x){return typeof x=="string"||x instanceof String}function Q1(x){return typeof x=="number"||x instanceof Number}function FC(x){return typeof x=="boolean"||x instanceof Boolean}const mn={"to-boolean":Si,"to-color":dh,"to-number":$r,"to-string":Da};class $f{constructor(d,m){this.type=d,this.args=m}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");const v=d[0],C=[];let E=Rp;if(v==="to-array"){if(!Array.isArray(d[1]))return null;const P=d[1].length;if(m.expectedType){if(m.expectedType.kind!=="array")return m.error(`Expected ${m.expectedType.kind} but found array.`);E=qd(m.expectedType.itemType,P)}else{if(!(P>0&&X1(d[1][0])))return null;E=qd(Tc(d[1][0]),P)}for(let R=0;R4?`Invalid rbga value ${JSON.stringify(m)}: expected an array containing either three or four numeric values.`:sv(m[0],m[1],m[2],m[3]),!v))return new Ur(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new cc(v||`Could not parse color from value '${typeof m=="string"?m:String(JSON.stringify(m))}'`)}if(this.type.kind==="number"){let m=null;for(const v of this.args){if(m=v.evaluate(d),m===null)return 0;const C=Number(m);if(!isNaN(C))return C}throw new cc(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Du.fromString(Jm(this.args[0].evaluate(d))):this.type.kind==="resolvedImage"?Ou.build(Jm(this.args[0].evaluate(d))):this.type.kind==="array"?this.args.map(m=>m.evaluate(d)):Jm(this.args[0].evaluate(d))}eachChild(d){this.args.forEach(d)}outputDefined(){return this.args.every(d=>d.outputDefined())}serialize(){if(this.type.kind==="formatted")return new Bf([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Hn(this.args[0]).serialize();const d=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(m=>{d.push(m.serialize())}),d}}const UE=["Unknown","Point","LineString","Polygon"];class zC{constructor(d,m,v){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=d,this.options=m,this.iconImageUseTheme=v}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?UE[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(d){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const d=this.featureDistanceData.center,m=this.featureDistanceData.scale,{x:v,y:C}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(v*m-d[0])+this.featureDistanceData.bearing[1]*(C*m-d[1])}return 0}parseColor(d){let m=this._parseColorCache[d];return m||(m=this._parseColorCache[d]=Ur.parse(d)),m}getConfig(d){return this.options?this.options.get(d):null}}class Ru{constructor(d,m,v,C,E){this.name=d,this.type=m,this._evaluate=v,this.args=C,this._overloadIndex=E}evaluate(d){if(!this._evaluate){const m=Ru.definitions[this.name];this._evaluate=Array.isArray(m)?m[2]:m.overloads[this._overloadIndex][1]}return this._evaluate(d,this.args)}eachChild(d){this.args.forEach(d)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(d=>d.serialize()))}static parse(d,m){const v=d[0],C=Ru.definitions[v];if(!C)return m.error(`Unknown expression "${v}". If you wanted a literal array, use ["literal", [...]].`,0);const E=Array.isArray(C)?C[0]:C.type,P=Array.isArray(C)?[[C[1],C[2]]]:C.overloads,R=[];let $=null,G=-1;for(const[te,se]of P){if(Array.isArray(te)&&te.length!==d.length-1)continue;R.push(te),G++,$=new XC(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const ae=[];let de=!1;for(let he=1;heae)).map(BC).join(" | "),se=[];for(let ae=1;aem;){if(v-m>600){const $=v-m+1,G=d-m+1,te=Math.log($),se=.5*Math.exp(2*te/3),ae=.5*Math.sqrt(te*se*($-se)/$)*(G-$/2<0?-1:1);$C(x,d,Math.max(m,Math.floor(d-G*se/$+ae)),Math.min(v,Math.floor(d+($-G)*se/$+ae)),C)}const E=x[d];let P=m,R=v;for(zp(x,m,d),C(x[v],E)>0&&zp(x,m,v);P0;)R--}C(x[m],E)===0?zp(x,m,R):(R++,zp(x,R,v)),R<=d&&(m=R+1),d<=R&&(v=R-1)}}function zp(x,d,m){const v=x[d];x[d]=x[m],x[m]=v}function VE(x,d){return xd?1:0}function jy(x){let d=0;for(let m,v,C=0,E=x.length,P=E-1;C=d[2]||x[1]<=d[1]||x[3]>=d[3])}function kme(x,d,m){const v=x[0]-d[0],C=x[1]-d[1],E=x[0]-m[0],P=x[1]-m[1];return v*P-E*C==0&&v*E<=0&&C*P<=0}function J1(x,d,m=!1){let v=!1;for(let R=0,$=d.length;R<$;R++){const G=d[R];for(let te=0,se=G.length,ae=se-1;te(C=x)[1]!=(P=he)[1]>C[1]&&C[0]<(P[0]-E[0])*(C[1]-E[1])/(P[1]-E[1])+E[0]&&(v=!v)}}var C,E,P;return v}function e2(x,d,m,v){const C=v[0]-m[0],E=v[1]-m[1],P=(x[0]-m[0])*E-C*(x[1]-m[1]),R=(d[0]-m[0])*E-C*(d[1]-m[1]);return P>0&&R<0||P<0&&R>0}function t2(x,d,m,v){return(C=[v[0]-m[0],v[1]-m[1]])[0]*(E=[d[0]-x[0],d[1]-x[1]])[1]-C[1]*E[0]!=0&&!(!e2(x,d,m,v)||!e2(m,v,x,d));var C,E}function sg(x){const d=new ft(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new ft(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const v of x[0])d.x>v.x&&(d.x=v.x),d.y>v.y&&(d.y=v.y),m.xm[2]){const C=.5*v;let E=x[0]-m[0]>C?-v:m[0]-x[0]>C?v:0;E===0&&(E=x[0]-m[2]>C?-v:m[2]-x[0]>C?v:0),x[0]+=E}ep(d,x)}function ER(x,d,m,v){const C=Math.pow(2,v.z)*Ny,E=[v.x*Ny,v.y*Ny],P=[];if(!x)return P;for(const R of x)for(const $ of R){const G=[$.x+E[0],$.y+E[1]];AR(G,d,m,C),P.push(G)}return P}function qC(x,d,m,v){const C=Math.pow(2,v.z)*Ny,E=[v.x*Ny,v.y*Ny],P=[];if(!x)return P;for(const $ of x){const G=[];for(const te of $){const se=[te.x+E[0],te.y+E[1]];ep(d,se),G.push(se)}P.push(G)}if(d[2]-d[0]<=C/2){(R=d)[0]=R[1]=1/0,R[2]=R[3]=-1/0;for(const $ of P)for(const G of $)AR(G,d,m,C)}var R;return P}class Sy{constructor(d,m){this.type=Si,this.geojson=d,this.geometries=m}static parse(d,m){if(d.length!==2)return m.error(`'within' expression requires exactly one argument, but found ${d.length-1} instead.`);if(X1(d[1])){const v=d[1];if(v.type==="FeatureCollection")for(let C=0;Cm)return UC(E,P,(m-(v-R))/R)}return d[d.length-1]}pointToSegmentDistance(d,m,v){let[C,E]=m,P=lm(v[0]-C)*this.kx,R=(v[1]-E)*this.ky;if(P!==0||R!==0){const $=(lm(d[0]-C)*this.kx*P+(d[1]-E)*this.ky*R)/(P*P+R*R);$>1?(C=v[0],E=v[1]):$>0&&(C+=P/this.kx*$,E+=R/this.ky*$)}return P=lm(d[0]-C)*this.kx,R=(d[1]-E)*this.ky,Math.sqrt(P*P+R*R)}pointOnLine(d,m){let v=1/0,C=d[0][0],E=d[0][1],P=0,R=0;for(let $=0;$1?(G=d[$+1][0],te=d[$+1][1]):de>0&&(G+=se/this.kx*de,te+=ae/this.ky*de)),se=lm(m[0]-G)*this.kx,ae=(m[1]-te)*this.ky;const he=se*se+ae*ae;heE.index||C.index===E.index&&C.t>E.t){const G=C;C=E,E=G}const P=[C.point],R=C.index+1,$=E.index;!GE(v[R],P[0])&&R<=$&&P.push(v[R]);for(let G=R+1;G<=$;G++)P.push(v[G]);return GE(v[$],E.point)||P.push(E.point),P}lineSliceAlong(d,m,v){let C=0;const E=[];for(let P=0;Pd&&E.length===0&&E.push(UC(R,$,(d-(C-G))/G)),C>=m)return E.push(UC(R,$,(m-(C-G))/G)),E;C>d&&E.push($)}return E}bufferPoint(d,m){const v=m/this.ky,C=m/this.kx;return[d[0]-C,d[1]-v,d[0]+C,d[1]+v]}bufferBBox(d,m){const v=m/this.ky,C=m/this.kx;return[d[0]-C,d[1]-v,d[2]+C,d[3]+v]}insideBBox(d,m){return lm(d[0]-m[0])>=0&&lm(d[0]-m[2])<=0&&d[1]>=m[1]&&d[1]<=m[3]}}function GE(x,d){return x[0]===d[0]&&x[1]===d[1]}function UC(x,d,m){const v=lm(d[0]-x[0]);return[x[0]+v*m,x[1]+(d[1]-x[1])*m]}function lm(x){for(;x<-180;)x+=360;for(;x>180;)x-=360;return x}class VC{constructor(d=[],m=(v,C)=>vC?1:0){if(this.data=d,this.length=this.data.length,this.compare=m,this.length>0)for(let v=(this.length>>1)-1;v>=0;v--)this._down(v)}push(d){this.data.push(d),this._up(this.length++)}pop(){if(this.length===0)return;const d=this.data[0],m=this.data.pop();return--this.length>0&&(this.data[0]=m,this._down(0)),d}peek(){return this.data[0]}_up(d){const{data:m,compare:v}=this,C=m[d];for(;d>0;){const E=d-1>>1,P=m[E];if(v(C,P)>=0)break;m[d]=P,d=E}m[d]=C}_down(d){const{data:m,compare:v}=this,C=this.length>>1,E=m[d];for(;d=0)break;m[d]=m[P],d=P}m[d]=E}}var tr=8192;function KE(x,d){return d.dist-x.dist}const HC=100,WC=50;function ZE(x){const d=[1/0,1/0,-1/0,-1/0];if(d.length!==x.length)return!1;for(let m=0;m=x[0]&&x[1]x[1])return[null,null];const m=r2(x);if(d){if(m===2)return[x,null];const v=Math.floor(m/2);return[[x[0],x[0]+v],[x[0]+v,x[1]]]}{if(m===1)return[x,null];const v=Math.floor(m/2)-1;return[[x[0],x[0]+v],[x[0]+v+1,x[1]]]}}function rv(x,d){const m=[1/0,1/0,-1/0,-1/0];if(!qf(d,x.length))return m;for(let v=d[0];v<=d[1];++v)ep(m,x[v]);return m}function nv(x){const d=[1/0,1/0,-1/0,-1/0];for(let m=0;md[2]&&(v=x[0]-d[2]),x[1]>d[3]&&(C=x[1]-d[3]),x[3]=v)return v;if(Jw(C,E)){if(QE(x,d))return 0}else if(QE(d,x))return 0;let P=v;for(const R of x)for(let $=0,G=R.length,te=G-1;$=E)continue;const te=G.range1;if(r2(te)<=R){if(!qf(te,x.length))return NaN;if(d){const se=Eme(x,te,m,v);if((E=Math.min(E,se))===0)return E}else for(let se=te[0];se<=te[1];++se){const ae=Ame(x[se],m,v);if((E=Math.min(E,ae))===0)return E}}else{const se=YE(te,d);if(se[0]!==null){const ae=Cy(rv(x,se[0]),$,v);ae=P)continue;const se=te.range1,ae=te.range2;if(r2(se)<=$&&r2(ae)<=G){if(!qf(se,x.length)||!qf(ae,m.length))return NaN;if(d&&v?P=Math.min(P,Fa(x,se,m,ae,C)):d||v?d&&!v?P=Math.min(P,XE(m,ae,x,se,C)):!d&&v&&(P=Math.min(P,XE(x,se,m,ae,C))):P=Math.min(P,Tme(x,se,m,ae,C)),P===0)return P}else{const de=YE(se,d),he=YE(ae,v);ho(R,P,C,x,m,de[0],he[0]),ho(R,P,C,x,m,de[0],he[1]),ho(R,P,C,x,m,de[1],he[0]),ho(R,P,C,x,m,de[1],he[1])}}return P}function JE(x,d,m,v,C=1/0){let E=C;const P=rv(x,[0,x.length-1]);for(const R of m)if(!(E!==1/0&&Cy(P,rv(R,[0,R.length-1]),v)>=E)&&(E=Math.min(E,DR(x,d,R,!0,v,E)),E===0))return E;return E}function ZC(x,d,m,v,C=1/0){let E=C;const P=rv(x,[0,x.length-1]);for(const R of m){if(E!==1/0&&Cy(P,nv(R),v)>=E)continue;const $=Ime(x,d,R,v,E);if(isNaN($))return $;if((E=Math.min(E,$))===0)return E}return E}function e6(x){return x==="Point"||x==="MultiPoint"||x==="LineString"||x==="MultiLineString"||x==="Polygon"||x==="MultiPolygon"}class av{constructor(d,m){this.type=$r,this.geojson=d,this.geometries=m}static parse(d,m){if(d.length!==2)return m.error(`'distance' expression requires either one argument, but found ' ${d.length-1} instead.`);if(X1(d[1])){const v=d[1];if(v.type==="FeatureCollection"){for(let C=0;C{d&&!sb(m)&&(d=!1)}),d}function n2(x){if(x instanceof Ru&&x.name==="feature-state")return!1;let d=!0;return x.eachChild(m=>{d&&!n2(m)&&(d=!1)}),d}function rb(x,d){if(x instanceof Ru&&d.indexOf(x.name)>=0)return!1;let m=!0;return x.eachChild(v=>{m&&!rb(v,d)&&(m=!1)}),m}function OR(x,d,m){return[x,d,m].filter(Boolean).join("")}function t6(x,d){switch(x){case"string":return Jm(d);case"number":return+d;case"boolean":return!!d;case"color":return Ur.parse(d);case"formatted":return Du.fromString(Jm(d));case"resolvedImage":return Ou.build(Jm(d))}return d}function RR(x,d,m,v){return v!==void 0&&(x=v*Math.round(x/v)),d!==void 0&&xm&&(x=m),x}class nb{constructor(d,m,v,C=!1){this.type=d,this.key=m,this.scope=v,this.featureConstant=C}static parse(d,m){let v=m.expectedType;if(v==null&&(v=pi),d.length<2||d.length>3)return m.error("Invalid number of arguments for 'config' expression.");const C=m.parse(d[1],1);if(!(C instanceof tg))return m.error("Key name of 'config' expression must be a string literal.");let E,P=!0;const R=Jm(C.value);if(d.length>=3){const $=m.parse(d[2],2);if(!($ instanceof tg))return m.error("Scope of 'config' expression must be a string literal.");E=Jm($.value)}if(m.options){const $=OR(R,E,m._scope),G=m.options.get($);G&&(P=sb(G.value||G.default))}return new nb(v,R,E,P)}evaluate(d){const m=OR(this.key,this.scope,d.scope),v=d.getConfig(m);if(!v)return null;const{type:C,value:E,values:P,minValue:R,maxValue:$,stepValue:G}=v,te=v.default.evaluate(d);let se=te;if(E){const ae=d.scope;d.scope=(ae||"").split("").slice(1).join(""),se=E.evaluate(d),d.scope=ae}return C&&(se=t6(C,se)),se===void 0||R===void 0&&$===void 0&&G===void 0||(typeof se=="number"?se=RR(se,R,$,G):Array.isArray(se)&&(se=se.map(ae=>typeof ae=="number"?RR(ae,R,$,G):ae))),E!==void 0&&se!==void 0&&P&&!P.includes(se)&&(se=te,C&&(se=t6(C,se))),(C&&C!==this.type||se!==void 0&&!DC(Tc(se),this.type))&&(se=t6(this.type.kind,se)),se}eachChild(){}outputDefined(){return!1}serialize(){const d=["config",this.key];return this.scope&&d.concat(this.scope),d}}class YC{constructor(d,m){this.type=m.type,this.name=d,this.boundExpression=m}static parse(d,m){if(d.length!==2||typeof d[1]!="string")return m.error("'var' expression requires exactly one string literal argument.");const v=d[1];return m.scope.has(v)?new YC(v,m.scope.get(v)):m.error(`Unknown variable "${v}". Make sure "${v}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(d){return this.boundExpression.evaluate(d)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class XC{constructor(d,m=[],v,C=new Y1,E=[],P,R,$){this.registry=d,this.path=m,this.key=m.map(G=>typeof G=="string"?`['${G}']`:`[${G}]`).join(""),this.scope=C,this.errors=E,this.expectedType=v,this._scope=P,this.options=R,this.iconImageUseTheme=$}parse(d,m,v,C,E={}){return m||v?this.concat(m,null,v,C)._parse(d,E):this._parse(d,E)}parseObjectValue(d,m,v,C,E,P={}){return this.concat(m,v,C,E)._parse(d,P)}_parse(d,m){function v(C,E,P){return P==="assert"?new Fp(E,[C]):P==="coerce"?new $f(E,[C]):C}if(d!==null&&typeof d!="string"&&typeof d!="boolean"&&typeof d!="number"||(d=["literal",d]),Array.isArray(d)){if(d.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const C=typeof d[0]=="string"?this.registry[d[0]]:void 0;if(C){let E=C.parse(d,this);if(!E)return null;if(this.expectedType){const P=this.expectedType,R=E.type;if(P.kind!=="string"&&P.kind!=="number"&&P.kind!=="boolean"&&P.kind!=="object"&&P.kind!=="array"||R.kind!=="value")if(P.kind!=="color"&&P.kind!=="formatted"&&P.kind!=="resolvedImage"||R.kind!=="value"&&R.kind!=="string"){if(this.checkSubtype(P,R))return null}else E=v(E,P,m.typeAnnotation||"coerce");else E=v(E,P,m.typeAnnotation||"assert")}if(!(E instanceof tg)&&E.type.kind!=="resolvedImage"&&s6(E)){const P=new zC(this._scope,this.options,this.iconImageUseTheme);try{E=new tg(E.type,E.evaluate(P))}catch(R){return this.error(R.message),null}}return E}return $f.parse(["to-array",d],this)}return this.error(d===void 0?"'undefined' value invalid. Use null instead.":typeof d=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof d} instead.`)}concat(d,m,v,C){let E=typeof d=="number"?this.path.concat(d):this.path;E=typeof m=="string"?E.concat(m):E;const P=C?this.scope.concat(C):this.scope;return new XC(this.registry,E,v||null,P,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(d,...m){const v=`${this.key}${m.map(C=>`[${C}]`).join("")}`;this.errors.push(new Qm(v,d))}checkSubtype(d,m){const v=wy(d,m);return v&&this.error(v),v}}function s6(x){if(x instanceof YC)return s6(x.boundExpression);if(x instanceof Ru&&x.name==="error"||x instanceof Gc||x instanceof Sy||x instanceof av||x instanceof nb)return!1;const d=x instanceof $f||x instanceof Fp;let m=!0;return x.eachChild(v=>{m=d?m&&s6(v):m&&v instanceof tg}),!!m&&sb(x)&&rb(x,["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 QC(x,d){const m=x.length-1;let v,C,E=0,P=m,R=0;for(;E<=P;)if(R=Math.floor((E+P)/2),v=x[R],C=x[R+1],v<=d){if(R===m||dd))throw new cc("Input is not a number.");P=R-1}return 0}class a2{constructor(d,m,v){this.type=d,this.input=m,this.labels=[],this.outputs=[];for(const[C,E]of v)this.labels.push(C),this.outputs.push(E)}static parse(d,m){if(d.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if((d.length-1)%2!=0)return m.error("Expected an even number of arguments.");const v=m.parse(d[1],1,$r);if(!v)return null;const C=[];let E=null;m.expectedType&&m.expectedType.kind!=="value"&&(E=m.expectedType);for(let P=1;P=R)return m.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',G);const se=m.parse($,te,E);if(!se)return null;E=E||se.type,C.push([R,se])}return new a2(E,v,C)}evaluate(d){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(d);const C=this.input.evaluate(d);if(C<=m[0])return v[0].evaluate(d);const E=m.length;return C>=m[E-1]?v[E-1].evaluate(d):v[QC(m,C)].evaluate(d)}eachChild(d){d(this.input);for(const m of this.outputs)d(m)}outputDefined(){return this.outputs.every(d=>d.outputDefined())}serialize(){const d=["step",this.input.serialize()];for(let m=0;m0&&d.push(this.labels[m]),d.push(this.outputs[m].serialize());return d}}const FR=.95047,zR=1.08883,BR=4/29,ab=6/29,$R=3*ab*ab,Lme=ab*ab*ab,Dme=Math.PI/180,Ome=180/Math.PI;function r6(x){return x>Lme?Math.pow(x,1/3):x/$R+BR}function n6(x){return x>ab?x*x*x:$R*(x-BR)}function a6(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}function i6(x){return(x/=255)<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)}function qR(x){const d=i6(x.r),m=i6(x.g),v=i6(x.b),C=r6((.4124564*d+.3575761*m+.1804375*v)/FR),E=r6((.2126729*d+.7151522*m+.072175*v)/1);return{l:116*E-16,a:500*(C-E),b:200*(E-r6((.0193339*d+.119192*m+.9503041*v)/zR)),alpha:x.a}}function JC(x){let d=(x.l+16)/116,m=isNaN(x.a)?d:d+x.a/500,v=isNaN(x.b)?d:d-x.b/200;return d=1*n6(d),m=FR*n6(m),v=zR*n6(v),new Ur(a6(3.2404542*m-1.5371385*d-.4985314*v),a6(-.969266*m+1.8760108*d+.041556*v),a6(.0556434*m-.2040259*d+1.0572252*v),x.alpha)}function e3(x,d,m){const v=d-x;return x+m*(v>180||v<-180?v-360*Math.round(v/360):v)}const ib={forward:qR,reverse:JC,interpolate:function(x,d,m){return{l:Zr(x.l,d.l,m),a:Zr(x.a,d.a,m),b:Zr(x.b,d.b,m),alpha:Zr(x.alpha,d.alpha,m)}}},i2={forward:function(x){const{l:d,a:m,b:v}=qR(x),C=Math.atan2(v,m)*Ome;return{h:C<0?C+360:C,c:Math.sqrt(m*m+v*v),l:d,alpha:x.a}},reverse:function(x){const d=x.h*Dme,m=x.c;return JC({l:x.l,a:Math.cos(d)*m,b:Math.sin(d)*m,alpha:x.alpha})},interpolate:function(x,d,m){return{h:e3(x.h,d.h,m),c:Zr(x.c,d.c,m),l:Zr(x.l,d.l,m),alpha:Zr(x.alpha,d.alpha,m)}}};var UR=Object.freeze({__proto__:null,hcl:i2,lab:ib});class cm{constructor(d,m,v,C,E){this.type=d,this.operator=m,this.interpolation=v,this.input=C,this.labels=[],this.outputs=[];for(const[P,R]of E)this.labels.push(P),this.outputs.push(R)}static interpolationFactor(d,m,v,C){let E=0;if(d.name==="exponential")E=t3(m,d.base,v,C);else if(d.name==="linear")E=t3(m,1,v,C);else if(d.name==="cubic-bezier"){const P=d.controlPoints;E=new vi(P[0],P[1],P[2],P[3]).solve(t3(m,1,v,C))}return E}static parse(d,m){let[v,C,E,...P]=d;if(!Array.isArray(C)||C.length===0)return m.error("Expected an interpolation type expression.",1);if(C[0]==="linear")C={name:"linear"};else if(C[0]==="exponential"){const G=C[1];if(typeof G!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);C={name:"exponential",base:G}}else{if(C[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(C[0])}`,1,0);{const G=C.slice(1);if(G.length!==4||G.some(te=>typeof te!="number"||te<0||te>1))return m.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);C={name:"cubic-bezier",controlPoints:G}}}if(d.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if(d.length-1>3&&(d.length-1)%2!=0)return m.error("Expected an even number of arguments.");if(E=m.parse(E,2,$r),!E)return null;const R=[];let $=null;v==="interpolate-hcl"||v==="interpolate-lab"?$=dh:m.expectedType&&m.expectedType.kind!=="value"&&($=m.expectedType);for(let G=0;G=te)return m.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ae);const he=m.parse(se,de,$);if(!he)return null;$=$||he.type,R.push([te,he])}return $.kind==="number"||$.kind==="color"||$.kind==="array"&&$.itemType.kind==="number"&&typeof $.N=="number"?new cm($,v,C,E,R):m.error(`Type ${_l($)} is not interpolatable.`)}evaluate(d){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(d);const C=this.input.evaluate(d);if(C<=m[0])return v[0].evaluate(d);const E=m.length;if(C>=m[E-1])return v[E-1].evaluate(d);const P=QC(m,C),R=cm.interpolationFactor(this.interpolation,C,m[P],m[P+1]),$=v[P].evaluate(d),G=v[P+1].evaluate(d);return this.operator==="interpolate"?tv[this.type.kind.toLowerCase()]($,G,R):this.operator==="interpolate-hcl"?i2.reverse(i2.interpolate(i2.forward($),i2.forward(G),R)):ib.reverse(ib.interpolate(ib.forward($),ib.forward(G),R))}eachChild(d){d(this.input);for(const m of this.outputs)d(m)}outputDefined(){return this.outputs.every(d=>d.outputDefined())}serialize(){let d;d=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const m=[this.operator,d,this.input.serialize()];for(let v=0;vwy(C,R.type));return new o2(P?pi:v,E)}evaluate(d){let m,v=null,C=0;for(const E of this.args){if(C++,v=E.evaluate(d),v&&v instanceof Ou&&!v.available&&(m||(m=v),v=null,C===this.args.length))return m;if(v!==null)break}return v}eachChild(d){this.args.forEach(d)}outputDefined(){return this.args.every(d=>d.outputDefined())}serialize(){const d=["coalesce"];return this.eachChild(m=>{d.push(m.serialize())}),d}}class rg{constructor(d,m){this.type=m.type,this.bindings=[].concat(d),this.result=m}evaluate(d){return this.result.evaluate(d)}eachChild(d){for(const m of this.bindings)d(m[1]);d(this.result)}static parse(d,m){if(d.length<4)return m.error(`Expected at least 3 arguments, but found ${d.length-1} instead.`);const v=[];for(let E=1;E=v.length)throw new cc("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new cc("Array index must be an integer. Use at-interpolated for fractional indices");return v[m]}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class r3{constructor(d,m,v){this.type=d,this.index=m,this.input=v}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,$r),C=m.parse(d[2],2,qd(m.expectedType||pi));return v&&C?new r3(C.type.itemType,v,C):null}evaluate(d){const m=this.index.evaluate(d),v=this.input.evaluate(d);if(m<0)throw new cc(`Array index out of bounds: ${m} < 0.`);if(m>v.length-1)throw new cc(`Array index out of bounds: ${m} > ${v.length-1}.`);if(m===Math.floor(m))return v[m];const C=Math.floor(m),E=Math.ceil(m),P=v[C],R=v[E];if(typeof P!="number"||typeof R!="number")throw new cc(`Cannot interpolate between non-number values at index ${m}.`);const $=m-C;return P*(1-$)+R*$}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class o6{constructor(d,m){this.type=Si,this.needle=d,this.haystack=m}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,pi),C=m.parse(d[2],2,pi);return v&&C?BE(v.type,[Si,Da,$r,Rp,pi])?new o6(v,C):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${_l(v.type)} instead`):null}evaluate(d){const m=this.needle.evaluate(d),v=this.haystack.evaluate(d);if(v==null)return!1;if(!Qw(m,["boolean","string","number","null"]))throw new cc(`Expected first argument to be of type boolean, string, number or null, but found ${_l(Tc(m))} instead.`);if(!Qw(v,["string","array"]))throw new cc(`Expected second argument to be of type array or string, but found ${_l(Tc(v))} instead.`);return v.indexOf(m)>=0}eachChild(d){d(this.needle),d(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ob{constructor(d,m,v){this.type=$r,this.needle=d,this.haystack=m,this.fromIndex=v}static parse(d,m){if(d.length<=2||d.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,pi),C=m.parse(d[2],2,pi);if(!v||!C)return null;if(!BE(v.type,[Si,Da,$r,Rp,pi]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${_l(v.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,$r);return E?new ob(v,C,E):null}return new ob(v,C)}evaluate(d){const m=this.needle.evaluate(d),v=this.haystack.evaluate(d);if(!Qw(m,["boolean","string","number","null"]))throw new cc(`Expected first argument to be of type boolean, string, number or null, but found ${_l(Tc(m))} instead.`);if(!Qw(v,["string","array"]))throw new cc(`Expected second argument to be of type array or string, but found ${_l(Tc(v))} instead.`);if(this.fromIndex){const C=this.fromIndex.evaluate(d);return v.indexOf(m,C)}return v.indexOf(m)}eachChild(d){d(this.needle),d(this.haystack),this.fromIndex&&d(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const d=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),d]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class l2{constructor(d,m,v,C,E,P){this.inputType=d,this.type=m,this.input=v,this.cases=C,this.outputs=E,this.otherwise=P}static parse(d,m){if(d.length<5)return m.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if(d.length%2!=1)return m.error("Expected an even number of arguments.");let v,C;m.expectedType&&m.expectedType.kind!=="value"&&(C=m.expectedType);const E={},P=[];for(let G=2;GNumber.MAX_SAFE_INTEGER)return ae.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof he=="number"&&Math.floor(he)!==he)return ae.error("Numeric branch labels must be integer values.");if(v){if(ae.checkSubtype(v,Tc(he)))return null}else v=Tc(he);if(E[String(he)]!==void 0)return ae.error("Branch labels must be unique.");E[String(he)]=P.length}const de=m.parse(se,G,C);if(!de)return null;C=C||de.type,P.push(de)}const R=m.parse(d[1],1,pi);if(!R)return null;const $=m.parse(d[d.length-1],d.length-1,C);return $?R.type.kind!=="value"&&m.concat(1).checkSubtype(v,R.type)?null:new l2(v,C,R,E,P,$):null}evaluate(d){const m=this.input.evaluate(d);return(DC(Tc(m),this.inputType)&&this.outputs[this.cases[m]]||this.otherwise).evaluate(d)}eachChild(d){d(this.input),this.outputs.forEach(d),d(this.otherwise)}outputDefined(){return this.outputs.every(d=>d.outputDefined())&&this.otherwise.outputDefined()}serialize(){const d=["match",this.input.serialize()],m=Object.keys(this.cases).sort(),v=[],C={};for(const P of m){const R=C[this.cases[P]];R===void 0?(C[this.cases[P]]=v.length,v.push([this.cases[P],[P]])):v[R][1].push(P)}const E=P=>this.inputType.kind==="number"?Number(P):P;for(const[P,R]of v)d.push(R.length===1?E(R[0]):R.map(E)),d.push(this.outputs[P].serialize());return d.push(this.otherwise.serialize()),d}}class c2{constructor(d,m,v){this.type=d,this.branches=m,this.otherwise=v}static parse(d,m){if(d.length<4)return m.error(`Expected at least 3 arguments, but found only ${d.length-1}.`);if(d.length%2!=0)return m.error("Expected an odd number of arguments.");let v;m.expectedType&&m.expectedType.kind!=="value"&&(v=m.expectedType);const C=[];for(let P=1;Pm.outputDefined())&&this.otherwise.outputDefined()}serialize(){const d=["case"];return this.eachChild(m=>{d.push(m.serialize())}),d}}class n3{constructor(d,m,v,C){this.type=d,this.input=m,this.beginIndex=v,this.endIndex=C}static parse(d,m){if(d.length<=2||d.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,pi),C=m.parse(d[2],2,$r);if(!v||!C)return null;if(!BE(v.type,[qd(pi),Da,pi]))return m.error(`Expected first argument to be of type array or string, but found ${_l(v.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,$r);return E?new n3(v.type,v,C,E):null}return new n3(v.type,v,C)}evaluate(d){const m=this.input.evaluate(d),v=this.beginIndex.evaluate(d);if(!Qw(m,["string","array"]))throw new cc(`Expected first argument to be of type array or string, but found ${_l(Tc(m))} instead.`);if(this.endIndex){const C=this.endIndex.evaluate(d);return m.slice(v,C)}return m.slice(v)}eachChild(d){d(this.input),d(this.beginIndex),this.endIndex&&d(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const d=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),d]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class l6{constructor(d,m){this.type=qd(Da),this.str=d,this.delimiter=m}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,Da),C=m.parse(d[2],2,Da);return v&&C?new l6(v,C):void 0}evaluate(d){const m=this.str.evaluate(d),v=this.delimiter.evaluate(d);return m.split(v)}eachChild(d){d(this.str),d(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function c6(x,d){return x==="=="||x==="!="?d.kind==="boolean"||d.kind==="string"||d.kind==="number"||d.kind==="null"||d.kind==="value":d.kind==="string"||d.kind==="number"||d.kind==="value"}function d6(x,d,m,v){return v.compare(d,m)===0}function lb(x,d,m){const v=x!=="=="&&x!=="!=";return class xWe{constructor(E,P,R){this.type=Si,this.lhs=E,this.rhs=P,this.collator=R,this.hasUntypedArgument=E.type.kind==="value"||P.type.kind==="value"}static parse(E,P){if(E.length!==3&&E.length!==4)return P.error("Expected two or three arguments.");const R=E[0];let $=P.parse(E[1],1,pi);if(!$)return null;if(!c6(R,$.type))return P.concat(1).error(`"${R}" comparisons are not supported for type '${_l($.type)}'.`);let G=P.parse(E[2],2,pi);if(!G)return null;if(!c6(R,G.type))return P.concat(2).error(`"${R}" comparisons are not supported for type '${_l(G.type)}'.`);if($.type.kind!==G.type.kind&&$.type.kind!=="value"&&G.type.kind!=="value")return P.error(`Cannot compare types '${_l($.type)}' and '${_l(G.type)}'.`);v&&($.type.kind==="value"&&G.type.kind!=="value"?$=new Fp(G.type,[$]):$.type.kind!=="value"&&G.type.kind==="value"&&(G=new Fp($.type,[G])));let te=null;if(E.length===4){if($.type.kind!=="string"&&G.type.kind!=="string"&&$.type.kind!=="value"&&G.type.kind!=="value")return P.error("Cannot use collator to compare non-string types.");if(te=P.parse(E[3],3,LC),!te)return null}return new xWe($,G,te)}evaluate(E){const P=this.lhs.evaluate(E),R=this.rhs.evaluate(E);if(v&&this.hasUntypedArgument){const $=Tc(P),G=Tc(R);if($.kind!==G.kind||$.kind!=="string"&&$.kind!=="number")throw new cc(`Expected arguments for "${x}" to be (string, string) or (number, number), but found (${$.kind}, ${G.kind}) instead.`)}if(this.collator&&!v&&this.hasUntypedArgument){const $=Tc(P),G=Tc(R);if($.kind!=="string"||G.kind!=="string")return d(E,P,R)}return this.collator?m(E,P,R,this.collator.evaluate(E)):d(E,P,R)}eachChild(E){E(this.lhs),E(this.rhs),this.collator&&E(this.collator)}outputDefined(){return!0}serialize(){const E=[x];return this.eachChild(P=>{E.push(P.serialize())}),E}}}const Rme=lb("==",function(x,d,m){return d===m},d6),Fme=lb("!=",function(x,d,m){return d!==m},function(x,d,m,v){return!d6(0,d,m,v)}),VR=lb("<",function(x,d,m){return d",function(x,d,m){return d>m},function(x,d,m,v){return v.compare(d,m)>0}),a3=lb("<=",function(x,d,m){return d<=m},function(x,d,m,v){return v.compare(d,m)<=0}),zme=lb(">=",function(x,d,m){return d>=m},function(x,d,m,v){return v.compare(d,m)>=0});class i3{constructor(d,m,v,C,E,P){this.type=Da,this.number=d,this.locale=m,this.currency=v,this.unit=C,this.minFractionDigits=E,this.maxFractionDigits=P}static parse(d,m){if(d.length!==3)return m.error("Expected two arguments.");const v=m.parse(d[1],1,$r);if(!v)return null;const C=d[2];if(typeof C!="object"||Array.isArray(C))return m.error("NumberFormat options argument must be an object.");let E=null;if(C.locale&&(E=m.parseObjectValue(C.locale,2,"locale",Da),!E))return null;let P=null;if(C.currency&&(P=m.parseObjectValue(C.currency,2,"currency",Da),!P))return null;let R=null;if(C.unit&&(R=m.parseObjectValue(C.unit,2,"unit",Da),!R))return null;let $=null;if(C["min-fraction-digits"]&&($=m.parseObjectValue(C["min-fraction-digits"],2,"min-fraction-digits",$r),!$))return null;let G=null;return C["max-fraction-digits"]&&(G=m.parseObjectValue(C["max-fraction-digits"],2,"max-fraction-digits",$r),!G)?null:new i3(v,E,P,R,$,G)}evaluate(d){return new Intl.NumberFormat(this.locale?this.locale.evaluate(d):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(d):void 0,unit:this.unit?this.unit.evaluate(d):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(d):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(d):void 0}).format(this.number.evaluate(d))}eachChild(d){d(this.number),this.locale&&d(this.locale),this.currency&&d(this.currency),this.unit&&d(this.unit),this.minFractionDigits&&d(this.minFractionDigits),this.maxFractionDigits&&d(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const d={};return this.locale&&(d.locale=this.locale.serialize()),this.currency&&(d.currency=this.currency.serialize()),this.unit&&(d.unit=this.unit.serialize()),this.minFractionDigits&&(d["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(d["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),d]}}class u6{constructor(d){this.type=$r,this.input=d}static parse(d,m){if(d.length!==2)return m.error(`Expected 1 argument, but found ${d.length-1} instead.`);const v=m.parse(d[1],1);return v?v.type.kind!=="array"&&v.type.kind!=="string"&&v.type.kind!=="value"?m.error(`Expected argument of type string or array, but found ${_l(v.type)} instead.`):new u6(v):null}evaluate(d){const m=this.input.evaluate(d);if(typeof m=="string"||Array.isArray(m))return m.length;throw new cc(`Expected value to be of type string or array, but found ${_l(Tc(m))} instead.`)}eachChild(d){d(this.input)}outputDefined(){return!1}serialize(){const d=["length"];return this.eachChild(m=>{d.push(m.serialize())}),d}}function WR(x){return function(){x=1831565813+(x|=0)|0;let d=Math.imul(x^x>>>15,1|x);return d=d+Math.imul(d^d>>>7,61|d)^d,((d^d>>>14)>>>0)/4294967296}}const cb={"==":Rme,"!=":Fme,">":HR,"<":VR,">=":zme,"<=":a3,array:Fp,at:s3,"at-interpolated":r3,boolean:Fp,case:c2,coalesce:o2,collator:Gc,format:Bf,image:Hn,in:o6,"index-of":ob,interpolate:cm,"interpolate-hcl":cm,"interpolate-lab":cm,length:u6,let:rg,literal:tg,match:l2,number:Fp,"number-format":i3,object:Fp,slice:n3,step:a2,string:Fp,"to-boolean":$f,"to-color":$f,"to-number":$f,"to-string":$f,var:YC,within:Sy,distance:av,config:nb,split:l6};function h6(x,[d,m,v,C]){d=d.evaluate(x),m=m.evaluate(x),v=v.evaluate(x);const E=C?C.evaluate(x):1,P=sv(d,m,v,E);if(P)throw new cc(P);return new Ur(d/255,m/255,v/255,E)}function m6(x,[d,m,v,C]){d=d.evaluate(x),m=m.evaluate(x),v=v.evaluate(x);const E=C?C.evaluate(x):1,P=function(G,te,se,ae){return typeof G=="number"&&G>=0&&G<=360?typeof te=="number"&&te>=0&&te<=100&&typeof se=="number"&&se>=0&&se<=100?ae===void 0||typeof ae=="number"&&ae>=0&&ae<=1?null:`Invalid hsla value [${[G,te,se,ae].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ae=="number"?[G,te,se,ae]:[G,te,se]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ae=="number"?[G,te,se,ae]:[G,te,se]).join(", ")}]: 'h' must be between 0 and 360.`}(d,m,v,E);if(P)throw new cc(P);const R=`hsla(${d}, ${m}%, ${v}%, ${E})`,$=Ur.parse(R);if(!$)throw new cc(`Failed to parse HSLA color: ${R}`);return $}function GR(x,d){return x in d}function p6(x,d){const m=d[x];return m===void 0?null:m}function Ty(x){return{type:x}}function iv(x){if(x instanceof nb)return new Set([x.key]);let d=new Set;return x.eachChild(m=>{d=new Set([...d,...iv(m)])}),d}function o3(x){if(x instanceof Ru&&x.name==="is-active-floor")return!0;let d=!1;return x.eachChild(m=>{!d&&o3(m)&&(d=!0)}),d}function KR(x){return{result:"success",value:x}}function Ay(x){return{result:"error",value:x}}function f6(x,d){return!!x&&!!x.parameters&&x.parameters.indexOf(d)>-1}function d2(x){return x["property-type"]==="data-driven"}function ZR(x){return f6(x.expression,"measure-light")}function YR(x){return f6(x.expression,"zoom")}function l3(x){return!!x.expression&&x.expression.interpolated}function c3(x){return typeof x=="object"&&x!==null&&!Array.isArray(x)}function XR(x){return x}function QR(x,d){const m=d.type==="color",v=x.stops&&typeof x.stops[0][0]=="object",C=v||!(v||x.property!==void 0),E=x.type||(l3(d)?"exponential":"interval");if(m&&((x=Object.assign({},x)).stops&&(x.stops=x.stops.map(G=>[G[0],Ur.parse(G[1])])),x.default=Ur.parse(x.default?x.default:d.default)),x.colorSpace&&x.colorSpace!=="rgb"&&!UR[x.colorSpace])throw new Error(`Unknown color space: ${x.colorSpace}`);let P,R,$;if(E==="exponential")P=JR;else if(E==="interval")P=$me;else if(E==="categorical"){P=Bme,R=Object.create(null);for(const G of x.stops)R[G[0]]=G[1];$=typeof x.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);P=eF}if(v){const G={},te=[];for(let de=0;dede[0]),evaluate:({zoom:de},he)=>JR({stops:se,base:x.base},d,de).evaluate(de,he)}}if(C){const G=E==="exponential"?{name:"exponential",base:x.base!==void 0?x.base:1}:null;return{kind:"camera",interpolationType:G,interpolationFactor:cm.interpolationFactor.bind(void 0,G),zoomStops:x.stops.map(te=>te[0]),evaluate:({zoom:te})=>P(x,d,te,R,$)}}return{kind:"source",evaluate(G,te){const se=te&&te.properties?te.properties[x.property]:void 0;return se===void 0?Uf(x.default,d.default):P(x,d,se,R,$)}}}function Uf(x,d,m){return x!==void 0?x:d!==void 0?d:m!==void 0?m:void 0}function Bme(x,d,m,v,C){return Uf(typeof m===C?v[m]:void 0,x.default,d.default)}function $me(x,d,m){if(!Q1(m))return Uf(x.default,d.default);const v=x.stops.length;if(v===1||m<=x.stops[0][0])return x.stops[0][1];if(m>=x.stops[v-1][0])return x.stops[v-1][1];const C=QC(x.stops.map(E=>E[0]),m);return x.stops[C][1]}function JR(x,d,m){const v=x.base!==void 0?x.base:1;if(!Q1(m))return Uf(x.default,d.default);const C=x.stops.length;if(C===1||m<=x.stops[0][0])return x.stops[0][1];if(m>=x.stops[C-1][0])return x.stops[C-1][1];const E=QC(x.stops.map(te=>te[0]),m),P=function(te,se,ae,de){const he=de-ae,Se=te-ae;return he===0?0:se===1?Se/he:(Math.pow(se,Se)-1)/(Math.pow(se,he)-1)}(m,v,x.stops[E][0],x.stops[E+1][0]),R=x.stops[E][1],$=x.stops[E+1][1];let G=tv[d.type]||XR;if(x.colorSpace&&x.colorSpace!=="rgb"){const te=UR[x.colorSpace];G=(se,ae)=>te.reverse(te.interpolate(te.forward(se),te.forward(ae),P))}return typeof R.evaluate=="function"?{evaluate(...te){const se=R.evaluate.apply(void 0,te),ae=$.evaluate.apply(void 0,te);if(se!==void 0&&ae!==void 0)return G(se,ae,P)}}:G(R,$,P)}function eF(x,d,m){return d.type==="color"?m=Ur.parse(m):d.type==="formatted"?m=Du.fromString(m.toString()):d.type==="resolvedImage"?m=Ou.build(m.toString()):Fr(m)===d.type||d.type==="enum"&&d.values[m]||(m=void 0),Uf(m,x.default,d.default)}Ru.register(cb,{error:[{kind:"error"},[Da],(x,[d])=>{throw new cc(d.evaluate(x))}],typeof:[Da,[pi],(x,[d])=>_l(Tc(d.evaluate(x)))],"to-rgba":[qd($r,4),[dh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[qd($r,4),[dh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[dh,[$r,$r,$r],h6],rgba:[dh,[$r,$r,$r,$r],h6],hsl:[dh,[$r,$r,$r],m6],hsla:[dh,[$r,$r,$r,$r],m6],has:{type:Si,overloads:[[[Da],(x,[d])=>GR(d.evaluate(x),x.properties())],[[Da,zf],(x,[d,m])=>GR(d.evaluate(x),m.evaluate(x))]]},get:{type:pi,overloads:[[[Da],(x,[d])=>p6(d.evaluate(x),x.properties())],[[Da,zf],(x,[d,m])=>p6(d.evaluate(x),m.evaluate(x))]]},"feature-state":[pi,[Da],(x,[d])=>p6(d.evaluate(x),x.featureState||{})],properties:[zf,[],x=>x.properties()],"geometry-type":[Da,[],x=>x.geometryType()],worldview:[Da,[],x=>x.globals.worldview||""],"is-active-floor":[Si,Ty(Da),(x,d)=>{if(!(x.globals.activeFloors&&x.globals.activeFloors.size>0))return!1;const m=x.globals.activeFloors;return d.some(v=>{const C=v.evaluate(x);return m.has(C)})}],id:[pi,[],x=>x.id()],zoom:[$r,[],x=>x.globals.zoom],pitch:[$r,[],x=>x.globals.pitch||0],"distance-from-center":[$r,[],x=>x.distanceFromCenter()],"measure-light":[$r,[Da],(x,[d])=>x.measureLight(d.evaluate(x))],"heatmap-density":[$r,[],x=>x.globals.heatmapDensity||0],"line-progress":[$r,[],x=>x.globals.lineProgress||0],"raster-value":[$r,[],x=>x.globals.rasterValue||0],"raster-particle-speed":[$r,[],x=>x.globals.rasterParticleSpeed||0],"sky-radial-progress":[$r,[],x=>x.globals.skyRadialProgress||0],accumulated:[pi,[],x=>x.globals.accumulated===void 0?null:x.globals.accumulated],"+":[$r,Ty($r),(x,d)=>{let m=0;for(const v of d)m+=v.evaluate(x);return m}],"*":[$r,Ty($r),(x,d)=>{let m=1;for(const v of d)m*=v.evaluate(x);return m}],"-":{type:$r,overloads:[[[$r,$r],(x,[d,m])=>d.evaluate(x)-m.evaluate(x)],[[$r],(x,[d])=>-d.evaluate(x)]]},"/":[$r,[$r,$r],(x,[d,m])=>d.evaluate(x)/m.evaluate(x)],"%":[$r,[$r,$r],(x,[d,m])=>d.evaluate(x)%m.evaluate(x)],ln2:[$r,[],()=>Math.LN2],pi:[$r,[],()=>Math.PI],e:[$r,[],()=>Math.E],"^":[$r,[$r,$r],(x,[d,m])=>Math.pow(d.evaluate(x),m.evaluate(x))],sqrt:[$r,[$r],(x,[d])=>Math.sqrt(d.evaluate(x))],log10:[$r,[$r],(x,[d])=>Math.log(d.evaluate(x))/Math.LN10],ln:[$r,[$r],(x,[d])=>Math.log(d.evaluate(x))],log2:[$r,[$r],(x,[d])=>Math.log2(d.evaluate(x))],sin:[$r,[$r],(x,[d])=>Math.sin(d.evaluate(x))],cos:[$r,[$r],(x,[d])=>Math.cos(d.evaluate(x))],tan:[$r,[$r],(x,[d])=>Math.tan(d.evaluate(x))],asin:[$r,[$r],(x,[d])=>Math.asin(d.evaluate(x))],acos:[$r,[$r],(x,[d])=>Math.acos(d.evaluate(x))],atan:[$r,[$r],(x,[d])=>Math.atan(d.evaluate(x))],min:[$r,Ty($r),(x,d)=>Math.min(...d.map(m=>m.evaluate(x)))],max:[$r,Ty($r),(x,d)=>Math.max(...d.map(m=>m.evaluate(x)))],abs:[$r,[$r],(x,[d])=>Math.abs(d.evaluate(x))],round:[$r,[$r],(x,[d])=>{const m=d.evaluate(x);return m<0?-Math.round(-m):Math.round(m)}],floor:[$r,[$r],(x,[d])=>Math.floor(d.evaluate(x))],ceil:[$r,[$r],(x,[d])=>Math.ceil(d.evaluate(x))],"filter-==":[Si,[Da,pi],(x,[d,m])=>x.properties()[d.value]===m.value],"filter-id-==":[Si,[pi],(x,[d])=>x.id()===d.value],"filter-type-==":[Si,[Da],(x,[d])=>x.geometryType()===d.value],"filter-<":[Si,[Da,pi],(x,[d,m])=>{const v=x.properties()[d.value],C=m.value;return typeof v==typeof C&&v{const m=x.id(),v=d.value;return typeof m==typeof v&&m":[Si,[Da,pi],(x,[d,m])=>{const v=x.properties()[d.value],C=m.value;return typeof v==typeof C&&v>C}],"filter-id->":[Si,[pi],(x,[d])=>{const m=x.id(),v=d.value;return typeof m==typeof v&&m>v}],"filter-<=":[Si,[Da,pi],(x,[d,m])=>{const v=x.properties()[d.value],C=m.value;return typeof v==typeof C&&v<=C}],"filter-id-<=":[Si,[pi],(x,[d])=>{const m=x.id(),v=d.value;return typeof m==typeof v&&m<=v}],"filter->=":[Si,[Da,pi],(x,[d,m])=>{const v=x.properties()[d.value],C=m.value;return typeof v==typeof C&&v>=C}],"filter-id->=":[Si,[pi],(x,[d])=>{const m=x.id(),v=d.value;return typeof m==typeof v&&m>=v}],"filter-has":[Si,[pi],(x,[d])=>d.value in x.properties()],"filter-has-id":[Si,[],x=>x.id()!==null&&x.id()!==void 0],"filter-type-in":[Si,[qd(Da)],(x,[d])=>d.value.indexOf(x.geometryType())>=0],"filter-id-in":[Si,[qd(pi)],(x,[d])=>d.value.indexOf(x.id())>=0],"filter-in-small":[Si,[Da,qd(pi)],(x,[d,m])=>m.value.indexOf(x.properties()[d.value])>=0],"filter-in-large":[Si,[Da,qd(pi)],(x,[d,m])=>function(v,C,E,P){for(;E<=P;){const R=E+P>>1;if(C[R]===v)return!0;C[R]>v?P=R-1:E=R+1}return!1}(x.properties()[d.value],m.value,0,m.value.length-1)],all:{type:Si,overloads:[[[Si,Si],(x,[d,m])=>d.evaluate(x)&&m.evaluate(x)],[Ty(Si),(x,d)=>{for(const m of d)if(!m.evaluate(x))return!1;return!0}]]},any:{type:Si,overloads:[[[Si,Si],(x,[d,m])=>d.evaluate(x)||m.evaluate(x)],[Ty(Si),(x,d)=>{for(const m of d)if(m.evaluate(x))return!0;return!1}]]},"!":[Si,[Si],(x,[d])=>!d.evaluate(x)],"is-supported-script":[Si,[Da],(x,[d])=>{const m=x.globals&&x.globals.isSupportedScript;return!m||m(d.evaluate(x))}],upcase:[Da,[Da],(x,[d])=>d.evaluate(x).toUpperCase()],downcase:[Da,[Da],(x,[d])=>d.evaluate(x).toLowerCase()],concat:[Da,Ty(pi),(x,d)=>d.map(m=>Jm(m.evaluate(x))).join("")],"resolved-locale":[Da,[LC],(x,[d])=>d.evaluate(x).resolvedLocale()],random:[$r,[$r,$r,pi],(x,d)=>{const[m,v,C]=d.map(P=>P.evaluate(x));if(m>v||m===v)return m;let E;if(typeof C=="string")E=function(P){let R=0;if(P.length===0)return R;for(let $=0;$JSON.stringify(se)).join(", ")}, but found ${JSON.stringify(te)} instead.`);return te}catch(te){const se=te;return this._warningHistory[se.message]||(this._warningHistory[se.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${se.message}`)),this._defaultValue}}}function u2(x){return Array.isArray(x)&&x.length>0&&typeof x[0]=="string"&&x[0]in cb}function Ey(x,d,m,v,C){const E=new XC(cb,[],d?function(R){const $={color:dh,string:Da,number:$r,enum:Da,boolean:Si,formatted:Yw,resolvedImage:Xw};return R.type==="array"?qd($[R.value]||pi,R.length):$[R.type]}(d):void 0,void 0,void 0,m,v,C),P=E.parse(x,void 0,void 0,void 0,d&&d.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?KR(new d3(P,d,m,v,C)):Ay(E.errors)}class db{constructor(d,m,v,C){this.kind=d,this._styleExpression=m,this.isLightConstant=v,this.isLineProgressConstant=C,this.isStateDependent=d!=="constant"&&!n2(m.expression),this.configDependencies=iv(m.expression),this.isIndoorDependent=o3(m.expression)}evaluateWithoutErrorHandling(d,m,v,C,E,P){return this._styleExpression.evaluateWithoutErrorHandling(d,m,v,C,E,P)}evaluate(d,m,v,C,E,P,R){return this._styleExpression.evaluate(d,m,v,C,E,P,void 0,void 0,R)}}class ov{constructor(d,m,v,C,E,P){this.kind=d,this.zoomStops=v,this._styleExpression=m,this.isStateDependent=d!=="camera"&&!n2(m.expression),this.isIndoorDependent=o3(m.expression),this.isLightConstant=E,this.isLineProgressConstant=P,this.configDependencies=iv(m.expression),this.interpolationType=C}evaluateWithoutErrorHandling(d,m,v,C,E,P){return this._styleExpression.evaluateWithoutErrorHandling(d,m,v,C,E,P)}evaluate(d,m,v,C,E,P){return this._styleExpression.evaluate(d,m,v,C,E,P)}interpolationFactor(d,m,v){return this.interpolationType?cm.interpolationFactor(this.interpolationType,d,m,v):0}}function x6(x,d,m,v,C){if((x=Ey(x,d,m,v,C)).result==="error")return x;const E=x.value.expression,P=sb(E);if(!P&&!d2(d))return Ay([new Qm("","data expressions not supported")]);const R=rb(E,["zoom","pitch","distance-from-center"]);if(!R&&!YR(d))return Ay([new Qm("","zoom expressions not supported")]);const $=rb(E,["measure-light"]);if(!$&&!ZR(d))return Ay([new Qm("","measure-light expression not supported")]);const G=rb(E,["line-progress"]);if(!G&&!function(ae){return f6(ae.expression,"line-progress")}(d))return Ay([new Qm("","line-progress expression not supported")]);const te=d.expression&&d.expression.relaxZoomRestriction,se=Bp(E);return se||R||te?se instanceof Qm?Ay([se]):se instanceof cm&&!l3(d)?Ay([new Qm("",'"interpolate" expressions cannot be used with this property')]):KR(se?new ov(P&&G?"camera":"composite",x.value,se.labels,se instanceof cm?se.interpolation:void 0,$,G):new db(P&&G?"constant":"source",x.value,$,G)):Ay([new Qm("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class u3{constructor(d,m){this._parameters=d,this._specification=m,Object.assign(this,QR(this._parameters,this._specification))}static deserialize(d){return new u3(d._parameters,d._specification)}static serialize(d){return{_parameters:d._parameters,_specification:d._specification}}}function Bp(x){let d=null;if(x instanceof rg)d=Bp(x.result);else if(x instanceof o2){for(const m of x.args)if(d=Bp(m),d)break}else(x instanceof a2||x instanceof cm)&&x.input instanceof Ru&&x.input.name==="zoom"&&(d=x);return d instanceof Qm||x.eachChild(m=>{const v=Bp(m);v instanceof Qm?d=v:d&&v&&d!==v&&(d=new Qm("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),d}var g6,tF,sF=function(){if(tF)return g6;tF=1,g6=d;var x=3;function d(m,v,C){var E=this.cells=[];if(m instanceof ArrayBuffer){this.arrayBuffer=m;var P=new Int32Array(this.arrayBuffer);m=P[0],this.d=(v=P[1])+2*(C=P[2]);for(var R=0;R=ae[Se+0]&&E>=ae[Se+1])?($[he]=!0,R.push(se[he])):$[he]=!1}}},d.prototype._forEachCell=function(m,v,C,E,P,R,$,G){for(var te=this._convertToCellCoord(m),se=this._convertToCellCoord(v),ae=this._convertToCellCoord(C),de=this._convertToCellCoord(E),he=te;he<=ae;he++)for(var Se=se;Se<=de;Se++){var Fe=this.d*Se+he;if((!G||G(this._convertFromCellCoord(he),this._convertFromCellCoord(Se),this._convertFromCellCoord(he+1),this._convertFromCellCoord(Se+1)))&&P.call(this,m,v,C,E,Fe,R,$,G))return}},d.prototype._convertFromCellCoord=function(m){return(m-this.padding)/this.scale},d.prototype._convertToCellCoord=function(m){return Math.max(0,Math.min(this.d-1,Math.floor(m*this.scale)+this.padding))},d.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var m=this.cells,v=x+this.cells.length+1+1,C=0,E=0;E=0||(C[E]=ng(x[E],d)));x instanceof Error&&(C.message=x.message)}if(C.$name)throw new Error("$name property is reserved for worker serialization logic.");return v!=="Object"&&(C.$name=v),C}throw new Error("can't serialize object of type "+typeof x)}function Py(x){if(x==null||typeof x=="boolean"||typeof x=="number"||typeof x=="string"||x instanceof Boolean||x instanceof Number||x instanceof String||x instanceof Date||x instanceof RegExp||h2(x)||x instanceof ImageBitmap||ArrayBuffer.isView(x)||x instanceof ImageData)return x;if(Array.isArray(x))return x.map(Py);if(typeof x=="object"){const d=x.$name||"Object";if(d==="Map"){const C=x.entries||[],E=new Map;for(let P=0;Px>=128&&x<=255,Arabic:x=>x>=1536&&x<=1791,"Arabic Supplement":x=>x>=1872&&x<=1919,"Arabic Extended-A":x=>x>=2208&&x<=2303,"Hangul Jamo":x=>x>=4352&&x<=4607,"Unified Canadian Aboriginal Syllabics":x=>x>=5120&&x<=5759,Khmer:x=>x>=6016&&x<=6143,"Unified Canadian Aboriginal Syllabics Extended":x=>x>=6320&&x<=6399,"General Punctuation":x=>x>=8192&&x<=8303,"Letterlike Symbols":x=>x>=8448&&x<=8527,"Number Forms":x=>x>=8528&&x<=8591,"Miscellaneous Technical":x=>x>=8960&&x<=9215,"Control Pictures":x=>x>=9216&&x<=9279,"Optical Character Recognition":x=>x>=9280&&x<=9311,"Enclosed Alphanumerics":x=>x>=9312&&x<=9471,"Geometric Shapes":x=>x>=9632&&x<=9727,"Miscellaneous Symbols":x=>x>=9728&&x<=9983,"Miscellaneous Symbols and Arrows":x=>x>=11008&&x<=11263,"CJK Radicals Supplement":x=>x>=11904&&x<=12031,"Kangxi Radicals":x=>x>=12032&&x<=12255,"Ideographic Description Characters":x=>x>=12272&&x<=12287,"CJK Symbols and Punctuation":x=>x>=12288&&x<=12351,Hiragana:x=>x>=12352&&x<=12447,Katakana:x=>x>=12448&&x<=12543,Bopomofo:x=>x>=12544&&x<=12591,"Hangul Compatibility Jamo":x=>x>=12592&&x<=12687,Kanbun:x=>x>=12688&&x<=12703,"Bopomofo Extended":x=>x>=12704&&x<=12735,"CJK Strokes":x=>x>=12736&&x<=12783,"Katakana Phonetic Extensions":x=>x>=12784&&x<=12799,"Enclosed CJK Letters and Months":x=>x>=12800&&x<=13055,"CJK Compatibility":x=>x>=13056&&x<=13311,"CJK Unified Ideographs Extension A":x=>x>=13312&&x<=19903,"Yijing Hexagram Symbols":x=>x>=19904&&x<=19967,"CJK Unified Ideographs":x=>x>=19968&&x<=40959,"Yi Syllables":x=>x>=40960&&x<=42127,"Yi Radicals":x=>x>=42128&&x<=42191,"Hangul Jamo Extended-A":x=>x>=43360&&x<=43391,"Hangul Syllables":x=>x>=44032&&x<=55215,"Hangul Jamo Extended-B":x=>x>=55216&&x<=55295,"Private Use Area":x=>x>=57344&&x<=63743,"CJK Compatibility Ideographs":x=>x>=63744&&x<=64255,"Arabic Presentation Forms-A":x=>x>=64336&&x<=65023,"Vertical Forms":x=>x>=65040&&x<=65055,"CJK Compatibility Forms":x=>x>=65072&&x<=65103,"Small Form Variants":x=>x>=65104&&x<=65135,"Arabic Presentation Forms-B":x=>x>=65136&&x<=65279,"Halfwidth and Fullwidth Forms":x=>x>=65280&&x<=65519,Osage:x=>x>=66736&&x<=66815,"CJK Unified Ideographs Extension B":x=>x>=131072&&x<=173791};function m2(x){for(const d of x)if(h3(d.charCodeAt(0)))return!0;return!1}function y6(x){for(const d of x)if(!rF(d.charCodeAt(0)))return!1;return!0}function rF(x){return!(en.Arabic(x)||en["Arabic Supplement"](x)||en["Arabic Extended-A"](x)||en["Arabic Presentation Forms-A"](x)||en["Arabic Presentation Forms-B"](x))}function h3(x){return!(x!==746&&x!==747&&(x<4352||!(en["Bopomofo Extended"](x)||en.Bopomofo(x)||en["CJK Compatibility Forms"](x)&&!(x>=65097&&x<=65103)||en["CJK Compatibility Ideographs"](x)||en["CJK Compatibility"](x)||en["CJK Radicals Supplement"](x)||en["CJK Strokes"](x)||!(!en["CJK Symbols and Punctuation"](x)||x>=12296&&x<=12305||x>=12308&&x<=12319||x===12336)||en["CJK Unified Ideographs Extension A"](x)||en["CJK Unified Ideographs"](x)||en["Enclosed CJK Letters and Months"](x)||en["Hangul Compatibility Jamo"](x)||en["Hangul Jamo Extended-A"](x)||en["Hangul Jamo Extended-B"](x)||en["Hangul Jamo"](x)||en["Hangul Syllables"](x)||en.Hiragana(x)||en["Ideographic Description Characters"](x)||en.Kanbun(x)||en["Kangxi Radicals"](x)||en["Katakana Phonetic Extensions"](x)||en.Katakana(x)&&x!==12540||!(!en["Halfwidth and Fullwidth Forms"](x)||x===65288||x===65289||x===65293||x>=65306&&x<=65310||x===65339||x===65341||x===65343||x>=65371&&x<=65503||x===65507||x>=65512&&x<=65519)||!(!en["Small Form Variants"](x)||x>=65112&&x<=65118||x>=65123&&x<=65126)||en["Unified Canadian Aboriginal Syllabics"](x)||en["Unified Canadian Aboriginal Syllabics Extended"](x)||en["Vertical Forms"](x)||en["Yijing Hexagram Symbols"](x)||en["Yi Syllables"](x)||en["Yi Radicals"](x))))}function m3(x){return!(h3(x)||function(d){return!!(en["Latin-1 Supplement"](d)&&(d===167||d===169||d===174||d===177||d===188||d===189||d===190||d===215||d===247)||en["General Punctuation"](d)&&(d===8214||d===8224||d===8225||d===8240||d===8241||d===8251||d===8252||d===8258||d===8263||d===8264||d===8265||d===8273)||en["Letterlike Symbols"](d)||en["Number Forms"](d)||en["Miscellaneous Technical"](d)&&(d>=8960&&d<=8967||d>=8972&&d<=8991||d>=8996&&d<=9e3||d===9003||d>=9085&&d<=9114||d>=9150&&d<=9165||d===9167||d>=9169&&d<=9179||d>=9186&&d<=9215)||en["Control Pictures"](d)&&d!==9251||en["Optical Character Recognition"](d)||en["Enclosed Alphanumerics"](d)||en["Geometric Shapes"](d)||en["Miscellaneous Symbols"](d)&&!(d>=9754&&d<=9759)||en["Miscellaneous Symbols and Arrows"](d)&&(d>=11026&&d<=11055||d>=11088&&d<=11097||d>=11192&&d<=11243)||en["CJK Symbols and Punctuation"](d)||en.Katakana(d)||en["Private Use Area"](d)||en["CJK Compatibility Forms"](d)||en["Small Form Variants"](d)||en["Halfwidth and Fullwidth Forms"](d)||d===8734||d===8756||d===8757||d>=9984&&d<=10087||d>=10102&&d<=10131||d===65532||d===65533)}(x))}function p3(x){return en.Arabic(x)||en["Arabic Supplement"](x)||en["Arabic Extended-A"](x)||en["Arabic Presentation Forms-A"](x)||en["Arabic Presentation Forms-B"](x)}function v6(x){return x>=1424&&x<=2303||en["Arabic Presentation Forms-A"](x)||en["Arabic Presentation Forms-B"](x)}function ag(x,d){return!(!d&&v6(x)||x>=2304&&x<=3583||x>=3840&&x<=4255||en.Khmer(x))}function qme(x){for(const d of x)if(v6(d.charCodeAt(0)))return!0;return!1}const Dh={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let b6=null,Fu=Dh.unavailable,ig=null;const p2=function(x){x&&typeof x=="string"&&x.indexOf("NetworkError")>-1&&(Fu=Dh.error),b6&&b6(x)};function f3(){x3.fire(new Xm("pluginStateChange",{pluginStatus:Fu,pluginURL:ig}))}const x3=new As,f2=function(){return Fu},nF=function(){if(Fu!==Dh.deferred||!ig)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Fu=Dh.loading,f3(),ig&&Lh({url:ig},x=>{x?p2(x):(Fu=Dh.loaded,f3())})},og={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Fu===Dh.loaded||og.applyArabicShaping!=null,isLoading:()=>Fu===Dh.loading,setState(x){Fu=x.pluginStatus,ig=x.pluginURL},isParsing:()=>Fu===Dh.parsing,isParsed:()=>Fu===Dh.parsed,getPluginURL:()=>ig};class Ki{constructor(d,m){this.zoom=d,m?(this.now=m.now,this.fadeDuration=m.fadeDuration,this.transition=m.transition,this.pitch=m.pitch,this.brightness=m.brightness,this.worldview=m.worldview,this.activeFloors=m.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(d){return function(m,v){for(const C of m)if(!ag(C.charCodeAt(0),v))return!1;return!0}(d,og.isLoaded())}}class g3{constructor(d,m,v,C,E){this.property=d,this.value=m,this.expression=function(P,R,$,G,te){if(c3(P))return new u3(P,R);if(u2(P)||Array.isArray(P)&&P.length>0){const se=x6(P,R,$,G,te);if(se.result==="error")throw new Error(se.value.map(ae=>`${ae.key}: ${ae.message}`).join(", "));return se.value}{let se=P;return typeof P=="string"&&R.type==="color"&&(se=Ur.parse(P)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>se}}}(m===void 0?d.specification.default:m,d.specification,v,C,E)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(d,m,v,C){return this.property.possiblyEvaluate(this,d,m,v,C)}}class _6{constructor(d,m,v,C){this.property=d,this.value=new g3(d,void 0,m,v,C)}transitioned(d,m){return new iF(this.property,this.value,m,Object.assign({},d.transition,this.transition),d.now)}untransitioned(){return new iF(this.property,this.value,null,{},0)}}class aF{constructor(d,m,v,C){this._properties=d,this._values=Object.create(d.defaultTransitionablePropertyValues),this._scope=m,this._options=v,this._iconImageUseTheme=C,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(d){return gs(this._values[d].value.value)}setValue(d,m){this._values.hasOwnProperty(d)||(this._values[d]=new _6(this._values[d].property,this._scope,this._options,this._iconImageUseTheme)),this._values[d].value=new g3(this._values[d].property,m===null?void 0:gs(m),this._scope,this._options,this._iconImageUseTheme),this._values[d].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[d].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[d].value.isIndoorDependent())}setTransitionOrValue(d,m){m&&(this._options=m);const v=this._properties.properties;if(d)for(const C in d){const E=d[C];if(C.endsWith("-transition")){const P=C.slice(0,-11);v[P]&&this.setTransition(P,E)}else v.hasOwnProperty(C)&&this.setValue(C,E)}}getTransition(d){return gs(this._values[d].transition)}setTransition(d,m){this._values.hasOwnProperty(d)||(this._values[d]=new _6(this._values[d].property)),this._values[d].transition=gs(m)||void 0}serialize(){const d={};for(const m of Object.keys(this._values)){const v=this.getValue(m);v!==void 0&&(d[m]=v);const C=this.getTransition(m);C!==void 0&&(d[`${m}-transition`]=C)}return d}transitioned(d,m){const v=new oF(this._properties);for(const C of Object.keys(this._values))v._values[C]=this._values[C].transitioned(d,m._values[C]);return v}untransitioned(){const d=new oF(this._properties);for(const m of Object.keys(this._values))d._values[m]=this._values[m].untransitioned();return d}isIndoorDependent(){return this._isIndoorDependent}}class iF{constructor(d,m,v,C,E){const P=C.delay||0,R=C.duration||0;E=E||0,this.property=d,this.value=m,this.begin=E+P,this.end=this.begin+R,d.specification.transition&&(C.delay||C.duration)&&(this.prior=v)}possiblyEvaluate(d,m,v){const C=d.now||0,E=this.value.possiblyEvaluate(d,m,v),P=this.prior;if(P){if(C>this.end)return this.prior=null,E;if(this.value.isDataDriven())return this.prior=null,E;if(C":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 cF(x){return x instanceof Number||x instanceof String||x instanceof Boolean?x.valueOf():x}function y3(x){if(Array.isArray(x))return x.map(y3);if(x instanceof Object&&!(x instanceof Number||x instanceof String||x instanceof Boolean)){const d={};for(const m in x)d[m]=y3(x[m]);return d}return cF(x)}function Vf(x){if(x===!0||x===!1)return!0;if(!Array.isArray(x)||x.length===0)return!1;switch(x[0]){case"has":return x.length>=2&&x[1]!=="$id"&&x[1]!=="$type";case"in":return x.length>=3&&(typeof x[1]!="string"||Array.isArray(x[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return x.length!==3||Array.isArray(x[1])||Array.isArray(x[2]);case"any":case"all":for(const d of x.slice(1))if(!Vf(d)&&typeof d!="boolean")return!1;return!0;default:return!0}}function v3(x,d="",m=null,v="fill"){if(x==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Vf(x)||(x=b3(x));const C=x;let E=!0;try{E=function(te){if(!hb(te))return te;let se=y3(te);return dF(se),se=hv(se),se}(C)}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(C,null,2)} `)}let P=null,R=null;if(v!=="background"&&v!=="sky"&&v!=="slot"){R=Kt[`filter_${v}`];const te=Ey(E,R,d,m);if(te.result==="error")throw new Error(te.value.map(se=>`${se.key}: ${se.message}`).join(", "));P=(se,ae,de)=>te.value.evaluate(se,ae,{},de)}let $=null,G=null;if(E!==C){const te=Ey(C,R,d,m);if(te.result==="error")throw new Error(te.value.map(se=>`${se.key}: ${se.message}`).join(", "));$=(se,ae,de,he,Se)=>te.value.evaluate(se,ae,{},de,void 0,void 0,he,Se),G=!sb(te.value.expression)}return{filter:P,dynamicFilter:$||void 0,needGeometry:uF(E),needFeature:!!G}}function hv(x){if(!Array.isArray(x))return x;const d=function(m){if(Ume.has(m[0])){for(let v=1;vhv(m))}function dF(x){let d=!1;const m=[];if(x[0]==="case"){for(let v=1;v",">=","<","<=","to-boolean"]);function Vme(x,d){return xd?1:0}function uF(x){if(!Array.isArray(x))return!1;if(x[0]==="within"||x[0]==="distance")return!0;for(let d=1;d"||d==="<="||d===">="?_3(x[1],x[2],d):d==="any"?(m=x.slice(1),["any"].concat(m.map(b3))):d==="all"?["all"].concat(x.slice(1).map(b3)):d==="none"?["all"].concat(x.slice(1).map(b3).map(x2)):d==="in"?w3(x[1],x.slice(2)):d==="!in"?x2(w3(x[1],x.slice(2))):d==="has"?j3(x[1]):d!=="!has"||x2(j3(x[1]));var m}function _3(x,d,m){switch(x){case"$type":return[`filter-type-${m}`,d];case"$id":return[`filter-id-${m}`,d];default:return[`filter-${m}`,x,d]}}function w3(x,d){if(d.length===0)return!1;switch(x){case"$type":return["filter-type-in",["literal",d]];case"$id":return["filter-id-in",["literal",d]];default:return d.length>200&&!d.some(m=>typeof m!=typeof d[0])?["filter-in-large",x,["literal",d.sort(Vme)]]:["filter-in-small",x,["literal",d]]}}function j3(x){switch(x){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",x]}}function x2(x){return["!",x]}const mv="";function $p(x,d){return d?`${x}${mv}${d}`:x}let hF;const mF=()=>hF||(hF=new Io({"icon-size":new ar(Kt.layout_symbol["icon-size"]),"icon-image":new ar(Kt.layout_symbol["icon-image"]),"icon-rotate":new ar(Kt.layout_symbol["icon-rotate"]),"icon-offset":new ar(Kt.layout_symbol["icon-offset"]),"text-size":new ar(Kt.layout_symbol["text-size"]),"text-rotate":new ar(Kt.layout_symbol["text-rotate"]),"text-offset":new ar(Kt.layout_symbol["text-offset"])}));class pF{constructor(d,m,v,C,E,P){const R=Ey(d,Kt.appearance.condition);if(R.result==="success"&&(this.condition=R.value),this.name=m,v){this.properties=new dv(mF()),this.unevaluatedLayout=new lF(mF(),C,E,P);for(const $ in v)this.unevaluatedLayout.setValue($,v[$])}}isActive(d){return!(this.condition||!d.isHidden||this.name!=="hidden")||this.condition.evaluate(d.globals,d.feature,d.featureState,d.canonical)}getCondition(){return this.condition}getName(){return this.name}getProperty(d){return this.properties.get(d)}getUnevaluatedProperties(){return this.unevaluatedLayout}getUnevaluatedProperty(d){return this.unevaluatedLayout._values[d]}recalculate(d,m,v){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(d,void 0,m,v))}serialize(){const d={};return d.condition=this.condition.expression.serialize(),this.name&&(d.name=this.name),this.unevaluatedLayout&&(d.properties=this.unevaluatedLayout.serialize()),d}hasIconProperties(){const d=this.hasProperty("icon-image"),m=this.hasProperty("icon-size"),v=this.hasProperty("icon-offset"),C=this.hasProperty("icon-rotate");return d||m||v||C}hasTextProperties(){const d=this.hasProperty("text-size"),m=this.hasProperty("text-offset"),v=this.hasProperty("text-rotate");return d||m||v}hasProperty(d){return this.getUnevaluatedProperty(d).value!==void 0}}const fF="-transition",Hf=new Set(["fill","line","background","hillshade","raster"]);class zu extends As{constructor(d,m,v,C,E,P){if(super(),this.id=d.id,this.fqid=$p(this.id,v),this.type=d.type,this.scope=v,this.lut=C,this.options=E,this.iconImageUseTheme=P,this.appearances=new Array,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},d.type!=="custom"){if(this.metadata=d.metadata,this.minzoom=d.minzoom,this.maxzoom=d.maxzoom,d.type&&d.type!=="background"&&d.type!=="sky"&&d.type!=="slot"){this.source=d.source,this.sourceLayer=d["source-layer"],this.filter=d.filter;const R=Ey(this.filter,Kt[`filter_${d.type}`]);R.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...R.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||R.value.isIndoorDependent)}if(d.slot&&(this.slot=d.slot),d.appearances&&this.setAppearances(d.appearances),m.layout&&(this._unevaluatedLayout=new lF(m.layout,this.scope,E,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),m.paint){this._transitionablePaint=new aF(m.paint,this.scope,E);for(const R in d.paint)this.setPaintProperty(R,d.paint[R]);for(const R in d.layout)this.setLayoutProperty(R,d.layout[R]);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 dv(m.paint)}}}onAdd(d){}onRemove(d){}isDraped(d){return!this.is3D(!0)&&Hf.has(this.type)}getLayoutProperty(d){return d==="visibility"?this.visibility:this._unevaluatedLayout.getValue(d)}setLayoutProperty(d,m){if(this.type==="custom"&&d==="visibility")return void(this.visibility=m);const v=this._unevaluatedLayout;v._properties.properties[d]&&(v.setValue(d,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...v.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||v.isIndoorDependent(),d==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(d){this.appearances=[],d.forEach(m=>{this.appearances.push(new pF(m.condition,m.name,m.properties,this.scope,this.options,this.iconImageUseTheme))})}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(d){return d.endsWith(fF)?this._transitionablePaint.getTransition(d.slice(0,-11)):this._transitionablePaint.getValue(d)}isPaintProperty(d){return!!this._transitionablePaint._properties.properties[d]}setPaintProperty(d,m){const v=this._transitionablePaint,C=v._properties.properties;if(d.endsWith(fF)){const se=d.slice(0,-11);return C[se]&&v.setTransition(se,m||void 0),!1}if(!C[d])return!1;const E=v._values[d],P=E.value.isDataDriven(),R=E.value;v.setValue(d,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...v.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||v.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(d);const $=v._values[d].value,G=$.isDataDriven(),te=d.endsWith("pattern")||d==="line-dasharray";return G||P||te||this._handleOverridablePaintPropertyUpdate(d,R,$)}_handleSpecialPaintPropertyUpdate(d){}getProgramIds(){return null}getDefaultProgramParams(d,m,v){return null}_handleOverridablePaintPropertyUpdate(d,m,v){return!1}isHidden(d){return!!(this.minzoom&&d=this.maxzoom)||this.visibility==="none"}updateTransitions(d){this._transitioningPaint=this._transitionablePaint.transitioned(d,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(d,m){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(d,void 0,m,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(d,void 0,m)}serialize(){const d={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&&(d.appearances=this.appearances.map(m=>m.serialize())),Ps(d,(m,v)=>!(m===void 0||v==="layout"&&!Object.keys(m).length||v==="paint"&&!Object.keys(m).length))}is3D(d){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 d in this.paint._values){const m=this.paint.get(d);if(m instanceof cv&&d2(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const d of this.appearances)if(!n2(d.condition.expression))return!0;return!1}compileFilter(d){this._filterCompiled||(this._featureFilter=v3(this.filter,this.scope,d),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(d){this._stats&&(d.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(d,m,v){return{}}queryRadius(d){}queryIntersectsFeature(d,m,v,C,E,P,R,$,G){}}const xF={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class g2{constructor(d,m){this._structArray=d,this._pos1=m*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const Hme=new ArrayBuffer(0);class ro{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(d,m){return d._trim(),m&&d.arrayBuffer&&m.add(d.arrayBuffer),{length:d.length,arrayBuffer:d.arrayBuffer}}static deserialize(d){const m=Object.create(this.prototype);return m.arrayBuffer=d.arrayBuffer,m.length=d.length,d.arrayBuffer?m.capacity=d.arrayBuffer.byteLength/m.bytesPerElement:(m.capacity=0,m.arrayBuffer=Hme),m._refreshViews(),m}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(d){this.reserve(d),this.length=d}reserve(d){if(d>this.capacity){this._reallocCount++,this.capacity=Math.max(d,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const m=this.uint8;this._refreshViews(),m&&this.uint8.set(m)}}reserveForAdditional(d){this.reserve(this.length+d)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...d){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...d){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 fa(x,d=1){let m=0,v=0;return{members:x.map(C=>{const E=xF[C.type].BYTES_PER_ELEMENT,P=m=gF(m,Math.max(d,E)),R=C.components||1;return v=Math.max(v,E),m+=E*R,{name:C.name,type:C.type,components:R,offset:P}}),size:gF(m,Math.max(v,d)),alignment:d}}function gF(x,d){return Math.ceil(x/d)*d}class Iy extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m){const v=this.length;return this.resize(v+1),this.emplace(v,d,m)}emplace(d,m,v){const C=2*d;return this.int16[C+0]=m,this.int16[C+1]=v,d}}Iy.prototype.bytesPerElement=4,kr(Iy,"StructArrayLayout2i4");class mb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=3*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=C,d}}mb.prototype.bytesPerElement=6,kr(mb,"StructArrayLayout3i6");class pb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,C)}emplace(d,m,v,C,E){const P=4*d;return this.int16[P+0]=m,this.int16[P+1]=v,this.int16[P+2]=C,this.int16[P+3]=E,d}}pb.prototype.bytesPerElement=8,kr(pb,"StructArrayLayout4i8");class lg extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.float32[1*d+0]=m,d}}lg.prototype.bytesPerElement=4,kr(lg,"StructArrayLayout1f4");class w6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=4*d,P=2*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.float32[P+1]=C,d}}w6.prototype.bytesPerElement=8,kr(w6,"StructArrayLayout2i1f8");class j6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=4*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=C,d}}j6.prototype.bytesPerElement=8,kr(j6,"StructArrayLayout3i8");class N6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,C,E)}emplace(d,m,v,C,E,P){const R=5*d;return this.int16[R+0]=m,this.int16[R+1]=v,this.int16[R+2]=C,this.int16[R+3]=E,this.int16[R+4]=P,d}}N6.prototype.bytesPerElement=10,kr(N6,"StructArrayLayout5i10");class N3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,C,E,P,R)}emplace(d,m,v,C,E,P,R,$){const G=6*d,te=12*d,se=3*d;return this.int16[G+0]=m,this.int16[G+1]=v,this.uint8[te+4]=C,this.uint8[te+5]=E,this.uint8[te+6]=P,this.uint8[te+7]=R,this.float32[se+2]=$,d}}N3.prototype.bytesPerElement=12,kr(N3,"StructArrayLayout2i4ub1f12");class dm extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=3*d;return this.float32[E+0]=m,this.float32[E+1]=v,this.float32[E+2]=C,d}}dm.prototype.bytesPerElement=12,kr(dm,"StructArrayLayout3f12");class uh extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,C,E)}emplace(d,m,v,C,E,P){const R=6*d,$=3*d;return this.uint16[R+0]=m,this.uint16[R+1]=v,this.uint16[R+2]=C,this.uint16[R+3]=E,this.float32[$+2]=P,d}}uh.prototype.bytesPerElement=12,kr(uh,"StructArrayLayout4ui1f12");class pv extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,C)}emplace(d,m,v,C,E){const P=4*d;return this.uint16[P+0]=m,this.uint16[P+1]=v,this.uint16[P+2]=C,this.uint16[P+3]=E,d}}pv.prototype.bytesPerElement=8,kr(pv,"StructArrayLayout4ui8");class k3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,v,C,E,P)}emplace(d,m,v,C,E,P,R){const $=6*d;return this.int16[$+0]=m,this.int16[$+1]=v,this.int16[$+2]=C,this.int16[$+3]=E,this.int16[$+4]=P,this.int16[$+5]=R,d}}k3.prototype.bytesPerElement=12,kr(k3,"StructArrayLayout6i12");class k6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G,te,se,ae){const de=this.length;return this.resize(de+1),this.emplace(de,d,m,v,C,E,P,R,$,G,te,se,ae)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de){const he=12*d;return this.int16[he+0]=m,this.int16[he+1]=v,this.int16[he+2]=C,this.int16[he+3]=E,this.uint16[he+4]=P,this.uint16[he+5]=R,this.uint16[he+6]=$,this.uint16[he+7]=G,this.int16[he+8]=te,this.int16[he+9]=se,this.int16[he+10]=ae,this.int16[he+11]=de,d}}k6.prototype.bytesPerElement=24,kr(k6,"StructArrayLayout4i4ui4i24");class S6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,v,C,E,P)}emplace(d,m,v,C,E,P,R){const $=10*d,G=5*d;return this.int16[$+0]=m,this.int16[$+1]=v,this.int16[$+2]=C,this.float32[G+2]=E,this.float32[G+3]=P,this.float32[G+4]=R,d}}S6.prototype.bytesPerElement=20,kr(S6,"StructArrayLayout3i3f20");class Ly extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,C)}emplace(d,m,v,C,E){const P=4*d;return this.float32[P+0]=m,this.float32[P+1]=v,this.float32[P+2]=C,this.float32[P+3]=E,d}}Ly.prototype.bytesPerElement=16,kr(Ly,"StructArrayLayout4f16");class S3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.uint32[1*d+0]=m,d}}S3.prototype.bytesPerElement=4,kr(S3,"StructArrayLayout1ul4");class um extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m){const v=this.length;return this.resize(v+1),this.emplace(v,d,m)}emplace(d,m,v){const C=2*d;return this.uint16[C+0]=m,this.uint16[C+1]=v,d}}um.prototype.bytesPerElement=4,kr(um,"StructArrayLayout2ui4");class C3 extends ro{_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(d,m,v,C,E,P,R,$,G,te,se,ae,de){const he=this.length;return this.resize(he+1),this.emplace(he,d,m,v,C,E,P,R,$,G,te,se,ae,de)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de,he){const Se=20*d,Fe=10*d;return this.int16[Se+0]=m,this.int16[Se+1]=v,this.int16[Se+2]=C,this.int16[Se+3]=E,this.int16[Se+4]=P,this.float32[Fe+3]=R,this.float32[Fe+4]=$,this.float32[Fe+5]=G,this.float32[Fe+6]=te,this.int16[Se+14]=se,this.uint32[Fe+8]=ae,this.uint16[Se+18]=de,this.uint16[Se+19]=he,d}}C3.prototype.bytesPerElement=40,kr(C3,"StructArrayLayout5i4f1i1ul2ui40");class M3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,C,E,P,R)}emplace(d,m,v,C,E,P,R,$){const G=8*d;return this.int16[G+0]=m,this.int16[G+1]=v,this.int16[G+2]=C,this.int16[G+4]=E,this.int16[G+5]=P,this.int16[G+6]=R,this.int16[G+7]=$,d}}M3.prototype.bytesPerElement=16,kr(M3,"StructArrayLayout3i2i2i16");class T3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,C,E)}emplace(d,m,v,C,E,P){const R=4*d,$=8*d;return this.float32[R+0]=m,this.float32[R+1]=v,this.float32[R+2]=C,this.int16[$+6]=E,this.int16[$+7]=P,d}}T3.prototype.bytesPerElement=16,kr(T3,"StructArrayLayout2f1f2i16");class C6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,v,C,E,P)}emplace(d,m,v,C,E,P,R){const $=20*d,G=5*d;return this.uint8[$+0]=m,this.uint8[$+1]=v,this.float32[G+1]=C,this.float32[G+2]=E,this.float32[G+3]=P,this.float32[G+4]=R,d}}C6.prototype.bytesPerElement=20,kr(C6,"StructArrayLayout2ub4f20");class $l extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,v)}emplace(d,m,v,C){const E=3*d;return this.uint16[E+0]=m,this.uint16[E+1]=v,this.uint16[E+2]=C,d}}$l.prototype.bytesPerElement=6,kr($l,"StructArrayLayout3ui6");class fb extends ro{_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(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt){const vt=this.length;return this.resize(vt+1),this.emplace(vt,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt){const At=30*d,zt=15*d,qt=60*d;return this.int16[At+0]=m,this.int16[At+1]=v,this.int16[At+2]=C,this.float32[zt+2]=E,this.float32[zt+3]=P,this.uint16[At+8]=R,this.uint16[At+9]=$,this.uint32[zt+5]=G,this.uint32[zt+6]=te,this.uint32[zt+7]=se,this.uint16[At+16]=ae,this.uint16[At+17]=de,this.uint16[At+18]=he,this.float32[zt+10]=Se,this.float32[zt+11]=Fe,this.uint8[qt+48]=Re,this.uint8[qt+49]=Ke,this.uint8[qt+50]=Xe,this.uint32[zt+13]=lt,this.int16[At+28]=kt,this.uint8[qt+58]=vt,d}}fb.prototype.bytesPerElement=60,kr(fb,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class M6 extends ro{_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(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt,At,zt,qt,ss,Gt,ds,js,Ns,Fs,Bs,Ls){const Os=this.length;return this.resize(Os+1),this.emplace(Os,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt,At,zt,qt,ss,Gt,ds,js,Ns,Fs,Bs,Ls)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt,At,zt,qt,ss,Gt,ds,js,Ns,Fs,Bs,Ls,Os){const ls=20*d,rs=40*d,Rs=80*d;return this.float32[ls+0]=m,this.float32[ls+1]=v,this.int16[rs+4]=C,this.int16[rs+5]=E,this.int16[rs+6]=P,this.int16[rs+7]=R,this.int16[rs+8]=$,this.int16[rs+9]=G,this.int16[rs+10]=te,this.int16[rs+11]=se,this.int16[rs+12]=ae,this.uint16[rs+13]=de,this.uint16[rs+14]=he,this.uint16[rs+15]=Se,this.uint16[rs+16]=Fe,this.uint16[rs+17]=Re,this.uint16[rs+18]=Ke,this.uint16[rs+19]=Xe,this.uint16[rs+20]=lt,this.uint16[rs+21]=kt,this.uint16[rs+22]=vt,this.uint16[rs+23]=At,this.uint16[rs+24]=zt,this.uint16[rs+25]=qt,this.uint16[rs+26]=ss,this.uint16[rs+27]=Gt,this.uint32[ls+14]=ds,this.float32[ls+15]=js,this.float32[ls+16]=Ns,this.float32[ls+17]=Fs,this.float32[ls+18]=Bs,this.uint8[Rs+76]=Ls,this.uint16[rs+39]=Os,d}}M6.prototype.bytesPerElement=80,kr(M6,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class T6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,v,C,E,P)}emplace(d,m,v,C,E,P,R){const $=6*d;return this.float32[$+0]=m,this.float32[$+1]=v,this.float32[$+2]=C,this.float32[$+3]=E,this.float32[$+4]=P,this.float32[$+5]=R,d}}T6.prototype.bytesPerElement=24,kr(T6,"StructArrayLayout6f24");class fv extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,C,E)}emplace(d,m,v,C,E,P){const R=5*d;return this.float32[R+0]=m,this.float32[R+1]=v,this.float32[R+2]=C,this.float32[R+3]=E,this.float32[R+4]=P,d}}fv.prototype.bytesPerElement=20,kr(fv,"StructArrayLayout5f20");class A6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,C,E,P,R)}emplace(d,m,v,C,E,P,R,$){const G=7*d;return this.float32[G+0]=m,this.float32[G+1]=v,this.float32[G+2]=C,this.float32[G+3]=E,this.float32[G+4]=P,this.float32[G+5]=R,this.float32[G+6]=$,d}}A6.prototype.bytesPerElement=28,kr(A6,"StructArrayLayout7f28");class E6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G,te,se){const ae=this.length;return this.resize(ae+1),this.emplace(ae,d,m,v,C,E,P,R,$,G,te,se)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae){const de=11*d;return this.float32[de+0]=m,this.float32[de+1]=v,this.float32[de+2]=C,this.float32[de+3]=E,this.float32[de+4]=P,this.float32[de+5]=R,this.float32[de+6]=$,this.float32[de+7]=G,this.float32[de+8]=te,this.float32[de+9]=se,this.float32[de+10]=ae,d}}E6.prototype.bytesPerElement=44,kr(E6,"StructArrayLayout11f44");class xb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G){const te=this.length;return this.resize(te+1),this.emplace(te,d,m,v,C,E,P,R,$,G)}emplace(d,m,v,C,E,P,R,$,G,te){const se=9*d;return this.float32[se+0]=m,this.float32[se+1]=v,this.float32[se+2]=C,this.float32[se+3]=E,this.float32[se+4]=P,this.float32[se+5]=R,this.float32[se+6]=$,this.float32[se+7]=G,this.float32[se+8]=te,d}}xb.prototype.bytesPerElement=36,kr(xb,"StructArrayLayout9f36");class Wf extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m){const v=this.length;return this.resize(v+1),this.emplace(v,d,m)}emplace(d,m,v){const C=2*d;return this.float32[C+0]=m,this.float32[C+1]=v,d}}Wf.prototype.bytesPerElement=8,kr(Wf,"StructArrayLayout2f8");class hh extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,C)}emplace(d,m,v,C,E){const P=6*d;return this.uint32[3*d+0]=m,this.uint16[P+2]=v,this.uint16[P+3]=C,this.uint16[P+4]=E,d}}hh.prototype.bytesPerElement=12,kr(hh,"StructArrayLayout1ul3ui12");class Dy extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.uint16[1*d+0]=m,d}}Dy.prototype.bytesPerElement=2,kr(Dy,"StructArrayLayout1ui2");class P6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe){const Re=this.length;return this.resize(Re+1),this.emplace(Re,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe)}emplace(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re){const Ke=16*d;return this.float32[Ke+0]=m,this.float32[Ke+1]=v,this.float32[Ke+2]=C,this.float32[Ke+3]=E,this.float32[Ke+4]=P,this.float32[Ke+5]=R,this.float32[Ke+6]=$,this.float32[Ke+7]=G,this.float32[Ke+8]=te,this.float32[Ke+9]=se,this.float32[Ke+10]=ae,this.float32[Ke+11]=de,this.float32[Ke+12]=he,this.float32[Ke+13]=Se,this.float32[Ke+14]=Fe,this.float32[Ke+15]=Re,d}}P6.prototype.bytesPerElement=64,kr(P6,"StructArrayLayout16f64");class A3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,C,E,P,R){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,C,E,P,R)}emplace(d,m,v,C,E,P,R,$){const G=10*d,te=5*d;return this.uint16[G+0]=m,this.uint16[G+1]=v,this.uint16[G+2]=C,this.uint16[G+3]=E,this.float32[te+2]=P,this.float32[te+3]=R,this.float32[te+4]=$,d}}A3.prototype.bytesPerElement=20,kr(A3,"StructArrayLayout4ui3f20");class I6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.int16[1*d+0]=m,d}}I6.prototype.bytesPerElement=2,kr(I6,"StructArrayLayout1i2");class E3 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.uint8[1*d+0]=m,d}}E3.prototype.bytesPerElement=1,kr(E3,"StructArrayLayout1ub1");class P3 extends g2{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]}}P3.prototype.size=40;class yF extends C3{get(d){return new P3(this,d)}}kr(yF,"CollisionBoxArray");class I3 extends g2{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(d){this._structArray.uint8[this._pos1+49]=d}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(d){this._structArray.uint8[this._pos1+50]=d}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(d){this._structArray.uint32[this._pos4+13]=d}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(d){this._structArray.uint8[this._pos1+58]=d}}I3.prototype.size=60;class vF extends fb{get(d){return new I3(this,d)}}kr(vF,"PlacedSymbolArray");class bF extends g2{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(d){this._structArray.uint32[this._pos4+14]=d}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(d){this._structArray.float32[this._pos4+18]=d}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}bF.prototype.size=80;class L6 extends M6{get(d){return new bF(this,d)}}kr(L6,"SymbolInstanceArray");class L3 extends lg{getoffsetX(d){return this.float32[1*d+0]}}kr(L3,"GlyphOffsetArray");class _F extends Iy{getx(d){return this.int16[2*d+0]}gety(d){return this.int16[2*d+1]}}kr(_F,"SymbolLineVertexArray");class D6 extends g2{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]}}D6.prototype.size=12;class O6 extends hh{get(d){return new D6(this,d)}}kr(O6,"FeatureIndexArray");class wF extends um{geta_centroid_pos0(d){return this.uint16[2*d+0]}geta_centroid_pos1(d){return this.uint16[2*d+1]}}kr(wF,"FillExtrusionCentroidArray");class D3 extends g2{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]}}D3.prototype.size=6;class y2 extends mb{get(d){return new D3(this,d)}}kr(y2,"FillExtrusionWallArray");const jF=fa([{name:"a_pos",components:2,type:"Int16"}],4),Wme=fa([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),NF=fa([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class bo{constructor(d=[]){this.segments=d}_prepareSegment(d,m,v,C){let E=this.segments[this.segments.length-1];return d>bo.MAX_VERTEX_ARRAY_LENGTH&&xr(`Max vertices per segment is ${bo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${d}`),(!E||E.vertexLength+d>bo.MAX_VERTEX_ARRAY_LENGTH||E.sortKey!==C)&&(E={vertexOffset:m,primitiveOffset:v,vertexLength:0,primitiveLength:0},C!==void 0&&(E.sortKey=C),this.segments.push(E)),E}prepareSegment(d,m,v,C){return this._prepareSegment(d,m.length,v.length,C)}get(){return this.segments}destroy(){for(const d of this.segments)for(const m in d.vaos)d.vaos[m].destroy()}static simpleSegment(d,m,v,C){return new bo([{vertexOffset:d,primitiveOffset:m,vertexLength:v,primitiveLength:C,vaos:{},sortKey:0}])}}function O3(x,d){return 256*(x=ke(Math.floor(x),0,255))+ke(Math.floor(d),0,255)}bo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,kr(bo,"SegmentVector");const Gme=fa([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Kme=fa([{name:"a_pattern_b",components:4,type:"Uint16"}]),Zme=fa([{name:"a_dash",components:4,type:"Uint16"}]);class v2{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(d,m,v,C){this.ids.push(R6(d)),this.positions.push(m,v,C)}eachPosition(d,m){const v=R6(d);let C=0,E=this.ids.length-1;for(;C>1;this.ids[P]>=v?E=P:C=P+1}for(;this.ids[C]===v;)m(this.positions[3*C],this.positions[3*C+1],this.positions[3*C+2]),C++}static serialize(d,m){const v=new Float64Array(d.ids),C=new Uint32Array(d.positions);return F6(v,C,0,v.length-1),m&&(m.add(v.buffer),m.add(C.buffer)),{ids:v,positions:C}}static deserialize(d){const m=new v2;let v;m.ids=d.ids,m.positions=d.positions;for(const C of m.ids)C!==v&&m.uniqueIds.push(C),v=C;return m.indexed=!0,m}}function R6(x){const d=+x;return Number.isSafeInteger(d)?d:Z1(String(x))}function F6(x,d,m,v){for(;m>1];let E=m-1,P=v+1;for(;;){do E++;while(x[E]C);if(E>=P)break;R3(x,E,P),R3(d,3*E,3*P),R3(d,3*E+1,3*P+1),R3(d,3*E+2,3*P+2)}P-m`u_${E}`),this.type=v,this.context=C}setUniform(d,m,v,C,E){const P=C.constantOr(this.value);m.set(d,E,P instanceof Ur?P.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):P)}getBinding(d,m){return this.type==="color"?new _2(d):new ql(d)}}class gb{constructor(d,m){this.uniformNames=m.map(v=>`u_${v}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(d,m){this.pixelRatio=d.pixelRatio||1,this.pattern=d.tl.concat(d.br),this.patternTransition=m?m.tl.concat(m.br):this.pattern}setUniform(d,m,v,C,E){let P=null;E!=="u_pattern"&&E!=="u_dash"||(P=this.pattern),E==="u_pattern_b"&&(P=this.patternTransition),E==="u_pixel_ratio"&&(P=this.pixelRatio),P&&m.set(d,E,P)}getBinding(d,m){return m==="u_pattern"||m==="u_pattern_b"||m==="u_dash"?new z3(d):new ql(d)}}class dg{constructor(d,m,v,C){this.expression=d,this.type=v,this.maxValue=0,this.paintVertexAttributes=m.map(E=>({name:`a_${E}`,type:"Float32",components:v==="color"?2:1,offset:0})),this.paintVertexArray=new C}populatePaintArray(d,m,v,C,E,P,R,$){const G=this.paintVertexArray.length,te=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Ki(0,{brightness:P,worldview:$}),m,{},E,C,R):this.expression.kind==="constant"&&this.expression.value,se=j2(this.lutExpression,m,{},C,E,P,R,$);this.paintVertexArray.resize(d),this._setPaintValue(G,d,te,se?null:this.context.lut)}updatePaintArray(d,m,v,C,E,P,R,$){const G=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:R,worldview:$},v,C,void 0,E):this.expression.kind==="constant"&&this.expression.value,te=j2(this.lutExpression,v,C,E,void 0,R,void 0,$);this._setPaintValue(d,m,G,te?null:this.context.lut)}_setPaintValue(d,m,v,C){if(this.type==="color"){const E=z6(v.toPremultipliedRenderColor(C));for(let P=d;P`u_${R}_t`),this.type=v,this.useIntegerZoom=C,this.context=E,this.maxValue=0,this.paintVertexAttributes=m.map(R=>({name:`a_${R}`,type:"Float32",components:v==="color"?4:2,offset:0})),this.paintVertexArray=new P}populatePaintArray(d,m,v,C,E,P,R,$){const G=this.expression.evaluate(new Ki(this.context.zoom,{brightness:P,worldview:$}),m,{},E,C,R),te=this.expression.evaluate(new Ki(this.context.zoom+1,{brightness:P,worldview:$}),m,{},E,C,R),se=j2(this.lutExpression,m,{},C,E,P,R,$),ae=this.paintVertexArray.length;this.paintVertexArray.resize(d),this._setPaintValue(ae,d,G,te,se?null:this.context.lut)}updatePaintArray(d,m,v,C,E,P,R,$){const G=this.expression.evaluate({zoom:this.context.zoom,brightness:R,worldview:$},v,C,void 0,E),te=this.expression.evaluate({zoom:this.context.zoom+1,brightness:R,worldview:$},v,C,void 0,E),se=j2(this.lutExpression,v,C,E,void 0,R,void 0,$);this._setPaintValue(d,m,G,te,se?null:this.context.lut)}_setPaintValue(d,m,v,C,E){if(this.type==="color"){const P=z6(v.toPremultipliedRenderColor(E)),R=z6(v.toPremultipliedRenderColor(E));for(let $=d;$!0){this.binders={},this._buffers=[],this.context=m;const C=[];for(const E in d.paint._values){const P=d.paint.get(E);if(E.endsWith("-use-theme")||!v(E)||!(P instanceof cv&&d2(P.property.specification)))continue;const R=Jme(E,d.type),$=P.value,G=P.property.specification.type,te=!!P.property.useIntegerZoom,se=E==="line-dasharray"||E.endsWith("pattern"),ae=d.paint.get(`${E}-use-theme`),de=E==="line-dasharray"&&d.layout.get("line-cap").value.kind!=="constant"||ae&&ae.value.kind!=="constant";if($.kind!=="constant"||de)if($.kind==="source"||de||se){const he=B6(E,G,"source");this.binders[E]=se?new hg($,R,G,he,d.id):new dg($,R,G,he),C.push(`/a_${E}`)}else{const he=B6(E,G,"composite");this.binders[E]=new ug($,R,G,te,m,he),C.push(`/z_${E}`)}else this.binders[E]=se?new gb($.value,R):new N2($.value,R,G,m),C.push(`/u_${E}`);ae&&(this.binders[E].lutExpression=ae.value)}this.cacheKey=C.sort().join("")}getMaxValue(d){const m=this.binders[d];return m instanceof dg||m instanceof ug?m.maxValue:0}populatePaintArrays(d,m,v,C,E,P,R,$){for(const G in this.binders){const te=this.binders[G];te.context=this.context,(te instanceof dg||te instanceof ug||te instanceof hg)&&te.populatePaintArray(d,m,v,C,E,P,R,$)}}setConstantPatternPositions(d,m){for(const v in this.binders){const C=this.binders[v];C instanceof gb&&C.setConstantPatternPositions(d,m)}}getPatternTransitionVertexBuffer(d){const m=this.binders[d];return m instanceof hg?m.paintTransitionVertexBuffer:null}updatePaintArrays(d,m,v,C,E,P,R,$,G,te){let se=!1;const ae=Object.keys(d),de=ae.length!==0&&!$,he=de?ae:m.uniqueIds;this.context.lut=E.lut;for(const Se in this.binders){const Fe=this.binders[Se];if(Fe.context=this.context,(Fe instanceof dg||Fe instanceof ug||Fe instanceof hg)&&Fe.expression&&Fe.expression.kind&&Fe.expression.kind!=="constant"&&(Fe.expression.isStateDependent===!0||Fe.expression.isLightConstant===!1)){const Re=E.paint.get(Se);Fe.expression=Re.value;for(const Ke of he){const Xe=d[Ke.toString()];m.eachPosition(Ke,(lt,kt,vt)=>{const At=C.feature(lt);Fe.updatePaintArray(kt,vt,At,Xe,P,R,G,te)})}if(!de)for(const Ke of v.uniqueIds){const Xe=d[Ke.toString()];v.eachPosition(Ke,(lt,kt,vt)=>{const At=C.feature(lt);Fe.updatePaintArray(kt,vt,At,Xe,P,R,G,te)})}se=!0}}return se}defines(){const d=[];for(const m in this.binders){const v=this.binders[m];(v instanceof N2||v instanceof gb)&&d.push(...v.uniformNames.map(C=>`#define HAS_UNIFORM_${C}`))}return d}getPaintVertexBuffers(){return this._buffers}getUniforms(d){const m=[];for(const v in this.binders){const C=this.binders[v];if(C instanceof N2||C instanceof gb||C instanceof ug)for(const E of C.uniformNames)m.push({name:E,property:v,binding:C.getBinding(d,E)})}return m}setUniforms(d,m,v,C,E){for(const{name:P,property:R,binding:$}of v)this.binders[R].setUniform(d,$,E,C.get(R),P)}updatePaintBuffers(){this._buffers=[];for(const d in this.binders){const m=this.binders[d];(m instanceof dg||m instanceof ug||m instanceof hg)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof hg&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(d){for(const m in this.binders){const v=this.binders[m];(v instanceof dg||v instanceof ug||v instanceof hg)&&v.upload(d)}this.updatePaintBuffers()}destroy(){for(const d in this.binders){const m=this.binders[d];(m instanceof dg||m instanceof ug||m instanceof hg)&&m.destroy()}}}class qp{constructor(d,m,v=()=>!0){this.programConfigurations={};for(const C of d)this.programConfigurations[C.id]=new Oy(C,m,v);this.needsUpload=!1,this._featureMap=new v2,this._featureMapWithoutIds=new v2,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(d,m,v,C,E,P,R,$,G){for(const te in this.programConfigurations)this.programConfigurations[te].populatePaintArrays(d,m,C,E,P,R,$,G);m.id!==void 0?this._featureMap.add(m.id,v,this._bufferOffset,d):(this._featureMapWithoutIds.add(this._idlessCounter,v,this._bufferOffset,d),this._idlessCounter+=1),this._bufferOffset=d,this.needsUpload=!0}updatePaintArrays(d,m,v,C,E,P,R,$){for(const G of v)this.needsUpload=this.programConfigurations[G.id].updatePaintArrays(d,this._featureMap,this._featureMapWithoutIds,m,G,C,E,P,R||0,$)||this.needsUpload}get(d){return this.programConfigurations[d]}upload(d){if(this.needsUpload){for(const m in this.programConfigurations)this.programConfigurations[m].upload(d);this.needsUpload=!1}}destroy(){for(const d in this.programConfigurations)this.programConfigurations[d].destroy()}}const Qme={"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 Jme(x,d){return Qme[x]||[x.replace(`${d}-`,"").replace(/-/g,"_")]}const epe={"line-pattern":{source:uh,composite:uh},"fill-pattern":{source:uh,composite:uh},"fill-extrusion-pattern":{source:uh,composite:uh},"line-dasharray":{source:pv,composite:pv}},tpe={color:{source:Wf,composite:Ly},number:{source:lg,composite:Wf}};function B6(x,d,m){const v=epe[x];return v&&v[m]||tpe[d][m]}kr(N2,"ConstantBinder"),kr(gb,"PatternConstantBinder"),kr(dg,"SourceExpressionBinder"),kr(hg,"PatternCompositeBinder"),kr(ug,"CompositeExpressionBinder"),kr(Oy,"ProgramConfiguration",{omit:["_buffers"]}),kr(qp,"ProgramConfigurationSet");const Ud=tr/Math.PI/2,sp=5,q3=6,spe=16383,yb=64,$6=[yb,32,16],rp=-Ud,np=Ud;function xv(x,d,m,v=Ud){return m=jr(m),[x*Math.sin(m)*v,-d*v,x*Math.cos(m)*v]}function vb(x,d,m){return xv(Math.cos(jr(x)),Math.sin(jr(x)),d,m)}const T=63710088e-1,h=2*Math.PI*T;class y{constructor(d,m){if(isNaN(d)||isNaN(m))throw new Error(`Invalid LngLat object: (${d}, ${m})`);if(this.lng=+d,this.lat=+m,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new y(Ye(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(d){const m=Math.PI/180,v=this.lat*m,C=d.lat*m,E=Math.sin(v)*Math.sin(C)+Math.cos(v)*Math.cos(C)*Math.cos((d.lng-this.lng)*m);return T*Math.acos(Math.min(E,1))}toBounds(d=0){const m=360*d/40075017,v=m/Math.cos(Math.PI/180*this.lat);return new A({lng:this.lng-v,lat:this.lat-m},{lng:this.lng+v,lat:this.lat+m})}toEcef(d){return vb(this.lat,this.lng,Ud+d*Ud/T)}static convert(d){if(d instanceof y)return d;if(Array.isArray(d)&&(d.length===2||d.length===3))return new y(Number(d[0]),Number(d[1]));if(!Array.isArray(d)&&typeof d=="object"&&d!==null)return new y(Number("lng"in d?d.lng:d.lon),Number(d.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class A{constructor(d,m){d&&(m?this.setSouthWest(d).setNorthEast(m):Array.isArray(d)&&d.length===4?this.setSouthWest([d[0],d[1]]).setNorthEast([d[2],d[3]]):this.setSouthWest(d[0]).setNorthEast(d[1]))}setNorthEast(d){return this._ne=d instanceof y?new y(d.lng,d.lat):y.convert(d),this}setSouthWest(d){return this._sw=d instanceof y?new y(d.lng,d.lat):y.convert(d),this}extend(d){const m=this._sw,v=this._ne;let C,E;if(d instanceof y)C=d,E=d;else{if(!(d instanceof A))return Array.isArray(d)?d.length===4||d.every(Array.isArray)?this.extend(A.convert(d)):this.extend(y.convert(d)):typeof d=="object"&&d!==null&&d.hasOwnProperty("lat")&&(d.hasOwnProperty("lon")||d.hasOwnProperty("lng"))?this.extend(y.convert(d)):this;if(C=d._sw,E=d._ne,!C||!E)return this}return m||v?(m.lng=Math.min(C.lng,m.lng),m.lat=Math.min(C.lat,m.lat),v.lng=Math.max(E.lng,v.lng),v.lat=Math.max(E.lat,v.lat)):(this._sw=new y(C.lng,C.lat),this._ne=new y(E.lng,E.lat)),this}getCenter(){return new y((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 y(this.getWest(),this.getNorth())}getSouthEast(){return new y(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(d){const{lng:m,lat:v}=y.convert(d);let C=this._sw.lng<=m&&m<=this._ne.lng;return this._sw.lng>this._ne.lng&&(C=this._sw.lng>=m&&m>=this._ne.lng),this._sw.lat<=v&&v<=this._ne.lat&&C}static convert(d){if(d)return d instanceof A?d:new A(d)}}const D=0,F=25.5;function z(x){return h*Math.cos(x*Math.PI/180)}function W(x){return(180+x)/360}function J(x){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+x*Math.PI/360)))/360}function ne(x,d){return x/z(d)}function le(x){return 360*x-180}function je(x){return 360/Math.PI*Math.atan(Math.exp((180-360*x)*Math.PI/180))-90}function ve(x,d){return x*z(je(d))}const Ne=85.051129;function De(x){return Math.cos(jr(ke(x,-Ne,Ne)))}function Pe(x,d){const m=ke(d,D,F),v=Math.pow(2,m);return De(x)*h/(512*v)}function Ge(x){return 1/Math.cos(x*Math.PI/180)}function Ve(x,d=0){const m=Math.exp(Math.PI*(1-(x.y+d/tr)/(1<=$?(ut(x,d,m,G,te,E,se,R,$),ut(x,G,te,v,C,se,P,R,$)):x.push(P)}function ot(x,d,m){let v=x[0],C=v.x,E=v.y;d(v);const P=[v];for(let R=1;Rx.x+1||vx.y+1)&&xr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),x}function Ot(x,d,m){const v=x.loadGeometry(),C=x.extent,E=tr/C;if(d&&m&&m.projection.isReprojectedInTileSpace){const P=1<{const de=le((d.x+ae.x/C)/P),he=je((d.y+ae.y/C)/P),Se=te.project(de,he);ae.x=(Se.x*R-$)*C,ae.y=(Se.y*R-G)*C};for(let ae=0;ae=C||he.y<0||he.y>=C||(se(he),de.push(he));v[ae]=de}}for(const P of v)for(const R of P)yt(R,E);return v}function Wt(x,d){return{type:x.type,id:x.id,properties:x.properties,geometry:d?Ot(x):[]}}class Ht{constructor(d,m,v,C,E){this.properties={},this.extent=v,this.type=0,this.id=void 0,this._pbf=d,this._geometry=-1,this._keys=C,this._values=E,d.readFields(es,this,m)}loadGeometry(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos,v=[];let C,E=1,P=0,R=0,$=0;for(;d.pos>3}if(P--,E===1||E===2)R+=d.readSVarint(),$+=d.readSVarint(),E===1&&(C&&v.push(C),C=[]),C&&C.push(new ft(R,$));else{if(E!==7)throw new Error(`unknown command ${E}`);C&&C.push(C[0].clone())}}return C&&v.push(C),v}bbox(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos;let v=1,C=0,E=0,P=0,R=1/0,$=-1/0,G=1/0,te=-1/0;for(;d.pos>3}if(C--,v===1||v===2)E+=d.readSVarint(),P+=d.readSVarint(),E$&&($=E),Pte&&(te=P);else if(v!==7)throw new Error(`unknown command ${v}`)}return[R,G,$,te]}toGeoJSON(d,m,v){const C=this.extent*Math.pow(2,v),E=this.extent*d,P=this.extent*m,R=this.loadGeometry();function $(ae){return[360*(ae.x+E)/C-180,360/Math.PI*Math.atan(Math.exp((1-2*(ae.y+P)/C)*Math.PI))-90]}function G(ae){return ae.map($)}let te;if(this.type===1){const ae=[];for(const he of R)ae.push(he[0]);const de=G(ae);te=ae.length===1?{type:"Point",coordinates:de[0]}:{type:"MultiPoint",coordinates:de}}else if(this.type===2){const ae=R.map(G);te=ae.length===1?{type:"LineString",coordinates:ae[0]}:{type:"MultiLineString",coordinates:ae}}else{if(this.type!==3)throw new Error("unknown feature type");{const ae=function(he){const Se=he.length;if(Se<=1)return[he];const Fe=[];let Re,Ke;for(let Xe=0;Xe=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[d];const m=this._pbf.readVarint()+this._pbf.pos;return new Ht(this._pbf,m,this.extent,this._keys,this._values)}}function qs(x,d,m){x===15?d.version=m.readVarint():x===1?d.name=m.readString():x===5?d.extent=m.readVarint():x===2?d._features.push(m.pos):x===3?d._keys.push(m.readString()):x===4&&d._values.push(function(v){let C=null;const E=v.readVarint()+v.pos;for(;v.pos>3;C=P===1?v.readString():P===2?v.readFloat():P===3?v.readDouble():P===4?v.readVarint64():P===5?v.readVarint():P===6?v.readSVarint():P===7?v.readBoolean():null}if(C==null)throw new Error("unknown feature value");return C}(m))}class Yt{constructor(d,m){this.layers=d.readFields(Bt,{},m)}}function Bt(x,d,m){if(x===3){const v=new xs(m,m.readVarint()+m.pos);v.length&&(d[v.name]=v)}}const as="3d_elevation_id",Jt="level";class Is{constructor(){this._valid=!1}reset(d){return this.feature=d,this._valid=!0,this._geometry=d.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(d,m){return this._valid&&d(m(this._geometry)),this}require(d,m,v){return this.get(d,!0,m,v)}optional(d,m,v){return this.get(d,!1,m,v)}success(){return this._valid}get(d,m,v,C){const E=this.feature.properties.hasOwnProperty(d)?+this.feature.properties[d]:void 0;return this._valid&&E!==void 0&&!Number.isNaN(E)?v(C?C(E):E):m&&(this._valid=!1),this}}class rr{constructor(d,m){this.featureFunc=d,this.vertexFunc=m}parseFeature(d,m,v){return this.featureFunc(d,m,v)}parseVertex(d,m,v){return this.vertexFunc(d,m,v)}}const yr=new rr((x,d,m)=>x.reset(d).require(as,v=>{m.id=v}).optional("fixed_height_relative",v=>{m.constantHeight=v},Us.decodeRelativeHeight).geometry(v=>{m.bounds=v},sg).success(),(x,d,m)=>x.reset(d).require(as,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height_relative",v=>{m.height=v},Us.decodeRelativeHeight).geometry(v=>{m.position=v},Us.getPoint).success()),Js=new rr((x,d,m)=>x.reset(d).require(as,v=>{m.id=v}).optional("fixed_height",v=>{m.constantHeight=v},Us.decodeMetricHeight).geometry(v=>{m.bounds=v},sg).success(),(x,d,m)=>x.reset(d).require(as,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height",v=>{m.height=v},Us.decodeMetricHeight).geometry(v=>{m.position=v},Us.getPoint).success());class Us{static getPoint(d){return xt(d[0][0].x,d[0][0].y)}static decodeRelativeHeight(d){return 1e-4*d*5}static decodeMetricHeight(d){return 1e-4*d}static getVersionSchema(d){return d?d==="1.0.1"?Js:void 0:yr}static parse(d){const m=[],v=[],C=d.length,E=new Is;for(let P=0;P=0);if(E===0)return 0;E!==d.length&&(m=!1)}return m?2:1}function Pn(x,d){for(const m of x.projections){const v=br(d,x.points[0],m.axis);if(m.projection[1]v[1])return 0}return 1}function wa(x,d){let m=0;const v=[0,0,0,0];for(let P=0;P=0&&m++;var C,E;return m}class si{constructor(d,m){this.points=d||new Array(8).fill([0,0,0]),this.planes=m||new Array(6).fill([0,0,0,0]),this.bounds=Or.fromPoints(this.points),this.projections=[],this.frustumEdges=[Me([],this.points[2],this.points[3]),Me([],this.points[0],this.points[3]),Me([],this.points[4],this.points[0]),Me([],this.points[5],this.points[1]),Me([],this.points[6],this.points[2]),Me([],this.points[7],this.points[3])];for(const v of this.frustumEdges){const C=[0,-v[2],v[1]],E=[v[2],0,-v[0]];this.projections.push({axis:C,projection:br(this.points,this.points[0],C)}),this.projections.push({axis:E,projection:br(this.points,this.points[0],E)})}}static fromInvProjectionMatrix(d,m,v,C){const E=Math.pow(2,v),P=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(G=>{const te=Qe([],G,d),se=1/te[3]/m*E;return(ae=te)[0]=(de=te)[0]*(he=[se,se,C?1/te[3]:se,se])[0],ae[1]=de[1]*he[1],ae[2]=de[2]*he[2],ae[3]=de[3]*he[3],ae;var ae,de,he}),R=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(G=>{const te=we([],tt([],Me([],P[G[0]],P[G[1]]),Me([],P[G[2]],P[G[1]]))),se=-Le(te,P[G[1]]);return te.concat(se)}),$=[];for(let G=0;GG[1]||G[0]>$[1])return 0}return 1}containsPoint(d){for(const m of this.planes){const v=m[3];if(Le([m[0],m[1],m[2]],d)+v<0)return!1}return!0}}class Or{static fromPoints(d){const m=[1/0,1/0,1/0],v=[-1/0,-1/0,-1/0];for(const C of d)ue(m,m,C),pe(v,v,C);return new Or(m,v)}static fromTileIdAndHeight(d,m,v){const C=1<d.max[m]||d.min[m]>this.max[m])return!1;return!0}intersectsAabbXY(d){return!(this.min[0]>d.max[0]||d.min[0]>this.max[0]||this.min[1]>d.max[1]||d.min[1]>this.max[1])}encapsulate(d){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],d.min[m]),this.max[m]=Math.max(this.max[m],d.max[m])}encapsulatePoint(d){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],d[m]),this.max[m]=Math.max(this.max[m],d[m])}closestPoint(d){return[Math.max(Math.min(this.max[0],d[0]),this.min[0]),Math.max(Math.min(this.max[1],d[1]),this.min[1]),Math.max(Math.min(this.max[2],d[2]),this.min[2])]}}kr(Or,"Aabb");class Ka{constructor(d,m){this.feature=d,this.metersToTile=m,this.index=0}get(){const d=this.feature.vertices[this.index],m=this.feature.vertexProps[this.index].dir,v=m[1],C=-m[0],E=(d.extent+1)*this.metersToTile;return[new ft(Math.trunc(d.position[0]+v*E),Math.trunc(d.position[1]+C*E)),new ft(Math.trunc(d.position[0]-v*E),Math.trunc(d.position[1]-C*E))]}next(){this.index++}valid(){return this.index{return R.a0?_e($,$,1/G):oe($,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(d){if(this.edges.length===0)return;let m=0,v=Number.POSITIVE_INFINITY,C=0;const[E,P,R,$,G,te,se]=this._tmpVec2;Es(se,d.x,d.y);const ae=new Pr(se,null);for(let de=0;de0?Ea($,R)/lt:0,vt=ke(kt,0,1),At=Math.abs((kt-vt)*this.edgeProps[de].len);Mr(G,se,Fe),Es(te,Se[1],-Se[0]);const zt=At+Math.abs(Ea(G,te));zt=0;--P){const R=this.edges[P].a,$=this.edges[P].b,{position:G,height:te,extent:se}=this.vertices[R],{position:ae,height:de,extent:he}=this.vertices[$],Se=this.vertexProps[R].dir,Fe=this.vertexProps[$].dir;if(oe(m,G[0]/d,G[1]/d,te),oe(v,ae[0]/d,ae[1]/d,de),oe(C,Se[1],-Se[0],0),_e(C,C,se),oe(E,Fe[1],-Fe[0],0),_e(E,E,he),this.distSqLines(re(m[0]+.5*C[0],m[1]+.5*C[1],m[2]+.5*C[2]),re(v[0]-.5*E[0],v[1]-.5*E[1],v[2]-.5*E[2]),re(m[0]-.5*C[0],m[1]-.5*C[1],m[2]-.5*C[2]),re(v[0]+.5*E[0],v[1]+.5*E[1],v[2]+.5*E[2]))<=.0025000000000000005)continue;const Re=this.vertices.length,Ke=ur(er(),G,ae);this.vertices.push({position:Lr(Ke,Ke,.5),height:.5*(te+de),extent:.5*(se+he)});const Xe=ur(er(),Se,Fe);this.vertexProps.push({dir:ki(Xe,Xe)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:R,b:Re}),this.edges.push({a:Re,b:$});const lt=Mr(er(),this.vertices[Re].position,G),kt=fn(lt),vt={vec:lt,dir:Lr(er(),lt,1/kt),len:kt};this.edgeProps.push(vt),this.edgeProps.push(vt)}}distSqLines(d,m,v,C){const E=ge(ee(),m,d),P=ge(ee(),C,v),R=ge(ee(),d,v),$=Le(E,E),G=Le(E,P),te=Le(E,R),se=Le(P,P),ae=Le(P,R),de=$*se-G*G;if(de===0)return Ie(Te(E,v,C,Le(R,P)/Le(P,P)),d);const he=($*ae-G*te)/de;return Ie(Te(E,d,m,(G*ae-te*se)/de),Te(P,v,C,he))}}class di{static parseFrom(d,m){const v=Us.parse(d);if(!v)return[];let{vertices:C,features:E}=v;const P=1/Ve(m);E.sort((te,se)=>te.id-se.id),C.sort((te,se)=>te.id-se.id||te.idx-se.idx),C=C.filter((te,se,ae)=>se===ae.findIndex(de=>de.id===te.id&&de.idx===te.idx));const R=new Array;let $=0;const G=C.length;for(const te of E){if(te.constantHeight){R.push(new Cn(te.id,te.bounds,te.constantHeight));continue}for(;$!==G&&C[$].idC.id===v)}}class Ci{constructor(d,m){this.zScale=1,this.xOffset=0,this.yOffset=0,d.equals(m)||(this.zScale=Math.pow(2,m.z-d.z),this.xOffset=(d.x*this.zScale-m.x)*tr,this.yOffset=(d.y*this.zScale-m.y)*tr)}constantElevation(d,m){if(d.constantHeight!=null)return this.computeBiasedHeight(d.constantHeight,m)}pointElevation(d,m,v){const C=this.constantElevation(m,v);return C??(d.x=d.x*this.zScale+this.xOffset,d.y=d.y*this.zScale+this.yOffset,this.computeBiasedHeight(m.pointElevation(d),v))}computeBiasedHeight(d,m){return m<=0?d:d+m*Be(0,m,d>=0?d:Math.abs(.5*d))}}kr(Cn,"ElevationFeature");class bi{constructor(d){this.zoom=d.zoom,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.projection=d.projection,this.layoutVertexArray=new Iy,this.indexArray=new $l,this.segments=new bo,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new lg),this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){const E=this.layers[0],P=[];let R=null;E.type==="circle"&&(R=E.layout.get("circle-sort-key"));for(const{feature:G,id:te,index:se,sourceLayerIndex:ae}of d){const de=this.layers[0]._featureFilter.needGeometry,he=Wt(G,de);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),he,v))continue;const Se=R?R.evaluate(he,{},v):void 0,Fe={id:te,properties:G.properties,type:G.type,sourceLayerIndex:ae,index:se,geometry:de?he.geometry:Ot(G,v,C),patterns:{},sortKey:Se};P.push(Fe)}R&&P.sort((G,te)=>G.sortKey-te.sortKey);let $=null;C.projection.name==="globe"&&(this.globeExtVertexArray=new k3,$=C.projection);for(const G of P){const{geometry:te,index:se,sourceLayerIndex:ae}=G,de=d[se].feature;this.addFeature(G,te,se,m.availableImages,v,$,m.brightness,m.elevationFeatures),m.featureIndex.insert(de,te,se,ae,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(d,m,v,C,E,P,R){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,jF.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,NF.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=d.createVertexBuffer(this.elevatedLayoutVertexArray,Wme.members))),this.programConfigurations.upload(d),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(d,m,v,C,E,P,R,$){let G;this.elevationMode!=="none"&&(G=di.getElevationFeature(d,$));for(const te of m)for(const se of te){const ae=se.x,de=se.y;if(ae<0||ae>=tr||de<0||de>=tr)continue;if(P){const Fe=P.projectTilePoint(ae,de,E),Re=P.upVector(E,ae,de);this.addGlobeExtVertex(Fe,Re),this.addGlobeExtVertex(Fe,Re),this.addGlobeExtVertex(Fe,Re),this.addGlobeExtVertex(Fe,Re)}const he=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,d.sortKey),Se=he.vertexLength;if(this.addCircleVertex(ae,de,-1,-1),this.addCircleVertex(ae,de,1,-1),this.addCircleVertex(ae,de,1,1),this.addCircleVertex(ae,de,-1,1),this.elevationMode!=="none"){const Fe=G?G.pointElevation(new ft(ae,de)):0;this.hasElevation=this.hasElevation||Fe!==0;for(let Re=0;Re<4;Re++)this.elevatedLayoutVertexArray.emplaceBack(Fe)}this.indexArray.emplaceBack(Se,Se+1,Se+2),this.indexArray.emplaceBack(Se,Se+2,Se+3),he.vertexLength+=4,he.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,v,{},C,E,R,void 0,this.worldview)}addCircleVertex(d,m,v,C){this.layoutVertexArray.emplaceBack(2*d+(v+1)/2,2*m+(C+1)/2)}addGlobeExtVertex(d,m){this.globeExtVertexArray.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}}function Ga(x,d){for(let m=0;m1){if(no(x,d))return!0;for(let v=0;v1?m:m.sub(d)._mult(C)._add(d))}function _o(x,d){let m,v,C,E=!1;for(let P=0;Pd.y!=C.y>d.y&&d.x<(C.x-v.x)*(d.y-v.y)/(C.y-v.y)+v.x&&(E=!E)}return E}function Di(x,d){let m=!1;for(let v=0,C=x.length-1;vd.y!=P.y>d.y&&d.x<(P.x-E.x)*(d.y-E.y)/(P.y-E.y)+E.x&&(m=!m)}return m}function Bu(x,d,m,v,C){for(const P of x)if(d<=P.x&&m<=P.y&&v>=P.x&&C>=P.y)return!0;const E=[new ft(d,m),new ft(d,C),new ft(v,C),new ft(v,m)];if(x.length>2){for(const P of E)if(Di(x,P))return!0}for(let P=0;PC.x&&d.x>C.x||x.yC.y&&d.y>C.y)return!1;const E=Dn(x,d,m[0]);return E!==Dn(x,d,m[1])||E!==Dn(x,d,m[2])||E!==Dn(x,d,m[3])}function Ul(x,d,m,v,C,E){let P=d.y-x.y,R=x.x-d.x;if(E=E||0){const $=P*P+R*R;if($===0)return!0;const G=Math.sqrt($);P/=G,R/=G}return!((m.x-x.x)*P+(m.y-x.y)*R-E<0||(v.x-x.x)*P+(v.y-x.y)*R-E<0||(C.x-x.x)*P+(C.y-x.y)*R-E<0)}function Vd(x,d,m,v,C,E,P){return!(Ul(x,d,v,C,E,P)||Ul(d,m,v,C,E,P)||Ul(m,x,v,C,E,P)||Ul(v,C,x,d,m,P)||Ul(C,E,x,d,m,P)||Ul(E,v,x,d,m,P))}function Hd(x,d,m){const v=d.paint.get(x).value;return v.kind==="constant"?v.value:m.programConfigurations.get(d.id).getMaxValue(x)}function od(x){return Math.sqrt(x[0]*x[0]+x[1]*x[1])}function hm(x,d,m,v,C){if(!d[0]&&!d[1])return x;const E=ft.convert(d)._mult(C);m==="viewport"&&E._rotate(-v);const P=[];for(let R=0;R>m&&d.y===this.y>>m}url(d,m){const v=function(E,P,R){var $=Jo(256*E,256*(P=Math.pow(2,R)-P-1),R),G=Jo(256*(E+1),256*(P+1),R);return $[0]+","+$[1]+","+G[0]+","+G[1]}(this.x,this.y,this.z),C=function(E,P,R){let $,G="";for(let te=E;te>0;te--)$=1<this.canonical.z?new Co(d,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Co(d,this.wrap,d,this.canonical.x>>m,this.canonical.y>>m)}calculateScaledKey(d,m=!0){if(this.overscaledZ===d&&m)return this.key;if(d>this.canonical.z)return wo(this.wrap*+m,d,this.canonical.z,this.canonical.x,this.canonical.y);{const v=this.canonical.z-d;return wo(this.wrap*+m,d,d,this.canonical.x>>v,this.canonical.y>>v)}}isChildOf(d){if(d.wrap!==this.wrap)return!1;const m=this.canonical.z-d.canonical.z;return d.overscaledZ===0||d.overscaledZ>m&&d.canonical.y===this.canonical.y>>m}children(d){if(this.overscaledZ>=d)return[new Co(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const m=this.canonical.z+1,v=2*this.canonical.x,C=2*this.canonical.y;return[new Co(m,this.wrap,m,v,C),new Co(m,this.wrap,m,v+1,C),new Co(m,this.wrap,m,v,C+1),new Co(m,this.wrap,m,v+1,C+1)]}isLessThan(d){return this.wrapd.wrap)&&(this.overscaledZd.overscaledZ)&&(this.canonical.xd.canonical.x)&&this.canonical.y{let d=x.canonical.x-1,m=x.wrap;return d<0&&(d=(1<{let d=x.canonical.x+1,m=x.wrap;return d===1<new Co(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,(x.canonical.y===0?1<new Co(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y===(1<1?null:function(v,C,E,P){const R=Math.sin(E);return v*(Math.sin((1-P)*E)/R)+C*(Math.sin(P*E)/R)}(x.a[d],x.b[d],x.angle,ke(m,0,1))+x.center[d]}function Vp(x){if(x.z<=1)return mg[x.z+2*x.y+x.x];const d=rpe(kF(x));return Or.fromPoints(d)}function fg(x,d,m){return _e(x,x,1-m),$e(x,x,d,m)}function yCe(x,d,m){for(const v of x)pt(v,v,d),_e(v,v,m)}function vCe(x,d,m,v){const C=d/x.worldSize,E=x.globeMatrix;if(m.z<=1){const qt=Vp(m).getCorners();return yCe(qt,E,C),Or.fromPoints(qt)}const P=kF(m,v),R=rpe(P,Ud+Kf(x._tileCoverLift));yCe(R,E,C);const $=Number.MAX_VALUE,G=[-$,-$,-$],te=[$,$,$];if(P.contains(x.center)){for(const Gt of R)ue(te,te,Gt),pe(G,G,Gt);G[2]=0;const qt=x.point,ss=[qt.x*C,qt.y*C,0];return ue(te,te,ss),pe(G,G,ss),new Or(te,G)}if(x._tileCoverLift>0){for(const qt of R)ue(te,te,qt),pe(G,G,qt);return new Or(te,G)}const se=[E[12]*C,E[13]*C,E[14]*C],ae=P.getCenter(),de=ke(x.center.lat,-Ne,Ne),he=ke(ae.lat,-Ne,Ne),Se=W(x.center.lng),Fe=J(de);let Re=Se-W(ae.lng);const Ke=Fe-J(he);Re>.5?Re-=1:Re<-.5&&(Re+=1);let Xe=0;Math.abs(Re)>Math.abs(Ke)?Xe=Re>=0?1:3:(Xe=Ke>=0?0:2,$e(se,se,[E[4]*C,E[5]*C,E[6]*C],-Math.sin(jr(Ke>=0?P.getSouth():P.getNorth()))*Ud));const lt=R[Xe],kt=R[(Xe+1)%4],vt=new Ry(lt,kt,se),At=[pg(vt,0)||lt[0],pg(vt,1)||lt[1],pg(vt,2)||lt[2]],zt=wb(x.zoom);if(zt>0){const qt=function({x:Gt,y:ds,z:js},Ns,Fs,Bs,Ls){const Os=1/(1<.5?Vs=-1:zr<-.5&&(Vs=1),ls=((ls+Vs)*Ns-(Bs*=Ns))*Fs+Bs,rs=((rs+Vs)*Ns-Bs)*Fs+Bs,Rs=(Rs*Ns-(Ls*=Ns))*Fs+Ls,sr=(sr*Ns-Ls)*Fs+Ls,[[ls,sr,0],[rs,sr,0],[rs,Rs,0],[ls,Rs,0]]}(m,d,x._pixelsPerMercatorPixel,Se,Fe);for(let Gt=0;GtMath.PI/2*1.01}const NCe=jr(85),Ect=Math.cos(NCe),Pct=Math.sin(NCe),Ict=_(),kCe=x=>{const d=[];return x.paint.get("circle-pitch-alignment")==="map"&&d.push("PITCH_WITH_MAP"),x.paint.get("circle-pitch-scale")==="map"&&d.push("SCALE_WITH_MAP"),d};function SCe(x,d,m,v,C,E,P,R,$){if(E&&x.queryGeometry.isAboveHorizon)return!1;E&&($*=x.pixelToTileUnitsFactor);const G=x.tileID.canonical,te=m.projection.upVectorScale(G,m.center.lat,m.worldSize).metersToTile;for(const se of d)for(const ae of se){const de=ae.add(R),he=C&&m.elevation?m.elevation.exaggeration()*C.getElevationAt(de.x,de.y,!0):0,Se=m.projection.projectTilePoint(de.x,de.y,G);if(he>0){const Xe=m.projection.upVector(G,de.x,de.y);Se.x+=Xe[0]*te*he,Se.y+=Xe[1]*te*he,Se.z+=Xe[2]*te*he}const Fe=E?de:Lct(Se.x,Se.y,Se.z,v),Re=E?x.tilespaceRays.map(Xe=>Oct(Xe,he)):x.queryGeometry.screenGeometry,Ke=Qe([],[Se.x,Se.y,Se.z,1],v);if(!P&&E?$*=Ke[3]/m.cameraToCenterDistance:P&&!E&&($*=m.cameraToCenterDistance/Ke[3]),E){const Xe=je((ae.y/tr+G.y)/(1<x.width||C.height>x.height||m.x>x.width-C.width||m.y>x.height-C.height)throw new RangeError("out of range source coordinates for image copy");if(C.width>d.width||C.height>d.height||v.x>d.width-C.width||v.y>d.height-C.height)throw new RangeError("out of range destination coordinates for image copy");const $=x.data,G=d.data,te=E===4&&R;for(let se=0;se{d[x.evaluationKey]=$;const G=x.expression.evaluate(d),te=G?G.toNonPremultipliedRenderColor(null):null;te&&(C.data[P+R+0]=Math.floor(255*te.r),C.data[P+R+1]=Math.floor(255*te.g),C.data[P+R+2]=Math.floor(255*te.b),C.data[P+R+3]=Math.floor(255*te.a))};if(x.clips)for(let P=0,R=0;P80*m){R=x[0],$=x[1];let te=R,se=$;for(let ae=m;aete&&(te=de),he>se&&(se=he)}G=Math.max(te-R,se-$),G=G!==0?32767/G:0}return V6(E,P,m,R,$,G,0),P}function OCe(x,d,m,v,C){let E;if(C===function(P,R,$,G){let te=0;for(let se=R,ae=$-G;se<$;se+=G)te+=(P[ae]-P[se])*(P[se+1]+P[ae+1]),ae=se;return te}(x,d,m,v)>0)for(let P=d;P=d;P-=v)E=BCe(P/v|0,x[P],x[P+1],E);return E&&V3(E,E.next)&&(G6(E),E=E.next),E}function C2(x,d){if(!x)return x;d||(d=x);let m,v=x;do if(m=!1,v.steiner||!V3(v,v.next)&&Kc(v.prev,v,v.next)!==0)v=v.next;else{if(G6(v),v=d=v.prev,v===v.next)break;m=!0}while(m||v!==d);return d}function V6(x,d,m,v,C,E,P){if(!x)return;!P&&E&&function($,G,te,se){let ae=$;do ae.z===0&&(ae.z=lpe(ae.x,ae.y,G,te,se)),ae.prevZ=ae.prev,ae.nextZ=ae.next,ae=ae.next;while(ae!==$);ae.prevZ.nextZ=null,ae.prevZ=null,function(de){let he,Se=1;do{let Fe,Re=de;de=null;let Ke=null;for(he=0;Re;){he++;let Xe=Re,lt=0;for(let vt=0;vt0||kt>0&&Xe;)lt!==0&&(kt===0||!Xe||Re.z<=Xe.z)?(Fe=Re,Re=Re.nextZ,lt--):(Fe=Xe,Xe=Xe.nextZ,kt--),Ke?Ke.nextZ=Fe:de=Fe,Fe.prevZ=Ke,Ke=Fe;Re=Xe}Ke.nextZ=null,Se*=2}while(he>1)}(ae)}(x,v,C,E);let R=x;for(;x.prev!==x.next;){const $=x.prev,G=x.next;if(E?qct(x,v,C,E):$ct(x))d.push($.i,x.i,G.i),G6(x),x=G.next,R=G.next;else if((x=G)===R){P?P===1?V6(x=Uct(C2(x),d),d,m,v,C,E,2):P===2&&Vct(x,d,m,v,C,E):V6(C2(x),d,m,v,C,E,1);break}}}function $ct(x){const d=x.prev,m=x,v=x.next;if(Kc(d,m,v)>=0)return!1;const C=d.x,E=m.x,P=v.x,R=d.y,$=m.y,G=v.y,te=Math.min(C,E,P),se=Math.min(R,$,G),ae=Math.max(C,E,P),de=Math.max(R,$,G);let he=v.next;for(;he!==d;){if(he.x>=te&&he.x<=ae&&he.y>=se&&he.y<=de&&H6(C,R,E,$,P,G,he.x,he.y)&&Kc(he.prev,he,he.next)>=0)return!1;he=he.next}return!0}function qct(x,d,m,v){const C=x.prev,E=x,P=x.next;if(Kc(C,E,P)>=0)return!1;const R=C.x,$=E.x,G=P.x,te=C.y,se=E.y,ae=P.y,de=Math.min(R,$,G),he=Math.min(te,se,ae),Se=Math.max(R,$,G),Fe=Math.max(te,se,ae),Re=lpe(de,he,d,m,v),Ke=lpe(Se,Fe,d,m,v);let Xe=x.prevZ,lt=x.nextZ;for(;Xe&&Xe.z>=Re&<&<.z<=Ke;){if(Xe.x>=de&&Xe.x<=Se&&Xe.y>=he&&Xe.y<=Fe&&Xe!==C&&Xe!==P&&H6(R,te,$,se,G,ae,Xe.x,Xe.y)&&Kc(Xe.prev,Xe,Xe.next)>=0||(Xe=Xe.prevZ,lt.x>=de&<.x<=Se&<.y>=he&<.y<=Fe&<!==C&<!==P&&H6(R,te,$,se,G,ae,lt.x,lt.y)&&Kc(lt.prev,lt,lt.next)>=0))return!1;lt=lt.nextZ}for(;Xe&&Xe.z>=Re;){if(Xe.x>=de&&Xe.x<=Se&&Xe.y>=he&&Xe.y<=Fe&&Xe!==C&&Xe!==P&&H6(R,te,$,se,G,ae,Xe.x,Xe.y)&&Kc(Xe.prev,Xe,Xe.next)>=0)return!1;Xe=Xe.prevZ}for(;lt&<.z<=Ke;){if(lt.x>=de&<.x<=Se&<.y>=he&<.y<=Fe&<!==C&<!==P&&H6(R,te,$,se,G,ae,lt.x,lt.y)&&Kc(lt.prev,lt,lt.next)>=0)return!1;lt=lt.nextZ}return!0}function Uct(x,d){let m=x;do{const v=m.prev,C=m.next.next;!V3(v,C)&&FCe(v,m,m.next,C)&&W6(v,C)&&W6(C,v)&&(d.push(v.i,m.i,C.i),G6(m),G6(m.next),m=x=C),m=m.next}while(m!==x);return C2(m)}function Vct(x,d,m,v,C,E){let P=x;do{let R=P.next.next;for(;R!==P.prev;){if(P.i!==R.i&&Zct(P,R)){let $=zCe(P,R);return P=C2(P,P.next),$=C2($,$.next),V6(P,d,m,v,C,E,0),void V6($,d,m,v,C,E,0)}R=R.next}P=P.next}while(P!==x)}function Hct(x,d){let m=x.x-d.x;return m===0&&(m=x.y-d.y,m===0)&&(m=(x.next.y-x.y)/(x.next.x-x.x)-(d.next.y-d.y)/(d.next.x-d.x)),m}function Wct(x,d){const m=function(C,E){let P=E;const R=C.x,$=C.y;let G,te=-1/0;if(V3(C,P))return P;do{if(V3(C,P.next))return P.next;if($<=P.y&&$>=P.next.y&&P.next.y!==P.y){const Se=P.x+($-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(Se<=R&&Se>te&&(te=Se,G=P.x=P.x&&P.x>=ae&&R!==P.x&&RCe($G.x||P.x===G.x&&Gct(G,P)))&&(G=P,he=Se)}P=P.next}while(P!==se);return G}(x,d);if(!m)return d;const v=zCe(m,x);return C2(v,v.next),C2(m,m.next)}function Gct(x,d){return Kc(x.prev,x,d.prev)<0&&Kc(d.next,x,x.next)<0}function lpe(x,d,m,v,C){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=(x-m)*C|0)|x<<8))|x<<4))|x<<2))|x<<1))|(d=1431655765&((d=858993459&((d=252645135&((d=16711935&((d=(d-v)*C|0)|d<<8))|d<<4))|d<<2))|d<<1))<<1}function Kct(x){let d=x,m=x;do(d.x=(x-P)*(E-R)&&(x-P)*(v-R)>=(m-P)*(d-R)&&(m-P)*(E-R)>=(C-P)*(v-R)}function H6(x,d,m,v,C,E,P,R){return!(x===P&&d===R)&&RCe(x,d,m,v,C,E,P,R)}function Zct(x,d){return x.next.i!==d.i&&x.prev.i!==d.i&&!function(m,v){let C=m;do{if(C.i!==m.i&&C.next.i!==m.i&&C.i!==v.i&&C.next.i!==v.i&&FCe(C,C.next,m,v))return!0;C=C.next}while(C!==m);return!1}(x,d)&&(W6(x,d)&&W6(d,x)&&function(m,v){let C=m,E=!1;const P=(m.x+v.x)/2,R=(m.y+v.y)/2;do C.y>R!=C.next.y>R&&C.next.y!==C.y&&P<(C.next.x-C.x)*(R-C.y)/(C.next.y-C.y)+C.x&&(E=!E),C=C.next;while(C!==m);return E}(x,d)&&(Kc(x.prev,x,d.prev)||Kc(x,d.prev,d))||V3(x,d)&&Kc(x.prev,x,x.next)>0&&Kc(d.prev,d,d.next)>0)}function Kc(x,d,m){return(d.y-x.y)*(m.x-d.x)-(d.x-x.x)*(m.y-d.y)}function V3(x,d){return x.x===d.x&&x.y===d.y}function FCe(x,d,m,v){const C=TF(Kc(x,d,m)),E=TF(Kc(x,d,v)),P=TF(Kc(m,v,x)),R=TF(Kc(m,v,d));return C!==E&&P!==R||!(C!==0||!MF(x,m,d))||!(E!==0||!MF(x,v,d))||!(P!==0||!MF(m,x,v))||!(R!==0||!MF(m,d,v))}function MF(x,d,m){return d.x<=Math.max(x.x,m.x)&&d.x>=Math.min(x.x,m.x)&&d.y<=Math.max(x.y,m.y)&&d.y>=Math.min(x.y,m.y)}function TF(x){return x>0?1:x<0?-1:0}function W6(x,d){return Kc(x.prev,x,x.next)<0?Kc(x,d,x.next)>=0&&Kc(x,x.prev,d)>=0:Kc(x,d,x.prev)<0||Kc(x,x.next,d)<0}function zCe(x,d){const m=cpe(x.i,x.x,x.y),v=cpe(d.i,d.x,d.y),C=x.next,E=d.prev;return x.next=d,d.prev=x,m.next=C,C.prev=m,v.next=m,m.prev=v,E.next=v,v.prev=E,v}function BCe(x,d,m,v){const C=cpe(x,d,m);return v?(C.next=v.next,C.prev=v,v.next.prev=C,v.next=C):(C.prev=C,C.next=C),C}function G6(x){x.next.prev=x.prev,x.prev.next=x.next,x.prevZ&&(x.prevZ.nextZ=x.nextZ),x.nextZ&&(x.nextZ.prevZ=x.prevZ)}function cpe(x,d,m){return{i:x,x:d,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function K6(x,d){const m=x.length;if(m<=1)return[x];const v=[];let C,E;for(let P=0;P1)for(let P=0;P=tr&&m>=tr}static evaluate(d){if(d.length===0)return new gv;let m=[];for(const $ of d)m.push(...$.portals);if(m.length===0)return new gv;for(const $ of m){const G=$.va,te=$.vb;(gv.isOnBorder(G.x,te.x)||gv.isOnBorder(G.y,te.y))&&($.type="border")}const v=m.filter($=>$.type!=="unevaluated"),C=m.filter($=>$.type==="unevaluated");if(C.length===0)return new gv;C.sort(($,G)=>$.hash===G.hash?$.isTunnel===G.isTunnel?0:$.isTunnel?-1:1:$.hash$.hashE!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new qp(m,{zoom:v,lut:C},E=>E!=="fill-bridge-guard-rail-color")}addVertices(d,m){const v=this.unevalVertices.length;for(let C=0;C=E.min.x&&se.x<=E.max.x&&se.y>=E.min.y&&se.y<=E.max.y||ae.x>=E.min.x&&ae.x<=E.max.x&&ae.y>=E.min.y&&ae.y<=E.max.y||Td(se,ae,R))||this.isOnBorder(se.x,ae.x)||this.isOnBorder(se.y,ae.y))continue;const de=mm.computeEdgeHash(this.unevalVertices[G],this.unevalVertices[te]);let he,Se=this.vertexHashLookup.get(mm.computePosHash(se));Se!=null?he=Se.next:(Se=this.vertexHashLookup.get(mm.computePosHash(ae)),he=Se!=null?Se.prev:de),this.unevalEdges.push({polygonIdx:d,a:G,b:te,hash:de,portalHash:he,isTunnel:C,type:"unevaluated",featureInfo:P})}}addPortalCandidates(d,m,v,C,E){if(m.length===0)return;this.portalPolygons.add(d,{geometry:m,zLevel:E});const P=m[0];this.vertexHashLookup.clear();let R=mm.computeEdgeHash(P[P.length-2],P[P.length-1]);for(let $=0;$({vertexOffset:0,primitiveOffset:this.indexArray.length}),v=ae=>{ae.primitiveLength=this.indexArray.length-ae.primitiveOffset},C=new Xct(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(d.portals,this.unevalEdges);const E=m(),P=m(),R=m(),$=(ae,de)=>{ae.sort((Se,Fe)=>Se.type===de&&Fe.type!==de?-1:Se.type!==de&&Fe.type===de?1:0);const he=ae.findIndex(Se=>Se.type!==de);return he>=0?he:ae.length};let G=0;this.unevalEdges.length>0&&(G=$(this.unevalEdges,"none"),this.constructBridgeStructures(C,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:G},this.tileToMeters)),v(R);const te=m(),se=m();if(this.unevalEdges.length>0){const ae=this.unevalEdges.splice(G),de=$(ae,"tunnel")+G;this.unevalEdges.push(...ae),this.constructTunnelStructures(C,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:G},{min:G,max:de})}v(te),C.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),v(se),C.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),v(P),C.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),v(E),this.maskSegments=bo.simpleSegment(0,se.primitiveOffset,0,se.primitiveLength),this.depthSegments=bo.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=bo.simpleSegment(0,R.primitiveOffset,0,R.primitiveLength),this.renderableTunnelSegments=bo.simpleSegment(0,te.primitiveOffset,0,te.primitiveLength),this.shadowCasterSegments=bo.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength)}update(d,m,v,C,E,P,R,$){this.bridgeProgramConfigurations.updatePaintArrays(d,m,E,v,C,P,R,$),this.tunnelProgramConfigurations.updatePaintArrays(d,m,E,v,C,P,R,$)}upload(d){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=d.createVertexBuffer(this.vertexPositions,zct.members),this.vertexBufferNormal=d.createVertexBuffer(this.vertexNormals,Bct.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(d),this.tunnelProgramConfigurations.upload(d))}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(d,m,v,C,E){const P=(R,$)=>{for(let G=0;G<$.length-1;G++){const te=$[G].featureIndex,se=$[G+1].vertexStart,ae=d.feature(te);R.populatePaintArrays(se,ae,te,{},v,m,C,void 0,E)}};P(this.bridgeProgramConfigurations,this.bridgeFeatureSections),P(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(d,m,v,C,E){const P=new Map;for(let R=C;Roe(Fs,m[Bs].x,m[Bs].y,v[Bs]*$),se=ee(),ae=ee(),de=ee(),he=ee(),Se=ee(),Fe=(Fs,Bs)=>{const Ls=R.get(mm.computePosHash(m[Bs])),Os=Ls.from,ls=Ls.to;if(!Os||!ls)return;te(se,Os),te(ae,Bs),te(de,ls),at(he),et(se,ae)||(Me(Se,ae,se),we(he,Se)),et(de,ae)||(Me(Se,de,ae),ce(he,he,we(Se,Se)));const rs=He(he);return rs>0?_e(Fs,he,1/rs):void 0};let Re=Number.POSITIVE_INFINITY;this.sortSubarray(C,E.min,E.max,(Fs,Bs)=>Fs.featureInfo.featureIndex-Bs.featureInfo.featureIndex);const Ke=ee(),Xe=ee(),lt=ee(),kt=ee(),vt=ee(),At=ee(),zt=ee(),qt=ee(),ss=ee(),Gt=[ee(),ee(),ee(),ee()],ds=[ee(),ee(),ee(),ee()],js=[{coord:new ft(0,0),height:0},{coord:new ft(0,0),height:0}],Ns=(Fs,Bs)=>Fs>Bs;for(let Fs=E.min;FsRe.featureInfo.featureIndex-Ke.featureInfo.featureIndex;this.sortSubarray(C,E.min,E.max,$),this.sortSubarray(C,P.min,P.max,$);const G=Re=>we(Re,Re),te=[{coord:new ft(0,0),height:0},{coord:new ft(0,0),height:0}],se=(Re,Ke)=>ReR.hash===$.hash?$.polygonIdx-R.polygonIdx:$.hash>R.hash?1:-1);let v=0,C=0,E=0,P=m[v].polygonIdx;do C++,(C===m.length||m[v].hash!==m[C].hash)&&((C-v==1||m[C-1].polygonIdx!==P)&&(EG.portalHashte.hash?R++:te.hash>G.portalHash?$++:(G.type=te.type,R++)}}}isOnBorder(d,m){return d<=0&&m<=0||d>=tr&&m>=tr}addFeatureSection(d,m,v,C){return d!==m&&(m=d,v.push({featureIndex:d,vertexStart:C.getVertexCount()}),C.clearVertexLookup()),m}sortSubarray(d,m,v,C){const E=d.slice(m,v);E.sort(C),d.splice(m,E.length,...E)}static computeEdgeHash(d,m){return(d.y===m.y&&d.x>m.x||d.y>m.y)&&([d,m]=[m,d]),BigInt(mm.computePosHash(d))<<32n|BigInt(mm.computePosHash(m))}static computePosHash(d){return((65535&d.x)<<16|65535&d.y)>>>0}}var UCe,VCe={exports:{}},HCe=(UCe||(UCe=1,function(x){function d(_t,Ct){return _t>Ct?1:_t0){var Br=zs+Math.floor(lr/2),Vr={key:Ct[Br],data:us[Br],parent:_t};return Vr.left=C(Vr,Ct,us,zs,Br),Vr.right=C(Vr,Ct,us,Br+1,or),Vr}return null}function E(_t,Ct,us,zs,or){if(!(us>=zs)){for(var lr=_t[us+zs>>1],Br=us-1,Vr=zs+1;;){do Br++;while(or(_t[Br],lr)<0);do Vr--;while(or(_t[Vr],lr)>0);if(Br>=Vr)break;var In=_t[Br];_t[Br]=_t[Vr],_t[Vr]=In,In=Ct[Br],Ct[Br]=Ct[Vr],Ct[Vr]=In}E(_t,Ct,us,Vr,or),E(_t,Ct,Vr+1,zs,or)}}m.prototype.rotateLeft=function(_t){var Ct=_t.right;Ct&&(_t.right=Ct.left,Ct.left&&(Ct.left.parent=_t),Ct.parent=_t.parent),_t.parent?_t===_t.parent.left?_t.parent.left=Ct:_t.parent.right=Ct:this._root=Ct,Ct&&(Ct.left=_t),_t.parent=Ct},m.prototype.rotateRight=function(_t){var Ct=_t.left;Ct&&(_t.left=Ct.right,Ct.right&&(Ct.right.parent=_t),Ct.parent=_t.parent),_t.parent?_t===_t.parent.left?_t.parent.left=Ct:_t.parent.right=Ct:this._root=Ct,Ct&&(Ct.right=_t),_t.parent=Ct},m.prototype._splay=function(_t){for(;_t.parent;){var Ct=_t.parent;Ct.parent?Ct.left===_t&&Ct.parent.left===Ct?(this.rotateRight(Ct.parent),this.rotateRight(Ct)):Ct.right===_t&&Ct.parent.right===Ct?(this.rotateLeft(Ct.parent),this.rotateLeft(Ct)):Ct.left===_t&&Ct.parent.right===Ct?(this.rotateRight(Ct),this.rotateLeft(Ct)):(this.rotateLeft(Ct),this.rotateRight(Ct)):Ct.left===_t?this.rotateRight(Ct):this.rotateLeft(Ct)}},m.prototype.splay=function(_t){for(var Ct,us,zs,or,lr;_t.parent;)(us=(Ct=_t.parent).parent)&&us.parent?((zs=us.parent).left===us?zs.left=_t:zs.right=_t,_t.parent=zs):(_t.parent=null,this._root=_t),or=_t.left,lr=_t.right,_t===Ct.left?(us&&(us.left===Ct?(Ct.right?(us.left=Ct.right,us.left.parent=us):us.left=null,Ct.right=us,us.parent=Ct):(or?(us.right=or,or.parent=us):us.right=null,_t.left=us,us.parent=_t)),lr?(Ct.left=lr,lr.parent=Ct):Ct.left=null,_t.right=Ct,Ct.parent=_t):(us&&(us.right===Ct?(Ct.left?(us.right=Ct.left,us.right.parent=us):us.right=null,Ct.left=us,us.parent=Ct):(lr?(us.left=lr,lr.parent=us):us.left=null,_t.right=us,us.parent=_t)),or?(Ct.right=or,or.parent=Ct):Ct.right=null,_t.left=Ct,Ct.parent=_t)},m.prototype.replace=function(_t,Ct){_t.parent?_t===_t.parent.left?_t.parent.left=Ct:_t.parent.right=Ct:this._root=Ct,Ct&&(Ct.parent=_t.parent)},m.prototype.minNode=function(_t){if(_t===void 0&&(_t=this._root),_t)for(;_t.left;)_t=_t.left;return _t},m.prototype.maxNode=function(_t){if(_t===void 0&&(_t=this._root),_t)for(;_t.right;)_t=_t.right;return _t},m.prototype.insert=function(_t,Ct){var us=this._root,zs=null,or=this._compare;if(this._noDuplicates)for(;us;){if(zs=us,or(us.key,_t)===0)return;us=or(us.key,_t)<0?us.right:us.left}else for(;us;)zs=us,us=or(us.key,_t)<0?us.right:us.left;return us={key:_t,data:Ct,left:null,right:null,parent:zs},zs?or(zs.key,us.key)<0?zs.right=us:zs.left=us:this._root=us,this.splay(us),this._size++,us},m.prototype.find=function(_t){for(var Ct=this._root,us=this._compare;Ct;){var zs=us(Ct.key,_t);if(zs<0)Ct=Ct.right;else{if(!(zs>0))return Ct;Ct=Ct.left}}return null},m.prototype.contains=function(_t){for(var Ct=this._root,us=this._compare;Ct;){var zs=us(_t,Ct.key);if(zs===0)return!0;Ct=zs<0?Ct.left:Ct.right}return!1},m.prototype.remove=function(_t){var Ct=this.find(_t);if(!Ct)return!1;if(this.splay(Ct),Ct.left)if(Ct.right){var us=this.minNode(Ct.right);us.parent!==Ct&&(this.replace(us,us.right),us.right=Ct.right,us.right.parent=us),this.replace(Ct,us),us.left=Ct.left,us.left.parent=us}else this.replace(Ct,Ct.left);else this.replace(Ct,Ct.right);return this._size--,!0},m.prototype.removeNode=function(_t){if(!_t)return!1;if(this.splay(_t),_t.left)if(_t.right){var Ct=this.minNode(_t.right);Ct.parent!==_t&&(this.replace(Ct,Ct.right),Ct.right=_t.right,Ct.right.parent=Ct),this.replace(_t,Ct),Ct.left=_t.left,Ct.left.parent=Ct}else this.replace(_t,_t.left);else this.replace(_t,_t.right);return this._size--,!0},m.prototype.erase=function(_t){var Ct=this.find(_t);if(Ct){this.splay(Ct);var us=Ct.left,zs=Ct.right,or=null;us&&(us.parent=null,or=this.maxNode(us),this.splay(or),this._root=or),zs&&(us?or.right=zs:this._root=zs,zs.parent=or),this._size--}},m.prototype.pop=function(){var _t=this._root,Ct=null;if(_t){for(;_t.left;)_t=_t.left;Ct={key:_t.key,data:_t.data},this.remove(_t.key)}return Ct},m.prototype.next=function(_t){var Ct=_t;if(Ct)if(Ct.right)for(Ct=Ct.right;Ct&&Ct.left;)Ct=Ct.left;else for(Ct=_t.parent;Ct&&Ct.right===_t;)_t=Ct,Ct=Ct.parent;return Ct},m.prototype.prev=function(_t){var Ct=_t;if(Ct)if(Ct.left)for(Ct=Ct.left;Ct&&Ct.right;)Ct=Ct.right;else for(Ct=_t.parent;Ct&&Ct.left===_t;)_t=Ct,Ct=Ct.parent;return Ct},m.prototype.forEach=function(_t){for(var Ct=this._root,us=[],zs=!1,or=0;!zs;)Ct?(us.push(Ct),Ct=Ct.left):us.length>0?(_t(Ct=us.pop(),or++),Ct=Ct.right):zs=!0;return this},m.prototype.range=function(_t,Ct,us,zs){for(var or=[],lr=this._compare,Br=this._root;or.length!==0||Br;)if(Br)or.push(Br),Br=Br.left;else{if(lr((Br=or.pop()).key,Ct)>0)break;if(lr(Br.key,_t)>=0&&us.call(zs,Br))return this;Br=Br.right}return this},m.prototype.keys=function(){for(var _t=this._root,Ct=[],us=[],zs=!1;!zs;)_t?(Ct.push(_t),_t=_t.left):Ct.length>0?(_t=Ct.pop(),us.push(_t.key),_t=_t.right):zs=!0;return us},m.prototype.values=function(){for(var _t=this._root,Ct=[],us=[],zs=!1;!zs;)_t?(Ct.push(_t),_t=_t.left):Ct.length>0?(_t=Ct.pop(),us.push(_t.data),_t=_t.right):zs=!0;return us},m.prototype.at=function(_t){for(var Ct=this._root,us=[],zs=!1,or=0;!zs;)if(Ct)us.push(Ct),Ct=Ct.left;else if(us.length>0){if(Ct=us.pop(),or===_t)return Ct;or++,Ct=Ct.right}else zs=!0;return null},m.prototype.load=function(_t,Ct,us){if(_t===void 0&&(_t=[]),Ct===void 0&&(Ct=[]),us===void 0&&(us=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var zs=_t.length;return us&&E(_t,Ct,0,zs-1,this._compare),this._root=C(null,_t,Ct,0,zs),this._size=zs,this},m.prototype.min=function(){var _t=this.minNode(this._root);return _t?_t.key:null},m.prototype.max=function(){var _t=this.maxNode(this._root);return _t?_t.key:null},m.prototype.isEmpty=function(){return this._root===null},v.size.get=function(){return this._size},m.createTree=function(_t,Ct,us,zs,or){return new m(us,or).load(_t,Ct,zs)},Object.defineProperties(m.prototype,v);var P=0,R=1,$=2,G=3,te=0,se=1,ae=2,de=3;function he(_t,Ct,us){Ct===null?(_t.inOut=!1,_t.otherInOut=!0):(_t.isSubject===Ct.isSubject?(_t.inOut=!Ct.inOut,_t.otherInOut=Ct.otherInOut):(_t.inOut=!Ct.otherInOut,_t.otherInOut=Ct.isVertical()?!Ct.inOut:Ct.inOut),Ct&&(_t.prevInResult=!Se(Ct,us)||Ct.isVertical()?Ct.prevInResult:Ct));var zs=Se(_t,us);_t.resultTransition=zs?function(or,lr){var Br,Vr=!or.inOut,In=!or.otherInOut;switch(lr){case te:Br=Vr&&In;break;case se:Br=Vr||In;break;case de:Br=Vr^In;break;case ae:Br=or.isSubject?Vr&&!In:In&&!Vr}return Br?1:-1}(_t,us):0}function Se(_t,Ct){switch(_t.type){case P:switch(Ct){case te:return!_t.otherInOut;case se:return _t.otherInOut;case ae:return _t.isSubject&&_t.otherInOut||!_t.isSubject&&!_t.otherInOut;case de:return!0}break;case $:return Ct===te||Ct===se;case G:return Ct===ae;case R:return!1}return!1}var Fe=function(_t,Ct,us,zs,or){this.left=Ct,this.point=_t,this.otherEvent=us,this.isSubject=zs,this.type=or||P,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},Re={inResult:{configurable:!0}};function Ke(_t,Ct){return _t[0]===Ct[0]&&_t[1]===Ct[1]}Fe.prototype.isBelow=function(_t){var Ct=this.point,us=this.otherEvent.point;return this.left?(Ct[0]-_t[0])*(us[1]-_t[1])-(us[0]-_t[0])*(Ct[1]-_t[1])>0:(us[0]-_t[0])*(Ct[1]-_t[1])-(Ct[0]-_t[0])*(us[1]-_t[1])>0},Fe.prototype.isAbove=function(_t){return!this.isBelow(_t)},Fe.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Re.inResult.get=function(){return this.resultTransition!==0},Fe.prototype.clone=function(){var _t=new Fe(this.point,this.left,this.otherEvent,this.isSubject,this.type);return _t.contourId=this.contourId,_t.resultTransition=this.resultTransition,_t.prevInResult=this.prevInResult,_t.isExteriorRing=this.isExteriorRing,_t.inOut=this.inOut,_t.otherInOut=this.otherInOut,_t},Object.defineProperties(Fe.prototype,Re);var Xe=11102230246251565e-32,lt=134217729,kt=(3+8*Xe)*Xe;function vt(_t,Ct,us,zs,or){var lr,Br,Vr,In,Kn=Ct[0],Qn=zs[0],xa=0,an=0;Qn>Kn==Qn>-Kn?(lr=Kn,Kn=Ct[++xa]):(lr=Qn,Qn=zs[++an]);var vn=0;if(xa<_t&&anKn==Qn>-Kn?(Vr=lr-((Br=Kn+lr)-Kn),Kn=Ct[++xa]):(Vr=lr-((Br=Qn+lr)-Qn),Qn=zs[++an]),lr=Br,Vr!==0&&(or[vn++]=Vr);xa<_t&&anKn==Qn>-Kn?(Vr=lr-((Br=lr+Kn)-(In=Br-lr))+(Kn-In),Kn=Ct[++xa]):(Vr=lr-((Br=lr+Qn)-(In=Br-lr))+(Qn-In),Qn=zs[++an]),lr=Br,Vr!==0&&(or[vn++]=Vr);for(;xa<_t;)Vr=lr-((Br=lr+Kn)-(In=Br-lr))+(Kn-In),Kn=Ct[++xa],lr=Br,Vr!==0&&(or[vn++]=Vr);for(;an0!=xa>0)return an;var vn=Math.abs(Qn+xa);return Math.abs(an)>=zt*vn?an:-function(Va,Za,Ya,_i,Ri,Ei,ri){var hi,Zn,Sa,mo,sn,ga,Li,Ui,Zi,el,Hi,rn,jo,wi,ao,Vl,Ec,wl,jl=Va-Ri,uc=Ya-Ri,ph=Za-Ei,Wi=_i-Ei;Gt[0]=(ao=(Ui=jl-(Li=(ga=lt*jl)-(ga-jl)))*(el=Wi-(Zi=(ga=lt*Wi)-(ga-Wi)))-((wi=jl*Wi)-Li*Zi-Ui*Zi-Li*el))-((Hi=ao-(Ec=(Ui=ph-(Li=(ga=lt*ph)-(ga-ph)))*(el=uc-(Zi=(ga=lt*uc)-(ga-uc)))-((Vl=ph*uc)-Li*Zi-Ui*Zi-Li*el)))+(sn=ao-Hi))+(sn-Ec),Gt[1]=(jo=wi-((rn=wi+Hi)-(sn=rn-wi))+(Hi-sn))-((Hi=jo-Vl)+(sn=jo-Hi))+(sn-Vl),Gt[2]=rn-((wl=rn+Hi)-(sn=wl-rn))+(Hi-sn),Gt[3]=wl;var Wo=function(By,Ad){for(var $u=Ad[0],fm=1;fm<4;fm++)$u+=Ad[fm];return $u}(0,Gt),tl=qt*ri;if(Wo>=tl||-Wo>=tl||(hi=Va-(jl+(sn=Va-jl))+(sn-Ri),Sa=Ya-(uc+(sn=Ya-uc))+(sn-Ri),Zn=Za-(ph+(sn=Za-ph))+(sn-Ei),mo=_i-(Wi+(sn=_i-Wi))+(sn-Ei),hi===0&&Zn===0&&Sa===0&&mo===0)||(tl=ss*ri+kt*Math.abs(Wo),(Wo+=jl*mo+Wi*hi-(ph*Sa+uc*Zn))>=tl||-Wo>=tl))return Wo;Fs[0]=(ao=(Ui=hi-(Li=(ga=lt*hi)-(ga-hi)))*(el=Wi-(Zi=(ga=lt*Wi)-(ga-Wi)))-((wi=hi*Wi)-Li*Zi-Ui*Zi-Li*el))-((Hi=ao-(Ec=(Ui=Zn-(Li=(ga=lt*Zn)-(ga-Zn)))*(el=uc-(Zi=(ga=lt*uc)-(ga-uc)))-((Vl=Zn*uc)-Li*Zi-Ui*Zi-Li*el)))+(sn=ao-Hi))+(sn-Ec),Fs[1]=(jo=wi-((rn=wi+Hi)-(sn=rn-wi))+(Hi-sn))-((Hi=jo-Vl)+(sn=jo-Hi))+(sn-Vl),Fs[2]=rn-((wl=rn+Hi)-(sn=wl-rn))+(Hi-sn),Fs[3]=wl;var Oh=vt(4,Gt,4,Fs,ds);Fs[0]=(ao=(Ui=jl-(Li=(ga=lt*jl)-(ga-jl)))*(el=mo-(Zi=(ga=lt*mo)-(ga-mo)))-((wi=jl*mo)-Li*Zi-Ui*Zi-Li*el))-((Hi=ao-(Ec=(Ui=ph-(Li=(ga=lt*ph)-(ga-ph)))*(el=Sa-(Zi=(ga=lt*Sa)-(ga-Sa)))-((Vl=ph*Sa)-Li*Zi-Ui*Zi-Li*el)))+(sn=ao-Hi))+(sn-Ec),Fs[1]=(jo=wi-((rn=wi+Hi)-(sn=rn-wi))+(Hi-sn))-((Hi=jo-Vl)+(sn=jo-Hi))+(sn-Vl),Fs[2]=rn-((wl=rn+Hi)-(sn=wl-rn))+(Hi-sn),Fs[3]=wl;var Hl=vt(Oh,ds,4,Fs,js);Fs[0]=(ao=(Ui=hi-(Li=(ga=lt*hi)-(ga-hi)))*(el=mo-(Zi=(ga=lt*mo)-(ga-mo)))-((wi=hi*mo)-Li*Zi-Ui*Zi-Li*el))-((Hi=ao-(Ec=(Ui=Zn-(Li=(ga=lt*Zn)-(ga-Zn)))*(el=Sa-(Zi=(ga=lt*Sa)-(ga-Sa)))-((Vl=Zn*Sa)-Li*Zi-Ui*Zi-Li*el)))+(sn=ao-Hi))+(sn-Ec),Fs[1]=(jo=wi-((rn=wi+Hi)-(sn=rn-wi))+(Hi-sn))-((Hi=jo-Vl)+(sn=jo-Hi))+(sn-Vl),Fs[2]=rn-((wl=rn+Hi)-(sn=wl-rn))+(Hi-sn),Fs[3]=wl;var Yf=vt(Hl,js,4,Fs,Ns);return Ns[Yf-1]}(or,lr,Br,Vr,In,Kn,vn)}(_t[0],_t[1],Ct[0],Ct[1],us[0],us[1]);return zs>0?-1:zs<0?1:0}function Ls(_t,Ct){var us=_t.point,zs=Ct.point;return us[0]>zs[0]?1:us[0]zs[1]?1:-1:function(or,lr,Br,Vr){return or.left!==lr.left?or.left?1:-1:Bs(Br,or.otherEvent.point,lr.otherEvent.point)!==0?or.isBelow(lr.otherEvent.point)?-1:1:!or.isSubject&&lr.isSubject?1:-1}(_t,Ct,us)}function Os(_t,Ct,us){var zs=new Fe(Ct,!1,_t,_t.isSubject),or=new Fe(Ct,!0,_t.otherEvent,_t.isSubject);return Ke(_t.point,_t.otherEvent.point)&&console.warn("what is that, a collapsed segment?",_t),zs.contourId=or.contourId=_t.contourId,Ls(or,_t.otherEvent)>0&&(_t.otherEvent.left=!0,or.left=!1),_t.otherEvent.otherEvent=or,_t.otherEvent=zs,us.push(or),us.push(zs),us}function ls(_t,Ct){return _t[0]*Ct[1]-_t[1]*Ct[0]}function rs(_t,Ct){return _t[0]*Ct[0]+_t[1]*Ct[1]}function Rs(_t,Ct,us){var zs=function(In,Kn,Qn,xa,an){var vn=[Kn[0]-In[0],Kn[1]-In[1]],Va=[xa[0]-Qn[0],xa[1]-Qn[1]];function Za(ga,Li,Ui){return[ga[0]+Li*Ui[0],ga[1]+Li*Ui[1]]}var Ya=[Qn[0]-In[0],Qn[1]-In[1]],_i=ls(vn,Va),Ri=_i*_i,Ei=rs(vn,vn);if(Ri>0){var ri=ls(Ya,Va)/_i;if(ri<0||ri>1)return null;var hi=ls(Ya,vn)/_i;return hi<0||hi>1?null:ri===0||ri===1?[Za(In,ri,vn)]:hi===0||hi===1?[Za(Qn,hi,Va)]:[Za(In,ri,vn)]}if((Ri=(_i=ls(Ya,vn))*_i)>0)return null;var Zn=rs(vn,Ya)/Ei,Sa=Zn+rs(vn,Va)/Ei,mo=Math.min(Zn,Sa),sn=Math.max(Zn,Sa);return mo<=1&&sn>=0?mo===1?[Za(In,mo>0?mo:0,vn)]:sn===0?[Za(In,sn<1?sn:1,vn)]:[Za(In,mo>0?mo:0,vn),Za(In,sn<1?sn:1,vn)]:null}(_t.point,_t.otherEvent.point,Ct.point,Ct.otherEvent.point),or=zs?zs.length:0;if(or===0||or===1&&(Ke(_t.point,Ct.point)||Ke(_t.otherEvent.point,Ct.otherEvent.point))||or===2&&_t.isSubject===Ct.isSubject)return 0;if(or===1)return Ke(_t.point,zs[0])||Ke(_t.otherEvent.point,zs[0])||Os(_t,zs[0],us),Ke(Ct.point,zs[0])||Ke(Ct.otherEvent.point,zs[0])||Os(Ct,zs[0],us),1;var lr=[],Br=!1,Vr=!1;return Ke(_t.point,Ct.point)?Br=!0:Ls(_t,Ct)===1?lr.push(Ct,_t):lr.push(_t,Ct),Ke(_t.otherEvent.point,Ct.otherEvent.point)?Vr=!0:Ls(_t.otherEvent,Ct.otherEvent)===1?lr.push(Ct.otherEvent,_t.otherEvent):lr.push(_t.otherEvent,Ct.otherEvent),Br&&Vr||Br?(Ct.type=R,_t.type=Ct.inOut===_t.inOut?$:G,Br&&!Vr&&Os(lr[1].otherEvent,lr[0].point,us),2):Vr?(Os(lr[0],lr[1].point,us),3):lr[0]!==lr[3].otherEvent?(Os(lr[0],lr[1].point,us),Os(lr[1],lr[2].point,us),3):(Os(lr[0],lr[1].point,us),Os(lr[3].otherEvent,lr[2].point,us),3)}function sr(_t,Ct){if(_t===Ct)return 0;if(Bs(_t.point,_t.otherEvent.point,Ct.point)!==0||Bs(_t.point,_t.otherEvent.point,Ct.otherEvent.point)!==0)return Ke(_t.point,Ct.point)?_t.isBelow(Ct.otherEvent.point)?-1:1:_t.point[0]===Ct.point[0]?_t.point[1]Ct.contourId?1:-1:Ls(_t,Ct)===1?1:-1}var Vs=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function zr(_t,Ct,us,zs){var or,lr=_t+1,Br=Ct[_t].point,Vr=Ct.length;for(lrzs;)lr--;return lr}Vs.prototype.isExterior=function(){return this.holeOf==null};var mr=Tr,_r=Tr;function Tr(_t,Ct){if(!(this instanceof Tr))return new Tr(_t,Ct);if(this.data=_t||[],this.length=this.data.length,this.compare=Ct||ta,this.length>0)for(var us=(this.length>>1)-1;us>=0;us--)this._down(us)}function ta(_t,Ct){return _tCt?1:0}Tr.prototype={push:function(_t){this.data.push(_t),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var _t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),_t}},peek:function(){return this.data[0]},_up:function(_t){for(var Ct=this.data,us=this.compare,zs=Ct[_t];_t>0;){var or=_t-1>>1,lr=Ct[or];if(us(zs,lr)>=0)break;Ct[_t]=lr,_t=or}Ct[_t]=zs},_down:function(_t){for(var Ct=this.data,us=this.compare,zs=this.length>>1,or=Ct[_t];_t=0)break;Ct[_t]=Vr,_t=lr}Ct[_t]=or}},mr.default=_r;var Zs=Math.max,Ar=Math.min,_n=0;function ja(_t,Ct,us,zs,or,lr){var Br,Vr,In,Kn,Qn,xa;for(Br=0,Vr=_t.length-1;Br0?xa.left=!0:Qn.left=!0;var an=In[0],vn=In[1];or[0]=Ar(or[0],an),or[1]=Ar(or[1],vn),or[2]=Zs(or[2],an),or[3]=Zs(or[3],vn),zs.push(Qn),zs.push(xa)}}var Ca=[];function $n(_t,Ct,us){typeof _t[0][0][0]=="number"&&(_t=[_t]),typeof Ct[0][0][0]=="number"&&(Ct=[Ct]);var zs=function(vn,Va,Za){var Ya=null;return vn.length*Va.length==0&&(Za===te?Ya=Ca:Za===ae?Ya=vn:Za!==se&&Za!==de||(Ya=vn.length===0?Va:vn)),Ya}(_t,Ct,us);if(zs)return zs===Ca?null:zs;var or=[1/0,1/0,-1/0,-1/0],lr=[1/0,1/0,-1/0,-1/0],Br=function(vn,Va,Za,Ya,_i){var Ri,Ei,ri,hi,Zn,Sa,mo=new mr(null,Ls);for(ri=0,hi=vn.length;riYa[2]||Ya[0]>Za[2]||Za[1]>Ya[3]||Ya[1]>Za[3])&&(_i===te?Ri=Ca:_i===ae?Ri=vn:_i!==se&&_i!==de||(Ri=vn.concat(Va))),Ri}(_t,Ct,or,lr,us))return zs===Ca?null:zs;for(var Vr=function(vn){var Va,Za,Ya=function(ri){var hi,Zn,Sa,mo,sn=[];for(Zn=0,Sa=ri.length;Zn0){var Hi=ga[el];if(Hi.holeOf!=null){var rn=Hi.holeOf;ga[rn].holeIds.push(Li),Ui.holeOf=rn,Ui.depth=ga[el].depth}else ga[el].holeIds.push(Li),Ui.holeOf=el,Ui.depth=ga[el].depth+1}else Ui.holeOf=null,Ui.depth=ga[el].depth}else Ui.holeOf=null,Ui.depth=0;return Ui}(Ya[Va],Ri,ri),Zn=function(sn){_i[sn]=!0,sn=Ya.length)&&Ya[Sa];);Ri.push(hi)}};for(Va=0,Za=Ya.length;Vamo||Ri===ae&&sn.point[0]>Ya[2])break;if(sn.left){ri=Ei=Zn.insert(sn),Ei=Ei!==(hi=Zn.minNode())?Zn.prev(Ei):null,ri=Zn.next(ri);var ga=Ei?Ei.key:null;if(he(sn,ga,Ri),ri&&Rs(sn,ri.key,vn)===2&&(he(sn,ga,Ri),he(ri.key,sn,Ri)),Ei&&Rs(Ei.key,sn,vn)===2){var Li=Ei;he(ga,(Li=Li!==hi?Zn.prev(Li):null)?Li.key:null,Ri),he(sn,ga,Ri)}}else ri=Ei=Zn.find(sn=sn.otherEvent),Ei&&ri&&(Ei=Ei!==hi?Zn.prev(Ei):null,ri=Zn.next(ri),Zn.remove(sn),ri&&Ei&&Rs(Ei.key,ri.key,vn))}return Sa}(Br,0,0,or,lr,us)),In=[],Kn=0;Kn * @license MIT * @preserve */function AF(x,d,m,v){const C=[],E=v===0?(P,R,$,G,te,se)=>{P.push(new ft(se,$+(se-R)/(G-R)*(te-$)))}:(P,R,$,G,te,se)=>{P.push(new ft(R+(se-$)/(te-$)*(G-R),se))};for(const P of x){const R=[];for(const $ of P){if($.length<=2)continue;const G=[];for(let ae=0;ae<$.length-1;ae++){const de=$[ae].x,he=$[ae].y,Se=$[ae+1].x,Fe=$[ae+1].y,Re=v===0?de:he,Ke=v===0?Se:Fe;Red&&E(G,de,he,Se,Fe,d):Re>m?Ke=d&&E(G,de,he,Se,Fe,d),Ke>m&&Re<=m&&E(G,de,he,Se,Fe,m)}let te=$[$.length-1];const se=v===0?te.x:te.y;se>=d&&se<=m&&G.push(te),G.length&&(te=G[G.length-1],G[0].x===te.x&&G[0].y===te.y||G.push(G[0]),R.push(G))}R.length&&C.push(R)}return C}function Qct(x,d){const m=hpe(x),v=hpe([d]),C=HCe.intersection(m,v);return C==null?[]:WCe(C)}function Jct(x,d){let v=hpe(x,65536);const C=[];for(;d.valid();d.next()){const[E,P]=d.get(),R=E.x*65536,$=E.y*65536,G=P.x*65536,te=P.y*65536,se=G-R,ae=te-$,de=Math.hypot(se,ae);if(de===0)continue;const he=Math.trunc(ae/de*3),Se=-Math.trunc(se/de*3);C.push([[[R,$],[G,te],[G+he,te+Se],[R+he,$+Se],[R,$]]])}return C.length>0&&(v=HCe.diff(v,C)),WCe(v,1/65536)}function hpe(x,d=1){return[x.map(m=>m.map(v=>[v.x*d,v.y*d]))]}function WCe(x,d=1){return x.map(m=>m.map((v,C)=>{const E=v.map(P=>new ft(P[0]*d,P[1]*d).round());return C>0&&E.reverse(),E}))}class mpe{constructor(d,m){this.layoutVertexArray=new Iy,this.indexArray=new $l,this.lineIndexArray=new um,this.triangleSegments=new bo,this.lineSegments=new bo,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new lg)}update(d,m,v,C,E,P,R,$){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R,$)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,Rct.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.lineIndexBuffer=d.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=d.createVertexBuffer(this.elevatedLayoutVertexArray,Fct.members))),this.programConfigurations.upload(d),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(d,m,v,C,E,P,R){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,m,v,C,E,P,void 0,R)}}class ppe{constructor(d){this.zoom=d.zoom,this.pixelRatio=d.pixelRatio,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=d.lut,this.bufferData=new mpe(d,!1),this.elevationBufferData=new mpe(d,!0),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=d.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=d.sourceLayerIndex,this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){this.hasPattern=dpe("fill",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("fill-sort-key"),P=[];for(const{feature:R,id:$,index:G,sourceLayerIndex:te}of d){const se=this.layers[0]._featureFilter.needGeometry,ae=Wt(R,se);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ae,v))continue;const de=E?E.evaluate(ae,{},v,m.availableImages):void 0,he={id:$,properties:R.properties,type:R.type,sourceLayerIndex:te,index:G,geometry:se?ae.geometry:Ot(R,v,C),patterns:{},sortKey:de};P.push(he)}E&&P.sort((R,$)=>R.sortKey-$.sortKey);for(const R of P){const{geometry:$,index:G,sourceLayerIndex:te}=R;if(this.hasPattern){const se=upe("fill",this.layers,R,this.zoom,this.pixelRatio,m);this.patternFeatures.push(se)}else this.addFeature(R,$,G,v,{},m.availableImages,m.brightness,m.elevationFeatures);m.featureIndex.insert(d[G].feature,$,G,te,this.index)}}update(d,m,v,C,E,P,R){this.bufferData.update(d,m,v,C,E,P,R,this.worldview),this.elevationBufferData.update(d,m,v,C,E,P,R,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(d,m,v,C,E,P,R,this.worldview)}addFeatures(d,m,v,C,E,P){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,m,v,C,P,d.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(d){this.bufferData.upload(d),this.elevationBufferData.upload(d),this.elevatedStructures&&this.elevatedStructures.upload(d)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(d,m,v,C,E,P=[],R,$){const G=K6(m,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(d,G,C,v,$):this.addGeometry(G,this.bufferData),this.bufferData.populatePaintArrays(d,v,E,P,C,R,this.worldview),this.elevationBufferData.populatePaintArrays(d,v,E,P,C,R,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(d,m,v,C,E){this.elevatedStructures&&(this.elevatedStructures.construct(d),this.elevatedStructures.populatePaintArrays(m,v,C,E,this.worldview))}addElevatedRoadFeature(d,m,v,C,E){const P=new Array,R=di.getElevationFeature(d,E);if(!R)return void this.addGeometry(m,this.bufferData);{const G=this.clipPolygonsToTile(m,1);G.length>0&&P.push({polygons:G,elevationFeature:R,elevationTileID:v})}const $={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(d,{},v),featureIndex:C};for(const G of P)if(G.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new mm(G.elevationTileID,this.layers,this.zoom,this.lut));const se=G.elevationFeature.isTunnel();let ae=0;d.properties.hasOwnProperty(Jt)&&(ae=+d.properties[Jt]);for(const de of G.polygons)this.elevatedStructures.addPortalCandidates(G.elevationFeature.id,de,se,G.elevationFeature,ae)}G.elevationFeature.constantHeight==null&&(G.polygons=this.prepareElevatedPolygons(G.polygons,G.elevationFeature,G.elevationTileID));const te=new Ci(v,G.elevationTileID);this.addElevatedGeometry(G.polygons,te,G.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,C,$)}}addElevatedGeometry(d,m,v,C,E,P){const R={elevation:v,elevationSampler:m,bias:C,index:E,featureInfo:P},[$,G]=this.addGeometry(d,this.elevationBufferData,R);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:$,max:G}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,$),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,G))}addGeometry(d,m,v){let C=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,P=null;v&&(P=v.elevationSampler.constantElevation(v.elevation,v.bias),P!=null&&(C=P,E=P));const R=($,G,te)=>{if(v!=null)if(G.push($),P!=null)m.elevatedLayoutVertexArray.emplaceBack(P),te.push(P);else{const se=v.elevationSampler.pointElevation($,v.elevation,v.bias);m.elevatedLayoutVertexArray.emplaceBack(se),te.push(se),C=Math.min(C,se),E=Math.max(E,se)}};for(const $ of d){let G=0;for(const Xe of $)G+=Xe.length;const te=m.triangleSegments.prepareSegment(G,m.layoutVertexArray,m.indexArray),se=te.vertexLength,ae=[],de=[],he=[],Se=[],Fe=[],Re=m.layoutVertexArray.length;for(const Xe of $){if(Xe.length===0)continue;Xe!==$[0]&&de.push(ae.length/2);const lt=m.lineSegments.prepareSegment(Xe.length,m.layoutVertexArray,m.lineIndexArray),kt=lt.vertexLength;v&&Fe.push(m.layoutVertexArray.length-Re),R(Xe[0],he,Se),m.layoutVertexArray.emplaceBack(Xe[0].x,Xe[0].y),m.lineIndexArray.emplaceBack(kt+Xe.length-1,kt),ae.push(Xe[0].x),ae.push(Xe[0].y);for(let vt=1;vt0&&v&&this.elevationMode==="hd-road-base"){const Xe=v.elevation.isTunnel(),lt=v.elevation.safeArea,kt=this.elevatedStructures.addVertices(he,Se);this.elevatedStructures.addTriangles(Ke,kt,Xe);const vt=Fe.length;if(vt>0){for(let At=0;At=v&&de.max.x<=E&&de.min.y>=C&&de.max.y<=P?$:G).push(ae)}if($.length===d.length)return d;const te=[new ft(v,C),new ft(E,C),new ft(E,P),new ft(v,P),new ft(v,C)],se=$;for(const ae of G)se.push(...Qct(ae,te));return se}}let GCe,KCe,ZCe,YCe;kr(ppe,"FillBucket",{omit:["layers","patternFeatures"]}),kr(mpe,"FillBufferData"),kr(mm,"ElevatedStructures");class EF{constructor(d,m,v,C){if(this.triangleCount=m.length/3,this.min=new ft(0,0),this.max=new ft(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||d.length===0)return;const[E,P]=[d[0].clone(),d[0].clone()];for(let se=1;sese.cellIdx-ae.cellIdx||se.triIdx-ae.triIdx);let te=0;for(;tethis.max.x||this.min.x>d.x||d.y>this.max.y||this.min.y>d.y)return;const v=Fy(d.x-this.min.x,this.xScale,this.cellsX),C=Fy(d.y-this.min.y,this.yScale,this.cellsY),E=this.cells[C*this.cellsX+v];if(E){this._lazyInitLookup();for(let P=0;Pthis.max.x||this.min.x>m.x||d.y>this.max.y||this.min.y>m.y)return;this._lazyInitLookup();const C=Fy(d.x-this.min.x,this.xScale,this.cellsX),E=Fy(m.x-this.min.x,this.xScale,this.cellsX),P=Fy(d.y-this.min.y,this.yScale,this.cellsY),R=Fy(m.y-this.min.y,this.yScale,this.cellsY);for(let $=P;$<=R;$++)for(let G=C;G<=E;G++){const te=this.cells[$*this.cellsX+G];if(te)for(let se=0;sem.fqid),this.index=d.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.footprints=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){for(const v of this.footprints)m.push({footprint:v,id:d})}updateAppearances(d,m,v,C){}populate(d,m,v,C){const E=[];for(const{feature:P,id:R,index:$,sourceLayerIndex:G}of d){const te=this.layers[0]._featureFilter.needGeometry,se=Wt(P,te);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),se,v))continue;const ae={id:R,properties:P.properties,type:P.type,sourceLayerIndex:G,index:$,geometry:te?se.geometry:Ot(P,v,C),patterns:{}};E.push(ae)}for(const P of E){const{geometry:R,index:$,sourceLayerIndex:G}=P;this.addFeature(P,R,$,v,{},m.availableImages,m.brightness),m.featureIndex.insert(d[$].feature,R,$,G,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(d){}update(d,m,v,C,E,P,R){}destroy(){}addFeature(d,m,v,C,E,P=[],R){for(const $ of K6(m,2)){const G=[],te=[],se=[],ae=new ft(1/0,1/0),de=new ft(-1/0,-1/0);for(const Fe of $)if(Fe.length!==0){Fe!==$[0]&&se.push(te.length/2);for(let Re=0;ReP===C)===void 0}(v,x.clipScope)}function PF(x,d){return x.x-d.x||x.y-d.y}function e3e(x,d){return PF(x.min,d.min)===0&&PF(x.max,d.max)===0}function fpe(x,d){return!(x.min.x>d.max.x||x.max.xd.max.y||x.max.ynew ft(($.x+E.x*tr)*R-P.x*tr,($.y+E.y*tr)*R-P.y*tr))}return xpe(m,C,x.indices,0,x.indices.length,0,0)}function r3e(x,d,m,v){const C=Math.pow(2,v.z-m.z);return new ft((x+m.x*tr)*C-v.x*tr,(d+m.y*tr)*C-v.y*tr)}function n3e(x,d){const m=[];d.grid.queryPoint(x,m);const v=d.indices,C=d.vertices;for(let E=0;E0&&(v.length>1&&m.push(v),v=[])}return v.length>1&&m.push(v),m}const ype=Ht.types,cdt=["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"],ddt=["fill-extrusion-flood-light-ground-radius"],udt=Math.pow(2,13),hdt=Math.pow(2,15)-1,i3e=new ft(0,1),yv=2147483648,o3e=7,l3e=450;function Y6(x,d,m,v,C,E,P,R){x.emplaceBack((d<<1)+P,(m<<1)+E,(Math.floor(v*udt)<<1)+C,Math.round(R))}function X6(x,d,m){x.emplaceBack(d.x*tr,d.y*tr,m?1:0)}function LF(x,d,m,v,C,E){x.emplaceBack(d.x,d.y,(m.x<<1)+v,(m.y<<1)+C,E)}function Q6(x,d,m){x.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}class c3e{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class d3e{constructor(){this.centroidXY=new ft(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 ft(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new ft(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new ft(this.max.x-this.min.x,this.max.y-this.min.y)}}class u3e{constructor(){this.acc=new ft(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(d,m){d.min.x===Number.MAX_VALUE&&(d.min.x=d.max.x=m.x,d.min.y=d.max.y=m.y)}appendEdge(d,m,v){this.accCount++,this.acc._add(m);let C=!!this.borders;m.xd.max.x&&(d.max.x=m.x,C=!0),m.yd.max.y&&(d.max.y=m.y,C=!0),((m.x===0||m.x===tr)&&m.x===v.x)!=((m.y===0||m.y===tr)&&m.y===v.y)&&this.processBorderOverlap(m,v),C&&this.checkBorderIntersection(m,v)}checkBorderIntersection(d,m){m.x<0!=d.x<0&&this.addBorderIntersection(0,Zr(m.y,d.y,(0-m.x)/(d.x-m.x))),m.x>tr!=d.x>tr&&this.addBorderIntersection(1,Zr(m.y,d.y,(tr-m.x)/(d.x-m.x))),m.y<0!=d.y<0&&this.addBorderIntersection(2,Zr(m.x,d.x,(0-m.y)/(d.y-m.y))),m.y>tr!=d.y>tr&&this.addBorderIntersection(3,Zr(m.x,d.x,(tr-m.y)/(d.y-m.y)))}addBorderIntersection(d,m){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const v=this.borders[d];mv[1]&&(v[1]=m)}processBorderOverlap(d,m){if(d.x===m.x){if(d.y===m.y)return;const v=d.x===0?0:1;this.addBorderIntersection(v,m.y),this.addBorderIntersection(v,d.y)}else{const v=d.y===0?2:3;this.addBorderIntersection(v,m.x),this.addBorderIntersection(v,d.x)}}centroid(){return this.accCount===0?new ft(0,0):new ft(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((d,m)=>d+ +(m[0]!==Number.MAX_VALUE),0):0}}function h3e(x,d){const m=x.add(d)._unit(),v=ke(x.x*m.x+x.y*m.y,-1,1);var C,E,P;return C=Math.acos(v),Math.min(4,Math.max(-4,Math.tan(C)))/4*hdt*((E=x).x*(P=d).y-E.y*P.x<0?-1:1)}const mdt=[x=>x.x<0,x=>x.x>tr,x=>x.y<0,x=>x.y>tr];function pdt(x,d,m,v){const C=[4];if(v===0)return C;m._mult(v);const E=x.sub(m),P=d.sub(m),R=[x,d,E,P];for(let $=0;$<4;$++)for(const G of R)if(mdt[$](G)){C.push($);break}return C}class vpe{constructor(d){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new N6,this.indexArray=new $l,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut},m=>ddt.includes(m)),this._segments=new bo,this.hiddenByLandmarkVertexArray=new E3,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new bo}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(d,m,v,C=!1){const E=d.length;if(E>2){let P=Math.max(0,this._segments.get().length-1);const R=this._segments._prepareSegment(4*E,this.vertexArray.length,2*this._segmentToGroundQuads[P].length);let $;P!==this._segments.get().length-1&&(P++,this._segmentToGroundQuads[P]=[],this._segmentToRegionTriCounts[P]=[0,0,0,0,0]);{const G=d[0],te=d[1];$=h3e(G.sub(d[E-1])._perp()._unit(),te.sub(G)._perp()._unit())}for(let G=0;GC.region-E.region);for(let v=0;v$+G,0);let R=0;for(let $=0;$<=4;$++){const G=P[$];if(G!==0){let te=this.regionSegments[$];te||(te=this.regionSegments[$]=new bo);const se={vertexOffset:E.vertexOffset,primitiveOffset:E.primitiveOffset+R,vertexLength:E.vertexLength,primitiveLength:G};te.get().push(se)}R+=G}for(let $=0;$0?this.hiddenByLandmarkVertexBuffer=d.createVertexBuffer(this.hiddenByLandmarkVertexArray,adt.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 d=0;d<=4;d++){const m=this.regionSegments[d];m&&m.destroy()}}}}class DF{constructor(d){this.zoom=d.zoom,this.canonical=d.canonical,this.overscaling=d.overscaling,this.layers=d.layers,this.pixelRatio=d.pixelRatio,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=d.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new $l,this.footprintVertices=new Iy,this.footprintSegments=[],this.layoutVertexArray=new pb,this.centroidVertexArray=new wF,this.wallVertexArray=new y2,this.indexArray=new $l,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut},m=>cdt.includes(m)),this.segments=new bo,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new vpe(d),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){this.features=[],this.hasPattern=dpe("fill-extrusion",this.layers,this.pixelRatio,m),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Ve(v),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(const{feature:E,id:P,index:R,sourceLayerIndex:$}of d){const G=this.layers[0]._featureFilter.needGeometry,te=Wt(E,G);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),te,v))continue;const se={id:P,sourceLayerIndex:$,index:R,geometry:G?te.geometry:Ot(E,v,C),properties:E.properties,type:E.type,patterns:{}},ae=this.layoutVertexArray.length,de=ype[se.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:upe("fill-extrusion",this.layers,se,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const he of se.geometry)for(const Se of a3e(he,de))this.addFeature(E.id,se,[Se],R,v,{},m.availableImages,C,m.brightness);else this.addFeature(E.id,se,se.geometry,R,v,{},m.availableImages,C,m.brightness);m.featureIndex.insert(E,se.geometry,R,$,this.index,ae)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(d,m,v,C,E,P){for(const{featureId:R,feature:$}of this.features){const G=ype[$.type]==="Polygon",{geometry:te}=$;if(this.wallMode)for(const se of te)for(const ae of a3e(se,G))this.addFeature(R,$,[ae],$.index,m,v,C,E,P);else this.addFeature(R,$,te,$.index,m,v,C,E,P)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(d,m,v,C,E,P,R){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R,this.worldview),this.groundEffect.update(d,m,E,v,C,P,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,odt),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.wallVertexBuffer=d.createVertexBuffer(this.wallVertexArray,ndt.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=d.createVertexBuffer(this.layoutVertexExtArray,idt.members,!0)),this.groundEffect.upload(d)),this.groundEffect.uploadPaintProperties(d),this.programConfigurations.upload(d),this.uploaded=!0}uploadCentroid(d){this.groundEffect.uploadHiddenByLandmark(d),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=d.createVertexBuffer(this.centroidVertexArray,rdt.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(d,m,v,C,E,P,R,$,G){const te=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(m,{})/this.tileToMeter,se=[new ft(0,0),new ft(tr,tr)],ae=$.projection,de=ae.name==="globe",he=this.wallMode||ype[m.type]==="Polygon",Se=new u3e;Se.centroidDataIndex=this.centroidData.length;const Fe=new d3e;Fe.buildingId=d,m.properties&&m.properties.hasOwnProperty("building_id")&&(Fe.buildingId=m.properties.building_id);const Re=this.layers[0].paint.get("fill-extrusion-base").evaluate(m,{},E)<=0,Ke=this.layers[0].paint.get("fill-extrusion-height").evaluate(m,{},E);let Xe;if(Fe.height=Ke,Fe.vertexArrayOffset=this.layoutVertexArray.length,Fe.groundVertexArrayOffset=this.groundEffect.vertexArray.length,de&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new k3),this.wallMode){if(de)return void xr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(v.length!==1)return;Xe=function(Gt){const ds=Gt[0].x===Gt[Gt.length-1].x&&Gt[0].y===Gt[Gt.length-1].y;(function(_r){let Tr=0;const ta=_r.length;for(let Zs=0;Zs=0})(Gt)||(Gt=Gt.reverse());const Ns={geometry:[],joinNormals:[],indices:[]},Fs=[],Bs=[],Ls=[];let Os=Gt.length;for(;Os>=2&&Gt[Os-1].equals(Gt[Os-2]);)Os--;if(Os<(ds?3:2))return Ns;let ls,rs,Rs,sr,Vs,zr=0;for(;zr0;let _n="miter";const ja=2;_n==="miter"&&Zs>ja&&(_n="bevel"),_n==="bevel"&&(Zs>100&&(_n="flipbevel"),Zs{const us=new ft($n.x,$n.y),zs=new ft($n.x,$n.y);us.x+=Ai.x*Ct,us.y+=Ai.y*Ct,zs.x-=Ai.x*Math.max(_t,1),zs.y-=Ai.y*Math.max(_t,1),Ls.push(Ai),Fs.push(us),Bs.push(zs)};if(_n==="miter")Tr._mult(Zs),Ca(ls,Tr,0,0);else if(_n==="flipbevel")Tr=Vs.mult(-1),Ca(ls,Tr,0,0),Ca(ls,Tr.mult(-1),0,0);else{const $n=-Math.sqrt(Zs*Zs-1),Ai=Ar?$n:0,_t=Ar?0:$n;rs&&Ca(ls,sr,Ai,_t),Rs&&Ca(ls,Vs,Ai,_t)}}Ns.geometry=[...Fs,...Bs.reverse(),Fs[0]],Ns.joinNormals=[...Ls,...Ls.reverse(),Ls[Ls.length-1]];const mr=Ns.geometry.length-1;for(let _r=0;_rGt<(ds.length-1)/2||Gt===ds.length-1,kt=this.wallMode?[v]:K6(v,500);for(let Gt=kt.length-1;Gt>=0;Gt--){const ds=kt[Gt];(ds.length===0||(vt=ds[0]).every(js=>js.x<=0)||vt.every(js=>js.x>=tr)||vt.every(js=>js.y<=0)||vt.every(js=>js.y>=tr))&&kt.splice(Gt,1)}var vt;let At;if(de)At=v3e(kt,se,E);else{At=[];for(const Gt of kt)At.push({polygon:Gt,bounds:se})}const zt=he?this.edgeRadius:0,qt=zt>0&&this.zoom<17,ss=(Gt,ds)=>{if(Gt.length===0)return!1;const js=Gt[Gt.length-1];return ds.x===js.x&&ds.y===js.y};for(const{polygon:Gt,bounds:ds}of At){let js=0,Ns=0;for(const Os of Gt)he&&!Os[0].equals(Os[Os.length-1])&&Os.push(Os[0]),Ns+=he?Os.length-1:Os.length;const Fs=this.segments.prepareSegment((he?5:4)*Ns,this.layoutVertexArray,this.indexArray);Fe.footprintSegIdx<0&&(Fe.footprintSegIdx=this.footprintSegments.length),Fe.polygonSegIdx<0&&(Fe.polygonSegIdx=this.polygonSegments.length);const Bs={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ls=new c3e;if(Ls.vertexOffset=this.footprintVertices.length,Ls.indexOffset=3*this.footprintIndices.length,Ls.ringIndices=[],he){const Os=[],ls=[];js=Fs.vertexLength;for(let Rs=0;Rs4&&x3e(ls[ls.length-2],ls[0],ls[1]),Rs=zt?fdt(ls[ls.length-2],ls[0],ls[1],zt):0;const sr=[];let Vs,zr,mr;zr=ls[1].sub(ls[0])._perp()._unit();let _r=!0;for(let Tr=1,ta=0;Tr0?1:0,Ai=Zs.dist(Ar);if(ta+Ai>32768&&(ta=0),zt){mr=_n.sub(Ar)._perp()._unit();let zs=p3e(Zs,Ar,_n,m3e(zr,mr),zt);isNaN(zs)&&(zs=0);const or=Ar.sub(Zs)._unit();Zs=Zs.add(or.mult(Rs))._round(),Ar=Ar.add(or.mult(-zs))._round(),Rs=zs,zr=mr,Re&&this.zoom>=17&&(ss(sr,Zs)||sr.push(Zs),ss(sr,Ar)||sr.push(Ar))}const _t=Fs.vertexLength,Ct=ls.length>4&&x3e(Zs,Ar,_n);let us=g3e(ta,rs,_r);if(Y6(this.layoutVertexArray,Zs.x,Zs.y,Ca,$n,0,0,us),Y6(this.layoutVertexArray,Zs.x,Zs.y,Ca,$n,0,1,us),this.wallMode){const zs=lt(Tr-1,ls),or=Xe.joinNormals[Tr-1];X6(this.wallVertexArray,or,zs),X6(this.wallVertexArray,or,zs)}if(ta+=Ai,us=g3e(ta,Ct,!_r),rs=Ct,Y6(this.layoutVertexArray,Ar.x,Ar.y,Ca,$n,0,0,us),Y6(this.layoutVertexArray,Ar.x,Ar.y,Ca,$n,0,1,us),this.wallMode){const zs=lt(Tr,ls),or=Xe.joinNormals[Tr];X6(this.wallVertexArray,or,zs),X6(this.wallVertexArray,or,zs)}if(Fs.vertexLength+=4,this.indexArray.emplaceBack(_t+0,_t+1,_t+2),this.indexArray.emplaceBack(_t+1,_t+3,_t+2),Fs.primitiveLength+=2,zt){const zs=js+(Tr===1?ls.length-2:Tr-2),or=Tr===1?js:zs+1;if(this.indexArray.emplaceBack(_t+1,zs,_t+3),this.indexArray.emplaceBack(zs,or,_t+3),Fs.primitiveLength+=2,Vs===void 0&&(Vs=_t),!bpe(_n,ls[Tr],ds)){const lr=Tr===ls.length-1?Vs:Fs.vertexLength;this.indexArray.emplaceBack(_t+2,_t+3,lr),this.indexArray.emplaceBack(_t+3,lr+1,lr),this.indexArray.emplaceBack(_t+3,or,lr+1),Fs.primitiveLength+=3}_r=!_r}if(de){const zs=this.layoutVertexExtArray,or=ae.projectTilePoint(Zs.x,Zs.y,E),lr=ae.projectTilePoint(Ar.x,Ar.y,E),Br=ae.upVector(E,Zs.x,Zs.y),Vr=ae.upVector(E,Ar.x,Ar.y);Q6(zs,or,Br),Q6(zs,or,Br),Q6(zs,lr,Vr),Q6(zs,lr,Vr)}}he&&(js+=ls.length-1),Re&&zt&&this.zoom>=17&&(sr.length!==0&&ss(sr,sr[0])&&sr.pop(),this.groundEffect.addData(sr,ds,te,zt>0))}this.footprintSegments.push(Ls),Bs.triangleCount=this.indexArray.length-Bs.triangleArrayOffset,this.polygonSegments.push(Bs),++Fe.footprintSegLen,++Fe.polygonSegLen}if(Fe.vertexCount=this.layoutVertexArray.length-Fe.vertexArrayOffset,Fe.groundVertexCount=this.groundEffect.vertexArray.length-Fe.groundVertexArrayOffset,Fe.vertexCount!==0){if(Fe.centroidXY=Se.borders?i3e:this.encodeCentroid(Se,Fe),this.centroidData.push(Fe),Se.borders){this.featuresOnBorder.push(Se);const Gt=this.featuresOnBorder.length-1;for(let ds=0;dsthis.featuresOnBorder[m].borders[d][0]-this.featuresOnBorder[v].borders[d][0])}splitToSubtiles(){const d=[];for(let R=0;Rtr),te=2*G+(+($.min.x+$.max.x>tr)^G);for(let se=0;se<$.polygonSegLen;se++){const ae=$.polygonSegIdx+se;d.push({centroidIdx:R,subtile:te,polygonSegmentIdx:ae,triangleSegmentIdx:this.polygonSegments[ae].triangleSegIdx})}}const m=new $l;d.sort((R,$)=>R.triangleSegmentIdx===$.triangleSegmentIdx?R.subtile-$.subtile:R.triangleSegmentIdx-$.triangleSegmentIdx);let v=0,C=0,E=0;for(const R of d){if(R.triangleSegmentIdx!==v)break;E++}const P=d.length;for(;C!==d.length;){v=d[C].triangleSegmentIdx;let R=0,$=C,G=C;for(let te=$;te0&&this.triangleSubSegments.push({segment:de,min:se,max:ae}),$=G;for(let he=$;he[Se[0]*(1-Re[0])+Fe[0]*Re[0],Se[1]*(1-Re[1])+Fe[1]*Re[1]],de=[],he=[];for(const Se of this.triangleSubSegments){de[0]=Se.min.x/tr,de[1]=Se.min.y/tr,he[0]=Se.max.x/tr,he[1]=Se.max.y/tr;const Fe=ae(te,se,de),Re=ae(te,se,he);if(new Or([Fe[0],Fe[1],E],[Re[0],Re[1],P]).intersectsPrecise(v)===0){G&&(C.segments.push(G),G=void 0);continue}const Ke=Se.segment;G&&G.vertexOffset!==Ke.vertexOffset&&(C.segments.push(G),G=void 0),G?(G.vertexLength+=Ke.vertexLength,G.primitiveLength+=Ke.primitiveLength):G={vertexOffset:Ke.vertexOffset,primitiveLength:Ke.primitiveLength,vertexLength:Ke.vertexLength,primitiveOffset:Ke.primitiveOffset,sortKey:void 0,vaos:{}}}return G&&C.segments.push(G),C}encodeCentroid(d,m){const v=d.centroid(),C=m.span(),E=Math.min(7,Math.round(C.x*this.tileToMeter/10)),P=Math.min(7,Math.round(C.y*this.tileToMeter/10));return new ft(ke(v.x,1,tr-1)<<3|E,ke(v.y,1,tr-1)<<3|P)}encodeBorderCentroid(d){if(!d.borders)return new ft(0,0);const m=d.borders,v=Number.MAX_VALUE;if(m[0][0]!==v||m[1][0]!==v){const C=m[0][0]!==v?0:1;return new ft(6|(m[0][0]!==v?0:65528),(m[C][0]+m[C][1])/2<<3|6)}{const C=m[2][0]!==v?2:3;return new ft((m[C][0]+m[C][1])/2<<3|6,6|(m[2][0]!==v?0:65528))}}showCentroid(d){const m=this.centroidData[d.centroidDataIndex];m.flags&=2147483647,m.centroidXY.x=0,m.centroidXY.y=0,this.writeCentroidToBuffer(m)}writeCentroidToBuffer(d){this.groundEffect.updateHiddenByLandmark(d);const m=d.vertexArrayOffset,v=d.vertexCount+d.vertexArrayOffset,C=d.flags&yv?i3e:d.centroidXY,E=this.centroidVertexArray.geta_centroid_pos0(m);if(this.centroidVertexArray.geta_centroid_pos1(m)!==C.y||E!==C.x){for(let P=m;P$.max.x||$.min.x>P.max.x||P.min.y>$.max.y||$.min.y>P.max.y||P.footprint.buildingIds.has($.buildingId)&&($.flags|=yv);else for(const $ of this.centroidData)if(!($.flags&yv||P.min.x>$.max.x||$.min.x>P.max.x||P.min.y>$.max.y||$.min.y>P.max.y))for(let G=0;G<$.footprintSegLen;G++){const te=this.footprintSegments[$.footprintSegIdx+G];if(E.length=0,xdt(this.footprintVertices,te.vertexOffset,te.vertexCount,P.footprintTileId.canonical,d.canonical,E),xpe(P.footprint,E,this.footprintIndices.uint16,te.indexOffset,te.indexCount,-te.vertexOffset,-R)){$.flags|=yv;break}}}for(const P of this.centroidData)this.writeCentroidToBuffer(P);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(d,m,v){let C=!1;for(let E=0;Em!=de>m&&d<(this.footprintVertices.int16[2*(te+P.vertexOffset)+0]-se)*(m-ae)/(de-ae)+se&&(C=!C)}R=$}}return C}getHeightAtTileCoord(d,m){let v=Number.NEGATIVE_INFINITY,C=!0;const E=4*(d+tr)*tr+(m+tr);if(this.partLookup.hasOwnProperty(E)){const P=this.partLookup[E];return P?{height:P.height,hidden:!!(P.flags&yv)}:void 0}for(const P of this.centroidData)d>P.max.x||P.min.x>d||m>P.max.y||P.min.y>m||P.height<=v||this.footprintContainsPoint(d,m,P)&&(v=P.height,this.partLookup[E]=P,C=!!(P.flags&yv));if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:C};this.partLookup[E]=void 0}}function m3e(x,d){const m=x.add(d)._unit();return x.x*m.x+x.y*m.y}function fdt(x,d,m,v){const C=d.sub(x)._perp()._unit(),E=m.sub(d)._perp()._unit();return p3e(x,d,m,m3e(C,E),v)}function p3e(x,d,m,v,C){const E=Math.sqrt(1-v*v);return Math.min(x.dist(d)/3,d.dist(m)/3,C*E/v)}function bpe(x,d,m){return x.xm[1].x&&d.x>m[1].x||x.ym[1].y&&d.y>m[1].y}function f3e(x,d){return x.xd[1].x||x.yd[1].y}function x3e(x,d,m){if(x.x<0||x.x>=tr||d.x<0||d.x>=tr||m.x<0||m.x>=tr)return!1;const v=m.sub(d),C=v.perp(),E=x.sub(d);return(v.x*E.x+v.y*E.y)/Math.sqrt((v.x*v.x+v.y*v.y)*(E.x*E.x+E.y*E.y))>-.866&&C.x*E.x+C.y*E.y<0}function g3e(x,d,m){const v=d?2|x:-3&x;return m?1|v:-2&v}function y3e(){const x=Math.PI/32,d=Math.tan(x),m=T;return m*Math.sqrt(1+2*d*d)-m}function v3e(x,d,m){const v=1<{for(const zt of vt)he.push({polygon:zt,bounds:At})},Fe=Math.ceil(Math.log2(te)),Re=Math.ceil(Math.log2(se)),Ke=Fe-Re,Xe=[];for(let vt=0;vt0?0:1);for(let vt=0;vtAt+1?kt.push({polygons:Ns,bounds:Bs,depth:At+1}):Se(Ns,Bs)}if(Fs.length){const Bs=[new ft(zt===0?js:qt.x,zt===1?js:qt.y),ss];Xe.length>At+1?kt.push({polygons:Fs,bounds:Bs,depth:At+1}):Se(Fs,Bs)}}return he}(x,d,Math.ceil((E-C)/11.25),Math.ceil((P-R)/11.25),1,($,G,te)=>{if($===0)return .5*(G+te);{const se=je((m.y+G/tr)/v);return(J(.5*(je((m.y+te/tr)/v)+se))*v-m.y)*tr}})}function xdt(x,d,m,v,C,E){const P=Math.pow(2,v.z-C.z);for(let R=0;R=$[P]&&(R=d,$=x),R[P]C&&j3e(R,$,P,C),R[P]E&&j3e($,R,P,E)}}function OF(x,d,m,v,C,E){const P=[];for(let R=0;R=v&&he.x>=v||(de.x>=v?de=new ft(v,de.y+(v-de.x)/(he.x-de.x)*(he.y-de.y))._round():he.x>=v&&(he=new ft(v,de.y+(v-de.x)/(he.x-de.x)*(he.y-de.y))._round()),de.y>=C&&he.y>=C||(de.y>=C?de=new ft(de.x+(C-de.y)/(he.y-de.y)*(he.x-de.x),C)._round():he.y>=C&&(he=new ft(de.x+(C-de.y)/(he.y-de.y)*(he.x-de.x),C)._round()),G&&de.equals(G[G.length-1])||(G=[de],P.push(G),E&&E.push({progress:{min:Fe+k3e(Re,Ke,de)*Se,max:1},parentIndex:R,prevPoint:Re,nextPoint:Ke})),G.push(he),E&&(E[E.length-1].progress.max=Fe+k3e(Re,Ke,he)*Se,E[E.length-1].nextPoint=Ke)))))}if(E&&se>0)for(let ae=te;aeG.t-te.t);let P=0,R=0,$=[];for(v.push($);P!==x.length;){if(R===E.length){for(;P!==x.length;)$.length!==0&&$[$.length-1].equals(x[P])||$.push(x[P]),P++;break}E[R].t<=P?($.length!==0&&$[$.length-1].equals(E[R].point)||$.push(E[R].point),Math.trunc(E[R].t),R++):($.length!==0&&$[$.length-1].equals(x[P])||$.push(x[P]),P++)}}function k3e(x,d,m){return x.x!==d.x?(m.x-x.x)/(d.x-x.x):x.y!==d.y?(m.y-x.y)/(d.y-x.y):0}function J6(x,d){return x.x*d.x+x.y*d.y}function S3e(x,d){if(x.length===1){let m=0;const v=d[m++];let C;for(;!C||v.equals(C);)if(C=d[m++],!C)return 1/0;for(;m{js[0]=Ns,js[1]=Fs,js[2]=Bs,js[3]=1},ds=y3e();de>0&&(de+=ds),he+=ds;for(const js of ae){const Ns=[],Fs=[];for(const Bs of js){const Ls=Bs.x+Se.x,Os=Bs.y+Se.y,ls=se.projection.projectTilePoint(Ls,Os,kt),rs=se.projection.upVector(kt,Bs.x,Bs.y);let Rs=de,sr=he;if(Re){const Vs=T3e(Ls,Os,de,he,Re,Ke,Xe,lt);Rs+=Vs.base,sr+=Vs.top}de!==0?Gt(qt,ls.x+rs[0]*zt*Rs,ls.y+rs[1]*zt*Rs,ls.z+rs[2]*zt*Rs):Gt(qt,ls.x,ls.y,ls.z),Gt(ss,ls.x+rs[0]*zt*sr,ls.y+rs[1]*zt*sr,ls.z+rs[2]*zt*sr),pt(qt,qt,Fe),pt(ss,ss,Fe),Ns.push(new M2(qt[0],qt[1],qt[2])),Fs.push(new M2(ss[0],ss[1],ss[2]))}vt.push(Ns),At.push(Fs)}return[vt,At]}(x,d,m,v,C,E,P,R,$,G,te):P?function(se,ae,de,he,Se,Fe,Re,Ke,Xe){const lt=[],kt=[],vt=[0,0,0,1];for(const At of se){const zt=[],qt=[];for(const ss of At){const Gt=ss.x+he.x,ds=ss.y+he.y,js=T3e(Gt,ds,ae,de,Fe,Re,Ke,Xe);vt[0]=Gt,vt[1]=ds,vt[2]=js.base,vt[3]=1,Qe(vt,vt,Se),vt[3]=Math.max(vt[3],1e-5);const Ns=new M2(vt[0]/vt[3],vt[1]/vt[3],vt[2]/vt[3]);vt[0]=Gt,vt[1]=ds,vt[2]=js.top,vt[3]=1,Qe(vt,vt,Se),vt[3]=Math.max(vt[3],1e-5);const Fs=new M2(vt[0]/vt[3],vt[1]/vt[3],vt[2]/vt[3]);zt.push(Ns),qt.push(Fs)}lt.push(zt),kt.push(qt)}return[lt,kt]}(d,m,v,C,E,P,R,$,G):function(se,ae,de,he,Se){const Fe=[],Re=[],Ke=Se[8]*ae,Xe=Se[9]*ae,lt=Se[10]*ae,kt=Se[11]*ae,vt=Se[8]*de,At=Se[9]*de,zt=Se[10]*de,qt=Se[11]*de;for(const ss of se){const Gt=[],ds=[];for(const js of ss){const Ns=js.x+he.x,Fs=js.y+he.y,Bs=Se[0]*Ns+Se[4]*Fs+Se[12],Ls=Se[1]*Ns+Se[5]*Fs+Se[13],Os=Se[2]*Ns+Se[6]*Fs+Se[14],ls=Se[3]*Ns+Se[7]*Fs+Se[15],rs=Bs+Ke,Rs=Ls+Xe,sr=Os+lt,Vs=Math.max(ls+kt,1e-5),zr=Bs+vt,mr=Ls+At,_r=Os+zt,Tr=Math.max(ls+qt,1e-5);Gt.push(new M2(rs/Vs,Rs/Vs,sr/Vs)),ds.push(new M2(zr/Tr,mr/Tr,_r/Tr))}Fe.push(Gt),Re.push(ds)}return[Fe,Re]}(d,m,v,C,E)}function T3e(x,d,m,v,C,E,P,R){const $=P*C.getElevationAt(x,d,!0,!0),G=E[0]!==0,te=G?E[1]===0?P*(E[0]/o3e-l3e):P*function(se,ae,de){const he=Math.floor(ae[0]/8),Se=Math.floor(ae[1]/8),Fe=10*(ae[0]-8*he),Re=10*(ae[1]-8*Se),Ke=se.getElevationAt(he,Se,!0,!0),Xe=se.getMeterToDEM(de),lt=Math.floor(.5*(Fe*Xe-1)),kt=Math.floor(.5*(Re*Xe-1)),vt=se.tileCoordToPixel(he,Se),At=2*lt+1,zt=2*kt+1,qt=function(Fs,Bs,Ls,Os,ls){return[Fs.getElevationAtPixel(Bs,Ls,!0),Fs.getElevationAtPixel(Bs+ls,Ls,!0),Fs.getElevationAtPixel(Bs,Ls+ls,!0),Fs.getElevationAtPixel(Bs+Os,Ls+ls,!0)]}(se,vt.x-lt,vt.y-kt,At,zt),ss=Math.abs(qt[0]-qt[1]),Gt=Math.abs(qt[2]-qt[3]),ds=Math.abs(qt[0]-qt[2])+Math.abs(qt[1]-qt[3]),js=Math.min(.25,.5*Xe*(ss+Gt)/At),Ns=Math.min(.25,.5*Xe*ds/zt);return Ke+Math.max(js*Fe,Ns*Re)}(C,E,R):$;return{base:$+(m===0?-1:m),top:G?Math.max(te+v,$+m+2):$+v}}class ydt{constructor(d){this._callback=d,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 vdt{constructor(){this.tasks={},this.taskQueue=[],Ut(["process"],this),this.invoker=new ydt(this.process),this.nextId=0}add(d,m){const v=this.nextId++,C=function({type:E,isSymbolTile:P,zoom:R}){return R=R||0,E==="message"?0:E!=="maybePrepare"||P?E!=="parseTile"||P?E==="parseTile"&&P?300-R:E==="maybePrepare"&&P?400-R:500:200-R:100-R}(m);if(C===0){try{d()}finally{}return null}return this.tasks[v]={fn:d,metadata:m,priority:C,id:v},this.taskQueue.push(v),this.invoker.trigger(),{cancel:()=>{delete this.tasks[v]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(v=>!!this.tasks[v]),!this.taskQueue.length)return;const d=this.pick();if(d===null)return;const m=this.tasks[d];if(delete this.tasks[d],this.taskQueue.length&&this.invoker.trigger(),!m)return;m.fn()}finally{}}pick(){let d=null,m=1/0;for(let C=0;C{v&&delete this.callbacks[R],this.target.postMessage({id:R,type:"",targetMapId:C,sourceMapId:this.mapId})}}}receive(d){const m=d.data;if(!m)return;const v=m.id;if(v&&(!m.targetMapId||this.mapId===m.targetMapId))if(m.type===""){const C=this.cancelCallbacks[v];delete this.cancelCallbacks[v],C&&C.cancel()}else if(m.mustQueue||_a(self)){const C=this.callbacks[v],E=this.scheduler.add(()=>this.processTask(v,m),C&&C.metadata||{type:"message"});E&&(this.cancelCallbacks[v]=E)}else this.processTask(v,m)}processTask(d,m){if(delete this.cancelCallbacks[d],m.type===""){const v=this.callbacks[d];delete this.callbacks[d],v&&(m.error?v(Py(m.error)):v(null,Py(m.data)))}else{const v=new Set,C=m.hasCallback?(P,R)=>{this.target.postMessage({id:d,type:"",sourceMapId:this.mapId,error:P?ng(P):null,data:ng(R,v)},v)}:()=>{},E=Py(m.data);if(this.parent[m.type])this.parent[m.type](m.sourceMapId,E,C);else if(this.parent.getWorkerSource){const P=m.type.split("."),{source:R,scope:$}=E;this.parent.getWorkerSource(m.sourceMapId,P[0],R,$)[P[1]](E,C)}else C(new Error(`Could not find function ${m.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var eP={workerUrl:"",workerClass:null,workerParams:void 0};const _pe="mapboxgl_preloaded_worker_pool";class T2{constructor(d){this.active={},this.name=d}acquire(d,m=T2.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[_pe]}numActive(){return Object.keys(this.active).length}}T2.workerCount=2;class H3{constructor(d,m,v="Worker",C=T2.workerCount){this.workerPool=d,this.actors=[],this.currentActor=0,this.id=Ft();const E=this.workerPool.acquire(this.id,C);for(let P=0;P{this.ready=!0})}broadcast(d,m,v){bt(this.actors,(C,E)=>{C.send(d,m,E)},v=v||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(d=>{d.remove()}),this.actors=[],this.workerPool.release(this.id)}}let tP,wpe;function RF(){return tP||(tP=new T2),tP}H3.Actor=A3e;const jpe=4096;class bdt{constructor(d){this.module=d,this.memoryStack=this.module.malloc(jpe),this.memoryStackNextFree=this.memoryStack}createIntArray(d){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>jpe?-1:(new Int32Array(this.module.heap32.buffer,m,d.length).set(d),m)}createFloatArray(d){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>jpe?-1:(new Float32Array(this.module.heapF32.buffer,m,d.length).set(d),m)}readStringBuffer(d){let m="";for(;this.module.heapU8[d]!==0;)m+=String.fromCharCode(this.module.heapU8[d]),++d;return m}setStyle(d){const m=d.normalScale;this.module.setStyle(m[0],m[1],m[2],d.tileToMeters)}setAOOptions(d,m){this.module.setAOOptions(d?1:0,m)}setMetricOptions(d,m){this.module.setMetricOptions(d?1:0,m)}setStructuralOptions(d){this.module.setStructuralOptions(d?1:0)}setFacadeOptions(d,m){this.module.setFacadeOptions(d,m?1:0)}setFauxFacadeOptions(d,m,v){this.module.setFauxFacadeOptions(d?1:0,m?1:0,v)}setFacadeClassifierOptions(d){this.module.setFacadeClassifierOptions(d)}generateMesh(d,m){this.memoryStackNextFree=this.memoryStack;for(const R of d){const $=this.createIntArray(R.ringIndices),G=this.createFloatArray(R.coordinates);if($===-1||G===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(R.id,R.sourceId,R.minHeight,R.height,R.roofType,G,$,R.ringIndices.length-1)}for(const R of m){let $;$=R.entrances?JSON.parse(R.entrances):[];const G=this.createFloatArray($),te=this.createFloatArray(R.coordinates);if(G===-1||te===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(R.sourceId,R.crossPerc,R.distanceToRoad,G,$.length,te,R.coordinates.length)}if(!this.module.generateMesh()){const R=this.module.getLastError();return this.readStringBuffer(R)}const v=this.module.getMeshCount(),C=new Array(v);for(let R=0;RC.arrayBuffer()).then(C=>{d.buffers[m]=C})}function F3e(x,d){const m=x.json.bufferViews[d];return new Uint8Array(x.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function Sdt(x,d,m,v){if(x.uri){const C=R3e(x.uri,v);return fetch(C).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{d.images[m]=E})}if(x.bufferView!==void 0){const C=F3e(d,x.bufferView),E=new Blob([C],{type:x.mimeType});return createImageBitmap(E).then(P=>{d.images[m]=P})}}function z3e(x,d=0,m){const v={json:null,images:[],buffers:[]};if(new Uint32Array(x,d,1)[0]===D3e){const te=new Uint32Array(x,d);let se=2;const ae=(te[se++]>>2)-3,de=te[se++]>>2;if(se++,v.json=JSON.parse(O3e.decode(te.subarray(se,se+de))),se+=de,se{const te=[],se=R&&R.includes(Spe),ae=R&&R.includes(BF);if(se&&te.push(function(){if(!xg)return sP??(sP=function(de){let he,Se=null;function Fe(){he=new Uint8Array(Se.buffer)}function Re(){throw new Error("Unexpected Draco error.")}const Ke={a:{a:Re,d:function(Xe,lt,kt){return he.copyWithin(Xe,lt,lt+kt)},c:function(Xe){const lt=he.length,kt=Math.max(Xe>>>0,Math.ceil(1.2*lt)),vt=Math.ceil((kt-lt)/65536);try{return Se.grow(vt),Fe(),!0}catch{return!1}},b:Re}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(de,Ke):de.then(Xe=>Xe.arrayBuffer()).then(Xe=>WebAssembly.instantiate(Xe,Ke))).then(Xe=>{const{Rb:lt,Qb:kt,P:vt,T:At,X:zt,Ja:qt,La:ss,Qa:Gt,Va:ds,Wa:js,eb:Ns,jb:Fs,f:Bs,e:Ls,yb:Os,zb:ls,Ab:rs,Bb:Rs,Db:sr,Gb:Vs}=Xe.instance.exports;Se=Ls;const zr=(()=>{let mr=0,_r=0,Tr=0,ta=0;return Zs=>{Tr&&(lt(ta),lt(mr),_r+=Tr,Tr=mr=0),mr||(_r+=128,mr=kt(_r));const Ar=Zs.length+7&-8;let _n=mr;Ar>=_r&&(Tr=Ar,_n=ta=kt(Ar));for(let ja=0;ja{xg=de,sP=void 0}))}()),ae&&te.push(function(){if(kpe)return;const de=function(he){let Se;const Fe=WebAssembly.instantiateStreaming(he,{}).then(Xe=>{Se=Xe.instance,Se.exports.__wasm_call_ctors()}),Re={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ke={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Fe,supported:!0,decodeGltfBuffer(Xe,lt,kt,vt,At,zt){(function(qt,ss,Gt,ds,js,Ns,Fs){const Bs=qt.exports.sbrk,Ls=ds+3&-4,Os=Bs(Ls*js),ls=Bs(Ns.length),rs=new Uint8Array(qt.exports.memory.buffer);rs.set(Ns,ls);const Rs=ss(Os,ds,js,ls,Ns.length);if(Rs===0&&Fs&&Fs(Os,Ls,js),Gt.set(rs.subarray(Os,Os+ds*js)),Bs(Os-Bs(0)),Rs!==0)throw new Error(`Malformed buffer data: ${Rs}`)})(Se,Se.exports[Ke[At]],Xe,lt,kt,vt,Se.exports[Re[zt]])}}}(fetch(I3e()));return de.ready.then(()=>{kpe=de})}()),E)for(let de=0;de{if(se&&P)for(const{primitives:de}of P)for(const he of de)jdt(he,v);if(ae&&P&&$)for(const de of $)Ndt(de,v);return v})})}function B3e(x){return fetch(x).then(d=>d.arrayBuffer()).then(d=>z3e(d,0,x))}function Cpe(x){switch(x){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 Mpe(x){switch(x){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 Tpe{constructor(d,m,v,C){this.context=d,this.format=v,this.useMipmap=C&&C.useMipmap,this.texture=d.gl.createTexture(),this.update(m,{premultiply:C&&C.premultiply})}update(d,m){const v=d&&d instanceof HTMLVideoElement&&d.width===0?d.videoWidth:d.width,C=d&&d instanceof HTMLVideoElement&&d.height===0?d.videoHeight:d.height,{context:E}=this,{gl:P}=E,{x:R,y:$}=m&&m.position?m.position:{x:0,y:0},G=R+v,te=$+C;!this.size||this.size[0]===G&&this.size[1]===te||(P.bindTexture(P.TEXTURE_2D,null),P.deleteTexture(this.texture),this.texture=P.createTexture(),this.size=null),P.bindTexture(P.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===P.RGBA8&&(!m||m.premultiply!==!1));const se=d instanceof HTMLImageElement||d instanceof HTMLCanvasElement||d instanceof HTMLVideoElement||d instanceof ImageData||ImageBitmap&&d instanceof ImageBitmap;if(!this.size&&G>0&&te>0){const ae=this.useMipmap?Math.floor(Math.log2(Math.max(G,te)))+1:1;P.texStorage2D(P.TEXTURE_2D,ae,this.format,G,te),this.size=[G,te]}this.size&&(se?P.texSubImage2D(P.TEXTURE_2D,0,R,$,Cpe(this.format),Mpe(this.format),d):"data"in d&&d.data&&P.texSubImage2D(P.TEXTURE_2D,0,R,$,v,C,Cpe(this.format),Mpe(this.format),d.data)),this.useMipmap&&P.generateMipmap(P.TEXTURE_2D)}bind(d,m,v=!1){const{context:C}=this,{gl:E}=C;E.bindTexture(E.TEXTURE_2D,this.texture),d!==this.minFilter&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MAG_FILTER,d),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MIN_FILTER,this.useMipmap&&!v?d===E.NEAREST?E.NEAREST_MIPMAP_NEAREST:E.LINEAR_MIPMAP_LINEAR:d),this.minFilter=d),m!==this.wrapS&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_S,m),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_T,m),this.wrapS=m)}bindExtraParam(d,m,v,C,E){const{context:P}=this,{gl:R}=P;R.bindTexture(R.TEXTURE_2D,this.texture),m!==this.magFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MAG_FILTER,m),this.magFilter=m),d!==this.minFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MIN_FILTER,this.useMipmap?d===R.NEAREST?R.NEAREST_MIPMAP_NEAREST:R.LINEAR_MIPMAP_LINEAR:d),this.minFilter=d),v!==this.wrapS&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_S,v),this.wrapS=v),C!==this.wrapT&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_T,C),this.wrapT=C),E!==this.compareMode&&(E?(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.COMPARE_REF_TO_TEXTURE),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_FUNC,E)):R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.NONE),this.compareMode=E)}destroy(){const{gl:d}=this.context;d.deleteTexture(this.texture),this.texture=null}}class nP{constructor(d,m){this.context=d,this.texture=m}bind(d,m){const{context:v}=this,{gl:C}=v;C.bindTexture(C.TEXTURE_2D,this.texture),d!==this.minFilter&&(C.texParameteri(C.TEXTURE_2D,C.TEXTURE_MAG_FILTER,d),C.texParameteri(C.TEXTURE_2D,C.TEXTURE_MIN_FILTER,d),this.minFilter=d),m!==this.wrapS&&(C.texParameteri(C.TEXTURE_2D,C.TEXTURE_WRAP_S,m),C.texParameteri(C.TEXTURE_2D,C.TEXTURE_WRAP_T,m),this.wrapS=m)}}const Cdt=fa([{name:"a_pos_3f",components:3,type:"Float32"}]),Mdt=fa([{name:"a_color_3f",components:3,type:"Float32"}]),Tdt=fa([{name:"a_color_4f",components:4,type:"Float32"}]),Adt=fa([{name:"a_uv_2f",components:2,type:"Float32"}]),Edt=fa([{name:"a_normal_3f",components:3,type:"Float32"}]),Pdt=fa([{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"}]),Idt=fa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function $3e(x,d){const m=$F(x.projection,x.zoom,x.width,x.height),v=function(E,P,R,$,G){const te=new y(R.lng-180*Nb,R.lat),se=new y(R.lng+180*Nb,R.lat),ae=E.project(te.lng,te.lat),de=E.project(se.lng,se.lat),he=-Math.atan2(de.y-ae.y,de.x-ae.x),Se=nt.fromLngLat(R);Se.y=ke(Se.y,-1+Nb,1-Nb);const Fe=Se.toLngLat(),Re=E.project(Fe.lng,Fe.lat),Ke=nt.fromLngLat(Fe);Ke.x+=Nb;const Xe=Ke.toLngLat(),lt=E.project(Xe.lng,Xe.lat),kt=U3e(lt.x-Re.x,lt.y-Re.y,he),vt=nt.fromLngLat(Fe);vt.y+=Nb;const At=vt.toLngLat(),zt=E.project(At.lng,At.lat),qt=U3e(zt.x-Re.x,zt.y-Re.y,he),ss=Math.abs(kt.x)/Math.abs(qt.y),Gt=w([]);q(Gt,Gt,-he*(1-(G?0:$)));const ds=w([]);return L(ds,ds,[1,1-(1-ss)*$,1]),ds[4]=-qt.x/qt.y*$,q(ds,ds,he),S(ds,Gt,ds),ds}(x.projection,0,x.center,m,d),C=q3e(x);return L(v,v,[C,C,1]),v}function q3e(x){const d=x.projection,m=$F(x.projection,x.zoom,x.width,x.height),v=Ape(d,x.center),C=Ape(d,y.convert(d.center));return Math.pow(2,v*m+(1-m)*C)}function $F(x,d,m,v,C=1/0){const E=x.range;if(!E)return 0;const P=Math.min(C,Math.max(m,v)),R=Math.log2(P/1024);return Be(E[0]+R,E[1]+R,d)}const Nb=1/4e4;function Ape(x,d){const m=ke(d.lat,-Ne,Ne),v=new y(d.lng-180*Nb,m),C=new y(d.lng+180*Nb,m),E=x.project(v.lng,m),P=x.project(C.lng,m),R=nt.fromLngLat(v),$=nt.fromLngLat(C),G=P.x-E.x,te=P.y-E.y,se=$.x-R.x,ae=$.y-R.y,de=Math.sqrt((se*se+ae*ae)/(G*G+te*te));return Math.log2(de)}function U3e(x,d,m){const v=Math.cos(m),C=Math.sin(m);return{x:x*v-d*C,y:x*C+d*v}}function V3e(x,d,m){w(x),q(x,x,jr(d[2])),I(x,x,jr(d[0])),O(x,x,jr(d[1])),L(x,x,m),S(x,x,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function qF(x,d,m,v,C,E,P,R){const $=[m[0]-d[0],m[1]-d[1],0],G=[v[0]-d[0],v[1]-d[1],0];if(ie($)<1e-12||ie(G)<1e-12)return Je(x);const te=tt([],$,G);we(te,te),ge(G,v,d),$[2]=(E-C)*R,G[2]=(P-C)*R;const se=$;return tt(se,$,G),we(se,se),cs(x,te,se)}function UF(x,d,m=!1){const v=wb(d.zoom),C=function(E,P,R){const $=P.worldSize,G=[E[12],E[13],E[14]],te=je(G[1]/$),se=le(G[0]/$),ae=w([]),de=ne(1,te)*$,he=ne(1,0)*$*Pe(te,P.zoom),Se=1/ape($);let Fe=he*Se;if(R){const lt=$F(P.projection,P.zoom,P.width,P.height,1024);Fe=Se*P.projection.pixelSpaceConversion(P.center.lat,$,lt)}const Re=vb(te,se);ce(Re,Re,_e([],we([],Re),de*Fe*G[2]));const Ke=function(lt){const kt=[lt[0],lt[1],lt[2]];let vt=[0,1,0];const At=tt([],vt,kt);return tt(vt,kt,At),Ce(vt)===0&&(vt=[0,1,0],tt(At,kt,vt)),we(At,At),we(vt,vt),we(kt,kt),[At[0],At[1],At[2],0,vt[0],vt[1],vt[2],0,kt[0],kt[1],kt[2],0,lt[0],lt[1],lt[2],1]}(Re);L(ae,ae,[Fe,Fe,Fe*de]),M(ae,ae,[-G[0],-G[1],-G[2]]);const Xe=S([],P.globeMatrix,Ke);return S(Xe,Xe,ae),S(Xe,Xe,E),Xe}(x,d,m);if(v>0){const E=function(P,R){const $=R.worldSize,G=ne(1,0)*$*Pe(R.center.lat,R.zoom)/ape($),te=ne(1,R.center.lat)*$,se=w([]);O(se,se,jr(R.center.lng)),I(se,se,jr(R.center.lat)),M(se,se,[0,0,Ud]),L(se,se,[G,G,G*te]);const ae=R.point;return M(se,se,[-ae.x,-ae.y,0]),S(se,se,P),S(se,R.globeMatrix,se)}(x,d);return function(P,R,$){const G=(he,Se,Fe)=>{const Re=ie(he),Ke=ie(Se),Xe=fg(he,Se,Fe);return _e(Xe,Xe,1/ie(Xe)*Zr(Re,Ke,Fe))},te=G([P[0],P[1],P[2]],[R[0],R[1],R[2]],$),se=G([P[4],P[5],P[6]],[R[4],R[5],R[6]],$),ae=G([P[8],P[9],P[10]],[R[8],R[9],R[10]],$),de=fg([P[12],P[13],P[14]],[R[12],R[13],R[14]],$);return[te[0],te[1],te[2],0,se[0],se[1],se[2],0,ae[0],ae[1],ae[2],0,de[0],de[1],de[2],1]}(C,E,v)}return C}function Epe(x,d,m,v){const C=Or.projectAabbCorners(v,m);let E=Number.MAX_VALUE;for(let R=0;R0||Fe===0&&he[0]*Se[0]+he[1]*Se[1]>=0&&he[0]*he[0]+he[1]*he[1]>Se[0]*Se[0]+Se[1]*Se[1])&&(te=de)}se=te}while(se!==G);return $.length>0&&$.push($[0]),$}(C);if(Ga(x,P))return E}const A2=64,Z3={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function VF(x,d,m,v,C,E,P,R,$,G=!1){const te=m.zoom,se=m.project(v),ae=Pe(v.lat,te),de=1/ae;w(x),M(x,x,[se.x+P[0]*de,se.y+P[1]*de,P[2]]);let he=1,Se=1;const Fe=m.worldSize;if(G){if(m.projection.name==="mercator"){let lt=0;m.elevation&&(lt=m.elevation.getAtPointOrZero(new nt(se.x/Fe,se.y/Fe),0));const kt=Qe([],[se.x,se.y,lt,1],m.projMatrix)[3]/m.cameraToCenterDistance;he=kt,Se=kt*Pe(m.center.lat,te)}else if(m.projection.name==="globe"){const lt=UF(x,m),kt=[0,0,0,1];Qe(kt,kt,S([],m.projMatrix,lt));const vt=kt[3]/m.cameraToCenterDistance,At=wb(te),zt=m.projection.pixelsPerMeter(v.lat,Fe)*Pe(v.lat,te),qt=m.projection.pixelsPerMeter(m.center.lat,Fe)*Pe(m.center.lat,te);he=vt/Zr(zt,De(m.center.lat),At),Se=vt*ae/zt,he*=qt,Se*=qt}}else he=de;L(x,x,[he,he,Se]);const Re=[...x],Ke=d.orientation,Xe=[];if(V3e(Xe,[Ke[0]+(C?C[0]:0),Ke[1]+(C?C[1]:0),Ke[2]+(C?C[2]:0)],E),S(x,Re,Xe),R&&m.elevation){let lt=0;const kt=[];if($&&m.elevation){lt=function(At,zt,qt,ss,Gt){const ds=zt.elevation;if(!ds)return 0;const js=Or.projectAabbCorners(qt,ss),Ns=ne(1,Gt.lat)*zt.worldSize,Fs=function(_r,Tr){const ta=[0,0,1],Zs=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const Ar of Zs){const _n=_r[Ar.corners[0]],ja=_r[Ar.corners[1]],Ca=_r[Ar.corners[2]],$n=[ja[0]-_n[0],ja[1]-_n[1],Tr*(ja[2]-_n[2])],Ai=tt($n,$n,[Ca[0]-_n[0],Ca[1]-_n[1],Tr*(Ca[2]-_n[2])]);we(Ai,Ai),Ar.dotProductWithUp=Le(Ai,ta)}return Zs.sort((Ar,_n)=>Ar.dotProductWithUp-_n.dotProductWithUp),Zs[0].corners}(js,Ns),Bs=js[Fs[0]],Ls=js[Fs[1]],Os=js[Fs[2]],ls=js[Fs[3]],rs=ds.getAtPointOrZero(new nt(Bs[0]/zt.worldSize,Bs[1]/zt.worldSize),0),Rs=ds.getAtPointOrZero(new nt(Ls[0]/zt.worldSize,Ls[1]/zt.worldSize),0),sr=ds.getAtPointOrZero(new nt(Os[0]/zt.worldSize,Os[1]/zt.worldSize),0),Vs=ds.getAtPointOrZero(new nt(ls[0]/zt.worldSize,ls[1]/zt.worldSize),0),zr=(rs+Vs)/2,mr=(Rs+sr)/2;return zr>mr?Rs=d.gl.NEAREST_MIPMAP_NEAREST}),x.uploaded=!0,x.image=null)}function Ldt(x,d,m){x.indexBuffer=d.createIndexBuffer(x.indexArray,!1,!0),x.vertexBuffer=d.createVertexBuffer(x.vertexArray,Cdt.members,!1,!0),x.normalArray&&(x.normalBuffer=d.createVertexBuffer(x.normalArray,Edt.members,!1,!0)),x.texcoordArray&&(x.texcoordBuffer=d.createVertexBuffer(x.texcoordArray,Adt.members,!1,!0)),x.colorArray&&(x.colorBuffer=d.createVertexBuffer(x.colorArray,(x.colorArray.bytesPerElement===12?Mdt:Tdt).members,!1,!0)),x.featureArray&&(x.pbrBuffer=d.createVertexBuffer(x.featureArray,Idt.members,!0)),x.segments=bo.simpleSegment(0,0,x.vertexArray.length,x.indexArray.length);const v=x.material;v.pbrMetallicRoughness.baseColorTexture&&aP(v.pbrMetallicRoughness.baseColorTexture,d),v.pbrMetallicRoughness.metallicRoughnessTexture&&aP(v.pbrMetallicRoughness.metallicRoughnessTexture,d),v.normalTexture&&aP(v.normalTexture,d),v.occlusionTexture&&aP(v.occlusionTexture,d,m),v.emissionTexture&&aP(v.emissionTexture,d)}function Ppe(x,d,m){if(x.meshes)for(const v of x.meshes)Ldt(v,d,m);if(x.children)for(const v of x.children)Ppe(v,d,m)}function HF(x){if(x.meshes)for(const d of x.meshes)d.indexArray.destroy(),d.vertexArray.destroy(),d.colorArray&&d.colorArray.destroy(),d.normalArray&&d.normalArray.destroy(),d.texcoordArray&&d.texcoordArray.destroy(),d.featureArray&&d.featureArray.destroy();if(x.children)for(const d of x.children)HF(d)}function Ipe(x){if(x.meshes)for(const m of x.meshes)m.vertexBuffer&&(m.vertexBuffer.destroy(),m.indexBuffer.destroy(),m.normalBuffer&&m.normalBuffer.destroy(),m.texcoordBuffer&&m.texcoordBuffer.destroy(),m.colorBuffer&&m.colorBuffer.destroy(),m.pbrBuffer&&m.pbrBuffer.destroy(),m.segments.destroy(),m.material&&((d=m.material).pbrMetallicRoughness.baseColorTexture&&d.pbrMetallicRoughness.baseColorTexture.gfxTexture&&d.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),d.pbrMetallicRoughness.metallicRoughnessTexture&&d.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&d.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),d.normalTexture&&d.normalTexture.gfxTexture&&d.normalTexture.gfxTexture.destroy(),d.emissionTexture&&d.emissionTexture.gfxTexture&&d.emissionTexture.gfxTexture.destroy(),d.occlusionTexture&&d.occlusionTexture.gfxTexture&&d.occlusionTexture.gfxTexture.destroy()));var d;if(x.children)for(const m of x.children)Ipe(m)}function E2(x,d){const m=x.json.bufferViews[d.bufferView],v=zF[d.componentType];return new v(x.buffers[m.buffer],(d.byteOffset||0)+(m.byteOffset||0),d.count*(m.byteStride&&m.byteStride!==rP[d.type]*v.BYTES_PER_ELEMENT?m.byteStride/v.BYTES_PER_ELEMENT:rP[d.type]))}function Lpe(x,d,m,v){const C=zF[d.componentType],E=function(te){switch(te){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(C),P=x.json.bufferViews[d.bufferView],R=P.byteStride?P.byteStride/C.BYTES_PER_ELEMENT:rP[d.type],$=m.float32,G=$.length/m.capacity;for(let te=0,se=0;te0){for(let Fe=0;Fe0){E.texcoordArray=new Wf;const ae=d.json.accessors[C.TEXCOORD_0];E.texcoordArray.resize(ae.count);const de=E2(d,ae);Lpe(d,ae,E.texcoordArray,de)}if(C._FEATURE_ID_RGBA4444!==void 0){const ae=d.json.accessors[C._FEATURE_ID_RGBA4444];d.json.extensionsUsed&&d.json.extensionsUsed.includes("EXT_meshopt_compression")&&(E.featureData=E2(d,ae))}C._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array(E2(d,d.json.accessors[C._FEATURE_RGBA4444]).buffer));const se=x.material;return E.material=function(ae,de){const{emissiveFactor:he=[0,0,0],alphaMode:Se="OPAQUE",alphaCutoff:Fe=.5,normalTexture:Re,occlusionTexture:Ke,emissiveTexture:Xe,doubleSided:lt,name:kt}=ae,{baseColorFactor:vt=[1,1,1,1],metallicFactor:At=1,roughnessFactor:zt=1,baseColorTexture:qt,metallicRoughnessTexture:ss}=ae.pbrMetallicRoughness||{},Gt=Ke?de[Ke.index]:void 0;if(Ke&&Ke.extensions&&Ke.extensions.KHR_texture_transform&&Gt){const ds=Ke.extensions.KHR_texture_transform;Gt.offsetScale=[ds.offset[0],ds.offset[1],ds.scale[0],ds.scale[1]]}return{name:kt,pbrMetallicRoughness:{baseColorFactor:new Ur(...vt),metallicFactor:At,roughnessFactor:zt,baseColorTexture:qt?de[qt.index]:void 0,metallicRoughnessTexture:ss?de[ss.index]:void 0},doubleSided:lt,emissiveFactor:new Ur(...he),alphaMode:Se,alphaCutoff:Fe,normalTexture:Re?de[Re.index]:void 0,occlusionTexture:Gt,emissionTexture:Xe?de[Xe.index]:void 0,defined:ae.defined===void 0}}(se!==void 0?d.json.materials[se]:{defined:!1},m),E}function W3e(x,d,m){const{matrix:v,rotation:C,translation:E,scale:P,mesh:R,extras:$,children:G,name:te}=x,se={};if(se.name=te,se.localMatrix=v||function(ae,de,he,Se){var Fe=de[0],Re=de[1],Ke=de[2],Xe=de[3],lt=Fe+Fe,kt=Re+Re,vt=Ke+Ke,At=Fe*lt,zt=Fe*kt,qt=Fe*vt,ss=Re*kt,Gt=Re*vt,ds=Ke*vt,js=Xe*lt,Ns=Xe*kt,Fs=Xe*vt,Bs=Se[0],Ls=Se[1],Os=Se[2];return ae[0]=(1-(ss+ds))*Bs,ae[1]=(zt+Fs)*Bs,ae[2]=(qt-Ns)*Bs,ae[3]=0,ae[4]=(zt-Fs)*Ls,ae[5]=(1-(At+ds))*Ls,ae[6]=(Gt+js)*Ls,ae[7]=0,ae[8]=(qt+Ns)*Os,ae[9]=(Gt-js)*Os,ae[10]=(1-(At+ss))*Os,ae[11]=0,ae[12]=he[0],ae[13]=he[1],ae[14]=he[2],ae[15]=1,ae}([],C||[0,0,0,1],E||[0,0,0],P||[1,1,1]),se.globalMatrix=j(se.localMatrix),R!==void 0){se.meshes=m[R];const ae=se.anchor=[0,0];for(const de of se.meshes){const{min:he,max:Se}=de.aabb;ae[0]+=he[0]+Se[0],ae[1]+=he[1]+Se[1]}ae[0]=Math.floor(ae[0]/se.meshes.length/2),ae[1]=Math.floor(ae[1]/se.meshes.length/2)}if($&&($.id&&(se.id=$.id),$.lights&&(se.lights=function(ae){if(!ae.length)return[];const de=function(Ke){const Xe=atob(Ke),lt=new Uint8Array(Xe.length);for(let kt=0;kt1&&v[v.length-1].equals(v[0])&&v.pop();let C=0;for(let P=0;P0&&v.reverse();const E=U3(v.flatMap(P=>[P.x,P.y]),[]);return E.length===0?null:{vertices:v,indices:E}}function Fdt(x,d){const m=[],v=[];let C=0;const E=[];for(const P of x){C=m.length;const R=P.vertexArray.float32,$=P.indexArray.uint16;for(let G=0;G0&&([v[P+1],v[P+2]]=[v[P+2],v[P+1]])}return{vertices:m,indices:v}}function Dpe(x){const d=function($,G){const te=[],se=WebGL2RenderingContext;if($.json.textures)for(const ae of $.json.textures){const de={magFilter:se.LINEAR,minFilter:se.NEAREST,wrapS:se.REPEAT,wrapT:se.REPEAT};ae.sampler!==void 0&&Object.assign(de,$.json.samplers[ae.sampler]),te.push({image:G[ae.source],sampler:de,uploaded:!1})}return te}(x,x.images),m=function($,G){const te=[];for(const se of $.json.meshes){const ae=[];for(const de of se.primitives)ae.push(Ddt(de,$,G));te.push(ae)}return te}(x,d),{scenes:v,scene:C,nodes:E}=x.json,P=v?v[C||0].nodes:[...E.keys()],R=[];for(const $ of P)R.push(W3e(E[$],x,m));return function($,G,te){const se={},ae=new Set;for(let de=0;de<$.length;de++){const he=te[G[de]];if(!he.extras)continue;const Se=he.extras["mapbox:footprint:version"],Fe=he.extras["mapbox:footprint:id"];(Se||Fe)&&ae.add(de),Se==="1.0.0"&&Fe&&(se[Fe]=de)}for(let de=0;de<$.length;de++){if(ae.has(de))continue;const he=$[de],Se=te[G[de]];if(!Se.extras)continue;let Fe=null;he.id in se&&(Fe=Fdt($[se[he.id]].meshes,he.localMatrix)),Fe||(Fe=Rdt(Se)),Fe&&(he.footprint=Odt(Fe))}if(ae.size>0){const de=Array.from(ae.values()).sort((he,Se)=>he-Se);for(let he=de.length-1;he>=0;he--)$.splice(de[he],1)}}(R,P,x.json.nodes),R}function zdt(x){x.heightmap=new Float32Array(4096),x.heightmap.fill(-1);const d=x.vertexArray.float32,m=x.aabb.min[0]-1,v=x.aabb.min[1]-1,C=A2/(x.aabb.max[0]-m+2),E=A2/(x.aabb.max[1]-v+2);for(let P=0;Px.heightmap[G*A2+$]&&(x.heightmap[G*A2+$]=R)}}function G3e(x,d,m,v,C){m.reserve(m.length+4*x.length),v.reserve(v.length+10*x.length),C.reserve(C.length+10*x.length);let E=v.length;for(const P of x){const R=Math.min(10,Math.max(4,1.3*P.height))*d,$=[-P.normal[1],P.normal[0],0],G=Math.min(.29,.1*P.width/P.depth),te=P.width-2*P.depth*d*(G+.01),se=$e([],P.pos,$,te/2),ae=$e([],P.pos,$,-te/2),de=[se[0],se[1],se[2]+P.height],he=[ae[0],ae[1],ae[2]+P.height],Se=$e([],P.normal,$,G);_e(Se,Se,R);const Fe=$e([],P.normal,$,-G);_e(Fe,Fe,R),ce(Se,se,Se),ce(Fe,ae,Fe),se[2]+=.1,ae[2]+=.1,v.emplaceBack(Se[0],Se[1],Se[2]),v.emplaceBack(Fe[0],Fe[1],Fe[2]),v.emplaceBack(se[0],se[1],se[2]),v.emplaceBack(ae[0],ae[1],ae[2]),v.emplaceBack(de[0],de[1],de[2]),v.emplaceBack(he[0],he[1],he[2]),v.emplaceBack(se[0],se[1],se[2]),v.emplaceBack(ae[0],ae[1],ae[2]),v.emplaceBack(Se[0],Se[1],Se[2]),v.emplaceBack(Fe[0],Fe[1],Fe[2]);const Re=te/R/2;C.emplaceBack(-Re-G,-1,Re,.8),C.emplaceBack(Re+G,-1,Re,.8),C.emplaceBack(-Re,0,Re,1.3),C.emplaceBack(Re,0,Re,1.3),C.emplaceBack(Re+G,-.8,Re,.7),C.emplaceBack(Re+G,-.8,Re,.7),C.emplaceBack(0,0,Re,1.3),C.emplaceBack(0,0,Re,1.3),C.emplaceBack(Re+G,-1.2,Re,.8),C.emplaceBack(Re+G,-1.2,Re,.8),m.emplaceBack(6+E,4+E,8+E),m.emplaceBack(7+E,9+E,5+E),m.emplaceBack(0+E,1+E,2+E),m.emplaceBack(1+E,3+E,2+E),E+=10}}function Bdt(x,d){const m={};m.indexArray=new $l,m.vertexArray=new dm,m.colorArray=new Ly,G3e(x,d,m.indexArray,m.vertexArray,m.colorArray);const v={defined:!0};v.emissiveFactor=Ur.black;const C={};return C.baseColorFactor=Ur.white,v.pbrMetallicRoughness=C,m.material=v,m.aabb=new Or([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const K3e=fa([{name:"a_pos_3f",components:3,type:"Float32"}]),$dt=fa([{name:"a_normal_3",components:3,type:"Int16"}]),qdt=fa([{name:"a_centroid_3",components:3,type:"Int16"}]),Z3e=fa([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Udt=fa([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Vdt=fa([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Hdt=fa([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Wdt=fa([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Gdt=fa([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),Y3e=Ht.types,WF=32767;function Kdt(x,d){const m=tr+d;for(const v of x)for(const C of v)if(C.x<-d||C.x>m||C.y<-d||C.y>m)return!1;return!0}function Zdt(x){switch(x){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: ${x}`)}}class Ope{constructor(){this.layoutVertexArray=new dm,this.layoutAttenuationArray=new Ly,this.layoutColorArray=new um,this.indexArray=new $l,this.indexArrayForConflation=new $l,this.segmentsBucket=new bo}}class Rpe{constructor(d){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new bo,this.entranceBloom=new Ope;const m=66560;this.layoutVertexArray=new dm,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new mb,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new mb,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new um,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new Dy,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new E3,this.layoutAOArray.reserve(m),this.indexArray=new $l,this.indexArray.reserve(66560),this.indexArrayForConflation=new $l,this.segmentsBucket=new bo,this.entranceBloom=new Ope,d&&(this.layoutFacadePaintArray=new um,this.layoutFacadeDataArray=new pv,this.layoutFacadeVerticalRangeArray=new um)}reserve(d,m,v){this.layoutVertexArray.reserveForAdditional(d),this.layoutCentroidArray.reserveForAdditional(d),this.layoutFloodLightDataArray.reserveForAdditional(d),this.layoutNormalArray.reserveForAdditional(d),this.layoutAOArray.reserveForAdditional(d),this.layoutColorArray.reserveForAdditional(d),this.indexArray.reserveForAdditional(m),v&&(this.layoutFacadePaintArray.reserveForAdditional(d),this.layoutFacadeDataArray.reserveForAdditional(d),this.layoutFacadeVerticalRangeArray.reserveForAdditional(d))}}class X3e{constructor(d){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Wf,this.footprintsIndices=new Dy,this.footprintsMin=new ft(1/0,1/0),this.footprintsMax=new ft(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Rpe(!1),this.buildingWithFacade=new Rpe(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=d.zoom,this.canonical=d.canonical,this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.worldview=d.worldview,this.lut=d.lut,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=d.projection,this.groundEffect=new vpe(d),this.groundEffect.groundRadiusArray=new lg,this.hasAppearances=null}updateFootprints(d,m){const v=new EF([],[],1),C={vertices:[],indices:new Uint32Array(0),grid:v,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};m.push({footprint:C,id:d})}updateAppearances(d,m,v,C){}prepare(){return function(){if(FF!=null||E3e!=null)return null;if(K3!=null)return K3;const d=fetch(ua.BUILDING_GEN_URL);return K3=function(m){let v,C,E,P,R;function $(){v=new Uint8Array(R.buffer),C=new Int16Array(R.buffer),E=new Int32Array(R.buffer),P=new Float32Array(R.buffer)}function G(){throw new Error("Unexpected BuildingGen error.")}const te=()=>{},se={a:{a:G,f:function(ae){const de=v.length,he=Math.max(ae>>>0,Math.ceil(1.2*de)),Se=Math.ceil((he-de)/65536);try{return R.grow(Se),$(),!0}catch{return!1}},g:G,b:te,c:te,d:te,e:te}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(m,se):m.then(ae=>ae.arrayBuffer()).then(ae=>WebAssembly.instantiate(ae,se))).then(ae=>{const de=ae.instance.exports;return(0,de.g)(),R=de.f,$(),new bdt({setStyle:de.h,setAOOptions:de.i,setMetricOptions:de.j,setStructuralOptions:de.k,setFacadeOptions:de.l,setFauxFacadeOptions:de.m,setFacadeClassifierOptions:de.n,addFeature:de.o,addFacade:de.p,generateMesh:de.q,getLastError:de.r,getOuterRingLength:de.s,getMeshCount:de.t,getPositionsPtr:de.u,getPositionsLength:de.v,getNormalsPtr:de.w,getNormalsLength:de.x,getAOPtr:de.y,getAOLength:de.z,getUVPtr:de.A,getUVLength:de.B,getFauxFacadePtr:de.C,getFauxFacadeLength:de.D,getIndicesPtr:de.E,getIndicesLength:de.F,getBuildingPart:de.G,getRingCount:de.H,getRingPtr:de.I,getRingLength:de.J,malloc:de.K,free:de.L,heapU8:v,heap16:C,heap32:E,heapF32:P})})}(d).then(m=>(K3=null,FF=m,FF)).catch(m=>{xr("Could not load building-gen"),K3=null,E3e=m}),K3}()}populate(d,m,v,C){const E=_dt();if(!E)return;const P=Ve(v);this.tileToMeter=P,this.brightness=m.brightness,E.setStyle({normalScale:[1,-1,P],tileToMeters:P}),E.setAOOptions(!1,.3),E.setMetricOptions(!1,16),E.setStructuralOptions(!0),E.setFacadeClassifierOptions(3);const R=new Map,$=new Map;let G=0;for(const{feature:Re}of d){if(Y3e[Re.type]!=="LineString"){R.set(Re.id,Re.properties.source_id);continue}const Ke=this.layers[0]._featureFilter.needGeometry;if(Ke&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),Re,v))continue;const Xe=Wt(Re,Ke);if(!Ke&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),Xe,v))continue;const lt=Ke?Xe.geometry:Ot(Re,v,C),kt=[];for(const qt of lt)for(const ss of qt)kt.push(ss.x),kt.push(ss.y);const vt={coordinates:kt,crossPerc:Re.properties.cross_perc,distanceToRoad:Re.properties.distance_to_road,entrances:Re.properties.entrances,sourceId:0},At=Re.properties.source_id;let zt=$.get(At);zt||(zt=[],$.set(At,zt)),zt.push(vt),++G}this.maxHeight=0;const te=new Array,se=new Set,ae=Re=>{Re!=null&&se.add(Re)},de=(Re,Ke)=>{Re!=null&&te.push({buildingId:Re,footprintIndex:Ke})},he=64*(d.length-G),Se=he/2;this.buildingWithFacade.reserve(he,Se,!0),this.buildingWithoutFacade.reserve(2*he,2*Se,!1),this.footprintsIndices.reserve(16*(d.length-G)),this.footprintsVertices.reserve(8*(d.length-G));for(const{feature:Re,id:Ke,index:Xe,sourceLayerIndex:lt}of d){if(Y3e[Re.type]==="LineString")continue;const kt=this.layers[0]._featureFilter.needGeometry;if(kt&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),Re,v))continue;let vt=null;if(Re.properties&&Re.properties.hasOwnProperty("building_id")&&(vt=Re.properties.building_id,se.has(vt)))continue;const At=Wt(Re,kt);if(!kt&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),At,v))continue;const zt=kt?At.geometry:Ot(Re,v,C),qt=K6(zt,500);let ss=!1;for(const rn of qt)if(rn.length!==1){ss=!0;break}if(ss){ae(vt);continue}if(!Kdt(zt,163)){ae(vt);continue}const Gt=this.layers[0],ds=Zdt(Gt.layout.get("building-roof-shape").evaluate(Re,{},v)),js=Gt.layout.get("building-base").evaluate(Re,{},v),Ns=Gt.layout.get("building-height").evaluate(Re,{},v),Fs=Gt.layout.get("building-flood-light-ground-radius").evaluate(Re,{},v),Bs=Gt.paint.get("building-ambient-occlusion-intensity"),Ls=Fs/this.tileToMeter;Re.properties["building-part"]="roof";const Os=Gt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),ls=Gt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);Re.properties["building-part"]="wall";const rs=Gt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),Rs=Gt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);Re.properties["building-part"]="window";const sr=Gt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),Vs=Gt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);Re.properties["building-part"]="door";const zr=Gt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),mr=Gt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);let _r=Gt.layout.get("building-flood-light-wall-radius").evaluate(Re,{},v);_r=ke(_r,0,2048);const Tr=_r/2048*WF,ta=R.get(Ke),Zs=$.get(ta)||[],Ar=Zs.length!==0&&Gt.layout.get("building-facade").evaluate(Re,{},v);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(Ar,!1,1);let _n=0,ja=0,Ca=0,$n=0,Ai=0,_t=0,Ct=0,us=0,zs=0,or=0,lr=0;if(Ar){let rn=Math.round(Gt.layout.get("building-facade-floors").evaluate(Re,{},v));if(js===0){rn=Math.max(1,rn-(Zs.length>0?1:0));let wi=4;if(Ns>100){const ao=[10,13,15];wi=ao[Re.id?Re.id%ao.length:0]}else Ns<=10&&(wi=3);E.setFacadeOptions(wi,!0),Ai=(Ns<15?1.3:1.61803)*wi/P}else Ai=js/P;_t=Ns/P,Ai=Math.min(Ai,_t),Ca=Gt.layout.get("building-facade-unit-width").evaluate(Re,{},v)/P,$n=(_t-Ai)/rn,E.setFauxFacadeOptions(!0,!0,Ca);const jo=Gt.layout.get("building-facade-window").evaluate(Re,{},v);_n=jo[0],ja=jo[1],Ct=Math.floor(65535*Math.min(1,Ai/tr)),us=Math.floor(65535*Math.min(1,_t/tr)),zs=Math.floor(255*_n)<<8|Math.floor(255*ja),or=Math.floor(65535*Math.min(1,Ca/tr)),lr=Math.floor(65535*Math.min(1,$n/tr))}const Br=Array(qt.length),Vr={x:1/0,y:1/0},In={x:-1/0,y:-1/0},Kn={x:0,y:0};let Qn=0;for(let rn=0;rn0){const wi=[],ao=Array(jo.length+1);ao[0]=0;for(let Vl=0;Vltr||Vr.y<0||In.y>tr)&&this.featuresOnBorder.push({featureId:Re.id,footprintIndex:this.footprints.length});{const rn=U3(Li,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+rn.length),this.footprintsIndices.uint16.set(rn,sn),this.buildingIds.add(vt??Re.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Ui.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Ui.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Zi.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Zi.y);const jo={footprintVertexOffset:ga,footprintVertexLength:this.footprintsVertices.length-ga,footprintIndexOffset:sn,footprintIndexLength:this.footprintsIndices.length-sn,min:Ui,max:Zi,hiddenFlags:0,indicesOffset:hi,indicesLength:mo,bloomIndicesOffset:_i,bloomIndicesLength:Ri,groundEffectVertexOffset:el,groundEffectVertexLength:Hi,hasFauxFacade:Ar,height:Zn,promoteId:Ke,feature:At,parts:Za,buildingBloom:Ya},wi=this.footprints.length;Re.id!==void 0&&this.featureFootprintLookup.set(Re.id,wi),de(vt,wi),this.footprints.push(jo)}this.programConfigurations.populatePaintArrays(an.layoutVertexArray.length,Re,Xe,{},m.availableImages,v,m.brightness),this.groundEffect.addPaintPropertiesData(Re,Xe,{},m.availableImages,v,m.brightness),m.featureIndex.insert(Re,zt,Xe,lt,this.index,Ei)}te.forEach(({buildingId:Re,footprintIndex:Ke})=>{se.has(Re)&&(this.footprints[Ke].hiddenFlags|=4)});const Fe=new Set;this.buildingIds.forEach((Re,Ke,Xe)=>{se.has(Re)||Fe.add(Re)}),this.buildingIds=Fe,this.groundEffect.prepareBorderSegments()}update(d,m,v,C,E,P,R){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R),this.groundEffect.update(d,m,E,v,C,P,R),this.evaluate(this.layers[0],d),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(d){const m=v=>{v.layoutVertexBuffer=d.createVertexBuffer(v.layoutVertexArray,K3e.members),v.layoutNormalBuffer=d.createVertexBuffer(v.layoutNormalArray,$dt.members),v.layoutCentroidBuffer=d.createVertexBuffer(v.layoutCentroidArray,qdt.members),v.layoutFloodLightDataBuffer=d.createVertexBuffer(v.layoutFloodLightDataArray,Gdt.members),v.layoutFacadeDataArray&&v.layoutFacadeDataArray.length&&(v.layoutFacadeDataBuffer=d.createVertexBuffer(v.layoutFacadeDataArray,Vdt.members)),v.layoutFacadeVerticalRangeArray&&v.layoutFacadeVerticalRangeArray.length&&(v.layoutFacadeVerticalRangeBuffer=d.createVertexBuffer(v.layoutFacadeVerticalRangeArray,Hdt.members)),v.entranceBloom.layoutVertexArray.length&&(v.entranceBloom.layoutVertexBuffer=d.createVertexBuffer(v.entranceBloom.layoutVertexArray,K3e.members),v.entranceBloom.layoutAttenuationBuffer=d.createVertexBuffer(v.entranceBloom.layoutAttenuationArray,Wdt.members)),this.uploadUpdatedColorBuffer(d),this.uploadUpdatedIndexBuffer(d)};this.uploaded||(m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.groundEffect.upload(d)),this.groundEffect.uploadPaintProperties(d),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){const d=m=>{m.layoutVertexBuffer&&(m.layoutVertexBuffer.destroy(),m.layoutNormalBuffer.destroy(),m.layoutColorBuffer.destroy(),m.segmentsBucket.destroy(),m.indexBuffer&&m.indexBuffer.destroy(),m.entranceBloom.layoutVertexBuffer&&(m.entranceBloom.layoutVertexBuffer.destroy(),m.entranceBloom.layoutColorBuffer.destroy(),m.entranceBloom.layoutAttenuationBuffer.destroy(),m.entranceBloom.indexBuffer.destroy(),m.entranceBloom.segmentsBucket.destroy()))};d(this.buildingWithoutFacade),d(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(d,m,v=!0){let C=!1;const E=v?m:0,P=0|(v?-1:~m);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const R of d){const $=this.footprints[R],G=$.hiddenFlags&P|E;$.hiddenFlags!==G&&($.hiddenFlags=G,C=!0,this.groundEffect.updateHiddenByLandmarkRange($.groundEffectVertexOffset,$.groundEffectVertexLength,$.hiddenFlags!==0))}return C&&(this.indexArrayForConflationUploaded=!1),C}uploadUpdatedIndexBuffer(d){if(this.groundEffect.uploadHiddenByLandmark(d),this.indexArrayForConflationUploaded)return;const m=C=>{C.indexArray.length!==0&&(C.indexArrayForConflation.resize(C.indexArray.length),C.indexArrayForConflation.uint16.set(C.indexArray.uint16),C.entranceBloom.indexArrayForConflation.resize(C.entranceBloom.indexArray.length),C.entranceBloom.indexArrayForConflation.uint16.set(C.entranceBloom.indexArray.uint16))};m(this.buildingWithoutFacade),m(this.buildingWithFacade);for(const C of this.footprints){const E=C.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,P=C.indicesOffset+C.indicesLength;if(C.hiddenFlags!==0){for(let $=C.indicesOffset;${C.indexArray.length!==0&&(C.indexBuffer?C.indexBuffer.updateData(C.indexArrayForConflation):C.indexBuffer=d.createIndexBuffer(C.indexArrayForConflation,!0),C.entranceBloom.indexBuffer?C.entranceBloom.indexBuffer.updateData(C.entranceBloom.indexArrayForConflation):C.entranceBloom.indexBuffer=d.createIndexBuffer(C.entranceBloom.indexArrayForConflation,!0))};v(this.buildingWithoutFacade),v(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(d){const m=v=>{v.layoutColorBuffer?v.layoutColorBuffer.updateData(v.layoutColorArray):v.layoutColorBuffer=d.createVertexBuffer(v.layoutColorArray,Z3e.members,!0),v.layoutFacadePaintArray&&(v.layoutFacadePaintBuffer?v.layoutFacadePaintBuffer.updateData(v.layoutFacadePaintArray):v.layoutFacadePaintBuffer=d.createVertexBuffer(v.layoutFacadePaintArray,Udt.members,!0)),v.entranceBloom.layoutColorBuffer?v.entranceBloom.layoutColorBuffer.updateData(v.entranceBloom.layoutColorArray):v.entranceBloom.layoutColorBuffer=d.createVertexBuffer(v.entranceBloom.layoutColorArray,Z3e.members,!0)};m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(d,m){const v=d.paint.get("building-ambient-occlusion-intensity");for(const C of this.footprints){if(4&C.hiddenFlags)continue;const E=m[C.promoteId],P=C.feature;P.properties["building-part"]="roof";const R=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),$=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="wall";const G=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),te=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="window";const se=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ae=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="door";const de=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),he=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical),Se=C.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Re of C.parts){let Ke,Xe=R;Re.part===1?(Xe=R,Ke=$):Re.part===0?(Xe=G,Ke=te):Re.part===2?(Xe=se,Ke=ae):Re.part===3&&(Xe=de,Ke=he),Ke=ke(Ke,0,1);for(let lt=0;ltP.max.x||$.max.xP.max.y||$.max.yR.max.x||R.min.x>d||m>R.max.y||R.min.y>m||R.height<=v||Ydt(P,this.footprintsVertices.float32.subarray(2*R.footprintVertexOffset,2*(R.footprintVertexOffset+R.footprintVertexLength)),this.footprintsIndices.uint16.subarray(R.footprintIndexOffset,R.footprintIndexOffset+R.footprintIndexLength))&&(v=R.height,this.footprintLookup[E]=R,C=R.hiddenFlags!==0);if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:C};this.footprintLookup[E]=void 0}}function Ydt(x,d,m){for(let v=0;v1&&($=d[++R]);const te=Math.abs(G-$.left),se=Math.abs(G-$.right),ae=Math.min(te,se);let de;const he=E/v*(C+1);if($.isDash){const Se=C-Math.abs(he);de=Math.sqrt(ae*ae+Se*Se)}else de=C-Math.sqrt(ae*ae+he*he);this.image.data[P+G]=Math.max(0,Math.min(255,de+128))}}}addRegularDash(d,m){for(let $=d.length-1;$>=0;--$){const G=d[$],te=d[$+1];G.zeroLength?d.splice($,1):te&&te.isDash===G.isDash&&(te.left=G.left,d.splice($,1))}const v=d[0],C=d[d.length-1];v.isDash===C.isDash&&(v.left=C.left-this.width,C.right=v.right+this.width);const E=this.width*this.nextRow;let P=0,R=d[P];for(let $=0;$1&&(R=d[++P]);const G=Math.abs($-R.left),te=Math.abs($-R.right),se=Math.min(G,te);this.image.data[E+$]=Math.max(0,Math.min(255,(R.isDash?se:-se)+m+128))}}addDash(d,m){const v=this.getKey(d,m);if(this.positions[v])return this.positions[v];const C=m==="round",E=C?7:0,P=2*E+1;if(this.nextRow+P>this.height)return xr("LineAtlas out of space"),null;d.length===0&&d.push(1);let R=0;for(let te=0;tem.fqid),this.index=d.index,this.projection=d.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(m=>{this.gradients[m.id]={}}),this.layoutVertexArray=new N3,this.layoutVertexArray2=new dm,this.patternVertexArray=new dm,this.indexArray=new $l,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.segments=new bo,this.maxLineLength=0,this.zOffsetVertexArray=new dm,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.tessellationStep=d.tessellationStep?d.tessellationStep:tr/64,this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){this.hasPattern=dpe("line",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Ve(v);const P=this.layers[0].layout.get("line-elevation-reference");if(P==="hd-road-markup")this.elevationType="road";else{const ae=this.layers[0].layout.get("line-z-offset"),de=ae.isConstant()&&!ae.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&de?"none":"offset",this.elevationType==="offset"&&P==="none"&&xr(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const R=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&R!==void 0;const $=[];for(const{feature:ae,id:de,index:he,sourceLayerIndex:Se}of d){const Fe=this.layers[0]._featureFilter.needGeometry,Re=Wt(ae,Fe);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Re,v))continue;const Ke=E?E.evaluate(Re,{},v):void 0,Xe={id:de,properties:ae.properties,type:ae.type,sourceLayerIndex:Se,index:he,geometry:Fe?Re.geometry:Ot(ae,v,C),patterns:{},sortKey:Ke};$.push(Xe)}E&&$.sort((ae,de)=>ae.sortKey-de.sortKey);const{lineAtlas:G,featureIndex:te}=m,se=this.addConstantDashes(G);for(const ae of $){const{geometry:de,index:he,sourceLayerIndex:Se}=ae;if(se&&this.addFeatureDashes(ae,G),this.hasPattern){const Fe=upe("line",this.layers,ae,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Fe)}else this.addFeature(ae,de,he,v,G.positions,m.availableImages,m.brightness,m.elevationFeatures);te.insert(d[he].feature,de,he,Se,this.index)}}addConstantDashes(d){let m=!1;for(const v of this.layers){const C=v.paint.get("line-dasharray").value,E=v.layout.get("line-cap").value;if(C.kind!=="constant"||E.kind!=="constant")m=!0;else{const P=E.value,R=C.value;if(!R)continue;d.addDash(R,P)}}return m}addFeatureDashes(d,m){const v=this.zoom;for(const C of this.layers){const E=C.paint.get("line-dasharray").value,P=C.layout.get("line-cap").value;if(E.kind==="constant"&&P.kind==="constant")continue;let R,$;if(E.kind==="constant"){if(R=E.value,!R)continue}else R=E.evaluate({zoom:v},d);$=P.kind==="constant"?P.value:P.evaluate({zoom:v},d),m.addDash(R,$),d.patterns[C.id]=[m.getKey(R,$)]}}update(d,m,v,C,E,P,R,$){this.programConfigurations.updatePaintArrays(d,m,E,v,C,P,R,$)}addFeatures(d,m,v,C,E,P){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,m,v,C,P,d.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=d.createVertexBuffer(this.layoutVertexArray2,sut)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=d.createVertexBuffer(this.patternVertexArray,nut)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,Jdt.members,!0)),this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,eut),this.indexBuffer=d.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(d,m){let v,C;if(m&&m>0?(v=`mapbox_clip_start_${m}`,C=`mapbox_clip_end_${m}`):(v="mapbox_clip_start",C="mapbox_clip_end"),d.properties&&d.properties.hasOwnProperty(v)&&d.properties.hasOwnProperty(C))return{start:+d.properties[v],end:+d.properties[C]}}addFeature(d,m,v,C,E,P,R,$){const G=this.layers[0].layout,te=G.get("line-join").evaluate(d,{}),se=G.get("line-cap").evaluate(d,{}),ae=G.get("line-miter-limit"),de=G.get("line-round-limit");this.lineClips=this.lineFeatureClips(d),this.lineFeature=d;const he=!(!d.properties||!d.properties.hasOwnProperty("mapbox_line_metrics"))&&d.properties.mapbox_line_metrics;this.zOffsetValue=G.get("line-z-offset").value;const Se=this.layers[0].paint.get("line-width").value;if(Se.kind!=="constant"&&Se.isLineProgressConstant===!1&&(this.variableWidthValue=Se),this.elevationType==="road"){const Fe=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(d,m,C,$,te,se,ae,de)){const[Re,Ke]=this.clipRuntimeLinesToTile(m,1);for(let Xe=0;Xe0?kt.parentIndex:null)}this.fillNonElevatedRoadSegment(Fe)}}else for(let Fe=0;Fe0?Fe:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,v,E,P,C,R,void 0,this.worldview)}computeSegNextDir(d,m){return d.nextPoint.sub(m.at(-2)).unit()}computeSegPrevDir(d,m){return m[1].sub(d.prevPoint).unit()}clipLinesToTile(d,m){return OF(d,-m,-m,tr+m,tr+m)}clipRuntimeLinesToTile(d,m){const v=[];return[OF(d,-m,-m,tr+m,tr+m,v),v]}addElevatedRoadFeature(d,m,v,C,E,P,R,$){const G=[],te=di.getElevationFeature(d,C);if(te){const se=this.clipLinesToTile(m,1),ae=this.prepareElevatedLines(se,te,v);for(const de of ae)G.push({geometry:de,elevation:te,elevationTileID:v,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(G.length===0)return!1;for(const se of G){const ae=this.layoutVertexArray.length;this.addLine(se.geometry,d,v,E,P,R,$);const de=new Ci(v,se.elevationTileID);if(se.elevation)for(let he=ae;he>1,this.layoutVertexArray.int16[6*he+1]>>1),Fe=de.pointElevation(Se,se.elevation,.05);this.updateHeightRange(Fe),this.zOffsetVertexArray.emplaceBack(Fe,0,0)}else this.fillNonElevatedRoadSegment(ae)}return!0}prepareElevatedLines(d,m,v){if(m.constantHeight!=null)return d;const C=[],E=1/Ve(v);for(const P of d)gdt(P,new Ka(m,E),0,C);return C}fillNonElevatedRoadSegment(d){for(let m=d;m0,ae=$&&$.progress.max<1;if(this.lineClips){let qt={min:this.lineClips.start,max:this.lineClips.end},ss=1;if($){const js=this.lineClips.end-this.lineClips.start;qt=function(Ns,Fs,Bs){return{min:Ti(Ns.min,Fs,Bs),max:Ti(Ns.max,Fs,Bs)}}($.progress,{min:0,max:1},qt),js>0&&(ss=(qt.max-qt.min)/js)}const Gt=+m.properties.mapbox_clip_feature_len,ds=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(Gt)||Number.isNaN(ds)){for(let Ns=0;Ns=2&&d[he-1].equals(d[he-2]);)he--;let Se=0;for(;Se0,ls=this.overscaling<=16?15*tr/(512*this.overscaling):0;if(ss&&Gt==="round"){if(FsP&&(Gt="bevel"),Gt==="bevel"&&(Fs>2&&(Gt="flipbevel"),Fs2*ls){const sr=Re.sub(Re.sub(Ke)._mult(ls/rs)._round());this.updateDistance(Ke,sr),this.addCurrentVertex(sr,lt,0,0,Fe,zt),Ke=sr}this.updateDistance(Ke,Re),js._mult(Fs),this.addCurrentVertex(Re,js,0,0,Fe,zt);const Rs=Re.dist(Xe);if(Rs>2*ls){const sr=Re.add(Xe.sub(Re)._mult(ls/Rs)._round());this.updateDistance(Re,sr),this.addCurrentVertex(sr,kt,0,0,Fe,zt),Re=sr}}else js._mult(Fs),this.addCurrentVertex(Re,js,0,0,Fe,zt);else if(Gt==="flipbevel"){if(Fs>100)js=kt.mult(-1);else{const rs=Fs*lt.add(kt).mag()/lt.sub(kt).mag();js._perp()._mult(rs*(Os?-1:1))}this.addCurrentVertex(Re,js,0,0,Fe,zt),this.addCurrentVertex(Re,js.mult(-1),0,0,Fe,zt)}else if(Gt==="bevel"||Gt==="fakeround"){zt!=null&&Ke&&this.addCurrentVertex(Re,At||lt,-1,-1,Fe,zt);const rs=Re.dist(Ke)<=2*ls&&Gt!=="bevel",Rs=js.mult(Os?1:-1);Rs._mult(Fs);const sr=kt.mult(Os?-1:1),Vs=lt.mult(Os?-1:1),zr=this.evaluateLineProgressFeatures(this.distance);if(zt==null&&(this.addHalfVertex(Re,Rs.x,Rs.y,!1,!Os,0,Fe,zr),rs||this.addHalfVertex(Re,Rs.x+2*Vs.x,Rs.y+2*Vs.y,!1,Os,0,Fe,zr)),Gt==="fakeround"){const mr=Math.round(180*Bs/Math.PI/20);this.addHalfVertex(Re,Vs.x,Vs.y,!1,Os,0,Fe,zr);for(let _r=0;_r1){this.lineSoFar=d.w;const Se=(m.x-d.x)/se,Fe=(m.y-d.y)/se,Re=(m.z-d.z)/se,Ke=(m.w-d.w)/se;for(let Xe=1;Xe=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,te),$.primitiveLength++),P?this.e2=te:this.e1=te,G!=null&&this.zOffsetVertexArray.emplaceBack(G.zOffset,G.variableWidth,G.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(d,m){this.prevDistance=this.distance,this.distance+=d.dist(m),this.updateScaledDistance()}}function zpe(x,d,m){return x.xm||x.ym}let t5e,s5e;function r5e(x,d,m){return d*(tr/(x.tileSize*Math.pow(2,m-x.tileID.overscaledZ)))}kr(Fpe,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const n5e=(x,d,m)=>(1-m)*x+m*d;function a5e(x,d){return 1/r5e(x,1,d.tileZoom)}function i5e(x,d,m,v){return x.translatePosMatrix(v||d.tileID.projMatrix,d,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const o5e=x=>{const d=[];l5e(x)&&d.push("RENDER_LINE_DASH"),x.paint.get("line-gradient")&&d.push("RENDER_LINE_GRADIENT");const m=x.paint.get("line-trim-offset");m[0]===0&&m[1]===0||d.push("RENDER_LINE_TRIM_OFFSET"),x.paint.get("line-border-width").constantOr(1)!==0&&d.push("RENDER_LINE_BORDER");const v=x.layout.get("line-join").constantOr("miter")==="none",C=!!x.paint.get("line-pattern").constantOr(1);return v&&C&&d.push("LINE_JOIN_NONE"),d};function l5e(x){const d=x.paint.get("line-dasharray").value;return d.kind!=="constant"||d.value}let Bpe;const c5e=()=>Bpe||(Bpe={layout:t5e||(t5e=new Io({"line-cap":new ar(Kt.layout_line["line-cap"]),"line-join":new ar(Kt.layout_line["line-join"]),"line-miter-limit":new Xs(Kt.layout_line["line-miter-limit"]),"line-round-limit":new Xs(Kt.layout_line["line-round-limit"]),"line-sort-key":new ar(Kt.layout_line["line-sort-key"]),"line-z-offset":new ar(Kt.layout_line["line-z-offset"]),"line-elevation-reference":new Xs(Kt.layout_line["line-elevation-reference"]),"line-cross-slope":new Xs(Kt.layout_line["line-cross-slope"]),visibility:new Xs(Kt.layout_line.visibility),"line-width-unit":new Xs(Kt.layout_line["line-width-unit"])})),paint:s5e||(s5e=new Io({"line-opacity":new ar(Kt.paint_line["line-opacity"]),"line-color":new ar(Kt.paint_line["line-color"]),"line-translate":new Xs(Kt.paint_line["line-translate"]),"line-translate-anchor":new Xs(Kt.paint_line["line-translate-anchor"]),"line-width":new ar(Kt.paint_line["line-width"]),"line-gap-width":new ar(Kt.paint_line["line-gap-width"]),"line-offset":new ar(Kt.paint_line["line-offset"]),"line-blur":new ar(Kt.paint_line["line-blur"]),"line-dasharray":new ar(Kt.paint_line["line-dasharray"]),"line-pattern":new ar(Kt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Xs(Kt.paint_line["line-pattern-cross-fade"]),"line-gradient":new uv(Kt.paint_line["line-gradient"]),"line-trim-offset":new Xs(Kt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Xs(Kt.paint_line["line-trim-fade-range"]),"line-trim-color":new Xs(Kt.paint_line["line-trim-color"]),"line-emissive-strength":new ar(Kt.paint_line["line-emissive-strength"]),"line-border-width":new ar(Kt.paint_line["line-border-width"]),"line-border-color":new ar(Kt.paint_line["line-border-color"]),"line-occlusion-opacity":new Xs(Kt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"})}))},Bpe);class lut extends ar{possiblyEvaluate(d,m){return m=new Ki(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,transition:m.transition,worldview:m.worldview}),super.possiblyEvaluate(d,m)}evaluate(d,m,v,C){return m=Object.assign({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(d,m,v,C)}}let iP;function d5e(x,d){return d>0?d+2*x:x}const cut=fa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),dut=fa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),uut=fa([{name:"a_projected_pos",components:4,type:"Float32"}],4);fa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const hut=fa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),mut=fa([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),put=fa([{name:"a_texb",components:2,type:"Uint16"}]),fut=fa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),xut=fa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);fa([{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 u5e=fa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),gut=fa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);fa([{name:"triangle",components:3,type:"Uint16"}]),fa([{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"}]),fa([{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"}]),fa([{type:"Float32",name:"offsetX"}]),fa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ac=24;function yut(x,d,m){return x.sections.forEach(v=>{v.text=function(C,E,P){const R=E.layout.get("text-transform").evaluate(P,{});return R==="uppercase"?C=C.toLocaleUpperCase():R==="lowercase"&&(C=C.toLocaleLowerCase()),og.applyArabicShaping&&(C=og.applyArabicShaping(C)),C}(v.text,d,m)}),x}const oP={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function vut(x){return x==="︶"||x==="﹈"||x==="︸"||x==="﹄"||x==="﹂"||x==="︾"||x==="︼"||x==="︺"||x==="︘"||x==="﹀"||x==="︐"||x==="︓"||x==="︔"||x==="`"||x===" ̄"||x==="︑"||x==="︒"}function but(x){return x==="︵"||x==="﹇"||x==="︷"||x==="﹃"||x==="﹁"||x==="︽"||x==="︻"||x==="︹"||x==="︗"||x==="︿"}const $pe=4294967296,h5e=1/$pe,m5e=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let GF=class{constructor(x=new Uint8Array(16)){this.buf=ArrayBuffer.isView(x)?x:new Uint8Array(x),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(x,d,m=this.length){for(;this.pos>3,E=this.pos;this.type=7&v,x(C,d,this),this.pos===E&&this.skip(v)}return d}readMessage(x,d){return this.readFields(x,d,this.readVarint()+this.pos)}readFixed32(){const x=this.dataView.getUint32(this.pos,!0);return this.pos+=4,x}readSFixed32(){const x=this.dataView.getInt32(this.pos,!0);return this.pos+=4,x}readFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*$pe;return this.pos+=8,x}readSFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*$pe;return this.pos+=8,x}readFloat(){const x=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,x}readDouble(){const x=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,x}readVarint(x){const d=this.buf;let m,v;return v=d[this.pos++],m=127&v,v<128?m:(v=d[this.pos++],m|=(127&v)<<7,v<128?m:(v=d[this.pos++],m|=(127&v)<<14,v<128?m:(v=d[this.pos++],m|=(127&v)<<21,v<128?m:(v=d[this.pos],m|=(15&v)<<28,function(C,E,P){const R=P.buf;let $,G;if(G=R[P.pos++],$=(112&G)>>4,G<128||(G=R[P.pos++],$|=(127&G)<<3,G<128)||(G=R[P.pos++],$|=(127&G)<<10,G<128)||(G=R[P.pos++],$|=(127&G)<<17,G<128)||(G=R[P.pos++],$|=(127&G)<<24,G<128)||(G=R[P.pos++],$|=(1&G)<<31,G<128))return Y3(C,$,E);throw new Error("Expected varint not more than 10 bytes")}(m,x,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const x=this.readVarint();return x%2==1?(x+1)/-2:x/2}readBoolean(){return!!this.readVarint()}readString(){const x=this.readVarint()+this.pos,d=this.pos;return this.pos=x,x-d>=12&&m5e?m5e.decode(this.buf.subarray(d,x)):function(m,v,C){let E="",P=v;for(;P239?4:R>223?3:R>191?2:1;if(P+ae>C)break;ae===1?R<128&&(se=R):ae===2?($=m[P+1],(192&$)==128&&(se=(31&R)<<6|63&$,se<=127&&(se=null))):ae===3?($=m[P+1],G=m[P+2],(192&$)==128&&(192&G)==128&&(se=(15&R)<<12|(63&$)<<6|63&G,(se<=2047||se>=55296&&se<=57343)&&(se=null))):ae===4&&($=m[P+1],G=m[P+2],te=m[P+3],(192&$)==128&&(192&G)==128&&(192&te)==128&&(se=(15&R)<<18|(63&$)<<12|(63&G)<<6|63&te,(se<=65535||se>=1114112)&&(se=null))),se===null?(se=65533,ae=1):se>65535&&(se-=65536,E+=String.fromCharCode(se>>>10&1023|55296),se=56320|1023&se),E+=String.fromCharCode(se),P+=ae}return E}(this.buf,d,x)}readBytes(){const x=this.readVarint()+this.pos,d=this.buf.subarray(this.pos,x);return this.pos=x,d}readPackedVarint(x=[],d){const m=this.readPackedEnd();for(;this.pos127;);else if(d===2)this.pos=this.readVarint()+this.pos;else if(d===5)this.pos+=4;else{if(d!==1)throw new Error(`Unimplemented type: ${d}`);this.pos+=8}}writeTag(x,d){this.writeVarint(x<<3|d)}realloc(x){let d=this.length||16;for(;d268435455||x<0?function(d,m){let v,C;if(d>=0?(v=d%4294967296|0,C=d/4294967296|0):(v=~(-d%4294967296),C=~(-d/4294967296),4294967295^v?v=v+1|0:(v=0,C=C+1|0)),d>=18446744073709552e3||d<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");m.realloc(10),function(E,P,R){R.buf[R.pos++]=127&E|128,E>>>=7,R.buf[R.pos++]=127&E|128,E>>>=7,R.buf[R.pos++]=127&E|128,E>>>=7,R.buf[R.pos++]=127&E|128,R.buf[R.pos]=127&(E>>>=7)}(v,0,m),function(E,P){const R=(7&E)<<4;P.buf[P.pos++]|=R|((E>>>=3)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E)))))}(C,m)}(x,this):(this.realloc(4),this.buf[this.pos++]=127&x|(x>127?128:0),x<=127||(this.buf[this.pos++]=127&(x>>>=7)|(x>127?128:0),x<=127||(this.buf[this.pos++]=127&(x>>>=7)|(x>127?128:0),x<=127||(this.buf[this.pos++]=x>>>7&127))))}writeSVarint(x){this.writeVarint(x<0?2*-x-1:2*x)}writeBoolean(x){this.writeVarint(+x)}writeString(x){x=String(x),this.realloc(4*x.length),this.pos++;const d=this.pos;this.pos=function(v,C,E){for(let P,R,$=0;$55295&&P<57344){if(!R){P>56319||$+1===C.length?(v[E++]=239,v[E++]=191,v[E++]=189):R=P;continue}if(P<56320){v[E++]=239,v[E++]=191,v[E++]=189,R=P;continue}P=R-55296<<10|P-56320|65536,R=null}else R&&(v[E++]=239,v[E++]=191,v[E++]=189,R=null);P<128?v[E++]=P:(P<2048?v[E++]=P>>6|192:(P<65536?v[E++]=P>>12|224:(v[E++]=P>>18|240,v[E++]=P>>12&63|128),v[E++]=P>>6&63|128),v[E++]=63&P|128)}return E}(this.buf,x,this.pos);const m=this.pos-d;m>=128&&p5e(d,m,this),this.pos=d-1,this.writeVarint(m),this.pos+=m}writeFloat(x){this.realloc(4),this.dataView.setFloat32(this.pos,x,!0),this.pos+=4}writeDouble(x){this.realloc(8),this.dataView.setFloat64(this.pos,x,!0),this.pos+=8}writeBytes(x){const d=x.length;this.writeVarint(d),this.realloc(d);for(let m=0;m=128&&p5e(m,v,this),this.pos=m-1,this.writeVarint(v),this.pos+=v}writeMessage(x,d,m){this.writeTag(x,2),this.writeRawMessage(d,m)}writePackedVarint(x,d){d.length&&this.writeMessage(x,_ut,d)}writePackedSVarint(x,d){d.length&&this.writeMessage(x,wut,d)}writePackedBoolean(x,d){d.length&&this.writeMessage(x,kut,d)}writePackedFloat(x,d){d.length&&this.writeMessage(x,jut,d)}writePackedDouble(x,d){d.length&&this.writeMessage(x,Nut,d)}writePackedFixed32(x,d){d.length&&this.writeMessage(x,Sut,d)}writePackedSFixed32(x,d){d.length&&this.writeMessage(x,Cut,d)}writePackedFixed64(x,d){d.length&&this.writeMessage(x,Mut,d)}writePackedSFixed64(x,d){d.length&&this.writeMessage(x,Tut,d)}writeBytesField(x,d){this.writeTag(x,2),this.writeBytes(d)}writeFixed32Field(x,d){this.writeTag(x,5),this.writeFixed32(d)}writeSFixed32Field(x,d){this.writeTag(x,5),this.writeSFixed32(d)}writeFixed64Field(x,d){this.writeTag(x,1),this.writeFixed64(d)}writeSFixed64Field(x,d){this.writeTag(x,1),this.writeSFixed64(d)}writeVarintField(x,d){this.writeTag(x,0),this.writeVarint(d)}writeSVarintField(x,d){this.writeTag(x,0),this.writeSVarint(d)}writeStringField(x,d){this.writeTag(x,2),this.writeString(d)}writeFloatField(x,d){this.writeTag(x,5),this.writeFloat(d)}writeDoubleField(x,d){this.writeTag(x,1),this.writeDouble(d)}writeBooleanField(x,d){this.writeVarintField(x,+d)}};function Y3(x,d,m){return m?4294967296*d+(x>>>0):4294967296*(d>>>0)+(x>>>0)}function p5e(x,d,m){const v=d<=16383?1:d<=2097151?2:d<=268435455?3:Math.floor(Math.log(d)/(7*Math.LN2));m.realloc(v);for(let C=m.pos-1;C>=x;C--)m.buf[C+v]=m.buf[C]}function _ut(x,d){for(let m=0;m=0&&v>=d&&KF[this.text.charCodeAt(v)];v--)m--;this.text=this.text.substring(d,m),this.sectionIndex=this.sectionIndex.slice(d,m)}substring(d,m){const v=new X3;return v.text=this.text.substring(d,m),v.sectionIndex=this.sectionIndex.slice(d,m),v.sections=this.sections,v}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((d,m)=>Math.max(d,this.sections[m].scale),0)}addTextSection(d,m){this.text+=d.text,this.sections.push(lP.forText(d.scale,d.fontStack||m));const v=this.sections.length-1;for(let C=0;C=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Upe(x,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se=1){const Fe=X3.fromFeature(x,C,Se);se===pm.vertical&&Fe.verticalizePunctuation(ae);let Re=[];const Ke=function(At,zt,qt,ss,Gt,ds){if(!At)return[];const js=[],Ns=function(Os,ls,rs,Rs,sr,Vs){let zr=0;for(let mr=0;mr=0;let Bs=0;for(let Os=0;Os0&&Ya>$n&&($n=Ya)}else{const Va=qt[zs.fontStack];if(!Va)continue;Va[lr]&&(In=Va[lr]);const Za=zt[zs.fontStack];if(!Za)continue;const Ya=Za.glyphs[lr];if(!Ya)continue;if(Vr=Ya.metrics,Qn=lr!==8203?Ac:0,Vs){const _i=Za.ascender!==void 0?Math.abs(Za.ascender):0,Ri=Za.descender!==void 0?Math.abs(Za.descender):0,Ei=(_i+Ri)*Br;Ai-m/2;){if(P--,P<0)return!1;R-=x[P].dist(E),E=x[P]}R+=x[P].dist(x[P+1]),P++;const $=[];let G=0;for(;Rv;)G-=$.shift().angleDelta;if(G>C)return!1;P++,R+=te.dist(se)}return!0}function k5e(x){let d=0;for(let m=0;mG){const he=(G-$)/de,Se=Zr(se.x,ae.x,he),Fe=Zr(se.y,ae.y,he),Re=new vv(Se,Fe,0,ae.angleTo(se),te);return!P||N5e(x,Re,R,P,d)?Re:void 0}$+=de}}function Out(x,d,m,v,C,E,P,R,$){const G=S5e(v,E,P),te=C5e(v,C),se=te*P,ae=x[0].x===0||x[0].x===$||x[0].y===0||x[0].y===$;return d-se=0&<<$&&kt>=0&&kt<$&&ae-G>=0&&ae+G<=te){const vt=new vv(lt,kt,0,Ke,he);v&&!N5e(x,vt,E,v,C)||de.push(vt)}}se+=Re}return R||de.length||P||(de=M5e(x,se/2,m,v,C,E,P,!0,$)),de}function T5e(x){let d=0,m=0;for(const P of x)d+=P.w*P.h,m=Math.max(m,P.w);x.sort((P,R)=>R.h-P.h);const v=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(d/.95)),m),h:1/0}];let C=0,E=0;for(const P of x)for(let R=v.length-1;R>=0;R--){const $=v[R];if(!(P.w>$.w||P.h>$.h)){if(P.x=$.x,P.y=$.y,E=Math.max(E,P.y+P.h),C=Math.max(C,P.x+P.w),P.w===$.w&&P.h===$.h){const G=v.pop();G&&R1?he-1:he,Wd.copy(se.data,G,{x:0,y:0},{x:Se,y:Fe},se.data,v),Wd.copy(se.data,G,{x:0,y:Ke-he},{x:Se,y:Fe-he},{width:Re,height:he},v),Wd.copy(se.data,G,{x:0,y:0},{x:Se,y:Fe+Ke},{width:Re,height:he},v),Wd.copy(se.data,G,{x:Re-he,y:0},{x:Se-he,y:Fe},{width:he,height:Ke},v),Wd.copy(se.data,G,{x:0,y:0},{x:Se+Re,y:Fe},{width:he,height:Ke},v),Wd.copy(se.data,G,{x:Re-he,y:Ke-he},{x:Se-he,y:Fe-he},{width:he,height:he},v),Wd.copy(se.data,G,{x:0,y:Ke-he},{x:Se+Re,y:Fe-he},{width:he,height:he},v),Wd.copy(se.data,G,{x:0,y:0},{x:Se+Re,y:Fe+Ke},{width:he,height:he},v),Wd.copy(se.data,G,{x:Re-he,y:0},{x:Se-he,y:Fe+Ke},{width:he,height:he},v)}this.lut=v,this.image=G,this.iconPositions=C,this.patternPositions=E}addImages(d,m,v,C){for(const[E,P]of d.entries()){const{bin:R,imagePosition:$,imageVariant:G}=Kpe(E,P,v);m.set(E,$),C.push(R),P.hasRenderCallback&&this.haveRenderCallbacks.push(G.id)}}patchUpdatedImages(d,m,v){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(C=>d.hasImage(C,v)),d.dispatchRenderCallbacks(this.haveRenderCallbacks,v);for(const C of d.getUpdatedImages(v)){for(const E of this.iconPositions.keys()){const P=eg.parse(E);if(Qs.isEqual(P.id,C)){const R=d.getImage(C,v);this.patchUpdatedImage(this.iconPositions.get(E),R,m,null)}}for(const E of this.patternPositions.keys()){const P=eg.parse(E);if(Qs.isEqual(P.id,C)){const R=d.getImage(C,v);this.patchUpdatedImage(this.patternPositions.get(E),R,m,this.lut)}}}}patchUpdatedImage(d,m,v,C=null){if(!d||!m||d.version===m.version)return;d.version=m.version;const[E,P]=d.tl,R=d.sdf;if(this.lut||R){const $={width:m.data.width,height:m.data.height},G=new Wd($);Wd.copy(m.data,G,{x:0,y:0},{x:0,y:0},$,C,R),v.update(G,{position:{x:E,y:P}})}else v.update(m.data,{position:{x:E,y:P}})}}kr(cP,"ImagePosition"),kr(A5e,"ImageAtlas");const dP=1e20;function E5e(x,d,m,v,C,E,P,R,$){for(let G=d;G-1);$++,E[$]=R,P[$]=G,P[$+1]=dP}for(let R=0,$=0;R{let $=this.entries[E];$||($=this.entries[E]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let G=$.glyphs[P];if(G!==void 0)return void R(null,{stack:E,id:P,glyph:G});if(G=this._tinySDF($,E,P),G)return $.glyphs[P]=G,void R(null,{stack:E,id:P,glyph:G});const te=Math.floor(P/256);if(256*te>65535)return xr("glyphs > 65535 not supported"),void R(null,{stack:E,id:P,glyph:G});if($.ranges[te])return void R(null,{stack:E,id:P,glyph:G});let se=$.requests[te];se||(se=$.requests[te]=[],e5.loadGlyphRange(E,te,C,this.requestManager,(ae,de)=>{if(de){$.ascender=de.ascender,$.descender=de.descender;for(const he in de.glyphs)this._doesCharSupportLocalGlyph(+he)||($.glyphs[+he]=de.glyphs[+he]);$.ranges[te]=!0}for(const he of se)he(ae,de);delete $.requests[te]})),se.push((ae,de)=>{ae?R(ae):de&&R(null,{stack:E,id:P,glyph:de.glyphs[P]||null})})},(E,P)=>{if(E)m(E);else if(P){const R={};for(const{stack:$,id:G,glyph:te}of P)R[$]===void 0&&(R[$]={}),R[$].glyphs===void 0&&(R[$].glyphs={}),R[$].glyphs[G]=te&&{id:te.id,bitmap:te.bitmap.clone(),metrics:te.metrics},R[$].ascender=this.entries[$].ascender,R[$].descender=this.entries[$].descender;m(null,R)}})}_doesCharSupportLocalGlyph(d){return this.localGlyphMode!==Zpe.none&&(this.localGlyphMode===Zpe.all?!!this.localFontFamily:!!this.localFontFamily&&(en["CJK Unified Ideographs"](d)||en["Hangul Syllables"](d)||en.Hiragana(d)||en.Katakana(d)||en["CJK Symbols and Punctuation"](d)||en["CJK Unified Ideographs Extension A"](d)||en["CJK Unified Ideographs Extension B"](d)||en.Osage(d)))}_tinySDF(d,m,v){const C=this.localFontFamily;if(!C||!this._doesCharSupportLocalGlyph(v))return;let E=d.tinySDF;if(!E){let Se="400";/bold/i.test(m)?Se="900":/medium/i.test(m)?Se="500":/light/i.test(m)&&(Se="200"),E=d.tinySDF=new e5.TinySDF({fontFamily:C,fontWeight:Se,fontSize:24*yg,buffer:3*yg,radius:8*yg}),E.fontWeight=Se}if(this.localGlyphs[E.fontWeight][v])return this.localGlyphs[E.fontWeight][v];const P=String.fromCodePoint(v),{data:R,width:$,height:G,glyphWidth:te,glyphHeight:se,glyphLeft:ae,glyphTop:de,glyphAdvance:he}=E.draw(P);return this.localGlyphs[E.fontWeight][v]={id:v,bitmap:new jb({width:$,height:G},R),metrics:{width:te/yg,height:se/yg,left:ae/yg,top:de/yg-27,advance:he/yg,localGlyph:!0}}}}e5.loadGlyphRange=function(x,d,m,v,C){const E=256*d,P=E+255,R=v.transformRequest(v.normalizeGlyphsURL(m).replace("{fontstack}",x).replace("{range}",`${E}-${P}`),Xx.Glyphs);Lh(R,($,G)=>{if($)C($);else if(G){const te={},se=function(ae){return new GF(ae).readFields(Aut,{})}(G);for(const ae of se.glyphs)te[ae.id]=ae;C(null,{glyphs:te,ascender:se.ascender,descender:se.descender})}})},e5.TinySDF=class{constructor({fontSize:x=24,buffer:d=3,radius:m=8,cutoff:v=.25,fontFamily:C="sans-serif",fontWeight:E="normal",fontStyle:P="normal",lang:R=null}={}){this.buffer=d,this.cutoff=v,this.radius=m,this.lang=R;const $=this.size=x+4*d,G=this._createCanvas($),te=this.ctx=G.getContext("2d",{willReadFrequently:!0});te.font=`${P} ${E} ${x}px ${C}`,te.textBaseline="alphabetic",te.textAlign="left",te.fillStyle="black",this.gridOuter=new Float64Array($*$),this.gridInner=new Float64Array($*$),this.f=new Float64Array($),this.z=new Float64Array($+1),this.v=new Uint16Array($)}_createCanvas(x){const d=document.createElement("canvas");return d.width=d.height=x,d}draw(x){const{width:d,actualBoundingBoxAscent:m,actualBoundingBoxDescent:v,actualBoundingBoxLeft:C,actualBoundingBoxRight:E}=this.ctx.measureText(x),P=Math.ceil(m),R=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(E-C))),$=Math.min(this.size-this.buffer,P+Math.ceil(v)),G=R+2*this.buffer,te=$+2*this.buffer,se=Math.max(G*te,0),ae=new Uint8ClampedArray(se),de={data:ae,width:G,height:te,glyphWidth:R,glyphHeight:$,glyphTop:P,glyphLeft:0,glyphAdvance:d};if(R===0||$===0)return de;const{ctx:he,buffer:Se,gridInner:Fe,gridOuter:Re}=this;this.lang&&(he.lang=this.lang),he.clearRect(Se,Se,R,$),he.fillText(x,Se,Se+P);const Ke=he.getImageData(Se,Se,R,$);Re.fill(dP,0,se),Fe.fill(0,0,se);for(let Xe=0;Xe<$;Xe++)for(let lt=0;lt0?At*At:0,Fe[vt]=At<0?At*At:0}}E5e(Re,0,0,G,te,G,this.f,this.v,this.z),E5e(Fe,Se,Se,R,$,G,this.f,this.v,this.z);for(let Xe=0;Xe{const Fs=XF(Gt.stretch-Ke,Xe,te,x.left*C),Bs=QF(Gt.fixed-vt,At,Gt.stretch,he),Ls=XF(ds.stretch-lt,kt,se,x.top*C),Os=QF(ds.fixed-zt,qt,ds.stretch,Se),ls=XF(js.stretch-Ke,Xe,te,x.left*C),rs=QF(js.fixed-vt,At,js.stretch,he),Rs=XF(Ns.stretch-lt,kt,se,x.top*C),sr=QF(Ns.fixed-zt,qt,Ns.stretch,Se),Vs=new ft(Fs,Ls),zr=new ft(ls,Ls),mr=new ft(ls,Rs),_r=new ft(Fs,Rs),Tr=new ft(Bs/R,Os/R),ta=new ft(rs/R,sr/R),Zs=d*Math.PI/180;if(Zs){const Ai=Math.sin(Zs),_t=Math.cos(Zs),Ct=[_t,-Ai,Ai,_t];Vs._matMult(Ct),zr._matMult(Ct),_r._matMult(Ct),mr._matMult(Ct)}const Ar=Gt.stretch+Gt.fixed,_n=js.stretch+js.fixed,ja=ds.stretch+ds.fixed,Ca=Ns.stretch+Ns.fixed,$n=x.imageSecondary;return{tl:Vs,tr:zr,bl:_r,br:mr,texPrimary:{x:P.paddedRect.x+zy+Ar,y:P.paddedRect.y+zy+ja,w:_n-Ar,h:Ca-ja},texSecondary:$n?{x:$n.paddedRect.x+zy+Ar,y:$n.paddedRect.y+zy+ja,w:_n-Ar,h:Ca-ja}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Tr,pixelOffsetBR:ta,minFontScaleX:At/R/te,minFontScaleY:qt/R/se,isSDF:m}};if(v&&(P.stretchX||P.stretchY)){const Gt=L5e(ae,Fe,he),ds=L5e(de,Re,Se);for(let js=0;jsE)&&(E=he.x),(!de||he.y>P)&&(P=he.y)}const $=Math.min(E-v,P-C);let G=$/2;const te=new VC([],But);if($===0)return new ft(v,C);for(let de=v;dese.d||!se.d)&&(se=de,m&&console.log("found best %d after %d probes",Math.round(1e4*de.d)/1e4,ae)),de.max-se.d<=d||(G=de.h/2,te.push(new t5(de.p.x-G,de.p.y-G,G,x)),te.push(new t5(de.p.x+G,de.p.y-G,G,x)),te.push(new t5(de.p.x-G,de.p.y+G,G,x)),te.push(new t5(de.p.x+G,de.p.y+G,G,x)),ae+=4)}return m&&(console.log(`num probes: ${ae}`),console.log(`best distance: ${se.d}`)),se.p}function But(x,d){return d.max-x.max}class t5{constructor(d,m,v,C){this.p=new ft(d,m),this.h=v,this.d=function(E,P){let R=!1,$=1/0;for(let G=0;GE.y!=Se.y>E.y&&E.x<(Se.x-he.x)*(E.y-he.y)/(Se.y-he.y)+he.x&&(R=!R),$=Math.min($,Ho(E,he,Se))}}return(R?1:-1)*Math.sqrt($)}(this.p,C),this.max=this.d+this.h*Math.SQRT2}}const $ut=Object.keys,Xpe=Number.POSITIVE_INFINITY,qut=Math.sqrt(2);function kb(x,d,m,v,C){const E=Hpe(x)&&x.collisionPadding?x.collisionPadding:[0,0,0,0],P={top:x.top-E[1],bottom:x.bottom+E[3],left:x.left-E[0],right:x.right+E[2],scaled:!1};return v!==void 0&&function(R,$){R.top*=$,R.bottom*=$,R.left*=$,R.right*=$,R.scaled=!0}(P,v),m&&function(R,$){if(!$)return;const G=jr($),te=new ft(R.left,R.top),se=new ft(R.right,R.top),ae=new ft(R.left,R.bottom),de=new ft(R.right,R.bottom),he=new ft(0,0);te._rotateAround(G,he),se._rotateAround(G,he),ae._rotateAround(G,he),de._rotateAround(G,he),R.left=Math.min(te.x,se.x,ae.x,de.x),R.right=Math.max(te.x,se.x,ae.x,de.x),R.top=Math.min(te.y,se.y,ae.y,de.y),R.bottom=Math.max(te.y,se.y,ae.y,de.y)}(P,m),C&&(P.left+=C[0],P.right+=C[0],P.top+=C[1],P.bottom+=C[1]),d?{top:Math.min(d.top,P.top),bottom:Math.max(d.bottom,P.bottom),left:Math.min(d.left,P.left),right:Math.max(d.right,P.right),scaled:d.scaled||P.scaled}:P}function O5e(x,[d,m]){let v=0,C=0;if(m===Xpe){d<0&&(d=0);const E=d/qut;switch(x){case"top-right":case"top-left":C=E-7;break;case"bottom-right":case"bottom-left":C=7-E;break;case"bottom":C=7-d;break;case"top":C=d-7}switch(x){case"top-right":case"bottom-right":v=-E;break;case"top-left":case"bottom-left":v=E;break;case"left":v=d;break;case"right":v=-d}}else{switch(d=Math.abs(d),m=Math.abs(m),x){case"top-right":case"top-left":case"top":C=m-7;break;case"bottom-right":case"bottom-left":case"bottom":C=7-m}switch(x){case"top-right":case"bottom-right":case"right":v=-d;break;case"top-left":case"bottom-left":case"left":v=d}}return[v,C]}function Uut(x,d,m,v,C,E,P,R,$,G,te,se,ae,de){const he=x.layers[0],Se=he.appearances;if(Se.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Fe={iconBBox:null,iconVerticalBBox:null},Re={textBBox:null,textVerticalBBox:null},{baseIconRotate:Ke,baseTextRotate:Xe,iconScaleFactor:lt}=function(vt,At,zt){const qt=vt.get("icon-rotate").evaluate(At,{},zt),ss=vt.get("text-rotate").evaluate(At,{},zt),[Gt,ds]=vt.get("icon-size-scale-range");return{baseIconRotate:qt,baseTextRotate:ss,iconScaleFactor:ke(1,Gt,ds)}}(v,C,E);d&&(Fe.iconBBox=kb(d,Fe.iconBBox,Ke,P),m)&&(Fe.iconVerticalBBox=kb(m,Fe.iconVerticalBBox,Ke+90,P));const kt=e7(se.horizontal);kt&&(Re.textBBox=kb(kt,Re.textBBox,Xe,1,de)),se.vertical&&(Re.textVerticalBBox=kb(se.vertical,Re.textVerticalBBox,Xe+90,1,de));for(const vt of Se)vt.hasIconProperties()&&Vut(Fe,x,he,vt,C,E,R,Ke,P,$,d,G,lt,te),vt.hasTextProperties()&&Hut(Re,he,vt,C,E,de,Xe,ae,kt,se.vertical);return{iconBBox:Fe.iconBBox,iconVerticalBBox:Fe.iconVerticalBBox,textBBox:Re.textBBox,textVerticalBBox:Re.textVerticalBBox}}function Vut(x,d,m,v,C,E,P,R,$,G,te,se,ae,de){const{appearanceIconOffset:he,appearanceIconRotate:Se,appearanceIconSize:Fe}=function(lt,kt,vt,At,zt,qt,ss,Gt){const ds=lt.hasProperty("icon-offset")?kt.getAppearanceValueAndResolveTokens(lt,"icon-offset",vt,At,[]):null,js=ds&&Array.isArray(ds)?ds:zt,Ns=lt.hasProperty("icon-rotate")?kt.getAppearanceValueAndResolveTokens(lt,"icon-rotate",vt,At,[]):null,Fs=typeof Ns=="number"?Ns:qt,Bs=lt.hasProperty("icon-size")?kt.getAppearanceValueAndResolveTokens(lt,"icon-size",vt,At,[]):null;return{appearanceIconOffset:js,appearanceIconRotate:Fs,appearanceIconSize:typeof Bs=="number"?Bs*Gt.iconScaleFactor:ss}}(v,m,C,E,P,R,$,G);let Re=null,Ke=null,Xe=null;v.hasProperty("icon-image")?Xe=function(lt,kt,vt,At,zt,qt,ss){let Gt=null;const ds=kt.getAppearanceValueAndResolveTokens(vt,"icon-image",At,zt,[]);if(ds){const js=lt.getResolvedImageFromTokens(ds),Ns=vt.getUnevaluatedProperty("icon-size"),Fs=uP(js,Q3(lt.zoom,Ns,lt.worldview),Ns,zt,lt.zoom,At,lt.pixelRatio,ss,lt.worldview);Gt=qt.get(Fs.iconPrimary.toString())}return Gt}(d,m,v,C,E,se,ae):te&&(Xe=te.imagePrimary),Xe&&(Re=ZF(Xe,null,he,de),d.allowVerticalPlacement&&(Ke=ZF(Xe,null,he,de))),Re&&(x.iconBBox=kb(Re,x.iconBBox,Se,Fe)),Ke&&(x.iconVerticalBBox=kb(Ke,x.iconVerticalBBox,Se+90,Fe))}function Hut(x,d,m,v,C,E,P,R,$,G){const{appearanceTextOffset:te,appearanceTextRotate:se,appearanceTextSize:ae}=function(he,Se,Fe,Re,Ke,Xe,lt){const kt=he.hasProperty("text-offset")?Se.getAppearanceValueAndResolveTokens(he,"text-offset",Fe,Re,[]):null,vt=kt&&Array.isArray(kt)?[kt[0]*Ac,kt[1]*Ac]:Ke,At=he.hasProperty("text-rotate")?Se.getAppearanceValueAndResolveTokens(he,"text-rotate",Fe,Re,[]):null,zt=typeof At=="number"?At:Xe,qt=he.hasProperty("text-size")?Se.getAppearanceValueAndResolveTokens(he,"text-size",Fe,Re,[]):null;return{appearanceTextOffset:vt,appearanceTextRotate:zt,appearanceTextSize:typeof qt=="number"?qt:lt}}(m,d,v,C,E,P,R),de=ae/R;$&&(x.textBBox=kb($,x.textBBox,se,de,te)),G&&(x.textVerticalBBox=kb(G,x.textVerticalBBox,se+90,de,te))}function JF(x,d,m,v,C,E,P,R,$){if(!d||!d.usvg)return;const G=j5e(v),te=j5e(C),se=E!=="both"&&E!=="width"||!_5e(v)?1:te.width/G.width,ae=E!=="both"&&E!=="height"||!w5e(v)?1:te.height/G.height;m.scaleSelf(se,ae);const de=m.toString();P.set(de,m),R.set(de,d);const{imagePosition:he}=Kpe(de,d,P2);$.set(de,he)}function R5e(x,d,m,v,C,E,P,R,$){if(!x)return;const G=function(te,se,ae,de,he,Se){if(te.kind==="camera")return te.maxSize;if(te.kind==="composite"){const Fe=se.possiblyEvaluate(new Ki(te.maxZoom,{worldview:Se}),ae).evaluate(he,{},ae),Re=se.possiblyEvaluate(new Ki(te.minZoom,{worldview:Se}),ae).evaluate(he,{},ae);return Math.max(Fe,Re)}return se.possiblyEvaluate(new Ki(de,{worldview:Se})).evaluate(he,{},ae)}(d,m,v,C,E,$);return x.scaleSelf(G*R*P)}function uP(x,d,m,v,C,E,P,R,$){return{iconPrimary:R5e(x.getPrimary(),d,m,v,C,E,P,R,$),iconSecondary:R5e(x.getSecondary(),d,m,v,C,E,P,R,$)}}function Wut(x,d,m){if(!d)return;const v=m.get(x.toString()),C=m.get(d.toString());v&&C&&(v.paddedRect.w===C.paddedRect.w&&v.paddedRect.h===C.paddedRect.h||xr(`Mismatch in icon variant sizes: ${x.toString()} and ${d.toString()}`),v.usvg!==C.usvg&&xr(`Mismatch in icon variant image types: ${x.id} and ${d.id}`))}function F5e(x,d,m,v){if(!x)return;const C=d.get(m.toString());if(x.imagePrimary=C,v){const E=d.get(v.toString());x.imageSecondary=E}}function Gut(x,d){for(const m in x.horizontal)z5e(x.horizontal[m],d);z5e(x.vertical,d)}function z5e(x,d){if(x){for(const m of x.positionedLines)for(const v of m.positionedGlyphs)if(v.image!==null){const C=v.image.toString();v.rect=d.get(C).paddedRect}}}function Qpe(x){switch(x){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Kut(x,d,m,v,C,E,P,R,$){const G=e7(E.horizontal)||E.vertical,te=m.get("icon-text-fit-padding").evaluate(v,{},C);let se,ae=d;return d&&$!=="none"&&(x.allowVerticalPlacement&&E.vertical&&(se=Wpe(d,E.vertical,$,te,R,P)),G&&(ae=Wpe(d,G,$,te,R,P))),{defaultShapedIcon:ae,verticallyShapedIcon:se}}function Zut(x,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke,Xe,lt,kt,vt,At){let zt=P.textMaxSize.evaluate(d,{},ae);zt===void 0?zt=R*P.textScaleFactor:zt*=P.textScaleFactor;const qt=x.layers[0].layout,ss=Ac,Gt=R*P.textScaleFactor/ss,ds=e7(m.horizontal)||m.vertical;if(Fe!=="none"&&x.appearanceFeatureData&&d.index18&&Rs>2&&(Rs>>=1),Math.max(tr/(512*Rs),1)*qt.get("symbol-spacing")),Bs=qt.get("text-padding")*x.tilePixelRatio,Ls=qt.get("icon-padding")*x.tilePixelRatio,Os=jr(qt.get("text-max-angle")),ls=qt.get("icon-rotation-alignment")==="map"&&Xe!=="point",rs=Fs/2;var Rs;x.hasAnyIconTextFit===!1&&Fe!=="none"&&(x.hasAnyIconTextFit=!0);const sr=d.properties?+d.properties[as]:null,Vs=sr&&x.elevationFeatureIdToIndex?x.elevationFeatureIdToIndex.get(sr):65535,zr=(mr,_r,Tr)=>{if(_r.x<0||_r.x>=tr||_r.y<0||_r.y>=tr)return;let ta=null;if(js){const{x:Zs,y:Ar,z:_n}=de.projectTilePoint(_r.x,_r.y,Tr);ta={anchor:new vv(Zs,Ar,_n,0,void 0),up:de.upVector(Tr,_r.x,_r.y)}}(function(Zs,Ar,_n,ja,Ca,$n,Ai,_t,Ct,us,zs,or,lr,Br,Vr,In,Kn,Qn,xa,an,vn,Va,Za,Ya,_i,Ri,Ei,ri,hi,Zn,Sa,mo,sn){const ga=Zs.addToLineVertexArray(Ar,ja);let Li,Ui,Zi,el,Hi,rn,jo,wi=0,ao=0,Vl=0,Ec=0,wl=-1,jl=-1;const uc={};let ph=Z1("");const Wi=_n?_n.anchor:Ar,Wo=ri!=="none";let tl=0,Oh=0;if(Ct._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Ad=Ct.layout.get("text-offset").evaluate(vn,{},_i);tl=Ad[0]*Ac,Oh=Ad[1]*Ac}else tl=Ct.layout.get("text-radial-offset").evaluate(vn,{},_i)*Ac,Oh=Xpe;if(Zs.allowVerticalPlacement&&Ca.vertical){const Ad=Ca.vertical;if(Vr)rn=Jpe(Ad),_t&&(jo=Jpe(_t));else{const $u=Ct.layout.get("text-rotate").evaluate(vn,{},_i)+90;Zi=t7(us,Wi,Ar,zs,or,lr,Ad,Br,$u,In,mo),_t&&(el=t7(us,Wi,Ar,zs,or,lr,_t,Qn,$u,null,Sa))}}if($n){const Ad=Zs.iconSizeData,$u=Ct.layout.get("icon-rotate").evaluate(vn,{},_i),fm=Ype($n,$u,Za,Wo,Va.iconScaleFactor),Mb=_t?Ype(_t,$u,Za,Wo,Va.iconScaleFactor):void 0;Ui=t7(us,Wi,Ar,zs,or,lr,$n,Qn,$u,null,Zn);const l5=function(wg,TP,nTe,omt,aTe,iTe,lmt,cmt){const oTe=wg.layers[0],lTe=oTe.appearances;let c5=TP.length;if(nTe&&(c5=Math.max(c5,nTe.length)),lTe.length===0)return c5;const[dmt,umt]=omt.get("icon-size-scale-range"),hmt=ke(1,dmt,umt);for(const cTe of lTe){const dTe=cTe.getUnevaluatedProperties();if(dTe._values["icon-image"].value!==void 0){const uTe=oTe.getAppearanceValueAndResolveTokens(cTe,"icon-image",aTe,iTe,[]);if(uTe){const hTe=wg.getResolvedImageFromTokens(uTe);if(hTe){const mTe=dTe._values["icon-size"],mmt=uP(hTe,Q3(wg.zoom,mTe,wg.worldview),mTe,iTe,wg.zoom,aTe,wg.pixelRatio,hmt,wg.worldview),pmt=lmt.get(mmt.iconPrimary.toString());c5=Math.max(c5,Rut(pmt,cmt))}}}}return c5}(Zs,fm,Mb,Ct.layout,vn,_i,Zs.iconAtlasPositions,Wo);wi=4*l5;let _g=null;Ad.kind==="source"?(_g=[gg*Ct.layout.get("icon-size").evaluate(vn,{},_i)*Va.iconScaleFactor],_g[0]>bv&&xr(`${Zs.layerIds[0]}: Value for "icon-size" is >= ${hP}. Reduce your "icon-size".`)):Ad.kind==="composite"&&(_g=[gg*Va.compositeIconSizes[0].evaluate(vn,{},_i)*Va.iconScaleFactor,gg*Va.compositeIconSizes[1].evaluate(vn,{},_i)*Va.iconScaleFactor],(_g[0]>bv||_g[1]>bv)&&xr(`${Zs.layerIds[0]}: Value for "icon-size" is >= ${hP}. Reduce your "icon-size".`)),Zs.addSymbols(Zs.icon,fm,_g,an,xa,vn,void 0,_n,Ar,ga.lineStartIndex,ga.lineLength,-1,Ya,_i,Ri,Ei,Zs.symbolInstances.length,l5),wl=Zs.icon.placedSymbolArray.length-1,Mb&&(ao=4*l5,Zs.addSymbols(Zs.icon,Mb,_g,an,xa,vn,pm.vertical,_n,Ar,ga.lineStartIndex,ga.lineLength,-1,Ya,_i,Ri,Ei,Zs.symbolInstances.length,l5),jl=Zs.icon.placedSymbolArray.length-1)}for(const Ad in Ca.horizontal){const $u=Ad,fm=Ca.horizontal[$u];Li||(ph=Z1(fm.text),Vr?Hi=Jpe(fm):Li=t7(us,Wi,Ar,zs,or,lr,fm,Br,Ct.layout.get("text-rotate").evaluate(vn,{},_i),In,mo));const Mb=fm.positionedLines.length===1;if(Vl+=B5e(Zs,_n,Ar,fm,Ai,Ct,Vr,vn,In,ga,Ca.vertical?pm.horizontal:pm.horizontalOnly,Mb?$ut(Ca.horizontal):[$u],uc,wl,Va,Ya,_i,Zs.symbolInstances.length,Ri),Mb)break}Ca.vertical&&(Ec+=B5e(Zs,_n,Ar,Ca.vertical,Ai,Ct,Vr,vn,In,ga,pm.vertical,["vertical"],uc,jl,Va,Ya,_i,Zs.symbolInstances.length,Ri));let Hl=-1;const Yf=(Ad,$u)=>Ad?Math.max(Ad,$u):$u;Hl=Yf(Hi,Hl),Hl=Yf(rn,Hl),Hl=Yf(jo,Hl);const By=Hl>-1?1:0;Zs.glyphOffsetArray.length>=65535&&xr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),vn.sortKey!==void 0&&Zs.addToSortKeyRanges(Zs.symbolInstances.length,vn.sortKey),Zs.symbolInstances.emplaceBack(Ar.x,Ar.y,Wi.x,Wi.y,Wi.z,uc.right>=0?uc.right:-1,uc.center>=0?uc.center:-1,uc.left>=0?uc.left:-1,uc.vertical>=0?uc.vertical:-1,wl,jl,ph,Li!==void 0?Li:Zs.collisionBoxArray.length,Li!==void 0?Li+1:Zs.collisionBoxArray.length,Zi!==void 0?Zi:Zs.collisionBoxArray.length,Zi!==void 0?Zi+1:Zs.collisionBoxArray.length,Ui!==void 0?Ui:Zs.collisionBoxArray.length,Ui!==void 0?Ui+1:Zs.collisionBoxArray.length,el||Zs.collisionBoxArray.length,el?el+1:Zs.collisionBoxArray.length,zs,Vl,Ec,wi,ao,By,0,tl,Oh,Hl,0,Wo?1:0,hi)})(x,_r,ta,mr,m,v,E,C,x.layers[0],x.collisionBoxArray,d.index,d.sourceLayerIndex,x.index,Bs,Ke,G,0,Ls,ls,Re,d,P,te,se,ae,he,Se,Fe,Vs,lt,kt,vt)};if(Xe==="line")for(const mr of OF(d.geometry,0,0,tr,tr)){const _r=Out(mr,Fs,Os,m.vertical||ds,v,ss,Ns,x.overscaling,tr);for(const Tr of _r)ds&&Yut(x,ds.text,rs,Tr)||zr(mr,Tr,ae)}else if(Xe==="line-center"){for(const mr of d.geometry)if(mr.length>1){const _r=Dut(mr,Os,m.vertical||ds,v,ss,Ns);_r&&zr(mr,_r,ae)}}else if(d.type==="Polygon")for(const mr of K6(d.geometry,0)){const _r=zut(mr,16);zr(mr[0],new vv(_r.x,_r.y,0,0,void 0),ae)}else if(d.type==="LineString")for(const mr of d.geometry)zr(mr,new vv(mr[0].x,mr[0].y,0,0,void 0),ae);else if(d.type==="Point")for(const mr of d.geometry)for(const _r of mr)zr([_r],new vv(_r.x,_r.y,0,0,void 0),ae)}const hP=255,bv=hP*gg;function B5e(x,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke){const Xe=function(vt,At,zt,qt,ss,Gt,ds,js){const Ns=[];if(At.positionedLines.length===0)return Ns;const Fs=qt.layout.get("text-rotate").evaluate(Gt,{})*Math.PI/180,Bs=function(Rs){const sr=Rs[0],Vs=Rs[1],zr=sr*Vs;return zr>0?[sr,-Vs]:zr<0?[-sr,Vs]:sr===0?[Vs,sr]:[Vs,-sr]}(zt);let Ls=Math.abs(At.top-At.bottom);for(const Rs of At.positionedLines)Ls-=Rs.lineOffset;const Os=At.positionedLines.length,ls=Ls/Os;let rs=At.top-zt[1];for(let Rs=0;Rsbv&&xr(`${x.layerIds[0]}: Value for "text-size" is >= ${hP}. Reduce your "text-size".`)):lt.kind==="composite"&&(kt=[gg*he.compositeTextSizes[0].evaluate(R,{},Fe)*he.textScaleFactor,gg*he.compositeTextSizes[1].evaluate(R,{},Fe)*he.textScaleFactor],(kt[0]>bv||kt[1]>bv)&&xr(`${x.layerIds[0]}: Value for "text-size" is >= ${hP}. Reduce your "text-size".`)),x.addSymbols(x.text,Xe,kt,$,P,R,te,d,m,G.lineStartIndex,G.lineLength,de,Se,Fe,Ke,!1,Re,Xe.length);for(const vt of se)ae[vt]=x.text.placedSymbolArray.length-1;return 4*Xe.length}function e7(x){for(const d in x)return x[d];return null}function t7(x,d,m,v,C,E,P,R,$,G,te){let se,ae,de,he;if(se=te?te.top:P.top,ae=te?te.bottom:P.bottom,de=te?te.left:P.left,he=te?te.right:P.right,Hpe(P)&&P.collisionPadding){const Se=P.collisionPadding;de-=Se[0],se-=Se[1],he+=Se[2],ae+=Se[3]}if($){const Se=new ft(de,se),Fe=new ft(he,se),Re=new ft(de,ae),Ke=new ft(he,ae),Xe=jr($);let lt=new ft(0,0);G&&(lt=new ft(G[0],G[1])),Se._rotateAround(Xe,lt),Fe._rotateAround(Xe,lt),Re._rotateAround(Xe,lt),Ke._rotateAround(Xe,lt),de=Math.min(Se.x,Fe.x,Re.x,Ke.x),he=Math.max(Se.x,Fe.x,Re.x,Ke.x),se=Math.min(Se.y,Fe.y,Re.y,Ke.y),ae=Math.max(Se.y,Fe.y,Re.y,Ke.y)}return x.emplaceBack(d.x,d.y,d.z,m.x,m.y,de,se,he,ae,R,v,C,E),x.length-1}function Jpe(x){Hpe(x)&&x.collisionPadding&&(x.top-=x.collisionPadding[1],x.bottom+=x.collisionPadding[3]);const d=x.bottom-x.top;return d>0?Math.max(10,d):null}function Yut(x,d,m,v){const C=x.compareText;if(d in C){const E=C[d];for(let P=E.length-1;P>=0;P--)if(v.dist(E[P])Xe&&(lt(vt,Ns,zt,qt,ds,js),lt(Ns,At,ds,js,ss,Gt))}lt(se,ae,v,E,C,E),lt(ae,de,C,E,C,P),lt(de,he,C,P,v,P),lt(he,se,v,P,v,E),Se-=Xe,Fe-=Xe,Re+=Xe,Ke+=Xe;const kt=1/Math.max(Re-Se,Ke-Fe);return{scale:kt,x:Se*kt,y:Fe*kt,x2:Re*kt,y2:Ke*kt,projection:d}}function q5e(x,{x:d,y:m},v=0){return new ft(((d-v)*x.scale-x.x)*tr,(m*x.scale-x.y)*tr)}const Xut=w(new Float32Array(16));class Sb{constructor(d){this.spec=d,this.name=d.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(d,m){return{x:0,y:0,z:0}}unproject(d,m){return new y(0,0)}projectTilePoint(d,m,v){return{x:d,y:m,z:0}}locationPoint(d,m,v,C=!0){return d._coordinatePoint(d.locationCoordinate(m,v),C)}pixelsPerMeter(d,m){return ne(1,d)*m}pixelSpaceConversion(d,m,v){return 1}farthestPixelDistance(d){return $5e(d,d.pixelsPerMeter)}pointCoordinate(d,m,v,C){const E=d.horizonLineFromTop(!1),P=new ft(m,Math.max(E,v));return d.rayIntersectionCoordinate(d.pointRayIntersection(P,C))}pointCoordinate3D(d,m,v){const C=new ft(m,v);if(d.elevation)return d.elevation.pointCoordinate(C);{const E=this.pointCoordinate(d,C.x,C.y,0);return[E.x,E.y,E.z]}}isPointAboveHorizon(d,m){if(d.elevation&&d.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(d,m.x,m.y);const v=d.horizonLineFromTop();return m.y0?m<-s5+v&&(m=-s5+v):m>s5-v&&(m=s5-v);const P=E/Math.pow(r7(m),C);let R=P*Math.sin(C*d),$=E-P*Math.cos(C*d);return R=.5*(R/Math.PI+.5),$=.5*($/Math.PI+.5),{x:R,y:this.southernCenter?$:1-$,z:0}}unproject(d,m){d=(2*d-.5)*Math.PI,this.southernCenter&&(m=1-m),m=(2*(1-m)-.5)*Math.PI;const{n:v,f:C}=this,E=C-m,P=Math.sign(E),R=Math.sign(v)*Math.sqrt(d*d+E*E);let $=Math.atan2(d,Math.abs(E))*P;E*v<0&&($-=Math.PI*Math.sign(d)*P);const G=ke(ea($/v)+this.center[0],-180,180),te=ke(ea(2*Math.atan(Math.pow(C/R,1/v))-s5),-Ne,Ne);return new y(G,this.southernCenter?-te:te)}}class U5e extends Sb{constructor(d){super(d),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(d,m){return{x:W(d),y:J(m),z:0}}unproject(d,m){const v=le(d),C=je(m);return new y(v,C)}}const V5e=jr(Ne);class sht extends Sb{project(d,m){const v=(m=jr(m))*m,C=v*v;return{x:.5*((d=jr(d))*(.8707-.131979*v+C*(C*(.003971*v-.001529*C)-.013791))/Math.PI+.5),y:1-.5*(m*(1.007226+v*(.015085+C*(.028874*v-.044475-.005916*C)))/Math.PI+1),z:0}}unproject(d,m){d=(2*d-.5)*Math.PI;let v=m=(2*(1-m)-1)*Math.PI,C=25,E=0,P=v*v;do{P=v*v;const G=P*P;E=(v*(1.007226+P*(.015085+G*(.028874*P-.044475-.005916*G)))-m)/(1.007226+P*(.045255+G*(.259866*P-.311325-.005916*11*G))),v=ke(v-E,-V5e,V5e)}while(Math.abs(E)>1e-6&&--C>0);P=v*v;const R=ke(ea(d/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),$=ea(v);return new y(R,$)}}const H5e=jr(Ne);class rht extends Sb{project(d,m){m=jr(m),d=jr(d);const v=Math.cos(m),C=2/Math.PI,E=Math.acos(v*Math.cos(d/2)),P=Math.sin(E)/E,R=.5*(d*C+2*v*Math.sin(d/2)/P)||0,$=.5*(m+Math.sin(m)/P)||0;return{x:.5*(R/Math.PI+.5),y:1-.5*($/Math.PI+1),z:0}}unproject(d,m){let v=d=(2*d-.5)*Math.PI,C=m=(2*(1-m)-1)*Math.PI,E=25;const P=1e-6;let R=0,$=0;do{const G=Math.cos(C),te=Math.sin(C),se=2*te*G,ae=te*te,de=G*G,he=Math.cos(v/2),Se=Math.sin(v/2),Fe=2*he*Se,Re=Se*Se,Ke=1-de*he*he,Xe=Ke?1/Ke:0,lt=Ke?Math.acos(G*he)*Math.sqrt(1/Ke):0,kt=.5*(2*lt*G*Se+2*v/Math.PI)-d,vt=.5*(lt*te+C)-m,At=.5*Xe*(de*Re+lt*G*he*ae)+1/Math.PI,zt=Xe*(Fe*se/4-lt*te*Se),qt=.125*Xe*(se*Se-lt*te*de*Fe),ss=.5*Xe*(ae*he+lt*Re*G)+.5,Gt=zt*qt-ss*At;R=(vt*zt-kt*ss)/Gt,$=(kt*qt-vt*At)/Gt,v=ke(v-R,-Math.PI,Math.PI),C=ke(C-$,-H5e,H5e)}while((Math.abs(R)>P||Math.abs($)>P)&&--E>0);return new y(ea(v),ea(C))}}class W5e extends Sb{constructor(d){super(d),this.center=d.center||[0,0],this.parallels=d.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(jr(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(d,m){const{scale:v,cosPhi:C}=this;return{x:jr(d)*C*v+.5,y:-Math.sin(jr(m))/C*v+.5,z:0}}unproject(d,m){const{scale:v,cosPhi:C}=this,E=-(m-.5)/v,P=ke(ea((d-.5)/v)/C,-180,180),R=Math.asin(ke(E*C,-1,1)),$=ke(ea(R),-Ne,Ne);return new y(P,$)}}class nht extends U5e{constructor(d){super(d),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(d,m,v){const C=q6(d,m,v);return pt(C,C,CF(Vp(v))),{x:C[0],y:C[1],z:C[2]}}locationPoint(d,m,v){const C=vb(m.lat,m.lng),E=we([],C),P=v?d._centerAltitude+v:d.elevation?d.elevation.getAtPointOrZero(d.locationCoordinate(m),d._centerAltitude):d._centerAltitude;$e(C,C,E,ne(1,0)*tr*P);const R=w(new Float64Array(16));return S(R,d.pixelMatrix,d.globeMatrix),pt(C,C,R),new ft(C[0],C[1])}pixelsPerMeter(d,m){return ne(1,0)*m}pixelSpaceConversion(d,m,v){const C=ne(1,d)*m,E=Zr(ne(1,45)*m,C,v);return this.pixelsPerMeter(d,m)/E}createTileMatrix(d,m,v){const C=npe(Vp(v.canonical));return S(new Float64Array(16),d.globeMatrix,C)}createInversionMatrix(d,m){const{center:v}=d,C=CF(Vp(m));return O(C,C,jr(v.lng)),I(C,C,jr(v.lat)),L(C,C,[d._pixelsPerMercatorPixel,d._pixelsPerMercatorPixel,1]),Float32Array.from(C)}pointCoordinate(d,m,v,C){return _b(d,m,v,!0)||new nt(0,0)}pointCoordinate3D(d,m,v){const C=this.pointCoordinate(d,m,v,0);return[C.x,C.y,C.z]}isPointAboveHorizon(d,m){return!_b(d,m.x,m.y,!1)}farthestPixelDistance(d){const m=function(C,E){const P=C.cameraToCenterDistance,R=C._centerAltitude*E,$=C._camera,G=C._camera.forward(),te=ce([],_e([],G,-P),[0,0,R]),se=C.worldSize/(2*Math.PI),ae=[0,0,-se],de=C.width/C.height,he=Math.tan(C.fovAboveCenter),Se=_e([],$.up(),he),Fe=_e([],$.right(),he*de),Re=we([],ce([],ce([],G,Se),Fe)),Ke=[];let Xe;if(new Cr(te,Re).closestPointOnSphere(ae,se,Ke)){const lt=ce([],Ke,ae),kt=Me([],lt,te);Xe=Math.cos(C.fovAboveCenter)*ie(kt)}else{const lt=Me([],te,ae),kt=Me([],ae,te);we(kt,kt);const vt=ie(lt)-se;Xe=Math.sqrt(vt*(vt+2*se));const At=Math.acos(Xe/(se+vt))-Math.acos(Le(G,kt));Xe*=Math.cos(At)}return 1.01*Xe}(d,this.pixelsPerMeter(d.center.lat,d.worldSize)),v=wb(d.zoom);if(v>0){const C=$5e(d,ne(1,d.center.lat)*d.worldSize),E=d.worldSize/(2*Math.PI),P=Math.max(d.width,d.height)/d.worldSize*Math.PI;return Zr(m,C+E*(1-Math.cos(P)),Math.pow(v,10))}return m}upVector(d,m,v){return q6(m,v,d,1)}upVectorScale(d){return{metersToTile:Kf(SF(Vp(d)))}}}function G5e(x){const d=x.parallels,m=!!d&&Math.abs(d[0]+d[1])<.01;switch(x.name){case"mercator":return new U5e(x);case"equirectangular":return new eht(x);case"naturalEarth":return new sht(x);case"equalEarth":return new Jut(x);case"winkelTripel":return new rht(x);case"albers":return m?new W5e(x):new Qut(x);case"lambertConformalConic":return m?new W5e(x):new tht(x);case"globe":return new nht(x)}throw new Error(`Invalid projection name: ${x.name}`)}const aht=Ht.types,iht=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function yP(x,d,m,v,C,E,P,R,$,G,te,se,ae){const de=R?Math.min(bv,Math.round(R[0])):0,he=R?Math.min(bv,Math.round(R[1])):0;x.emplaceBack(d,m,Math.round(32*v),Math.round(32*C),E,P,(de<<1)+($?1:0),0+(he<<1),16*G,16*te,256*se,256*ae)}function vP(x,d,m){x.emplaceBack(d,m)}function bP(x,d,m,v,C,E,P){x.emplaceBack(d,m,v,C,E,P)}const n7=(x,d,m,v)=>{for(let C=0;C0&&(this.iconTransitioningVertexBuffer=d.createVertexBuffer(this.iconTransitioningVertexArray,put.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,dut.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,hut.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=d.createVertexBuffer(this.orientationVertexArray,mut.members,!0)),this.opacityVertexBuffer.itemSize=1),(v||C)&&this.programConfigurations.upload(d))}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())}}kr(efe,"SymbolBuffers");class tfe{constructor(d,m,v){this.layoutVertexArray=new d,this.layoutAttributes=m,this.indexArray=new v,this.segments=new bo,this.collisionVertexArray=new C6,this.collisionVertexArrayExt=new Ly}upload(d){this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=d.createVertexBuffer(this.collisionVertexArray,fut.members,!0),this.collisionVertexBufferExt=d.createVertexBuffer(this.collisionVertexArrayExt,xut.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}kr(tfe,"CollisionBuffers");class a7{constructor(d){this.collisionBoxArray=d.collisionBoxArray,this.zoom=d.zoom,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(P=>P.fqid),this.index=d.index,this.pixelRatio=d.pixelRatio,this.sourceLayerIndex=d.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=w([]),this.placementViewportMatrix=w([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=d.worldview,this.localizable=d.localizable,this.textSizeData=Q3(this.zoom,m["text-size"],this.worldview),this.iconSizeData=Q3(this.zoom,m["icon-size"],this.worldview);const v=this.layers[0].layout,C=v.get("symbol-sort-key"),E=v.get("symbol-z-order");this.lut=d.lut,this.canOverlap=v.get("text-allow-overlap")||v.get("icon-allow-overlap")||v.get("text-ignore-placement")||v.get("icon-ignore-placement"),this.sortFeaturesByKey=E!=="viewport-y"&&C.constantOr(1)!==void 0,this.sortFeaturesByY=(E==="viewport-y"||E==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=v.get("text-writing-mode").map(P=>pm[P]),this.stateDependentLayerIds=this.layers.filter(P=>P.isStateDependent()).map(P=>P.id),this.sourceID=d.sourceID,this.projection=d.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(d){const m=this.layers[0].getAppearances();return!(!m||m.length===0)&&m.some(v=>v.getProperty(d)!=null)}createArrays(){this.text=new efe(new qp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("text")||d.startsWith("symbol"))),this.icon=new efe(new qp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("icon")||d.startsWith("symbol"))),this.glyphOffsetArray=new L3,this.lineVertexArray=new _F,this.symbolInstances=new L6}calculateGlyphDependencies(d,m,v,C,E){for(const P of d){const R=P.codePointAt(0);if(R===void 0)break;if(m[R]=!0,C&&E&&R<=65535){const $=oP[P];$&&(m[$.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(d,m,v,C,E,P){let R=1;const $=d.getUnevaluatedProperties()._values["icon-size"],G=Q3(this.zoom,$,this.worldview),te=J3(G,m);if(G.kind!=="constant"&&G.kind!=="camera"||(R=te.uSize),G.kind==="composite"){const{minZoom:se,maxZoom:ae}=G,de=$.possiblyEvaluate(new Ki(se,{worldview:this.worldview}),C),he=$.possiblyEvaluate(new Ki(ae,{worldview:this.worldview}),C),Se=de.evaluate(v,{},C,E);R=Se+(he.evaluate(v,{},C,E)-Se)*te.uSizeT}return G.kind==="source"&&(R=$.possiblyEvaluate(new Ki(this.zoom,{worldview:this.worldview}),C).evaluate(v,{},C,E)),R*P}updateFootprints(d,m){}updateReplacement(d,m){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const v=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);return!IF(this.activeReplacements,v)&&(this.activeReplacements=v,!0)}getResolvedImageFromTokens(d){return typeof d=="string"?Ou.build(d):d}populate(d,m,v,C){const E=this.layers[0],P=E.layout,R=this.projection.name==="globe",$=P.get("text-font"),G=P.get("text-field"),te=P.get("icon-image"),[se,ae]=P.get("icon-size-scale-range"),de=ke(m.scaleFactor||1,se,ae),he=(G.value.kind!=="constant"||G.value.value instanceof Du&&!G.value.value.isEmpty()||G.value.value.toString().length>0)&&($.value.kind!=="constant"||$.value.value.length>0),Se=te.value.kind!=="constant"||!!te.value.value||Object.keys(te.parameters).length>0,Fe=this.hasAnyAppearanceProperty("icon-image"),Re=P.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!he&&!Se&&!Fe)return;const Ke=m.iconDependencies,Xe=m.glyphDependencies,lt=m.availableImages,kt=new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),vt=At=>{const zt=At.id.toString();Ke.has(zt)?Ke.get(zt).push(At):Ke.set(zt,[At])};for(const At of d){const{feature:zt,id:qt,index:ss,sourceLayerIndex:Gt}=At,ds=E._featureFilter.needGeometry,js=Wt(zt,ds);if(!E._featureFilter.filter(kt,js,v))continue;if(ds||(js.geometry=Ot(zt,v,C)),R&&zt.type!==1&&v.z<=5){const Rs=js.geometry,sr=.98078528056,Vs=(zr,mr)=>Le(q6(zr.x,zr.y,v,1),q6(mr.x,mr.y,v,1)){if(!Rs.getProperty("icon-image"))return;const sr=this.getCombinedIconPrimary(Rs,Bs,js,v,lt,ls,de);sr&&vt(sr)}),Ns){const Rs=$.evaluate(js,{},v).join(","),sr=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(pm.vertical)>=0;for(const Vs of Ns.sections)if(Vs.image){const zr=Vs.image.getPrimary().scaleSelf(this.pixelRatio),mr=zr.id.toString(),_r=Ke.get(mr)||[];_r.push(zr),Ke.set(mr,_r)}else{const zr=m2(Ns.toString()),mr=Vs.fontStack||Rs,_r=Xe[mr]=Xe[mr]||{};this.calculateGlyphDependencies(Vs.text,_r,sr,this.allowVerticalPlacement,zr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(At){const zt={},qt={},ss=[];let Gt=0;function ds(Bs){ss.push(At[Bs]),Gt++}function js(Bs,Ls,Os){const ls=qt[Bs];return delete qt[Bs],qt[Ls]=ls,ss[ls].geometry[0].pop(),ss[ls].geometry[0]=ss[ls].geometry[0].concat(Os[0]),ls}function Ns(Bs,Ls,Os){const ls=zt[Ls];return delete zt[Ls],zt[Bs]=ls,ss[ls].geometry[0].shift(),ss[ls].geometry[0]=Os[0].concat(ss[ls].geometry[0]),ls}function Fs(Bs,Ls,Os){const ls=Os?Ls[0][Ls[0].length-1]:Ls[0][0];return`${Bs}:${ls.x}:${ls.y}`}for(let Bs=0;BsBs.geometry)}(this.features)),P.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",m.elevationFeatures){!this.elevationFeatures&&m.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const At of m.elevationFeatures)this.elevationFeatureIdToIndex.set(At.id,this.elevationFeatures.length),this.elevationFeatures.push(At)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((At,zt)=>At.sortKey-zt.sortKey)}getCombinedIconPrimary(d,m,v,C,E,P,R){let $,G;const te=d.getUnevaluatedProperties();if(te._values["icon-image"].value!==void 0){const se=m.getAppearanceValueAndResolveTokens(d,"icon-image",v,C,E);$=this.getResolvedImageFromTokens(se)}else{const se=m.getValueAndResolveTokens("icon-image",v,C,E);$=this.getResolvedImageFromTokens(se)}if($){const se=te._values["icon-size"]||m._unevaluatedLayout._values["icon-size"];G=uP($,Q3(this.zoom,se,this.worldview),se,C,this.zoom,P,this.pixelRatio,R,this.worldview).iconPrimary}return G}updateAppearanceBasedIconTextures(d,m,v,C){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const E=this.layers[0];let P=!1,R=0;const $=E.layout,[G,te]=$.get("icon-size-scale-range"),se=ke(1,G,te);for(let ae=0;ae=0){const Fe=Se.id,Re=m&&Fe!==void 0?m[String(Fe)]:void 0,Ke={type:"Point",id:Se.id,properties:Se.properties,geometry:[]},Xe=this.layers[0].appearances&&this.layers[0].appearances.find(lt=>lt.isActive({globals:C,feature:Ke,canonical:d,featureState:Re}));if(Se.activeAppearance===Xe){R+=de.numIconVertices;continue}if(Xe){Se.activeAppearance=Xe;const lt=this.getCombinedIconPrimary(Xe,E,Ke,d,v,{sortKey:void 0,text:void 0,icon:null,index:de.featureIndex,sourceLayerIndex:de.featureIndex,geometry:[],properties:Se.properties,type:"Point",id:Se.id},se);if(!lt)continue;const kt=lt.toString(),vt=this.iconAtlasPositions&&this.iconAtlasPositions.get(kt);if(vt){const At=E.getAppearanceValueAndResolveTokens(Xe,"icon-offset",Ke,d,v),zt=At&&Array.isArray(At)?At:[0,0];let qt=ZF(vt,void 0,zt,E.layout.get("icon-anchor").evaluate(Ke,{},d));const ss=E.getAppearanceValueAndResolveTokens(Xe,"icon-rotate",Ke,d,v),Gt=typeof ss=="number"?ss:0,ds=vt.sdf,js=E.layout.get("icon-text-fit").constantOr("none");js!=="none"&&Se.textShaping&&Se.iconTextFitPadding&&Se.fontScale&&(qt=Wpe(qt,Se.textShaping,js,Se.iconTextFitPadding,zt,Se.fontScale));const Ns=this.calculateEffectiveAppearanceIconSize(Xe,C.zoom,Ke,d,v,se),Fs=0,Bs=1+(Math.min(bv,Math.round(Ns*gg))<<1),Ls=Ype(qt,Gt,ds,js!=="none",se);Se.isUsingAppearanceVertexData||(Se.isUsingAppearanceVertexData=!0,Se.layoutBasedVertexData=this.icon.getIconVertexData(R,de.numIconVertices));for(let ls=0;ls0&&(this.icon.updateIconVertexData(R,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(R+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(R+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(R+3,0,0,0,0,0,0,0,0,0,0,0,0),P=!0),R+=de.numIconVertices,Se.activeAppearance=null;else if(Se.isUsingAppearanceVertexData){const kt=Se.layoutBasedVertexData.length/12;for(let vt=0;vt0||ae>0,Fe=de>0,Re=this.elevationFeatures[$.elevationFeatureIndex];if(Re){const Ke=new ft($.tileAnchorX,$.tileAnchorY),Xe=.075+Re.pointElevation(Ke);$.zOffset!==Xe&&(m=!0,$.zOffset=Xe),Xe!==0&&(this.hasAnyZOffset=!0);const lt=Re.computeSlopeNormal(Ke,C),kt=cs(We(),re(0,0,1),lt);qe(G,G,kt),qe(te,te,kt),G[2]*=v,te[2]*=v,G[0]===1&&G[1]===0&&G[2]===0&&te[0]===0&&te[1]===1&&te[2]===0||(E=E||Se,P=P||Fe)}if(Se&&(n7(this.text.orientationVertexArray,se,G,te),n7(this.text.orientationVertexArray,ae,G,te)),Fe){const{placedIconSymbolIndex:Ke,verticalPlacedIconSymbolIndex:Xe}=$;Ke>=0&&n7(this.icon.orientationVertexArray,de,G,te),Xe>=0&&n7(this.icon.orientationVertexArray,he,G,te)}}E||(this.text.orientationVertexArray=void 0),P||(this.icon.orientationVertexArray=void 0),m&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const d=(E,P,R)=>{v+=P,v>E.length&&E.resize(v);for(let $=-P;$<0;$++)E.emplace($+v,R)},m=(E,P,R)=>{C+=P,C>E.length&&E.resize(C);for(let $=-P;$<0;$++)E.emplace($+C,R)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let v=0,C=0;for(let E=0;E0;if((R>0||$>0)&&(d(this.text.zOffsetVertexArray,R,te),d(this.text.zOffsetVertexArray,$,te)),se){const{placedIconSymbolIndex:ae,verticalPlacedIconSymbolIndex:de}=P;ae>=0&&m(this.icon.zOffsetVertexArray,G,te),de>=0&&m(this.icon.zOffsetVertexArray,P.numVerticalIconVertices,te)}}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(d,m,v,C,E){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(d),this.iconCollisionBox.upload(d)),this.text.upload(d,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,!1),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(P=>P.appearances&&P.appearances.length>0)),this.icon.upload(d,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(d,m,v,C){return!!(d&&m&&v)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(d,m,v,C)&&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=G5e(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(d,m){const v=this.lineVertexArray.length;if(d.segment!==void 0)for(const{x:C,y:E}of m)this.lineVertexArray.emplaceBack(C,E);return{lineStartIndex:v,lineLength:this.lineVertexArray.length-v}}addSymbols(d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se,Fe,Re,Ke){const Xe=d.indexArray,lt=d.layoutVertexArray,kt=d.globeExtVertexArray,vt=d.segments.prepareSegment(4*Ke,lt,Xe,this.canOverlap?P.sortKey:void 0),At=this.glyphOffsetArray.length,zt=vt.vertexLength,qt=this.allowVerticalPlacement&&R===pm.vertical?Math.PI/2:0,ss=P.text&&P.text.sections;for(let js=0;js=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:C),P=Gpe(this.textSizeData,d,E)/Ac;return this.tilePixelRatio*P}getSymbolInstanceIconSize(d,m,v){const C=this.icon.placedSymbolArray.get(v),E=Gpe(this.iconSizeData,d,C);return this.tilePixelRatio*E}_commitDebugCollisionVertexUpdate(d,m,v,C){d.emplaceBack(m,-v,-v,C),d.emplaceBack(m,v,-v,C),d.emplaceBack(m,v,v,C),d.emplaceBack(m,-v,v,C)}_updateTextDebugCollisionBoxes(d,m,v,C,E,P,R){for(let $=C;$0}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(d,m){const v=d.placedSymbolArray.get(m),C=v.vertexStartIndex+4*v.numGlyphs;for(let E=v.vertexStartIndex;EC[R]-C[$]||E[$]-E[R]),P}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let d=0;dthis.symbolInstances.get(m).zOffset-this.symbolInstances.get(d).zOffset)}addToSortKeyRanges(d,m){const v=this.sortKeyRanges[this.sortKeyRanges.length-1];v&&v.sortKey===m?v.symbolInstanceEnd=d+1:this.sortKeyRanges.push({sortKey:m,symbolInstanceStart:d,symbolInstanceEnd:d+1})}sortFeatures(d){if(this.sortFeaturesByY&&this.sortedAngle!==d&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(d),this.sortedAngle=d,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const m of this.symbolInstanceIndexes){const v=this.symbolInstances.get(m);this.featureSortOrder.push(v.featureIndex);const{rightJustifiedTextSymbolIndex:C,centerJustifiedTextSymbolIndex:E,leftJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:R,placedIconSymbolIndex:$,verticalPlacedIconSymbolIndex:G}=v;C>=0&&this.addIndicesForPlacedSymbol(this.text,C),E>=0&&E!==C&&this.addIndicesForPlacedSymbol(this.text,E),P>=0&&P!==E&&P!==C&&this.addIndicesForPlacedSymbol(this.text,P),R>=0&&this.addIndicesForPlacedSymbol(this.text,R),$>=0&&this.addIndicesForPlacedSymbol(this.icon,$),G>=0&&this.addIndicesForPlacedSymbol(this.icon,G)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(d){const m=this.symbolInstances.get(this.text.symbolInstanceIndices[d]).elevationFeatureIndex;let v;return this.elevationFeatures&&mv in x?String(x[v]):"")}let Z5e,Y5e,sfe;kr(a7,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),a7.addDynamicAttributes=r5;class X5e{constructor(d){this.type=d.property.overrides?d.property.overrides.runtimeType:Rp,this.defaultValue=d}evaluate(d){if(d.formattedSection){const m=this.defaultValue.property.overrides;if(m&&m.hasOverride(d.formattedSection))return m.getOverride(d.formattedSection)}return d.feature&&d.featureState?this.defaultValue.evaluate(d.feature,d.featureState):this.defaultValue.property.specification.default}eachChild(d){this.defaultValue.isConstant()||d(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}kr(X5e,"FormatSectionOverride",{omit:["defaultValue"]});const rfe=()=>sfe||(sfe={layout:Z5e||(Z5e=new Io({"symbol-placement":new Xs(Kt.layout_symbol["symbol-placement"]),"symbol-spacing":new Xs(Kt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Xs(Kt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ar(Kt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Xs(Kt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Xs(Kt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Xs(Kt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Xs(Kt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Xs(Kt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Xs(Kt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Xs(Kt.layout_symbol["icon-rotation-alignment"]),"icon-size":new ar(Kt.layout_symbol["icon-size"]),"icon-size-scale-range":new Xs(Kt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ar(Kt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ar(Kt.layout_symbol["icon-text-fit-padding"]),"icon-image":new ar(Kt.layout_symbol["icon-image"]),"icon-image-use-theme":new Xs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ar(Kt.layout_symbol["icon-rotate"]),"icon-padding":new Xs(Kt.layout_symbol["icon-padding"]),"icon-keep-upright":new Xs(Kt.layout_symbol["icon-keep-upright"]),"icon-offset":new ar(Kt.layout_symbol["icon-offset"]),"icon-anchor":new ar(Kt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Xs(Kt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Xs(Kt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Xs(Kt.layout_symbol["text-rotation-alignment"]),"text-field":new ar(Kt.layout_symbol["text-field"]),"text-font":new ar(Kt.layout_symbol["text-font"]),"text-size":new ar(Kt.layout_symbol["text-size"]),"text-size-scale-range":new Xs(Kt.layout_symbol["text-size-scale-range"]),"text-max-width":new ar(Kt.layout_symbol["text-max-width"]),"text-line-height":new ar(Kt.layout_symbol["text-line-height"]),"text-letter-spacing":new ar(Kt.layout_symbol["text-letter-spacing"]),"text-justify":new ar(Kt.layout_symbol["text-justify"]),"text-radial-offset":new ar(Kt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Xs(Kt.layout_symbol["text-variable-anchor"]),"text-anchor":new ar(Kt.layout_symbol["text-anchor"]),"text-max-angle":new Xs(Kt.layout_symbol["text-max-angle"]),"text-writing-mode":new Xs(Kt.layout_symbol["text-writing-mode"]),"text-rotate":new ar(Kt.layout_symbol["text-rotate"]),"text-padding":new Xs(Kt.layout_symbol["text-padding"]),"text-keep-upright":new Xs(Kt.layout_symbol["text-keep-upright"]),"text-transform":new ar(Kt.layout_symbol["text-transform"]),"text-offset":new ar(Kt.layout_symbol["text-offset"]),"text-allow-overlap":new Xs(Kt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Xs(Kt.layout_symbol["text-ignore-placement"]),"text-optional":new Xs(Kt.layout_symbol["text-optional"]),visibility:new Xs(Kt.layout_symbol.visibility)})),paint:Y5e||(Y5e=new Io({"icon-opacity":new ar(Kt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ar(Kt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ar(Kt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ar(Kt.paint_symbol["text-emissive-strength"]),"icon-color":new ar(Kt.paint_symbol["icon-color"]),"icon-halo-color":new ar(Kt.paint_symbol["icon-halo-color"]),"icon-halo-width":new ar(Kt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ar(Kt.paint_symbol["icon-halo-blur"]),"icon-translate":new Xs(Kt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Xs(Kt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Xs(Kt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ar(Kt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ar(Kt.paint_symbol["text-occlusion-opacity"]),"text-color":new ar(Kt.paint_symbol["text-color"],{runtimeType:dh,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new ar(Kt.paint_symbol["text-halo-color"]),"text-halo-width":new ar(Kt.paint_symbol["text-halo-width"]),"text-halo-blur":new ar(Kt.paint_symbol["text-halo-blur"]),"text-translate":new Xs(Kt.paint_symbol["text-translate"]),"text-translate-anchor":new Xs(Kt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Xs(Kt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Xs(Kt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Xs(Kt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Xs(Kt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ar(Kt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"})}))},sfe);class i7 extends zu{constructor(d,m,v,C){super(d,rfe(),m,v,C,d.layout?d.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=w([]),this.hasOcclusionOpacityProperties=d.paint!==void 0&&("icon-occlusion-opacity"in d.paint||"text-occlusion-opacity"in d.paint)}_handleSpecialPaintPropertyUpdate(d){d!=="icon-occlusion-opacity"&&d!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(d,m){super.recalculate(d,m),this.appearances&&this.appearances.forEach(C=>{C.recalculate(d,m,this.iconImageUseTheme)}),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const v=this.layout.get("text-writing-mode");if(v){const C=[];for(const E of v)C.indexOf(E)<0&&C.push(E);this.layout._values["text-writing-mode"]=C}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(d,m,v,C){return this._saturation===d&&this._contrast===m&&this._brightnessMin===v&&this._brightnessMax===C||(this._colorAdjustmentMatrix=function(E,P,R,$){E=lo(E),P=Ia(P);const G=_(),te=E/3,se=1-2*te,ae=[se,te,te,0,te,se,te,0,te,te,se,0,0,0,0,1],de=.5-.5*P,he=$-R;return S(G,[he,0,0,0,0,he,0,0,0,0,he,0,R,R,R,1],[P,0,0,0,0,P,0,0,0,0,P,0,de,de,de,1]),S(G,G,ae),G}(d,m,v,C),this._saturation=d,this._contrast=m,this._brightnessMin=v,this._brightnessMax=C),this._colorAdjustmentMatrix}getValueAndResolveTokens(d,m,v,C){const E=this.layout.get(d).evaluate(m,{},v,C),P=this._unevaluatedLayout._values[d];return P.isDataDriven()||u2(P.value)||!E?E:K5e(m.properties,E)}getAppearanceValueAndResolveTokens(d,m,v,C,E){const P=d.getProperty(m);if(!P)return;const R=P.evaluate(v,{},C,E),$=d.getUnevaluatedProperties()._values[m];return $.isDataDriven()||u2($.value)||!R||typeof R!="string"?R:K5e(v.properties,R)}createBucket(d){return new a7(d)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const d of rfe().paint.overridableProperties){if(!i7.hasPaintOverride(this.layout,d))continue;const m=this.paint.get(d),v=new X5e(m),C=new d3(v,m.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let E=null;E=m.value.kind==="constant"||m.value.kind==="source"?new db("source",C):new ov("composite",C,m.value.zoomStops,m.value.interpolationType),this.paint._values[d]=new cv(m.property,E,m.parameters)}}_handleOverridablePaintPropertyUpdate(d,m,v){return!(!this.layout||m.isDataDriven()||v.isDataDriven())&&i7.hasPaintOverride(this.layout,d)}static hasPaintOverride(d,m){const v=d.get("text-field"),C=rfe().paint.properties[m];let E=!1;const P=R=>{for(const $ of R)if(C.overrides&&C.overrides.hasOverride($))return void(E=!0)};if(v.value.kind==="constant"&&v.value.value instanceof Du)P(v.value.value.sections);else if(v.value.kind==="source"){const R=G=>{E||(G instanceof tg&&Tc(G.value)===Yw?P(G.value.sections):G instanceof Bf?P(G.sections):G.eachChild(R))},$=v.value;$._styleExpression&&R($._styleExpression.expression)}return E}getProgramIds(){return["symbol"]}getDefaultProgramParams(d,m,v){return{config:new Oy(this,{zoom:m,lut:v}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let Q5e,J5e,eMe,tMe;var nfe=fa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function o7(x,d,m,v,C,E,P,R){const $=[x,d,1,m,v,1,C,E,1],G=[P,R,1],te=g([],$),[se,ae,de]=fe(G,G,te);return b($,$,[se,0,0,0,ae,0,0,0,de])}function sMe(x,d,m,v,C,E,P,R){const $=function(G,te,se,ae,de,he,Se,Fe){const Re=o7(0,0,1,0,1,1,0,1),Ke=o7(G,te,se,ae,de,he,Se,Fe);return b(Ke,Ke,g([],Re))}(x,d,m,v,C,E,P,R);return[$[2]/$[8]/tr,$[5]/$[8]/tr]}function l7(x){return[x[0],Math.min(Math.max(x[1],-Ne),Ne)]}class rMe extends As{constructor(d,m,v,C){super(),this.id=d,this.dispatcher=v,this.coordinates=m.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(C),this.options=m,this._dirty=!1}load(d,m){if(this._loaded=m||!1,this.fire(new Xm("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return d&&(this.coordinates=d),this._loaded=!0,void this._finishLoading();this._imageRequest=by(this.map._requestManager.transformRequest(this.url,Xx.Image),(v,C)=>{this._imageRequest=null,this._loaded=!0,v?this.fire(new _y(v)):C&&(this.image=C instanceof HTMLImageElement?Bl.getImageData(C):C,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,d&&(this.coordinates=d),this._finishLoading())})}loaded(){return this._loaded}updateImage(d){return d.url?(this._imageRequest&&d.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=d.url,this.load(d.coordinates,this._loaded),this):this}setTexture(d){if(!(d.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new nP(this.map.painter.context,d.handle),this.width=d.dimensions[0],this.height=d.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Xm("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(d){this.map=d,this.load()}onRemove(d){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof nP||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(d){if(this.coordinates=d,this._boundsArray=void 0,this._unsupportedCoords=!1,!d.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let m=d[0][1],v=d[0][1];for(const E of d)E[1]>v&&(v=E[1]),E[1]Ne?this.onNorthPole=!0:C<-Ne&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=d.map(nt.fromLngLat);this.tileID=function(P){let R=1/0,$=1/0,G=-1/0,te=-1/0;for(const Se of P)R=Math.min(R,Se.x),$=Math.min($,Se.y),G=Math.max(G,Se.x),te=Math.max(te,Se.y);const se=Math.max(G-R,te-$),ae=Math.max(0,Math.floor(-Math.log2(se))),de=Math.pow(2,ae);let he=Math.floor((R+G)/2*de);return he>1&&(he-=1),new Oi(ae,he,Math.floor(($+te)/2*de))}(E),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Xm("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof nP||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(d){for(const Re in this.tiles){const Ke=this.tiles[Re];Ke.state!=="loaded"&&(Ke.state="loaded",Ke.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=mP(new Oi(0,0,0),this.map.transform.projection),v=[m.projection.project(this.coordinates[0][0],this.coordinates[0][1]),m.projection.project(this.coordinates[1][0],this.coordinates[1][1]),m.projection.project(this.coordinates[2][0],this.coordinates[2][1]),m.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(Re){const Ke=Re[1].x-Re[0].x,Xe=Re[1].y-Re[0].y,lt=Re[2].x-Re[1].x,kt=Re[2].y-Re[1].y,vt=Re[3].x-Re[2].x,At=Re[3].y-Re[2].y,zt=Re[0].x-Re[3].x,qt=Re[0].y-Re[3].y,ss=Ke*kt-lt*Xe,Gt=lt*At-vt*kt,ds=vt*qt-zt*At,js=zt*Xe-Ke*qt;return ss>0&&Gt>0&&ds>0&&js>0||ss<0&&Gt<0&&ds<0&&js<0}(v))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const C=mP(this.tileID,this.map.transform.projection),[E,P,R,$]=this.coordinates.map(Re=>{const Ke=C.projection.project(Re[0],Re[1]);return q5e(C,Ke)._round()});this.perspectiveTransform=sMe(E.x,E.y,P.x,P.y,R.x,R.y,$.x,$.y);const G=this._boundsArray=new pb;G.emplaceBack(E.x,E.y,0,0),G.emplaceBack(P.x,P.y,tr,0),G.emplaceBack($.x,$.y,0,tr),G.emplaceBack(R.x,R.y,tr,tr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=d.createVertexBuffer(G,nfe.members),this.boundsSegments=bo.simpleSegment(0,0,4,2);const te=[],se=[l7((ae=this.coordinates)[0]),l7(ae[1]),l7(ae[2]),l7(ae[3])];var ae;const[de,he,Se,Fe]=function(Re){let Ke=Re[0][0],Xe=Ke,lt=Re[0][1],kt=lt;for(let vt=1;vtXe&&(Xe=Re[vt][0]),Re[vt][1]kt&&(kt=Re[vt][1]);return[Ke,lt,Xe-Ke,kt-lt]}(se);{const Re=new pb,[Ke,Xe,lt,kt]=function(Ls){let Os=Ls[0].x,ls=Os,rs=Ls[0].y,Rs=rs;for(let sr=1;srls&&(ls=Ls[sr].x),Ls[sr].yRs&&(Rs=Ls[sr].y);return[Os,rs,ls-Os,Rs-rs]}(v),vt=Ls=>[(Ls.x-Ke)/lt,(Ls.y-Xe)/kt],[At,zt,qt,ss]=v.map(vt),Gt=function(Ls,Os,ls,rs,Rs,sr,Vs,zr){const mr=o7(0,0,1,0,1,1,0,1);return b(mr,mr,g([],o7(Ls,Os,ls,rs,Rs,sr,Vs,zr)))}(At[0],At[1],zt[0],zt[1],qt[0],qt[1],ss[0],ss[1]);this.elevatedGlobePerspectiveTransform=sMe(At[0],At[1],zt[0],zt[1],qt[0],qt[1],ss[0],ss[1]);const ds=(Ls,Os)=>{te.push(Ls.lng);const ls=Math.round((Ls.lng-de)/Se*tr),rs=Math.round((Ls.lat-he)/Fe*tr),Rs=vt(Os),sr=fe([],[Rs[0],Rs[1],1],Gt),Vs=Math.round(sr[0]/sr[2]*tr),zr=Math.round(sr[1]/sr[2]*tr);Re.emplaceBack(ls,rs,Vs,zr)},js=v[3].x-v[0].x,Ns=v[3].y-v[0].y,Fs=v[2].x-v[1].x,Bs=v[2].y-v[1].y;for(let Ls=0;Ls<65;Ls++){const Os=Ls/64,ls=[v[0].x+Os*js,v[0].y+Os*Ns],rs=[v[1].x+Os*Fs,v[1].y+Os*Bs],Rs=rs[0]-ls[0],sr=rs[1]-ls[1];for(let Vs=0;Vs<65;Vs++){const zr=Vs/64,mr={x:ls[0]+Rs*zr,y:ls[1]+sr*zr};ds(m.projection.unproject(mr.x,mr.y),mr)}}this.elevatedGlobeVertexBuffer=d.createVertexBuffer(Re,nfe.members)}{this.maxLongitudeTriangleSize=0;let Re=[],Ke=new $l;const Xe=(lt,kt,vt)=>{Ke.emplaceBack(lt,kt,vt);const At=te[lt],zt=te[kt],qt=te[vt],ss=Math.min(Math.min(At,zt),qt),Gt=Math.max(Math.max(At,zt),qt)-ss;Gt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Gt),Re.push(ss+Gt/2)};for(let lt=0;lt<64;lt++)for(let kt=0;kt<64;kt++){const vt=65*lt+kt,At=vt+1,zt=vt+65,qt=zt+1;Xe(vt,zt,At),Xe(At,zt,qt)}[Re,Ke]=function(lt,kt){const vt=Array.from({length:lt.length},(qt,ss)=>ss);vt.sort((qt,ss)=>lt[qt]-lt[ss]);const At=[],zt=new $l;for(let qt=0;qt{P.segments.push({vertexOffset:0,primitiveOffset:se,vertexLength:m.segments[0].vertexLength,primitiveLength:ae,sortKey:void 0,vaos:{}})},$=.51*this.maxLongitudeTriangleSize;if(Math.abs(v[0]-C)<=$){const se=oo(v,0,v.length,C+$);return se===v.length||R(se,hl(v,se+1,v.length,C+360-$)-se),P}Ctr?C-tr:C,new ft(Math.trunc(C),Math.trunc(v[m+1]))}translationForInstance(d){const m=16*d,v=this.instancedDataArray.float32;return[v[m+4],v[m+5],v[m+6]]}rotationScaleForInstance(d){const m=16*d,v=this.instancedDataArray.float32;return[v[m+7],v[m+8],v[m+9],v[m+10],v[m+11],v[m+12],v[m+13],v[m+14],v[m+15]]}transformForInstance(d){const m=16*d,v=this.instancedDataArray.float32;return[v[m+7],v[m+8],v[m+9],v[m+4],v[m+10],v[m+11],v[m+12],v[m+5],v[m+13],v[m+14],v[m+15],v[m+6],0,0,0,1]}}class ofe{constructor(d){this.zoom=d.zoom,this.canonical=d.canonical,this.overscaledZ=this.canonical.z+Math.log2(d.overscaling),this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.projection=d.projection,this.index=d.index,this.worldview=d.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=d.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,C){}populate(d,m,v,C){this.tileToMeter=Ve(v);const E=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:P,id:R,index:$,sourceLayerIndex:G}of d){const te=R??(P.properties&&P.properties.hasOwnProperty("id")?P.properties.id:void 0),se=Wt(P,E);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),se,v))continue;const ae={id:te,sourceLayerIndex:G,index:$,geometry:E?se.geometry:Ot(P,v,C),properties:P.properties,type:P.type,patterns:{}},de=this.addFeature(ae,ae.geometry,se);de&&m.featureIndex.insert(P,ae.geometry,$,G,this.index,this.instancesPerModel[de].instancedDataArray.length,tr/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const d=this.layers[0].modelManager,m=this.layers[0].scope;let v=0;for(const C of this.modelUris){const E=d.getModel(C,m);if(!E)continue;const P=this.instancesPerModel[C];if(P){const R=.5*Ae(E.aabb.max,E.aabb.min)*P.maxScale+P.maxXYTranslationDistance,$=Math.min(tr,Math.max(R/this.tileToMeter,tr/32));v=Math.max($,v)}}return v}update(d,m,v,C){for(const E in this.instancesPerModel){const P=this.instancesPerModel[E];for(const R in d)P.idToFeaturesIndex.hasOwnProperty(R)&&(this.evaluate(P.features[P.idToFeaturesIndex[R]],d[R],P,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let d=!1;for(const m in this.instancesPerModel){const v=this.instancesPerModel[m];for(const C of v.features){const E=this.layers[0],P=C.feature,R=this.canonical,$=E.paint.get("model-rotation").evaluate(P,{},R),G=E.paint.get("model-scale").evaluate(P,{},R),te=E.paint.get("model-translation").evaluate(P,{},R);et(C.rotation,$)&&et(C.scale,G)&&et(C.translation,te)||(this.evaluate(C,C.featureStates,v,!0),d=!0)}}return d}updateReplacement(d,m,v,C){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const E=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);if(IF(this.activeReplacements,E))return!1;this.activeReplacements=E;let P=!1;for(const R in this.instancesPerModel){const $=this.instancesPerModel[R],G=$.instancedDataArray;for(const te of $.features){const se=te.instancedDataOffset,ae=te.instancedDataCount;for(let de=0;detr;Se=Fe?Se-tr:Se;const Re=Math.floor(Se),Ke=Math.floor(G.float32[he+1]);let Xe=!1;for(const lt of this.activeReplacements)if(!JCe(lt,v,uMe.Model,C)&&!(lt.min.x>Re||Re>lt.max.x||lt.min.y>Ke||Ke>lt.max.y)&&(Xe=n3e(r3e(Re,Ke,d.canonical,lt.footprintTileId.canonical),lt.footprint),Xe))break;G.float32[he]=Xe?Se+tr:Se,P=P||Xe!==Fe}}}return P}isEmpty(){for(const d in this.instancesPerModel)if(this.instancesPerModel[d].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(d){if(!this.uploaded)for(const m in this.instancesPerModel){const v=this.instancesPerModel[m];v.instancedDataArray.length<0||v.instancedDataArray.length===0||(v.instancedDataBuffer?v.instancedDataBuffer.updateData(v.instancedDataArray):v.instancedDataBuffer=d.createVertexBuffer(v.instancedDataArray,Pdt.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(d){for(const v in this.instancesPerModel){const C=this.instancesPerModel[v];C.instancedDataArray.length!==0&&C.instancedDataBuffer&&C.instancedDataBuffer.destroy()}const m=this.layers[0].modelManager;if(d&&m&&this.modelUris&&this.modelsRequested)for(const v of this.modelUris)m.removeModel(v,"",!0)}addFeature(d,m,v){const C=this.layers[0],E=C.layout.get("model-id").evaluate(v,{},this.canonical);if(!E)return xr(`modelId is not evaluated for layer ${C.id} and it is not going to get rendered.`),E;(ife(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new mMe);const P=this.instancesPerModel[E],R=P.instancedDataArray,$=new hMe(v,R.length);for(const G of m)for(const te of G){if(te.x<0||te.x>=tr||te.y<0||te.y>=tr)continue;if(this.lookupDim!==0){const ae=(this.lookupDim-1)/tr,de=this.lookupDim*(te.y*ae|0)+te.x*ae|0;if(this.lookup){if(this.lookup[de]!==0)continue;this.lookup[de]=1}}this.instanceCount++;const se=R.length;R.resize(se+1),P.instancesEvaluatedElevation.push(0),R.float32[16*se]=te.x,R.float32[16*se+1]=te.y}return $.instancedDataCount=P.instancedDataArray.length-$.instancedDataOffset,$.instancedDataCount>0&&(d.id&&(P.idToFeaturesIndex[d.id]=P.features.length),P.features.push($),this.evaluate($,{},P,!1)),E}getModelUris(){return this.modelUris}evaluate(d,m,v,C){const E=this.layers[0],P=d.feature,R=this.canonical,$=d.rotation=E.paint.get("model-rotation").evaluate(P,m,R),G=d.scale=E.paint.get("model-scale").evaluate(P,m,R),te=d.translation=E.paint.get("model-translation").evaluate(P,m,R),se=Object.assign({},E.paint.get("model-color").evaluate(P,m,R));se.a=E.paint.get("model-color-mix-intensity").evaluate(P,m,R);const ae=[];this.maxVerticalOffset0?Math.sqrt(de):0;v.maxScale=Math.max(Math.max(v.maxScale,G[0]),Math.max(G[1],G[2])),v.maxXYTranslationDistance=Math.max(v.maxXYTranslationDistance,he),this.maxScale=Math.max(Math.max(this.maxScale,G[0]),Math.max(G[1],G[2])),V3e(ae,$,G);const Se=Math.round(100*se.a)+se.b/1.05;for(let Fe=0;Fe10?this.tileToMeter:Ve(R,kt)),Xe[Ke+4]=te[0],Xe[Ke+5]=te[1],Xe[Ke+6]=te[2]+lt,Xe[Ke+7]=ae[0],Xe[Ke+8]=ae[1],Xe[Ke+9]=ae[2],Xe[Ke+10]=ae[4],Xe[Ke+11]=ae[5],Xe[Ke+12]=ae[6],Xe[Ke+13]=ae[8],Xe[Ke+14]=ae[9],Xe[Ke+15]=ae[10],v.instancesEvaluatedElevation[Re]=te[2]}}}let pMe,fMe;kr(ofe,"ModelBucket",{omit:["layers"]}),kr(mMe,"PerModelAttributes"),kr(hMe,"ModelFeature");class n5{constructor(d,m,v){this._demTile=d,this._dem=this._demTile.dem,this._scale=m,this._offset=v}static create(d,m,v){const C=v||d.findDEMTileFor(m);if(!C||!C.dem)return;const E=C.dem,P=C.tileID,R=1<G.fqid),this.stateDependentLayerIds=this.layers.filter(G=>G.isStateDependent()).map(G=>G.id),this.modelTraits|=Z3.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,C&&(this.modelTraits|=Z3.HasMapboxMeshFeatures),E&&(this.modelTraits|=Z3.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=P,this.worldview=$,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const G of m)this.nodesInfo.push(new vMe(G)),gMe(G,R.featureIndexArray.length,R.grid),R.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,R.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(d,m){for(const v of this.getNodesInfo()){const C=v.node;C.footprint&&m.push({footprint:C.footprint,id:d})}}updateAppearances(d,m,v,C){}update(d){const m=Object.keys(d).length!==0;if(m&&!this.stateDependentLayers.length)return;const v=m?this.stateDependentLayers:this.layers;if(!ir(d,this.states))for(const C of v)this.evaluate(C,d);this.states=structuredClone(d)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(d){if(!this.needsUpload)return;const m=this.getNodesInfo();for(const v of m){const C=v.node;this.uploaded?this.updatePbrBuffer(C):Ppe(C,d,!0)}for(const v of m)HF(v.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(d){let m=!1;if(!d.meshes)return m;for(const v of d.meshes)v.pbrBuffer&&(v.pbrBuffer.updateData(v.featureArray),m=!0);return m}needsReEvaluation(d,m,v){const C=d.transform.projectionOptions,E=d.style.getBrightness(),P=this.brightness!==E;if(!this.uploaded||this.dirty||C.name!==this.projection.name||_P(v.paint.get("model-color").value,P)||_P(v.paint.get("model-color-mix-intensity").value,P)||_P(v.paint.get("model-roughness").value,P)||_P(v.paint.get("model-emissive-strength").value,P)||_P(v.paint.get("model-height-based-emissive-strength-multiplier").value,P)){this.projection=C,this.brightness=E;const R=this.getNodesInfo();for(const $ of R)$.state=null;return!0}return!1}evaluateTransform(d,m){if(d.transform.zoom===this.zoom)return;this.zoom=d.transform.zoom;const v=this.getNodesInfo(),C=this.id.canonical;for(const E of v){const P=E.feature;E.evaluatedTranslation=m.paint.get("model-translation").evaluate(P,{},C),E.evaluatedScale=m.paint.get("model-scale").evaluate(P,{},C)}}evaluate(d,m){const v=this.getNodesInfo();for(const C of v){if(!C.node.meshes)continue;const E=C.feature,P=m&&m[E.id];if(ir(P,C.state))continue;C.state=structuredClone(P);const R=C.node.meshes&&C.node.meshes[0].featureData,$=C.evaluatedColor[2],G=C.evaluatedRMEA[2],te=this.id.canonical;if(C.hasTranslucentParts=!1,R){for(let se=0;se=vt)continue;const Ls=lfe[Bs],Os=Math.abs(Ls);Os>Gt&&(ss=Ls,Gt=Os,ds=Fs,js=Ns)}if(Gt>.1){const Ns=1-(vt+.5*Math.abs(ds*js))/he;let Fs=m._dem.get(zt,At)+ss*Ns;const Bs=m._dem.get(zt+ds,At+js),Ls=m._dem.get(zt-ds,At-js,!0);(Fs-Bs)*(Fs-Ls)>0&&(Fs=(Bs+Ls)/2),lfe[qt]=m._dem.set(zt,At,Fs),I2[qt]=vt}}}}}R&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=Bl.now())}setFilter(d){this.filter=d?v3(d):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(d=>this.filter.filter(new Ki(this.id.overscaledZ,{worldview:this.worldview}),d.feature,this.id.canonical)):this.nodesInfo}destroy(){const d=this.getNodesInfo();for(const m of d)HF(m.node),Ipe(m.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(d,m){if(m.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=m.updateTime;const v=m.getReplacementRegionsForTile(d.toUnwrapped());for(const C of this.getNodesInfo()){const E=C.node.footprint;C.hiddenByReplacement=!!E&&!v.find(P=>P.footprint===E)}}getHeightAtTileCoord(d,m){const v=[],C=[0,0,0],E=w([]);for(const P of this.getNodesInfo()){const R=P.node.meshes[0],$=R.transformedAabb;if(d<$.min[0]||m<$.min[1]||d>$.max[0]||m>$.max[1])continue;if(P.node.hidden===!0)return{height:1/0,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};N(E,P.node.globalMatrix),C[0]=d,C[1]=m,pt(C,C,E);const G=(C[0]-R.aabb.min[0])/(R.aabb.max[0]-R.aabb.min[0])*A2|0,te=Math.min(63,(C[1]-R.aabb.min[1])/(R.aabb.max[1]-R.aabb.min[1])*A2|0)*A2+Math.min(63,G),se=R.heightmap[te];if(!(se<0&&P.node.footprint))return P.hiddenByReplacement?void 0:{height:se,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};if(P.node.footprint.grid.query(new ft(d,m),new ft(d,m),v),v.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function _P(x,d){return x instanceof db&&!x.isLightConstant&&d}function dht(x,d,m,v,C,E,P,R){let $=(61440&d|(61440&d)>>4)>>8,G=(3840&d|(3840&d)>>4)>>4,te=240&d|(240&d)>>4;m[3]>0&&($=Zr($,255*m[0],m[3]),G=Zr(G,255*m[1],m[3]),te=Zr(te,255*m[2],m[3]));const se=$<<8|G,ae=te<<8|Math.floor(255*v[3]),de=function(vt){const At=ke(vt,0,2);return Math.min(Math.round(.5*At*255),255)}(v[2])<<8|15*v[0]<<4|15*v[1],he=ke(C[0],0,1),Se=ke(C[1],0,1),Fe=ke(C[2],0,1),Re=ke(C[3],0,1);let Ke,Xe,lt,kt;if(he!==Se&&P!==E&&Se!==he){const vt=P-E;Xe=1/(vt*(Se-he)),lt=-(E+vt*he)/(vt*(Se-he));const At=ke(C[4],-1,1);kt=Math.pow(10,At),Ke=255*Fe<<8|255*Re}else Ke=65535,Xe=0,lt=1,kt=1;if(x.emplaceBack(se,ae,de,Ke,Xe,lt,kt),R){const vt=R.length;R.clear();for(let At=0;At>16&65535,te=E?$>>16&65535:65535&$,se=(15&te)<8?15&te:0,ae=x.evaluatedRMEA[se],de=x.evaluatedColor[se],he=x.emissionHeightBasedParams[se];let Se;if(R&&se===2&&v.lights&&(Se=new A3,Se.resize(10*v.lights.length)),dht(P.featureArray,G,de,ae,he,P.aabb.min[2],P.aabb.max[2],Se),Se&&R){R=!1;const Fe=v.meshes[v.lightMeshIndex];Fe.featureArray=Se,Fe.featureArray._trim()}}P.featureArray._trim(),C++}}kr(d7,"Tiled3dModelBucket",{omit:["layers"]}),kr(vMe,"Tiled3dModelFeature");const hht=["id","tile","layer","source","sourceLayer","state"];class L2{constructor(d,m,v,C,E){this.type="Feature",this._vectorTileFeature=d,this._z=m,this._x=v,this._y=C,this.properties=d?d.properties:{},this.id=E}clone(){const d=new L2(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(d.state=Object.assign({},this.state)),this.layer&&(d.layer=Object.assign({},this.layer)),this.source&&(d.source=this.source),this.sourceLayer&&(d.sourceLayer=this.sourceLayer),d}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(d){this._geometry=d}toJSON(){const d={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const m of hht)this[m]!==void 0&&(d[m]=this[m]);return d}}class D2 extends As{constructor(d,m,v,C){super(),this.id=d,this.type="model",this.models=[],this._loaded=!1,this._options=m,this._modelsInfo=new Map}load(){const d=[];for(const m in this._options.models){const v=this._options.models[m],C=this._modelsInfo.get(m);if(C){const E=C.model;E.position=v.position!=null?new y(v.position[0],v.position[1]):new y(0,0),E.orientation=v.orientation!=null?v.orientation:[0,0,0],C.modelSpec=v,D2.applyModelSpecification(E,v),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=B3e(this.map._requestManager.transformRequest(v.uri,Xx.Model).url).then(P=>{if(!P)return;const R=Dpe(P),$=new H3e(m,v.uri,v.position,v.orientation,R);D2.applyModelSpecification($,v),$.computeBoundsAndApplyParent(),this.models.push($),this._modelsInfo.set(m,{modelSpec:v,model:$})}).catch(P=>{this.fire(new _y(new Error(`Could not load model ${m} from ${v.uri}: ${P.message}`)))});d.push(E)}}Promise.allSettled(d).then(()=>{this._loaded=!0,this.fire(new Xm("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new _y(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(d,m){m.nodeOverrides&&D2.convertNodeOverrides(d,m.nodeOverrides),m.materialOverrides&&D2.convertMaterialOverrides(d,m.materialOverrides),m.nodeOverrideNames&&(d.nodeOverrideNames=[...m.nodeOverrideNames]),m.materialOverrideNames&&(d.materialOverrideNames=[...m.materialOverrideNames]),m.featureProperties&&(d.featureProperties=m.featureProperties)}static convertNodeOverrides(d,m){if(Array.isArray(m)&&m.every(v=>typeof v=="string")){d.nodeOverrideNames=[];for(const v of m)d.nodeOverrideNames.push(v)}else Object.entries(m).forEach(([v,C])=>{const E={orientation:[0,0,0]};if(C.hasOwnProperty("orientation")){const P=C.orientation;P&&(E.orientation=P)}d.nodeOverrides.set(v,E)})}static convertMaterialOverrides(d,m){if(Array.isArray(m)&&m.every(v=>typeof v=="string")){d.materialOverrideNames=[];for(const v of m)d.materialOverrideNames.push(v)}else Object.entries(m).forEach(([v,C])=>{const E={color:new Ur(1,1,1),colorMix:0,emissionStrength:0,opacity:1},P=C["model-color"];P!==void 0&&(E.color.r=P[0],E.color.g=P[1],E.color.b=P[2]);const R=C["model-color-mix-intensity"];R!==void 0&&(E.colorMix=R);const $=C["model-emissive-strength"];$!==void 0&&(E.emissionStrength=$);const G=C["model-opacity"];G!==void 0&&(E.opacity=G),d.materialOverrides.set(v,E)})}onAdd(d){this.map=d,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(d,m){}serialize(){return this._options}setProperty(d,m){return!1}reload(){const d=$p(this.id,this.scope);this.map.style.clearSource(d),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(d){this.models=[];const m=new Map;for(const v in d){const C=d[v];if(this._modelsInfo.has(v)){const E=this._modelsInfo.get(v);E&&E.modelSpec.uri===C.uri&&m.set(v,E)}}this._modelsInfo=m,this._options.models=d,this._loaded=!1,this.load()}}function cfe(x,d,m,v){const C=1<lt.polygon).flat());const Fe=de?R:null,[Re,Ke]=M3e(E,v,se,te,G,P,Fe,ae,he,E.center.lat,x.tileID.canonical),Xe=x.queryGeometry;return C3e(Re,Ke,Xe.isPointQuery()?Xe.screenBounds:Xe.screenGeometry)}},building:class extends zu{constructor(x,d,m,v){super(x,{layout:Q3e||(Q3e=new Io({visibility:new Xs(Kt.layout_building.visibility),"building-facade":new ar(Kt.layout_building["building-facade"]),"building-facade-floors":new ar(Kt.layout_building["building-facade-floors"]),"building-facade-unit-width":new ar(Kt.layout_building["building-facade-unit-width"]),"building-facade-window":new ar(Kt.layout_building["building-facade-window"]),"building-roof-shape":new ar(Kt.layout_building["building-roof-shape"]),"building-height":new ar(Kt.layout_building["building-height"]),"building-base":new ar(Kt.layout_building["building-base"]),"building-flood-light-wall-radius":new ar(Kt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ar(Kt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ar(Kt.layout_building["building-flip-roof-orientation"])})),paint:J3e||(J3e=new Io({"building-opacity":new Xs(Kt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Xs(Kt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Xs(Kt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Xs(Kt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Xs(Kt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Xs(Kt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Xs(Kt.paint_building["building-cast-shadows"]),"building-color":new ar(Kt.paint_building["building-color"]),"building-emissive-strength":new ar(Kt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Xs(Kt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Xs(Kt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Xs(Kt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Xs(Kt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Xs(Kt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ar({type:"string",default:"default","property-type":"data-driven"})}))},d,m,v),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(x){return new X3e(x)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(x){return!0}queryRadius(x){return 0}queryIntersectsFeature(x,d,m,v,C,E,P,R,$){let G=this.layout.get("building-height").evaluate(d,m);const te=this.layout.get("building-base").evaluate(d,m),se=x.tile.getBucket(this).getFootprint(d);if(se){if(se.hiddenFlags!==0)return!1;G=se.height}const[ae,de]=M3e(E,v,te,G,new ft(0,0),P,null,[0,0],1,E.center.lat,x.tileID.canonical),he=x.queryGeometry;return C3e(ae,de,he.isPointQuery()?he.screenBounds:he.screenGeometry)}},line:class extends zu{constructor(x,d,m,v){const C=c5e();super(x,C,d,m,v),C.layout&&(this.layout=new dv(C.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(x){if(x==="line-gradient"){const d=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=d._styleExpression&&d._styleExpression.expression instanceof a2,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(x,d){super.recalculate(x,d),this.paint._values["line-floorwidth"]=(()=>{if(iP)return iP;const m=c5e();return iP=new lut(m.paint.properties["line-width"].specification),iP.useIntegerZoom=!0,iP})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,x)}createBucket(x){return new Fpe(x)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(x,d,m){const v=o5e(this);return{config:new Oy(this,{zoom:d,lut:m}),defines:v,overrideFog:!1}}queryRadius(x){const d=x,m=d5e(Hd("line-width",this,d),Hd("line-gap-width",this,d)),v=Hd("line-offset",this,d);return m/2+Math.abs(v)+od(this.paint.get("line-translate"))}queryIntersectsFeature(x,d,m,v,C,E){if(x.queryGeometry.isAboveHorizon)return!1;const P=hm(x.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,x.pixelToTileUnitsFactor),R=x.pixelToTileUnitsFactor/2*d5e(this.paint.get("line-width").evaluate(d,m),this.paint.get("line-gap-width").evaluate(d,m)),$=this.paint.get("line-offset").evaluate(d,m);return $&&(v=function(G,te){const se=[],ae=new ft(0,0);for(let de=0;de=3){for(let he=0;he>16&255)/255,(x>>8&255)/255,(255&x)/255,1)}function Cht(x,d,m){x===1?(d.rgb_color=p7(m.readVarint()),d.paint="rgb_color"):x===2?(d.linear_gradient_idx=m.readVarint(),d.paint="linear_gradient_idx"):x===3?(d.radial_gradient_idx=m.readVarint(),d.paint="radial_gradient_idx"):x===5?m.readPackedFloat(d.dasharray):x===6?d.dashoffset=m.readFloat():x===7?d.miterlimit=m.readFloat():x===8?d.opacity=m.readVarint():x===9?d.width=m.readFloat():x===10?d.linecap=m.readVarint():x===11&&(d.linejoin=m.readVarint())}function Mht(x,d,m){x===1?d.transform=m7(m,m.readVarint()+m.pos):x===2?d.spread_method=m.readVarint():x===3?d.stops.push(jMe(m,m.readVarint()+m.pos)):x===4?d.x1=m.readFloat():x===5?d.y1=m.readFloat():x===6?d.x2=m.readFloat():x===7&&(d.y2=m.readFloat())}function jMe(x,d){return x.readFields(Tht,{offset:0,opacity:255,rgb_color:dfe},d)}function Tht(x,d,m){x===1?d.offset=m.readFloat():x===2?d.opacity=m.readVarint():x===3&&(d.rgb_color=p7(m.readVarint()))}function Aht(x,d,m){x===1?d.transform=m7(m,m.readVarint()+m.pos):x===2?d.spread_method=m.readVarint():x===3?d.stops.push(jMe(m,m.readVarint()+m.pos)):x===4?d.cx=m.readFloat():x===5?d.cy=m.readFloat():x===6?d.r=m.readFloat():x===7?d.fx=m.readFloat():x===8?d.fy=m.readFloat():x===9&&(d.fr=m.readFloat())}function Eht(x,d,m){x===1?d.transform=m7(m,m.readVarint()+m.pos):x===2?d.clip_path_idx=m.readVarint():x===3&&d.children.push(h7(m,m.readVarint()+m.pos))}function Pht(x,d,m){x===1?d.left=d.top=m.readFloat():x===2?d.width=d.height=m.readFloat():x===3?d.top=m.readFloat():x===4?d.height=m.readFloat():x===5?d.mask_type=m.readVarint():x===6?d.mask_idx=m.readVarint():x===7&&d.children.push(h7(m,m.readVarint()+m.pos))}class Iht{static calculate(d={},m=[]){const v=new Map,C=new Map;if(Object.keys(d).length===0)return v;m.forEach(E=>{C.set(E.name,E.rgb_color||new Ur(0,0,0))});for(const[E,P]of Object.entries(d))C.has(E)?v.set(C.get(E).toString(),P):console.warn(`Ignoring unknown image variable "${E}"`);return v}}function a5(x,d=255,m){const v=d/255,C=x.toString(),E=m.has(C)?m.get(C).clone():x.clone();return E.a*=v,E.toString()}function jP(x,d){if(!Km()){const m=document.createElement("canvas");return m.width=x,m.height=d,m}return new OffscreenCanvas(x,d)}let mfe,NP=null;function pfe(x,d,m,v,C){for(const E of v.children)NMe(x,d,m,E,C)}function NMe(x,d,m,v,C){v.group?(x.save(),function(E,P,R,$,G){const te=$.mask_idx!=null?R.masks[$.mask_idx]:null,se=$.clip_path_idx!=null?R.clip_paths[$.clip_path_idx]:null;if($.transform&&(P=i5($.transform).preMultiplySelf(P)),!function(he,Se,Fe){return he.opacity!==255||Se||Fe}($,se!=null,te!=null))return void pfe(E,P,R,$,G);const ae=jP(E.canvas.width,E.canvas.height),de=ae.getContext("2d");pfe(de,P,R,$,G),se&&EMe(de,P,R,se),te&&PMe(de,P,R,te,G),E.globalAlpha=$.opacity/255,E.drawImage(ae,0,0)}(x,d,m,v.group,C),x.restore()):v.path&&(x.save(),function(E,P,R,$,G){E.setTransform(P),$.paint_order===fht.PAINT_ORDER_FILL_AND_STROKE?(kMe(E,R,$,G),CMe(E,R,$,G)):(CMe(E,R,$,G),kMe(E,R,$,G))}(x,d,m,v.path,C),x.restore())}function kMe(x,d,m,v){const C=m.fill;if(!C)return;const E=C.opacity/255;switch(x.save(),x.beginPath(),IMe(m,x),C.paint){case"rgb_color":x.fillStyle=a5(C.rgb_color,C.opacity,v);break;case"linear_gradient_idx":{const P=d.linear_gradients[C.linear_gradient_idx];P.transform&&x.setTransform(i5(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=MMe(x,P,E,v);break}case"radial_gradient_idx":{const P=d.radial_gradients[C.radial_gradient_idx];P.transform&&x.setTransform(i5(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=TMe(x,P,E,v)}}x.fill(SMe(m)),x.restore()}function SMe(x){return x.rule===ufe.PATH_RULE_NON_ZERO?"nonzero":x.rule===ufe.PATH_RULE_EVEN_ODD?"evenodd":void 0}function CMe(x,d,m,v){const C=m.stroke;if(!C)return;const E=LMe(m);x.lineWidth=C.width,x.miterLimit=C.miterlimit,x.setLineDash(C.dasharray),x.lineDashOffset=C.dashoffset;const P=C.opacity/255;switch(C.paint){case"rgb_color":x.strokeStyle=a5(C.rgb_color,C.opacity,v);break;case"linear_gradient_idx":x.strokeStyle=MMe(x,d.linear_gradients[C.linear_gradient_idx],P,v,!0);break;case"radial_gradient_idx":x.strokeStyle=TMe(x,d.radial_gradients[C.radial_gradient_idx],P,v,!0)}switch(C.linejoin){case u7.LINE_JOIN_MITER_CLIP:case u7.LINE_JOIN_MITER:x.lineJoin="miter";break;case u7.LINE_JOIN_ROUND:x.lineJoin="round";break;case u7.LINE_JOIN_BEVEL:x.lineJoin="bevel"}switch(C.linecap){case hfe.LINE_CAP_BUTT:x.lineCap="butt";break;case hfe.LINE_CAP_ROUND:x.lineCap="round";break;case hfe.LINE_CAP_SQUARE:x.lineCap="square"}x.stroke(E)}function MMe(x,d,m,v,C=!1){if(d.stops.length===1){const ae=d.stops[0];return a5(ae.rgb_color,ae.opacity*m,v)}const{x1:E,y1:P,x2:R,y2:$}=d;let G=new DOMPoint(E,P),te=new DOMPoint(R,$);if(C){const ae=i5(d.transform);G=ae.transformPoint(G),te=ae.transformPoint(te)}const se=x.createLinearGradient(G.x,G.y,te.x,te.y);for(const ae of d.stops)se.addColorStop(ae.offset,a5(ae.rgb_color,ae.opacity*m,v));return se}function TMe(x,d,m,v,C=!1){if(d.stops.length===1){const Re=d.stops[0];return a5(Re.rgb_color,Re.opacity*m,v)}const E=i5(d.transform),{fx:P,fy:R,fr:$,cx:G,cy:te,r:se}=d;let ae=new DOMPoint(P,R),de=new DOMPoint(G,te),he=$,Se=se;if(C){ae=E.transformPoint(ae),de=E.transformPoint(de);const Re=(E.a+E.d)/2;he=$*Re,Se=d.r*Re}const Fe=x.createRadialGradient(ae.x,ae.y,he,de.x,de.y,Se);for(const Re of d.stops)Fe.addColorStop(Re.offset,a5(Re.rgb_color,Re.opacity*m,v));return Fe}function AMe(x,d,m,v){const C=v.transform?i5(v.transform).preMultiplySelf(d):d,E=jP(x.canvas.width,x.canvas.height),P=E.getContext("2d");for(const $ of v.children)if($.group)AMe(P,C,m,$.group);else if($.path){const G=$.path,te=new Path2D;te.addPath(LMe(G),C),P.fill(te,SMe(G))}const R=v.clip_path_idx!=null?m.clip_paths[v.clip_path_idx]:null;R&&EMe(P,C,m,R),x.globalCompositeOperation="source-over",x.drawImage(E,0,0)}function EMe(x,d,m,v){const C=jP(x.canvas.width,x.canvas.height);AMe(C.getContext("2d"),d,m,v),x.globalCompositeOperation="destination-in",x.drawImage(C,0,0)}function PMe(x,d,m,v,C){if(v.children.length===0)return;const E=v.mask_idx!=null?m.masks[v.mask_idx]:null;E&&PMe(x,d,m,E,C);const P=x.canvas.width,R=x.canvas.height,$=jP(P,R),G=$.getContext("2d"),te=v.width,se=v.height,ae=v.left,de=v.top,he=new Path2D,Se=new Path2D;Se.rect(ae,de,te,se),he.addPath(Se,d),G.clip(he);for(const Ke of v.children)NMe(G,d,m,Ke,C);const Fe=G.getImageData(0,0,P,R),Re=Fe.data;if(v.mask_type===bMe.MASK_TYPE_LUMINANCE)for(let Ke=0;Ked[P])return null}else{const R=1/v[P];let $=(x[P]-m[P])*R,G=(d[P]-m[P])*R;if($>G){const te=$;$=G,G=te}if($>C&&(C=$),GE)return null}return C}function RMe(x,d,m,v,C,E,P,R,$,G,te){const se=v-x,ae=C-d,de=E-m,he=P-x,Se=R-d,Fe=$-m,Re=te[1]*Fe-te[2]*Se,Ke=te[2]*he-te[0]*Fe,Xe=te[0]*Se-te[1]*he,lt=se*Re+ae*Ke+de*Xe;if(Math.abs(lt)<1e-15)return null;const kt=1/lt,vt=G[0]-x,At=G[1]-d,zt=G[2]-m,qt=(vt*Re+At*Ke+zt*Xe)*kt;if(qt<0||qt>1)return null;const ss=At*de-zt*ae,Gt=zt*se-vt*de,ds=vt*ae-At*se,js=(te[0]*ss+te[1]*Gt+te[2]*ds)*kt;return js<0||qt+js>1?null:(he*ss+Se*Gt+Fe*ds)*kt}function FMe(x,d,m){return(x-d)/(m-d)}function zMe(x,d,m,v,C,E,P,R,$){const G=1<{const Ke=Fe?1:0,Xe=(de+1)*Se-Ke,lt=he*Se,kt=(he+1)*Se-Ke;Re[0]=de*Se,Re[1]=lt,Re[2]=Xe,Re[3]=kt};let se=new DMe($);const ae=[];for(let de=0;de<$*$;de++){te(de%$,Math.floor(de/$),G,!1,ae);const he=Cb(ae[0],ae[1],E),Se=Cb(ae[2],ae[1],E),Fe=Cb(ae[2],ae[3],E),Re=Cb(ae[0],ae[3],E);se.minimums.push(Math.min(he,Se,Fe,Re)),se.maximums.push(Math.max(he,Se,Fe,Re)),se.leaves.push(1)}for(R.push(se),$/=2;$>=1;$/=2){const de=R[R.length-1];se=new DMe($);for(let he=0;he<$*$;he++){te(he%$,Math.floor(he/$),2,!0,ae);const Se=de.getElevation(ae[0],ae[1]),Fe=de.getElevation(ae[2],ae[1]),Re=de.getElevation(ae[2],ae[3]),Ke=de.getElevation(ae[0],ae[3]),Xe=de.isLeaf(ae[0],ae[1]),lt=de.isLeaf(ae[2],ae[1]),kt=de.isLeaf(ae[2],ae[3]),vt=de.isLeaf(ae[0],ae[3]),At=Math.min(Se.min,Fe.min,Re.min,Ke.min),zt=Math.max(Se.max,Fe.max,Re.max,Ke.max),qt=Xe&<&&kt&&vt;se.maximums.push(zt),se.minimums.push(At),se.leaves.push(zt-At<=5&&qt?1:0)}R.push(se)}return R}(this.dem),v=m.length-1,C=m[v];this._addNode(C.minimums[0],C.maximums[0],C.leaves[0]),this._construct(m,0,0,v,0)}raycastRoot(d,m,v,C,E,P,R=1){return OMe([d,m,-100],[v,C,this.maximums[0]*R],E,P)}raycast(d,m,v,C,E,P,R=1){if(!this.nodeCount)return null;const $=this.raycastRoot(d,m,v,C,E,P,R);if($==null)return null;const G=[],te=[],se=[],ae=[],de=[{idx:0,t:$,nodex:0,nodey:0,depth:0}];for(;de.length>0;){const{idx:he,t:Se,nodex:Fe,nodey:Re,depth:Ke}=de.pop();if(this.leaves[he]){zMe(Fe,Re,Ke,d,m,v,C,se,ae);const lt=1<=Bs[2])return Se}continue}let Xe=0;for(let lt=0;lt=G[te[zt]]&&(te.splice(zt,0,lt),At=!0);At||(te[Xe]=lt),Xe++}}for(let lt=0;lt=this.dim+1||m<-1||m>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(m+1)*this.stride+(d+1)}static pack(d,m){const v=[0,0,0,0],C=x7.getUnpackVector(m);let E=Math.floor((d+C[3])/C[2]);return v[2]=E%256,E=Math.floor(E/256),v[1]=E%256,E=Math.floor(E/256),v[0]=E,v}getPixels(){return new DCe({width:this.stride,height:this.stride},this.pixels)}backfillBorder(d,m,v){if(this.dim!==d.dim)throw new Error("dem dimension mismatch");let C=m*this.dim,E=m*this.dim+this.dim,P=v*this.dim,R=v*this.dim+this.dim;switch(m){case-1:C=E-1;break;case 1:E=C+1}switch(v){case-1:P=R-1;break;case 1:R=P+1}const $=-m*this.dim,G=-v*this.dim;for(let te=P;te=1;v--){const C=v===1?1:0,E=v===2?1:0;for(let P=0;P>>1^-(1&x[d]);return x}function Ght(x,d){switch(d){case"uint32":return x;case"uint16":for(let m=0;m>4|(61440&v)>>8|(240&C)<<4|61440&C,x[m+1]=15&v|(3840&v)>>4|(15&C)<<8|(3840&C)<<4}return x;case"uint8":for(let m=0;m>6|(192&C)>>4|(192&E)>>2|192&P,x[m+1]=(48&v)>>4|(48&C)>>2|48&E|(48&P)<<2,x[m+2]=(12&v)>>2|12&C|(12&E)<<2|(12&P)<<4,x[m+3]=3&v|(3&C)<<2|(3&E)<<4|(3&P)<<6}return x;default:throw new Error(`Invalid pixel format, "${d}"`)}}kr(x7,"DEMData"),kr(BMe,"DemMinMaxQuadTree",{omit:["dem"]});var Hp=Uint8Array,kP=Uint16Array,Kht=Int32Array,qMe=new Hp([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]),UMe=new Hp([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]),Zht=new Hp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),VMe=function(x,d){for(var m=new kP(31),v=0;v<31;++v)m[v]=d+=1<>1|(21845&dc)<<1;GMe[dc]=((65280&(o5=(61680&(o5=(52428&o5)>>2|(13107&o5)<<2))>>4|(3855&o5)<<4))>>8|(255&o5)<<8)>>1}var SP=function(x,d,m){for(var v=x.length,C=0,E=new kP(d);C>$]=G;return P},CP=new Hp(288);for(dc=0;dc<144;++dc)CP[dc]=8;for(dc=144;dc<256;++dc)CP[dc]=9;for(dc=256;dc<280;++dc)CP[dc]=7;for(dc=280;dc<288;++dc)CP[dc]=8;var KMe=new Hp(32);for(dc=0;dc<32;++dc)KMe[dc]=5;var Qht=SP(CP,9),Jht=SP(KMe,5),xfe=function(x){for(var d=x[0],m=1;md&&(d=x[m]);return d},vg=function(x,d,m){var v=d/8|0;return(x[v]|x[v+1]<<8)>>(7&d)&m},gfe=function(x,d){var m=d/8|0;return(x[m]|x[m+1]<<8|x[m+2]<<16)>>(7&d)},emt=["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"],bg=function(x,d,m){var v=new Error(d||emt[x]);if(v.code=x,Error.captureStackTrace&&Error.captureStackTrace(v,bg),!m)throw v;return v},tmt=new Hp(0),smt=typeof TextDecoder<"u"&&new TextDecoder;try{smt.decode(tmt,{stream:!0})}catch{}const rmt={gzip_data:"gzip"};class Zf extends Error{constructor(d){super(d),this.name="MRTError"}}const nmt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},ZMe={uint32:1,uint16:2,uint8:4},amt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let yfe;class g7{constructor(d=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=d}getLayer(d){const m=this.layers[d];if(!m)throw new Zf(`Layer '${d}' not found`);return m}getHeaderLength(d){const m=new Uint8Array(d),v=new DataView(d);if(m[0]!==13)throw new Zf("File is not a valid MRT.");return v.getUint32(1,!0)}parseHeader(d){const m=new Uint8Array(d),v=this.getHeaderLength(d);if(m.length= ${v} but got buffer of length ${m.length}`);const C=new yfe(m.subarray(0,v)).readFields(Rht,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==C.x||this.y!==C.y||this.z!==C.z))throw new Zf(`Invalid attempt to parse header ${C.z}/${C.x}/${C.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=C.x,this.y=C.y,this.z=C.z;for(const E of C.layers)this.layers[E.name]=new YMe(E,{cacheSize:this._cacheSize});return this}createDecodingTask(d){const m=[],v=this.getLayer(d.layerName);for(let C of d.blockIndices){const E=v.dataIndex[C],P=E.firstByte-d.firstByte,R=E.lastByte-d.firstByte;if(v._blocksInProgress.has(C))continue;const $={layerName:v.name,firstByte:P,lastByte:R,pixelFormat:v.pixelFormat,blockIndex:C,blockShape:[E.bands.length].concat(v.bandShape),buffer:v.buffer,codec:E.codec.codec,filters:E.filters.map(G=>G.filter)};v._blocksInProgress.add(C),m.push($)}return new XMe(m,()=>{m.forEach(C=>v._blocksInProgress.delete(C.blockIndex))},(C,E)=>{if(m.forEach(P=>v._blocksInProgress.delete(P.blockIndex)),C)throw C;E.forEach(P=>{this.getLayer(P.layerName).processDecodedData(P)})})}}class YMe{constructor({version:d,name:m,units:v,tileSize:C,pixelFormat:E,buffer:P,dataIndex:R},$){if(this.version=d,this.version!==1)throw new Zf(`Cannot parse raster layer encoded with MRT version ${d}`);this.name=m,this.units=v,this.tileSize=C,this.buffer=P,this.pixelFormat=nmt[E],this.dataIndex=R,this.bandShape=[C+2*P,C+2*P,ZMe[this.pixelFormat]],this._decodedBlocks=new f7($?$.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return ZMe[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:d})=>d).flat()}processDecodedData(d){const m=d.blockIndex.toString();this._decodedBlocks.get(m)||this._decodedBlocks.put(m,d.data)}getBlockForBand(d){let m=0;switch(typeof d){case"string":for(const[v,C]of this.dataIndex.entries()){for(const[E,P]of C.bands.entries())if(P===d)return{bandIndex:m+E,blockIndex:v,blockBandIndex:E};m+=C.bands.length}break;case"number":for(const[v,C]of this.dataIndex.entries()){if(d>=m&&dthis.cacheSize)throw new Zf(`Number of blocks to decode (${E.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:m,lastByte:v,blockIndices:C}}hasBand(d){const{blockIndex:m}=this.getBlockForBand(d);return m>=0}hasDataForBand(d){const{blockIndex:m}=this.getBlockForBand(d);return m>=0&&!!this._decodedBlocks.get(m.toString())}getBandView(d){const{blockIndex:m,blockBandIndex:v}=this.getBlockForBand(d);if(m<0)throw new Zf(`Band not found: ${JSON.stringify(d)}`);const C=this._decodedBlocks.get(m.toString());if(!C)throw new Zf(`Data for band ${JSON.stringify(d)} of layer "${this.name}" not decoded.`);const E=this.dataIndex[m],P=this.bandShape.reduce((G,te)=>G*te,1),R=v*P,$=C.subarray(R,R+P);return{data:$,bytes:new Uint8Array($.buffer).subarray($.byteOffset,$.byteOffset+$.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:E.offset,scale:E.scale}}}g7.setPbf=function(x){yfe=x};class XMe{constructor(d,m,v){this.tasks=d,this._onCancel=m,this._onComplete=v,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(d,m){this._finalized||(this._onComplete(d,m),this._finalized=!0)}}g7.performDecoding=function(x,d){const m=new Uint8Array(x);return Promise.all(d.tasks.map(v=>{const{layerName:C,firstByte:E,lastByte:P,pixelFormat:R,blockShape:$,blockIndex:G,filters:te,codec:se}=v,ae=m.subarray(E,P+1),de=new Uint32Array($[0]*$[1]*$[2]);let he;if(se!=="gzip_data")throw new Zf(`Unhandled codec: ${se}`);return he=function(Se,Fe){if(!globalThis.DecompressionStream&&Fe==="gzip_data")return Promise.resolve(((lt=function(At){At[0]==31&&At[1]==139&&At[2]==8||bg(6,"invalid gzip data");var zt=At[3],qt=10;4&zt&&(qt+=2+(At[10]|At[11]<<8));for(var ss=(zt>>3&1)+(zt>>4&1);ss>0;ss-=!At[qt++]);return qt+(2&zt)}(Xe=Se))+8>Xe.length&&bg(6,"invalid gzip data"),function(At,zt,qt,ss){var Gt=At.length;if(!Gt||zt.f&&!zt.l)return qt||new Hp(0);var ds=!qt,js=ds||zt.i!=2,Ns=zt.i;ds&&(qt=new Hp(3*Gt));var Fs,Bs,Ls=function(Ei){var ri=qt.length;if(Ei>ri){var hi=new Hp(Math.max(2*ri,Ei));hi.set(qt),qt=hi}},Os=zt.f||0,ls=zt.p||0,rs=zt.b||0,Rs=zt.l,sr=zt.d,Vs=zt.m,zr=zt.n,mr=8*Gt;do{if(!Rs){Os=vg(At,ls,1);var _r=vg(At,ls+1,3);if(ls+=3,!_r){var Tr=At[(us=4+((ls+7)/8|0))-4]|At[us-3]<<8,ta=us+Tr;if(ta>Gt){Ns&&bg(0);break}js&&Ls(rs+Tr),qt.set(At.subarray(us,ta),rs),zt.b=rs+=Tr,zt.p=ls=8*ta,zt.f=Os;continue}if(_r==1)Rs=Qht,sr=Jht,Vs=9,zr=5;else if(_r==2){var Zs=vg(At,ls,31)+257,Ar=vg(At,ls+10,15)+4,_n=Zs+vg(At,ls+5,31)+1;ls+=14;for(var ja=new Hp(_n),Ca=new Hp(19),$n=0;$n>4)<16)ja[$n++]=us;else{var or=0,lr=0;for(us==16?(lr=3+vg(At,ls,3),ls+=2,or=ja[$n-1]):us==17?(lr=3+vg(At,ls,7),ls+=3):us==18&&(lr=11+vg(At,ls,127),ls+=7);lr--;)ja[$n++]=or}}var Br=ja.subarray(0,Zs),Vr=ja.subarray(Zs);Vs=xfe(Br),zr=xfe(Vr),Rs=SP(Br,Vs),sr=SP(Vr,zr)}else bg(1);if(ls>mr){Ns&&bg(0);break}}js&&Ls(rs+131072);for(var In=(1<>4;if((ls+=15&or)>mr){Ns&&bg(0);break}if(or||bg(2),xa<256)qt[rs++]=xa;else{if(xa==256){Qn=ls,Rs=null;break}var an=xa-254;xa>264&&(an=vg(At,ls,(1<<(Za=qMe[$n=xa-257]))-1)+WMe[$n],ls+=Za);var vn=sr[gfe(At,ls)&Kn],Va=vn>>4;if(vn||bg(3),ls+=15&vn,Vr=Xht[Va],Va>3){var Za=UMe[Va];Vr+=gfe(At,ls)&(1<mr){Ns&&bg(0);break}js&&Ls(rs+131072);var Ya=rs+an;if(rsFs.length)&&(Bs=Fs.length),new Hp(Fs.subarray(0,Bs))):qt.subarray(0,rs)}(Xe.subarray(lt,-8),{i:2},new Hp(((Re=Xe)[(Ke=Re.length)-4]|Re[Ke-3]<<8|Re[Ke-2]<<16|Re[Ke-1]<<24)>>>0))));var Re,Ke,Xe,lt;const kt=rmt[Fe];if(!kt)throw new Error(`Unhandled codec: ${Fe}`);const vt=new globalThis.DecompressionStream(kt);return new Response(new Blob([Se]).stream().pipeThrough(vt)).arrayBuffer().then(At=>new Uint8Array(At))}(ae,se).then(Se=>(function(Fe,Re){Fe.readFields(Uht,Re)}(new yfe(Se),de),new amt[R](de.buffer))),he.then(Se=>{for(let Fe=te.length-1;Fe>=0;Fe--)switch(te[Fe]){case"delta_filter":Hht(Se,$);break;case"zigzag_filter":Wht(Se);break;case"bitshuffle_filter":Ght(Se,R);break;default:throw new Zf(`Unhandled filter "${te[Fe]}"`)}return{layerName:C,blockIndex:G,data:Se}}).catch(Se=>{throw Se})}))},kr(XMe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),kr(g7,"MapboxRasterTile"),kr(YMe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class QMe{constructor(d){this._stringToNumber={},this._numberToString=[];for(let m=0;m=0&&ae[3]>=0&&G.insert($,ae[0],ae[1],ae[2],ae[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yt(new GF(this.rawTileData)).layers,this.sourceLayerCoder=new QMe(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const d in this.vtLayers)this.vtFeatures[d]=[]}return this.vtLayers}query(d,m){const{tilespaceGeometry:v,transform:C,tileTransform:E,pixelPosMatrix:P,availableImages:R,worldview:$}=m;this.loadVTLayers(),this.serializedLayersCache.clear();const G=m.queryRadius?m.queryRadius:0,te=v.bufferedTilespaceBounds,se=this.grid.query(te.min.x,te.min.y,te.max.x,te.max.y,(Se,Fe,Re,Ke)=>Bu(v.bufferedTilespaceGeometry,Se-G,Fe-G,Re+G,Ke+G));se.sort(imt);let ae=null;C.elevation&&se.length>0&&(ae=n5.create(C.elevation,this.tileID));const de={};let he;for(let Se=0;Se(Ke||(Ke=Ot(Xe,this.tileID.canonical,E)),lt.queryIntersectsFeature(v,Xe,kt,Ke,this.z,C,P,ae,vt)))}return de}loadMatchingFeature(d,m,v,C,E,P){const{featureIndex:R,bucketIndex:$,sourceLayerIndex:G,layoutVertexArrayOffset:te}=m,se=this.bucketLayerIDs[$],ae=v.layers,de=Object.keys(ae);if(de.length&&!vr(de,se))return;const he=v.sourceCache,Se=this.sourceLayerCoder.decode(G),Fe=this.vtLayers[Se].feature(R),Re=this.getId(Fe,Se);for(let Ke=0;Ke`${R.key}: ${R.message}`).join(", ");return void xr(`Failed to create expression for promoteId: ${P}`)}this.promoteIdExpression=E.value}v=this.promoteIdExpression.evaluate({zoom:0},d)}else v=d.properties[C];typeof v=="boolean"&&(v=Number(v))}return v}}function eTe(x,d,m,v,C){return Xt(x,(E,P)=>{const R=d instanceof dv?d.get(P):null;return R&&R.evaluate?R.evaluate(m,v,void 0,C):R})}function imt(x,d){return d-x}kr(JMe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const tTe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class vfe{static from(d){if(!(d instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[m,v]=new Uint8Array(d,0,2);if(m!==219)throw new Error("Data does not appear to be in a KDBush format.");const C=v>>4;if(C!==1)throw new Error(`Got v${C} data when expected v1.`);const E=tTe[15&v];if(!E)throw new Error("Unrecognized array type.");const[P]=new Uint16Array(d,2,1),[R]=new Uint32Array(d,4,1);return new vfe(R,P,E,d)}constructor(d,m=64,v=Float64Array,C){if(isNaN(d)||d<0)throw new Error(`Unpexpected numItems value: ${d}.`);this.numItems=+d,this.nodeSize=Math.min(Math.max(+m,2),65535),this.ArrayType=v,this.IndexArrayType=d<65536?Uint16Array:Uint32Array;const E=tTe.indexOf(this.ArrayType),P=2*d*this.ArrayType.BYTES_PER_ELEMENT,R=d*this.IndexArrayType.BYTES_PER_ELEMENT,$=(8-R%8)%8;if(E<0)throw new Error(`Unexpected typed array class: ${v}.`);C&&C instanceof ArrayBuffer?(this.data=C,this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+R+$,2*d),this._pos=2*d,this._finished=!0):(this.data=new ArrayBuffer(8+P+R+$),this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+R+$,2*d),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+E]),new Uint16Array(this.data,2,1)[0]=m,new Uint32Array(this.data,4,1)[0]=d)}add(d,m){const v=this._pos>>1;return this.ids[v]=v,this.coords[this._pos++]=d,this.coords[this._pos++]=m,v}finish(){const d=this._pos>>1;if(d!==this.numItems)throw new Error(`Added ${d} items when expected ${this.numItems}.`);return bfe(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(d,m,v,C){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:E,coords:P,nodeSize:R}=this,$=[0,E.length-1,0],G=[];for(;$.length;){const te=$.pop()||0,se=$.pop()||0,ae=$.pop()||0;if(se-ae<=R){for(let Fe=ae;Fe<=se;Fe++){const Re=P[2*Fe],Ke=P[2*Fe+1];Re>=d&&Re<=v&&Ke>=m&&Ke<=C&&G.push(E[Fe])}continue}const de=ae+se>>1,he=P[2*de],Se=P[2*de+1];he>=d&&he<=v&&Se>=m&&Se<=C&&G.push(E[de]),(te===0?d<=he:m<=Se)&&($.push(ae),$.push(de-1),$.push(1-te)),(te===0?v>=he:C>=Se)&&($.push(de+1),$.push(se),$.push(1-te))}return G}within(d,m,v){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:C,coords:E,nodeSize:P}=this,R=[0,C.length-1,0],$=[],G=v*v;for(;R.length;){const te=R.pop()||0,se=R.pop()||0,ae=R.pop()||0;if(se-ae<=P){for(let Fe=ae;Fe<=se;Fe++)rTe(E[2*Fe],E[2*Fe+1],d,m)<=G&&$.push(C[Fe]);continue}const de=ae+se>>1,he=E[2*de],Se=E[2*de+1];rTe(he,Se,d,m)<=G&&$.push(C[de]),(te===0?d-v<=he:m-v<=Se)&&(R.push(ae),R.push(de-1),R.push(1-te)),(te===0?d+v>=he:m+v>=Se)&&(R.push(de+1),R.push(se),R.push(1-te))}return $}}function bfe(x,d,m,v,C,E){if(C-v<=m)return;const P=v+C>>1;sTe(x,d,P,v,C,E),bfe(x,d,m,v,P-1,1-E),bfe(x,d,m,P+1,C,1-E)}function sTe(x,d,m,v,C,E){for(;C>v;){if(C-v>600){const G=C-v+1,te=m-v+1,se=Math.log(G),ae=.5*Math.exp(2*se/3),de=.5*Math.sqrt(se*ae*(G-ae)/G)*(te-G/2<0?-1:1);sTe(x,d,m,Math.max(v,Math.floor(m-te*ae/G+de)),Math.min(C,Math.floor(m+(G-te)*ae/G+de)),E)}const P=d[2*m+E];let R=v,$=C;for(MP(x,d,v,m),d[2*C+E]>P&&MP(x,d,v,C);R<$;){for(MP(x,d,R,$),R++,$--;d[2*R+E]P;)$--}d[2*v+E]===P?MP(x,d,v,$):($++,MP(x,d,$,C)),$<=m&&(v=$+1),m<=$&&(C=$-1)}}function MP(x,d,m,v){_fe(x,m,v),_fe(d,2*m,2*v),_fe(d,2*m+1,2*v+1)}function _fe(x,d,m){const v=x[d];x[d]=x[m],x[m]=v}function rTe(x,d,m,v){const C=x-m,E=d-v;return C*C+E*E}i.$=FC,i.A=eg,i.B=$p,i.C=2,i.D=H3,i.E=As,i.F=cP,i.G=T5e,i.H=RC,i.I=Qs,i.J=cF,i.K=Fr,i.L=Q1,i.M=l3,i.N=d2,i.O=YR,i.P=ft,i.Q=u2,i.R=Xx,i.S=y3,i.T=Tpe,i.U=Ey,i.V=c7,i.W=x6,i.X=rb,i.Y=sb,i.Z=n2,i._=Ru,i.a=function(x){return ua.API_CDN_URL_REGEX.test(x)},i.a$=je,i.a0=yn,i.a1=ca,i.a2=Vf,i.a3=class extends c7{},i.a4=c3,i.a5=ZR,i.a6=Kt,i.a7=function(x){const d=x.value;return d?yn(d)?ife(d,!0)?[]:[new c7(x.key,d,`invalid url "${d}"`)]:[new c7(x.key,d,`string expected, "${Fr(d)}" found`)]:[]},i.a8=aF,i.a9=Io,i.aA=ke,i.aB=S,i.aC=Qe,i.aD=Ud,i.aE=Di,i.aF=W,i.aG=ot,i.aH=function(x,d){const m={};for(let v=0;v{v(E,P)},d):v(E,P),()=>{}}return C.callbacks.push(v),C.cancel||(C.cancel=m((E,P)=>{C.result=[E,P];for(const R of C.callbacks)this.scheduler?this.scheduler.add(()=>{R(E,P)},d):R(E,P);setTimeout(()=>delete this.entries[x],3e3)})),()=>{C.result||(C.callbacks=C.callbacks.filter(E=>E!==v),C.callbacks.length||(C.cancel(),delete this.entries[x]))}}},i.aL=function(x,d,m){const v=JSON.stringify(x.request);return x.data&&(this.deduped.entries[v]={result:[null,x.data]}),this.deduped.request(v,{type:"parseTile",isSymbolTile:x.isSymbolTile,zoom:x.tileZoom},C=>{const E=Lh(x.request,(P,R,$)=>{P?C(P):R&&C(null,{rawData:R,vectorTile:m?void 0:new Yt(new GF(R)),responseHeaders:new Map($.entries())})});return()=>{E.cancel(),C()}},d)},i.aM=function(x){return x?{cacheControl:x.get("Cache-Control"),expires:x.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=El,i.aO=function(x){Cd++,Cd>G1&&(x.getActor().send("enforceCacheSizeLimit",W1),Cd=0)},i.aP=function(x){return x<=1?1:Math.pow(2,Math.floor(Math.log2(x)))},i.aQ=Co,i.aR=nMe,i.aS=dMe,i.aT=y,i.aU=rMe,i.aV=function(x,d){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){d(null,m)};for(let v=0;v{}}},i.aW=nP,i.aX=D2,i.aY=Ut,i.aZ=mP,i.a_=le,i.aa=Xs,i.ab=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return En(x.expression.evaluate(d))}interpolate(x,d,m){return{x:Zr(x.x,d.x,m),y:Zr(x.y,d.y,m),z:Zr(x.z,d.z,m),azimuthal:Zr(x.azimuthal,d.azimuthal,m),polar:Zr(x.polar,d.polar,m)}}},i.ac=Ki,i.ad=ov,i.ae=nt,i.af=pt,i.ag=ie,i.ah=Be,i.ai=dv,i.aj=wb,i.ak=Zr,i.al=tr,i.am=ev,i.an=jr,i.ao=Ur,i.ap=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return function([m,v]){const C=En([1,m,v]);return{x:C.x,y:C.y,z:C.z}}(x.expression.evaluate(d))}interpolate(x,d,m){return{x:Zr(x.x,d.x,m),y:Zr(x.y,d.y,m),z:Zr(x.z,d.z,m)}}},i.aq=function(x,d,m=0,v=!0){const C=new ft(m,m),E=x.sub(C),P=d.add(C),R=[E,new ft(P.x,E.y),P,new ft(E.x,P.y)];return v&&R.push(E.clone()),R},i.ar=function(x,d){const m=[];for(let v=0;v1)return!1;const m=d.getSource().maxzoom,v=1<1)return d;const C=v.getSource().maxzoom,E=1<{const R=this.getAtTileOffset(x,C,E,P),$=v.upVector(x.canonical,C.x,C.y);return _e($,$,R*v.upVectorScale(x.canonical,d,m).metersToTile),$}}getForTilePoints(x,d,m,v){if(this.isUsingMockSource())return!1;const C=n5.create(this,x,v);return!!C&&(d.forEach(E=>{E[2]=this.exaggeration()*C.getElevationAt(E[0],E[1],m)}),!0)}getMinMaxForTile(x){if(this.isUsingMockSource())return null;const d=this.findDEMTileFor(x);if(!d||!d.dem)return null;const m=d.dem.tree,v=d.tileID,C=1<0&&(v+=(x[C]-0)*(x[C]-0)),d[C]<0&&(v+=(0-d[C])*(0-d[C]));return v},i.c0=n3e,i.c1=Vpe,i.c2=O5e,i.c3=Qpe,i.c4=vfe,i.c5=_e,i.c6=He,i.c7=Je,i.c8=function(x,d,m){m*=.5;var v=d[0],C=d[1],E=d[2],P=d[3],R=Math.sin(m),$=Math.cos(m);return x[0]=v*$+C*R,x[1]=C*$-v*R,x[2]=E*$+P*R,x[3]=P*$-E*R,x},i.c9=it,i.cA=ee,i.cB=si,i.cC=q3e,i.cD=Oi,i.cE=vCe,i.cF=function(x,d,m,v,C,E,P,R,$){if($.name==="globe")return vCe(x,d,new Oi(m,v,C),!1);const G=mP({z:m,x:v,y:C},$);return new Or([(E+G.x/G.scale)*d,d*(G.y/G.scale),P],[(E+G.x2/G.scale)*d,d*(G.y2/G.scale),R])},i.cG=function(x,d,m){return x[0]=Math.min(d[0],m[0]),x[1]=Math.min(d[1],m[1]),x[2]=Math.min(d[2],m[2]),x[3]=Math.min(d[3],m[3]),x},i.cH=function(x,d,m){return x[0]=Math.max(d[0],m[0]),x[1]=Math.max(d[1],m[1]),x[2]=Math.max(d[2],m[2]),x[3]=Math.max(d[3],m[3]),x},i.cI=function(x){const d=Math.round((x+45+360)%360/90)%4;return Pa[d]},i.cJ=Ne,i.cK=Ue,i.cL=q3,i.cM=function(x){const d=w(new Float64Array(16));S(d,x.pixelMatrix,x.globeMatrix);const m=[0,rp,0],v=[0,np,0];return pt(m,m,d),pt(v,v,d),[m[0]>0&&m[0]<=x.width&&m[1]>0&&m[1]<=x.height&&!ipe(x,new y(x.center.lat,90)),v[0]>0&&v[0]<=x.width&&v[1]>0&&v[1]<=x.height&&!ipe(x,new y(x.center.lat,-90))]},i.cN=function(x,d){const{scale:m}=x.tileTransform,v=m*tr/(x.tileSize*Math.pow(2,d.zoom-x.tileID.overscaledZ+x.tileID.canonical.z));return function(C,E,P){var R=E[1],$=E[2],G=E[3],te=P[0],se=P[1];return C[0]=E[0]*te,C[1]=R*te,C[2]=$*se,C[3]=G*se,C}(new Float32Array(4),d.inverseAdjustmentMatrix,[v,v])},i.cO=$F,i.cP=Q,i.cQ=$3e,i.cR=function(x){const d=$3e(x,!0);return p([],[d[0],d[1],d[4],d[5]])},i.cS=L,i.cT=hr,i.cU=I,i.cV=function(x){const{x:d,y:m}=x.point,{lng:v,lat:C}=x._center;return wCe(d,m,x.worldSize,v,C)},i.cW=ye,i.cX=ea,i.cY=wo,i.cZ=Td,i.c_=sp,i.ca=ti,i.cb=function(x,d){return x[0]=-d[0],x[1]=-d[1],x[2]=-d[2],x[3]=d[3],x},i.cc=Y,i.cd=function(x,d,m,v,C){var E=1/Math.tan(d/2);if(x[0]=E/m,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=E,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[11]=-1,x[12]=0,x[13]=0,x[15]=0,C!=null&&C!==1/0){var P=1/(v-C);x[10]=(C+v)*P,x[14]=2*C*v*P}else x[10]=-1,x[14]=-2*v;return x},i.ce=function(x,d,m,v,C,E,P){var R=1/(d-m),$=1/(v-C),G=1/(E-P);return x[0]=-2*R,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=-2*$,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=2*G,x[11]=0,x[12]=(d+m)*R,x[13]=(C+v)*$,x[14]=(P+E)*G,x[15]=1,x},i.cf=ne,i.cg=function(x,d,m){x[4*d+0]=m[0],x[4*d+1]=m[1],x[4*d+2]=m[2],x[4*d+3]=m[3]},i.ch=F3,i.ci=b2,i.cj=ql,i.ck=Gf,i.cl=w2,i.cm=G5e,i.cn=function(){var x=new u(4);return u!=Float32Array&&(x[1]=0,x[2]=0),x[0]=1,x[3]=1,x},i.co=function(x,d,m){var v=d[0],C=d[1],E=d[2],P=d[3],R=Math.sin(m),$=Math.cos(m);return x[0]=v*$+E*R,x[1]=C*$+P*R,x[2]=v*-R+E*$,x[3]=C*-R+P*$,x},i.cp=function(x,d){return x[0]===d[0]&&x[1]===d[1]&&x[2]===d[2]&&x[3]===d[3]},i.cq=et,i.cr=function(x){var d=x[0],m=x[1],v=x[2],C=x[3];return Math.sqrt(d*d+m*m+v*v+C*C)},i.cs=Cs,i.ct=qe,i.cu=ml,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=Te,i.d=function(x){return ua.API_TILEJSON_REGEX.test(x)},i.d$=class{constructor(x,d,m,v){this.context=x,this.format=v,this.size=m,this.texture=x.gl.createTexture();const[C,E,P]=this.size,{gl:R}=x;R.bindTexture(R.TEXTURE_3D,this.texture),x.pixelStoreUnpackFlipY.set(!1),x.pixelStoreUnpack.set(1),x.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in d&&d.data&&R.texImage3D(R.TEXTURE_3D,0,this.format,C,E,P,0,Cpe(this.format),Mpe(this.format),d.data)}bind(x,d){const{context:m}=this,{gl:v}=m;v.bindTexture(v.TEXTURE_3D,this.texture),x!==this.minFilter&&(v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MAG_FILTER,x),v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MIN_FILTER,x),this.minFilter=x),d!==this.wrapS&&(v.texParameteri(v.TEXTURE_3D,v.TEXTURE_WRAP_S,d),v.texParameteri(v.TEXTURE_3D,v.TEXTURE_WRAP_T,d),this.wrapS=d)}destroy(){const{gl:x}=this.context;x.deleteTexture(this.texture),this.texture=null}},i.d0=function(x){return x*x*x*x*x},i.d1=z,i.d2=45,i.d3=z3,i.d4=function(x,d,m){const v=Math.sqrt(x*x+d*d+m*m),C=v>0?Math.acos(m/v)*Sr:0;let E=x!==0||d!==0?Math.atan2(-d,-x)*Sr+90:0;return E<0&&(E+=360),[v,E,C]},i.d5=re,i.d6=En,i.d7=Ve,i.d8=ce,i.d9=Or,i.dA=function(x){return x({pluginStatus:Fu,pluginURL:ig}),x3.on("pluginStateChange",x),x},i.dB=_2,i.dC=class extends cg{constructor(x){super(x),this.current=B3}set(x,d,m){if(this.fetchUniformLocation(x,d)){for(let v=0;v<9;v++)if(m[v]!==this.current[v]){this.current=m,this.gl.uniformMatrix3fv(this.location,!1,m);break}}}},i.dD=Ii,i.dE=function(x,d,m){const v=wb(m.zoom),C=x.style.map._antialias,E=x.terrain&&x.terrain.exaggeration()>0;return v===0&&!C&&!E},i.dF=function(x){const d=x.pixelsPerMeter,m=d/ne(1,x.center.lat),v=w(new Float64Array(16));return M(v,v,[x.point.x,x.point.y,0]),L(v,v,[m,m,d]),Float32Array.from(v)},i.dG=kF,i.dH=function(x){const d=Ne-5;x=ke(x,-d,d)/d*90;const m=Math.pow(Math.abs(Math.sin(jr(x))),3);return Math.round(m*($6.length-1))},i.dI=function(x,d,m,v){const C=d.getNorth(),E=d.getSouth(),P=d.getWest(),R=d.getEast(),$=1<0){const he=180/v;b(de,de,[he/G+1,0,0,0,he/te+1,0,-.5*he/se,.5*he/ae,1])}return de[2]=$,de[5]=x.x,de[8]=x.y,de},i.dJ=Vp,i.dK=function(x,d,m){const v=w(new Float64Array(16)),C=(d/(1<({u_matrix:new w2(x),u_texsize:new Gf(x),u_pixels_to_tile_units:new $3(x),u_device_pixel_ratio:new ql(x),u_width_scale:new ql(x),u_floor_width_scale:new ql(x),u_image:new F3(x),u_units_to_pixels:new Gf(x),u_tile_units_to_pixels:new ql(x),u_alpha_discard_threshold:new ql(x),u_trim_offset:new Gf(x),u_trim_fade_range:new Gf(x),u_trim_color:new z3(x),u_zbias_factor:new ql(x),u_tile_to_meter:new ql(x),u_ground_shadow_factor:new b2(x),u_pattern_transition:new ql(x)}),i.dX=x=>({u_matrix:new w2(x),u_pixels_to_tile_units:new $3(x),u_device_pixel_ratio:new ql(x),u_width_scale:new ql(x),u_floor_width_scale:new ql(x),u_units_to_pixels:new Gf(x),u_dash_image:new F3(x),u_gradient_image:new F3(x),u_image_height:new ql(x),u_texsize:new Gf(x),u_tile_units_to_pixels:new ql(x),u_alpha_discard_threshold:new ql(x),u_trim_offset:new Gf(x),u_trim_fade_range:new Gf(x),u_trim_color:new z3(x),u_zbias_factor:new ql(x),u_tile_to_meter:new ql(x),u_ground_shadow_factor:new b2(x)}),i.dY=x=>({u_camera_to_center_distance:new ql(x),u_extrude_scale:new $3(x),u_device_pixel_ratio:new ql(x),u_matrix:new w2(x),u_inv_rot_matrix:new w2(x),u_merc_center:new Gf(x),u_tile_id:new b2(x),u_zoom_transition:new ql(x),u_up_dir:new b2(x),u_emissive_strength:new ql(x)}),i.dZ=T3,i.d_=gut,i.da=ge,i.db=function(x){return[Math.pow(x[0],1/2.2),Math.pow(x[1],1/2.2),Math.pow(x[2],1/2.2)]},i.dc=B3e,i.dd=Dpe,i.de=H3e,i.df=ife,i.dg=function(x,d){return x.readFields(xht,{icons:[]},d)},i.dh=RF,i.di=e5,i.dj=Zpe,i.dk=K1,i.dl=p2,i.dm=vy,i.dn=Z1,i.dp=gs,i.dq=function(x){const d=x.indexOf(mv);return d>=0?x.slice(0,d):x},i.dr=function(x){return x.indexOf(mv)>=0},i.ds=function(x){const d=x.lastIndexOf(mv);return d>=0?x.slice(d+1):""},i.dt=function(x){const d=[],m=x.id;return m===void 0&&d.push({message:`layers.${m}: missing required property "id"`}),x.render===void 0&&d.push({message:`layers.${m}: missing required method "render"`}),x.renderingMode&&x.renderingMode!=="2d"&&x.renderingMode!=="3d"&&d.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),d},i.du=function(x,d,m,v){return x.type==="custom"?new cht(x,d):new pht[x.type](x,d,m,v)},i.dv=Ps,i.dw=function(x){const d=x.indexOf(mv);return d>=0?x.slice(d+1):""},i.dx=class extends L2{constructor(x,d){super(x._vectorTileFeature,x._z,x._x,x._y,x.id),x.state&&(this.state=Object.assign({},x.state)),this.target=d.target,this.namespace=d.namespace,d.properties&&(this.properties=d.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=x.source,this.sourceLayer=x.sourceLayer,this.layer=x.layer)}toJSON(){const x=super.toJSON();return x.target=this.target,x.namespace=this.namespace,x}},i.dy=x3,i.dz=Qx,i.e=ua,i.e$=oe,i.e0=kCe,i.e1=(x,d,m,v,C,E)=>{const P=x.transform,R=P.projection.name==="globe";let $;if(E.paint.get("circle-pitch-alignment")==="map")if(R){const te=_Ce(P.zoom,d.canonical)*P._pixelsPerMercatorPixel;$=Float32Array.from([te,0,0,te])}else $=P.calculatePixelsToTileUnitsMatrix(m);else $=new Float32Array([P.pixelsToGLUnits[0],0,0,P.pixelsToGLUnits[1]]);const G={u_camera_to_center_distance:x.transform.getCameraToCenterDistance(P.projection),u_matrix:x.translatePosMatrix(d.projMatrix,m,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Bl.devicePixelRatio,u_extrude_scale:$,u_inv_rot_matrix:Ict,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:E.paint.get("circle-emissive-strength")};if(R){G.u_inv_rot_matrix=v,G.u_merc_center=C,G.u_tile_id=[d.canonical.x,d.canonical.y,1<{const te=x.transform,se=te.pitch<15?n5e(.07,.7,ke((14-te.zoom)/5,0,1)):.07,ae=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:i5e(x,d,m,v),u_texsize:d.imageAtlasTexture?d.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:te.calculatePixelsToTileUnitsMatrix(d),u_device_pixel_ratio:C,u_width_scale:E,u_floor_width_scale:P,u_image:0,u_tile_units_to_pixels:a5e(d,te),u_units_to_pixels:[1/te.pixelsToGLUnits[0],1/te.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:R,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ae?null:m.lut).toArray01(),u_zbias_factor:se,u_tile_to_meter:Ve(d.tileID.canonical,0),u_ground_shadow_factor:$,u_pattern_transition:G}},i.e5=(x,d,m,v,C,E,P,R,$,G)=>{const te=x.transform,se=te.calculatePixelsToTileUnitsMatrix(d),ae=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",de=te.pitch<15?n5e(.07,.7,ke((14-te.zoom)/5,0,1)):.07;return{u_matrix:i5e(x,d,m,v),u_pixels_to_tile_units:se,u_device_pixel_ratio:E,u_width_scale:P,u_floor_width_scale:R,u_units_to_pixels:[1/te.pixelsToGLUnits[0],1/te.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:C,u_texsize:l5e(m)&&d.lineAtlasTexture?d.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:a5e(d,x.transform),u_alpha_discard_threshold:0,u_trim_offset:$,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ae?null:m.lut).toArray01(),u_zbias_factor:de,u_tile_to_meter:Ve(d.tileID.canonical,0),u_ground_shadow_factor:G}},i.e6=Zt,i.e7=U6,i.e8=ve,i.e9=ip,i.eA=function(x,d){var m=2*Math.acos(d[3]),v=Math.sin(m/2);return v>c?(x[0]=d[0]/v,x[1]=d[1]/v,x[2]=d[2]/v):(x[0]=1,x[1]=0,x[2]=0),m},i.eB=cfe,i.eC=VF,i.eD=UF,i.eE=[1,1,1],i.eF=n5,i.eG=ct,i.eH=function(x,d,m,v){var C=d[0],E=d[1],P=d[2],R=d[3];return x[0]=C+v*(m[0]-C),x[1]=E+v*(m[1]-E),x[2]=P+v*(m[2]-P),x[3]=R+v*(m[3]-R),x},i.eI=Z3,i.eJ=um,i.eK=Wf,i.eL=function(x,d,m,v,C,E,P,R,$,G,te,se,ae,de,he,Se){var Fe=new u(16);return Fe[0]=x,Fe[1]=d,Fe[2]=m,Fe[3]=v,Fe[4]=C,Fe[5]=E,Fe[6]=P,Fe[7]=R,Fe[8]=$,Fe[9]=G,Fe[10]=te,Fe[11]=se,Fe[12]=ae,Fe[13]=de,Fe[14]=he,Fe[15]=Se,Fe},i.eM=T,i.eN=xb,i.eO=E6,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new ft(1/0,1/0),max:new ft(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(x,d=!1){const m=t3e(new ft(0,0),new ft(tr,tr),x),v=[];if(d&&!fpe(m,this._globalClipBounds))return v;for(const C of this._activeRegions){if(C.hiddenByOverlap||!fpe(m,C))continue;const E=ldt(C.min,C.max,x);v.push({min:E.min,max:E.max,sourceId:this._sourceIds[C.priority],footprint:C.footprint,footprintTileId:C.tileId,order:C.order,clipMask:C.clipMask,clipScope:C.clipScope})}return v}setSources(x){this._setSources(x.map(d=>({getSourceId:()=>d.cache.id,getFootprints:()=>{const m=[];for(const v of d.cache.getVisibleCoordinates()){const C=d.cache.getTile(v).buckets[d.layer];C&&C.updateFootprints(v.toUnwrapped(),m)}return m},getOrder:()=>d.order,getClipMask:()=>d.clipMask,getClipScope:()=>d.clipScope})))}_addSource(x){const d=x.getFootprints();if(d.length===0)return;const m=x.getOrder(),v=x.getClipMask(),C=x.getClipScope();for(const E of d){if(!E.footprint)continue;const P=t3e(E.footprint.min,E.footprint.max,E.id);this._activeRegions.push({min:P.min,max:P.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:E.id,footprint:E.footprint,order:m,clipMask:v,clipScope:C})}this._sourceIds.push(x.getSourceId())}_computeReplacement(){this._activeRegions.sort((d,m)=>d.priority-m.priority||PF(d.min,m.min)||PF(d.max,m.max)||d.order-m.order||d.clipMask-m.clipMask||function(v,C){const E=(P,R)=>P+R;return v.length-C.length||v.reduce(E,"").localeCompare(C.reduce(E,""))}(d.clipScope,m.clipScope));let x=this._activeRegions.length!==this._prevRegions.length;if(!x){let d=0;for(;!x&&d!==this._activeRegions.length;){const m=this._activeRegions[d],v=this._prevRegions[d];x=m.priority!==v.priority||!e3e(m,v)||m.order!==v.order||m.clipMask!==v.clipMask||!ir(m.clipScope,v.clipScope),this._activeRegions[d].hiddenByOverlap=v.hiddenByOverlap,++d}}if(x){++this._updateTime;for(const m of this._activeRegions)m.order!==Z6&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,m.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,m.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,m.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,m.max.y));const d=m=>{const v=this._activeRegions;if(m>=v.length)return m;const C=v[m].priority;for(;m1){let m=0,v=d(m);for(;m!==v;){let C=m;const E=m;for(;C!==v;){const P=this._activeRegions[C];P.hiddenByOverlap=!1;for(let R=0;R=0;d--)this._addSource(x[d]);this._computeReplacement()}},i.eQ=Z6,i.eR=class{constructor(x){this._createGrid(x),this._createPoles(x)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const x of this._poleSegments)x.destroy();for(const x of this._gridSegments)x.withSkirts.destroy(),x.withoutSkirts.destroy()}_fillGridMeshWithLods(x,d){const m=new Iy,v=new $l,C=[],E=x+1+2,P=d[0]+1,R=d[0]+1+(1+d.length),$=(G,te,se)=>{let ae=G===E-1?G-2:G===0?G:G-1;return ae+=se?24575:0,[ae,te]};for(let G=0;G0?(Fe=2*Math.sqrt(Se+1),x[3]=.25*Fe,x[0]=(se-de)/Fe,x[1]=(ae-$)/Fe,x[2]=(R-G)/Fe):P>te&&P>he?(Fe=2*Math.sqrt(1+P-te-he),x[3]=(se-de)/Fe,x[0]=.25*Fe,x[1]=(R+G)/Fe,x[2]=(ae+$)/Fe):te>he?(Fe=2*Math.sqrt(1+te-P-he),x[3]=(ae-$)/Fe,x[0]=(R+G)/Fe,x[1]=.25*Fe,x[2]=(se+de)/Fe):(Fe=2*Math.sqrt(1+he-P-te),x[3]=(R-G)/Fe,x[0]=(ae+$)/Fe,x[1]=(se+de)/Fe,x[2]=.25*Fe),x},i.f=function(x){return btoa(encodeURIComponent(x).replace(/%([0-9A-F]{2})/g,(d,m)=>String.fromCharCode(+("0x"+m))))},i.f0=function([x,d,m]){const v=Math.hypot(x,d,m),C=Math.atan2(x,m),E=.5*Math.PI-Math.acos(-d/v);return new y(ea(C),ea(E))},i.f1=Ze,i.f2=Ape,i.f3=function(x){const d=x.navigator?x.navigator.userAgent:null;return!!function(m){if(il==null){const v=m.navigator?m.navigator.userAgent:null;il=!!m.safari||!(!v||!(/\b(iPad|iPhone|iPod)\b/.test(v)||v.match("Safari")&&!v.match("Chrome")))}return il}(x)&&!(!d||!(d.match("Version/15.4")||d.match("Version/15.5")||d.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},i.f4=function(x,d){W1=x,G1=d},i.f5=ipe,i.f6=jCe,i.f7=function(x){const d=[0,0,0],m=w(new Float64Array(16));return S(m,x.pixelMatrix,x.globeMatrix),pt(d,d,m),new ft(d[0],d[1])},i.f8=function(){const x=tP;x&&(x.isPreloaded()&&x.numActive()===1?(x.release(_pe),tP=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(){RF().acquire(_pe)},i.fA=x7,i.fB=Ht,i.fC=function(x){let d=0;if(new Uint32Array(x,0,1)[0]!==D3e){const m=new Uint32Array(x,0,7),[,,v,C,E,P]=m;d=m.byteLength+C+E+P+E,(v!==x.byteLength||d>=x.byteLength)&&xr("Invalid b3dm header information.")}return z3e(x,d)},i.fD=function(x,d){const m=Dpe(x);for(const v of m){for(const C of v.meshes)zdt(C);v.lights&&(v.lightMeshIndex=v.meshes.length,v.meshes.push(Bdt(v.lights,d)))}return m},i.fE=d7,i.fF=_a,i.fG=A3e,i.fH=og,i.fI=Dh,i.fJ=function(x){$d(),am!=null&&am.then(d=>{d.keys().then(m=>{for(let v=0;vxr(C.message))}).catch(m=>xr(m.message))}).catch(d=>xr(d.message))},i.fa=f2,i.fb=function(x,d,m=!1){if(Fu===Dh.deferred||Fu===Dh.loading||Fu===Dh.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");ig=Bl.resolveURL(x),Fu=Dh.deferred,b6=d,f3(),m||nF()},i.fc=function(x){W3=Bl.resolveURL(x),G3||(G3=new H3(RF(),new As)),G3.broadcast("setMeshoptUrl",W3)},i.fd=I3e,i.fe=function(x){Npe=Bl.resolveURL(x),G3||(G3=new H3(RF(),new As)),G3.broadcast("setDracoUrl",Npe)},i.ff=P3e,i.fg=eP,i.fh=function(x){const d=im();if(!d)return;const m=d.delete(H1);x&&m.then(()=>x()).catch(x)},i.fi=T2,i.fj=kr,i.fk=jb,i.fl=yg,i.fm=QMe,i.fn=JMe,i.fo=e5e,i.fp=as,i.fq="hd_road_elevation",i.fr=di,i.fs=Xt,i.ft=gv,i.fu=Kpe,i.fv=P2,i.fw=function(x,d,m,v,C,E,P,R=1,$,G,te){x.createArrays(),x.tilePixelRatio=tr/(512*x.overscaling),x.compareText={},x.iconsNeedLinear=!1;const se=x.layers[0].layout,ae=x.layers[0]._unevaluatedLayout._values,de={};de.scaleFactor=R,de.textSizeScaleRange=se.get("text-size-scale-range"),de.iconSizeScaleRange=se.get("icon-size-scale-range");const[he,Se]=de.textSizeScaleRange,[Fe,Re]=de.iconSizeScaleRange;de.textScaleFactor=ke(de.scaleFactor,he,Se),de.iconScaleFactor=ke(de.scaleFactor,Fe,Re);const Ke=ae["text-size"],Xe=ae["icon-size"];if(x.textSizeData.kind==="composite"){const{minZoom:qt,maxZoom:ss}=x.textSizeData;de.compositeTextSizes=[Ke.possiblyEvaluate(new Ki(qt,{worldview:te}),E),Ke.possiblyEvaluate(new Ki(ss,{worldview:te}),E)]}if(x.iconSizeData.kind==="composite"){const{minZoom:qt,maxZoom:ss}=x.iconSizeData;de.compositeIconSizes=[Xe.possiblyEvaluate(new Ki(qt,{worldview:te}),E),Xe.possiblyEvaluate(new Ki(ss,{worldview:te}),E)]}de.layoutTextSize=Ke.possiblyEvaluate(new Ki(P+1,{worldview:te}),E),de.layoutIconSize=Xe.possiblyEvaluate(new Ki(P+1,{worldview:te}),E),de.textMaxSize=Ke.possiblyEvaluate(new Ki(18,{worldview:te}),E);const lt=se.get("symbol-placement"),kt=se.get("text-rotation-alignment")==="map"&<!=="point",vt=se.get("text-size");let At=!1;const zt=[];for(const qt of x.features){const ss=se.get("text-font").evaluate(qt,{},E).join(","),Gt=vt.evaluate(qt,{},E)*de.textScaleFactor,ds=de.layoutTextSize.evaluate(qt,{},E)*de.textScaleFactor,js=de.layoutIconSize.evaluate(qt,{},E)*de.iconScaleFactor,Ns={horizontal:{},vertical:void 0},Fs=qt.text;let Bs,Ls=[0,0];if(Fs){const $n=Fs.toString(),Ai=se.get("text-letter-spacing").evaluate(qt,{},E)*Ac,_t=se.get("text-line-height").evaluate(qt,{},E)*Ac,Ct=y6($n)?Ai:0,us=se.get("text-anchor").evaluate(qt,{},E),zs=se.get("text-variable-anchor");if(!zs){const In=se.get("text-radial-offset").evaluate(qt,{},E);if(In)Ls=O5e(us,[In*Ac,Xpe]);else{const Kn=se.get("text-offset").evaluate(qt,{},E);Ls=[Kn[0]*Ac,Kn[1]*Ac]}}let or=kt?"center":se.get("text-justify").evaluate(qt,{},E);const lr=lt==="point",Br=lr?se.get("text-max-width").evaluate(qt,{},E)*Ac:1/0,Vr=In=>{x.allowVerticalPlacement&&m2($n)&&(Ns.vertical=Upe(Fs,d,m,C,ss,Br,_t,us,In,Ct,Ls,pm.vertical,!0,ds,Gt,$))};if(!kt&&zs){const In=or==="auto"?zs.map(Qn=>Qpe(Qn)):[or];let Kn=!1;for(let Qn=0;Qn=0||!m2($n)){const In=Upe(Fs,d,m,C,ss,Br,_t,us,or,Ct,Ls,pm.horizontal,!1,ds,Gt,$);In&&(Ns.horizontal[or]=In)}Vr(lr?"left":or)}}let Os,ls,rs,Rs,sr,Vs,zr=!1;const mr=se.get("icon-text-fit").evaluate(qt,{},E);if(qt.icon&&qt.icon.hasPrimary()){const $n=uP(qt.icon,x.iconSizeData,ae["icon-size"],E,x.zoom,qt,$,de.iconScaleFactor,te);Os=$n.iconPrimary,rs=$n.iconSecondary;const Ai=Os.toString();if(ls=v.get(Ai),ls&&(sr=se.get("icon-offset").evaluate(qt,{},E),Vs=se.get("icon-anchor").evaluate(qt,{},E),Bs=ZF(C.get(Ai),rs?C.get(rs.toString()):void 0,sr,Vs),zr=ls.sdf,x.sdfIcons===void 0?x.sdfIcons=ls.sdf:x.sdfIcons!==ls.sdf&&xr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ls.pixelRatio!==x.pixelRatio||se.get("icon-rotate").constantOr(1)!==0)&&(x.iconsNeedLinear=!0)),rs){const _t=rs.toString();Rs=v.get(_t)}}At=At||!(!qt.icon||!qt.icon.hasSecondary());const _r=e7(Ns.horizontal)||Ns.vertical;x.iconsInText||(x.iconsInText=!!_r&&_r.iconsInText);const Tr=ds*de.textScaleFactor/Ac,{defaultShapedIcon:ta,verticallyShapedIcon:Zs}=Kut(x,Bs,se,qt,E,Ns,Tr,sr,mr);mr!=="none"&&Bs&&(_5e(Bs)||w5e(Bs))&&(JF(0,ls,Os,Bs,ta,mr,G,v,C),JF(0,Rs,rs,Bs,ta,mr,G,v,C),Zs&&(JF(0,ls,Os,Bs,Zs,mr,G,v,C),JF(0,Rs,rs,Bs,Zs,mr,G,v,C))),Bs=ta;const{iconBBox:Ar,iconVerticalBBox:_n,textBBox:ja,textVerticalBBox:Ca}=Uut(x,Bs,Zs,se,qt,E,js,sr,de,C,Vs,Ns,ds,Ls);zt.push({feature:qt,shapedTextOrientations:Ns,shapedText:_r,shapedIcon:Bs,iconPrimary:Os,iconSecondary:rs,iconOffset:sr,iconAnchor:Vs,verticallyShapedIcon:Zs,layoutTextSize:ds,layoutIconSize:js,textOffset:Ls,isSDFIcon:zr,iconTextFit:mr,iconCollisionBounds:Ar,iconVerticalCollisionBounds:_n,textCollisionBounds:ja,textVerticalCollisionBounds:Ca})}return{featureData:zt,sizes:de,hasAnySecondaryIcon:At,textAlongLine:kt,symbolPlacement:lt}},i.fx=A5e,i.fy=function(x,d,m,v,C,E,P,R,$,G){x.iconAtlasPositions=G.iconPositions;const{featureData:te,hasAnySecondaryIcon:se,sizes:ae,textAlongLine:de,symbolPlacement:he}=d;for(const Se of te){const{shapedIcon:Fe,verticallyShapedIcon:Re,feature:Ke,shapedTextOrientations:Xe,shapedText:lt,layoutTextSize:kt,textOffset:vt,isSDFIcon:At,iconPrimary:zt,iconSecondary:qt,iconTextFit:ss,iconOffset:Gt,iconCollisionBounds:ds,iconVerticalCollisionBounds:js,textCollisionBounds:Ns}=Se;F5e(Fe,G.iconPositions,zt,qt),F5e(Re,G.iconPositions,zt,qt),Gut(Xe,G.iconPositions),Wut(zt,qt,G.iconPositions),(lt||Fe)&&Zut(x,Ke,Xe,Fe,Re,$,ae,kt,0,vt,At,v,C,P,R,se,ss,Gt,de,he,ds,js,Ns)}m&&x.generateCollisionDebugBuffers(E,x.collisionBoxArray,ae.textScaleFactor)},i.fz=Yt,i.g=function(x,d){return Qx(Object.assign(x,{method:"GET"}),d)},i.h=function(x){return x.indexOf("mapbox:")===0},i.i=function(x){return ua.API_STYLE_REGEX.test(x)&&!Mc(x)},i.j=co,i.k=du,i.l=function(x){return decodeURIComponent(atob(x).split("").map(d=>"%"+("00"+d.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(x,d){return Qx(Object.assign(x,{type:"json"}),d)},i.n=by,i.o=Bl,i.p=function(x,d){return Qx(Object.assign(x,{method:"POST"}),d)},i.q=Wd,i.r=Km,i.s=function(x){try{const d=self[x];return d.setItem("_mapbox_test_",1),d.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return wpe||(wpe=new T2("ImageRasterizer")),wpe},i.u=function(){return function x(d){return d?(d^Math.random()*(16>>d/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,x)}()},i.v=function(x){return!!x&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(x)},i.w=xr,i.x=ffe,i.y=_y,i.z=Xm}),o(["./shared"],function(i){function c($t){const ke=$t?$t.url.toString():void 0;return ke?performance.getEntriesByName(ke):[]}function u($t){if(typeof $t=="number"||typeof $t=="boolean"||typeof $t=="string"||$t==null)return JSON.stringify($t);if(Array.isArray($t)){let Be="[";for(const Ye of $t)Be+=`${u(Ye)},`;return`${Be}]`}let ke="{";for(const Be of Object.keys($t).sort())ke+=`${Be}:${u($t[Be])},`;return`${ke}}`}function p($t){let ke="";for(const Be of i.bx)ke+=`/${u($t[Be])}`;return ke}class f{constructor(ke){this.keyCache={},this._layers={},this._layerConfigs={},ke&&this.replace(ke)}replace(ke,Be){this._layerConfigs={},this._layers={},this.update(ke,[],Be)}update(ke,Be,Ye){this._options=Ye;for(const gt of ke)this._layerConfigs[gt.id]=gt,(this._layers[gt.id]=i.du(gt,this.scope,null,this._options)).compileFilter(Ye),this.keyCache[gt.id]&&delete this.keyCache[gt.id];for(const gt of Be)delete this.keyCache[gt],delete this._layerConfigs[gt],delete this._layers[gt];this.familiesBySource={};const bt=function(gt,Ft){const Zt={};for(let Xt=0;Xtthis._layers[vr.id]),Zt=Ft[0];if(Zt.visibility==="none")continue;const Ut=Zt.source||"";let Xt=this.familiesBySource[Ut];Xt||(Xt=this.familiesBySource[Ut]={});const Ps=Zt.sourceLayer||"_geojsonTileLayer";let gs=Xt[Ps];gs||(gs=Xt[Ps]=[]),gs.push(Ft)}}}const g=1*i.fl;class b{constructor(ke){const Be={},Ye=[];for(const Zt in ke){const Ut=ke[Zt],Xt=Be[Zt]={};for(const Ps in Ut.glyphs){const gs=Ut.glyphs[+Ps];if(!gs||gs.bitmap.width===0||gs.bitmap.height===0)continue;const vr=gs.metrics.localGlyph?g:1,Hr={x:0,y:0,w:gs.bitmap.width+2*vr,h:gs.bitmap.height+2*vr};Ye.push(Hr),Xt[Ps]=Hr}}const{w:bt,h:gt}=i.G(Ye),Ft=new i.fk({width:bt||1,height:gt||1});for(const Zt in ke){const Ut=ke[Zt];for(const Xt in Ut.glyphs){const Ps=Ut.glyphs[+Xt];if(!Ps||Ps.bitmap.width===0||Ps.bitmap.height===0)continue;const gs=Be[Zt][Xt],vr=Ps.metrics.localGlyph?g:1;i.fk.copy(Ps.bitmap,Ft,{x:0,y:0},{x:gs.x+vr,y:gs.y+vr},Ps.bitmap)}}this.image=Ft,this.positions=Be}}function _($t,ke,Be){$t[ke]?Be&&($t[ke].center=Be):$t[ke]={floorIds:new Set,center:Be||[0,0],floors:{}}}function j($t,ke,Be,Ye){for(const bt of ke)_($t,bt),$t[bt].floors[Be]=Ye,$t[bt].floorIds.add(Be)}function w($t){return{id:$t.properties.id.toString(),center:$t.properties.center.toString().split(";").map(Number)}}function N($t){return{id:$t.properties.id.toString(),isDefault:!!$t.properties.is_default&&$t.properties.is_default,connections:$t.properties.connected_floor_ids?new Set($t.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:$t.properties.conflicted_floor_ids?new Set($t.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:$t.properties.building_ids?new Set($t.properties.building_ids.toString().split(";")):new Set,name:$t.properties.name.toString(),zIndex:$t.properties.z_index}}function S($t,ke){return ke.every(Be=>$t.properties&&$t.properties[Be]!=null)}function M($t){return S($t,["type","id","name"])&&$t.properties.type==="building"}function L($t){return S($t,["type","id","name","z_index"])&&$t.properties.type==="floor"}i.fj(b,"GlyphAtlas");class I{constructor(ke){this.tileID=new i.aQ(ke.tileID.overscaledZ,ke.tileID.wrap,ke.tileID.canonical.z,ke.tileID.canonical.x,ke.tileID.canonical.y),this.tileZoom=ke.tileZoom,this.uid=ke.uid,this.zoom=ke.zoom,this.lut=ke.lut,this.canonical=ke.tileID.canonical,this.pixelRatio=ke.pixelRatio,this.tileSize=ke.tileSize,this.source=ke.source,this.scope=ke.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=ke.showCollisionBoxes,this.collectResourceTiming=!!ke.request&&ke.request.collectResourceTiming,this.promoteId=ke.promoteId,this.isSymbolTile=ke.isSymbolTile,this.tileTransform=i.aZ(ke.tileID.canonical,ke.projection),this.projection=ke.projection,this.worldview=ke.worldview,this.localizableLayerIds=ke.localizableLayerIds,this.brightness=ke.brightness,this.extraShadowCaster=!!ke.extraShadowCaster,this.tessellationStep=ke.tessellationStep,this.scaleFactor=ke.scaleFactor,this.worldview=ke.worldview,this.indoor=ke.indoor}parse(ke,Be,Ye,bt,gt,Ft){this.status="parsing",this.data=ke,this.collisionBoxArray=new i.b3;const Zt=new i.fm(Object.keys(ke.layers).sort()),Ut=new i.fn(this.tileID,this.promoteId);Ut.bucketLayerIDs=[];const Xt={},Ps=new i.fo(256,256),gs={featureIndex:Ut,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ps,availableImages:Ye,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const Dn=this.indoor.indoorState.activeFloorsVisible,On=function(En,_a,vo){const il=function(oo,Ia){if(!oo)return i.w("No source layers defined in indoor specification"),Ia;if(oo.size===0)return Ia;const lo=oo.difference(Ia);for(const Ti of lo)i.w(`Missing source layer required in indoor specification: ${Ti}`);return Ia.intersection(Ia)}(_a.sourceLayers,new Set(Object.keys(En.layers))),ti=_a.indoorState,hl=function(oo,Ia,lo,Ti){const ua=new Set,co=new Set,Mc=new Set,Wc=new Map,lu={},Of=zl=>{const ch=Wc.get(zl)||new Set;for(const Sd of ua)if((Wc.get(Sd)||new Set).has(zl)||ch.has(Sd))return!0;return!1};for(const zl of Ia){const ch=oo.layers[zl];if(ch)for(let Sd=0;Sd=lo.maxzoom||lo.visibility==="none")continue;O(Ia,this.zoom,gs.brightness,Ye,this.worldview);const Ti=Xt[lo.id]=lo.createBucket({index:Ut.bucketLayerIDs.length,layers:Ia,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:il,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:bt,worldview:this.worldview,localizable:hl});Ut.bucketLayerIDs.push(Ia.map(co=>i.B(co.id,co.scope)));let ua=Ti.prepare?Ti.prepare():null;ua!=null?(ua=ua.then(()=>Ti.populate(ti,gs,this.tileID.canonical,this.tileTransform)),vr.push(ua)):Ti.populate(ti,gs,this.tileID.canonical,this.tileTransform)}}const xr=()=>{let Dn,On,En,_a,vo,il;Ps.trim();const ti={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},hl=()=>{if(Dn)return this.status="done",Ft(Dn);if(this.extraShadowCaster)this.status="done",Ft(null,{buckets:Object.values(Xt).filter(Ia=>!Ia.isEmpty()),featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:gs.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(On&&En&&_a){const Ia=new b(On),lo=new Map;for(const[co,Mc]of En.entries()){const{imagePosition:Wc}=i.fu(co,Mc,i.fv);lo.set(co,Wc)}const Ti={};for(const co in Xt){const Mc=Xt[co];Mc instanceof i.b4&&(O(Mc.layers,this.zoom,gs.brightness,Ye,this.worldview),Ti[co]=i.fw(Mc,On,Ia.positions,En,lo,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,vo,this.worldview))}const ua={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(gt,En,vo,()=>{ua.iconsPending=!1,oo(Ti,Ia,ua)}),this.rasterizeIfNeeded(gt,_a,il,()=>{ua.patternsPending=!1,oo(Ti,Ia,ua)})}},oo=(Ia,lo,Ti,ua)=>{if(Ti.iconsPending||Ti.patternsPending)return;const co=new i.fx(En,_a,this.lut);for(const Mc in Xt){const Wc=Xt[Mc];if(Mc in Ia)i.fy(Wc,Ia[Mc],this.showCollisionBoxes,Ye,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,En,co);else if(Wc.hasPattern&&(Wc instanceof i.ba||Wc instanceof i.bb||Wc instanceof i.ea)){O(Wc.layers,this.zoom,gs.brightness,Ye,this.worldview);const lu=Object.fromEntries(co.patternPositions);Wc.addFeatures(gs,this.tileID.canonical,lu,Ye,this.tileTransform,this.brightness)}}this.status="done",Ft(null,{buckets:Object.values(Xt).filter(Mc=>!Mc.isEmpty()),featureIndex:Ut,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:lo.image,lineAtlas:Ps,imageAtlas:co,brightness:gs.brightness})};if(!this.extraShadowCaster){const Ia=i.fs(gs.glyphDependencies,ua=>Object.keys(ua).map(Number));Object.keys(Ia).length?gt.send("getGlyphs",{uid:this.uid,stacks:Ia},(ua,co)=>{Dn||(Dn=ua,On=co,hl())},void 0,!1,ti):On={};const lo=Array.from(gs.iconDependencies.keys()).map(ua=>i.I.parse(ua));lo.length?gt.send("getImages",{images:lo,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ua,co)=>{Dn||(Dn=ua,En=new Map,vo=this.updateImageMapAndGetImageTaskQueue(En,co,gs.iconDependencies),hl())},void 0,!1,ti):(En=new Map,vo=new Map);const Ti=Array.from(gs.patternDependencies.keys()).map(ua=>i.I.parse(ua));Ti.length?gt.send("getImages",{images:Ti,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(ua,co)=>{Dn||(Dn=ua,_a=new Map,il=this.updateImageMapAndGetImageTaskQueue(_a,co,gs.patternDependencies),hl())},void 0,!1,ti):(_a=new Map,il=new Map)}if(gs.elevationFeatures&&gs.elevationFeatures.length>0){const Ia=[];for(const Ti of Object.values(Xt))if(Ti instanceof i.bb){const ua=Ti.getUnevaluatedPortalGraph();ua&&Ia.push(ua)}const lo=i.ft.evaluate(Ia);for(const Ti of Object.values(Xt))if(Ti instanceof i.bb){const ua=ke.layers[Zt.decode(Ti.sourceLayerIndex)];Ti.setEvaluatedPortalGraph(lo,ua,this.tileID.canonical,gs.availableImages,gs.brightness)}}hl()};vr.length>0?Promise.allSettled(vr).then(xr).catch(Ft):xr()}updateParameters(ke){this.scaleFactor=ke.scaleFactor,this.showCollisionBoxes=ke.showCollisionBoxes,this.projection=ke.projection,this.brightness=ke.brightness,this.tileTransform=i.aZ(ke.tileID.canonical,ke.projection),this.extraShadowCaster=ke.extraShadowCaster,this.lut=ke.lut,this.worldview=ke.worldview,this.indoor=ke.indoor}rasterizeIfNeeded(ke,Be,Ye,bt){Array.from(Be.values()).some(gt=>gt.usvg)?this.rasterize(ke,Be,Ye,bt):bt()}updateImageMapAndGetImageTaskQueue(ke,Be,Ye){const bt=new Map;for(const gt of Be.keys()){const Ft=Ye.get(gt)||[];for(const Zt of Ft){const Ut=Zt.toString(),Xt=Be.get(Zt.id.toString());Xt.usvg?bt.has(Ut)||(bt.set(Ut,Zt),ke.set(Ut,Object.assign({},Xt))):ke.set(Ut,Xt)}}return bt}rasterize(ke,Be,Ye,bt){this.rasterizeTask=ke.send("rasterizeImages",{scope:this.scope,tasks:Ye},(gt,Ft)=>{if(!gt)for(const[Zt,Ut]of Ft.entries()){const Xt=Object.assign(Be.get(Zt),{data:Ut});Be.set(Zt,Xt)}bt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function O($t,ke,Be,Ye,bt){const gt=new i.ac(ke,{brightness:Be,worldview:bt});for(const Ft of $t)Ft.recalculate(gt,Ye)}class q extends i.E{constructor(ke,Be,Ye,bt,gt,Ft,Zt){super(),this.actor=ke,this.layerIndex=Be,this.availableImages=Ye,this.availableModels=bt,this.loadVectorData=Ft||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(ke.scheduler),this.isSpriteLoaded=gt,this.scheduler=ke.scheduler,this.brightness=Zt}loadTile(ke,Be){const Ye=ke.uid,bt=ke&&ke.request,gt=bt&&bt.collectResourceTiming,Ft=this.loading[Ye]=new I(ke);Ft.abort=this.loadVectorData(ke,(Zt,Ut)=>{const Xt=!this.loading[Ye];if(delete this.loading[Ye],Ft.cancelRasterize(),Xt||Zt||!Ut)return Ft.status="done",Xt||(this.loaded[Ye]=Ft),Be(Zt);const Ps=Ut.rawData,gs={},vr=i.aM(Ut.responseHeaders);vr&&vr.expires&&(gs.expires=vr.expires),vr&&vr.cacheControl&&(gs.cacheControl=vr.cacheControl),Ft.vectorTile=Ut.vectorTile||new i.fz(new i.bt(Ps));const Hr=()=>{Ft.parse(Ft.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(xr,Dn)=>{if(xr||!Dn)return Be(xr);const On={};if(gt){const En=c(bt);En.length>0&&(On.resourceTiming=JSON.parse(JSON.stringify(En)))}Be(null,Object.assign({rawTileData:Ps.slice(0),responseHeaders:Ut.responseHeaders},Dn,gs,On))})};this.isSpriteLoaded?Hr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Hr,{type:"parseTile",isSymbolTile:ke.isSymbolTile,zoom:ke.tileZoom}):Hr()}),this.loaded=this.loaded||{},this.loaded[Ye]=Ft})}reloadTile(ke,Be){const Ye=this.loaded,bt=ke.uid;if(Ye&&Ye[bt]){const gt=Ye[bt];gt.updateParameters(ke);const Ft=(Zt,Ut)=>{const Xt=gt.reloadCallback;Xt&&(delete gt.reloadCallback,gt.parse(gt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Xt)),Be(Zt,Ut)};gt.status==="parsing"?gt.reloadCallback=Ft:gt.status==="done"&&(gt.vectorTile?gt.parse(gt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Ft):Ft())}else Be(null,void 0)}abortTile(ke,Be){const Ye=ke.uid,bt=this.loading[Ye];bt&&(bt.abort&&bt.abort(),delete this.loading[Ye]),Be()}removeTile(ke,Be){const Ye=this.loaded,bt=ke.uid;Ye&&Ye[bt]&&delete Ye[bt],Be()}}class U{loadTile(ke,Be){const{uid:Ye,encoding:bt,rawImageData:gt,padding:Ft}=ke,Zt=ImageBitmap&> instanceof ImageBitmap?this.getImageData(gt,Ft):gt;Be(null,new i.fA(Ye,Zt,bt,Ft<1))}reloadTile(ke,Be){Be(null,null)}abortTile(ke,Be){Be()}removeTile(ke,Be){Be()}getImageData(ke,Be){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(ke.width,ke.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=ke.width,this.offscreenCanvas.height=ke.height,this.offscreenCanvasContext.drawImage(ke,0,0,ke.width,ke.height);const Ye=this.offscreenCanvasContext.getImageData(-Be,-Be,ke.width+2*Be,ke.height+2*Be);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Ye}}i.bs.setPbf(i.bt);class B{constructor(ke){this._mrt=new i.bs(ke.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=ke.uid,this.tileID=ke.tileID,this.source=ke.source}parse(ke,Be){const Ye=this._mrt;this.status="parsing",this._entireBuffer=ke;try{Ye.parseHeader(ke),this._isHeaderLoaded=!0;const bt=[];for(const gt in Ye.layers){const Ft=Ye.getLayer(gt),Zt=Ft.getDataRange(Ft.getBandList()),Ut=Ye.createDecodingTask(Zt),Xt=ke.slice(Zt.firstByte,Zt.lastByte+1),Ps=i.bs.performDecoding(Xt,Ut).then(gs=>Ut.complete(null,gs)).catch(gs=>Ut.complete(gs,null));bt.push(Ps)}Promise.allSettled(bt).then(()=>Be(null,Ye)).catch(gt=>Be(gt))}catch(bt){Be(bt)}}}class V{constructor(ke){this.actor=ke,this.loading={},this.loaded={}}loadTile(ke,Be){const Ye=ke.uid,bt=ke.request,gt=this.loading[Ye]=new B(ke),{cancel:Ft}=i.bu(bt,(Zt,Ut,Xt)=>{const Ps=!this.loading[Ye];if(delete this.loading[Ye],Ps||Zt||!Ut)return gt.status="done",Ps||(this.loaded[Ye]=gt),Be(Zt);gt.parse(Ut,(gs,vr)=>{if(gs||!vr)return Be(gs);Be(null,vr,Xt)}),this.loaded[Ye]=gt});gt.abort=Ft}reloadTile(ke,Be){Be(null,void 0)}abortTile(ke,Be){const Ye=ke.uid,bt=this.loading[Ye];bt&&(bt.abort&&bt.abort(),delete this.loading[Ye]),Be()}removeTile(ke,Be){const Ye=ke.uid;this.loaded[Ye]&&delete this.loaded[Ye],Be()}decodeRasterArray(ke,Be){i.bs.performDecoding(ke.buffer,ke.task).then(Ye=>Be(null,Ye)).catch(Ye=>Be(Ye))}}const Y=i.fB.prototype.toGeoJSON;class Q{constructor(ke){this._feature=ke,this.extent=i.al,this.type=ke.type,this.properties=ke.tags,"id"in ke&&!isNaN(ke.id)&&(this.id=parseInt(ke.id,10))}loadGeometry(){if(this._feature.type===1){const ke=[];for(const Be of this._feature.geometry)ke.push([new i.P(Be[0],Be[1])]);return ke}{const ke=[];for(const Be of this._feature.geometry){const Ye=[];for(const bt of Be)Ye.push(new i.P(bt[0],bt[1]));ke.push(Ye)}return ke}}toGeoJSON(ke,Be,Ye){return Y.call(this,ke,Be,Ye)}}class ee{constructor(ke,Be){this.name=ke,this.extent=i.al,this.length=Be.length,this._jsonFeatures=Be}feature(ke){return new Q(this._jsonFeatures[ke])}}class X{constructor(ke){this.layers={},this.extent=i.al;for(const Be of Object.keys(ke))this.layers[Be]=new ee(Be,ke[Be])}}const ie=64/4096,re=128;class oe{constructor(){this.features=new Map}clear(){this.features.clear()}load(ke=[],Be){for(const Ye of ke){const bt=Ye.id;if(bt==null)continue;let gt=this.features.get(bt);gt&&this.updateCache(gt,Be),Ye.geometry?(gt=ge(Ye),this.updateCache(gt,Be),this.features.set(bt,gt)):this.features.delete(bt),this.updateCache(gt,Be)}}updateCache(ke,Be){for(const{canonical:Ye,uid:bt}of Object.values(Be)){const{z:gt,x:Ft,y:Zt}=Ye;ce(ke,Math.pow(2,gt),Ft,Zt)&&delete Be[bt]}}getTile(ke,Be,Ye){const bt=Math.pow(2,ke),gt=[];for(const Ft of this.features.values())ce(Ft,bt,Be,Ye)&>.push(_e(Ft,bt,Be,Ye));return{features:gt}}getFeatures(){return[...this.features.values()]}}function ce({minX:$t,minY:ke,maxX:Be,maxY:Ye},bt,gt,Ft){return $t<(gt+1+ie)/bt&&ke<(Ft+1+ie)/bt&&Be>(gt-ie)/bt&&Ye>(Ft-ie)/bt}function ge($t){const{id:ke,geometry:Be,properties:Ye}=$t;if(!Be)return;if(Be.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:bt,coordinates:gt}=Be,Ft={id:ke,type:1,geometry:[],tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Zt=Ft.geometry;if(bt==="Point")ye(gt,Zt,Ft);else if(bt==="MultiPoint")for(const Ut of gt)ye(Ut,Zt,Ft);else if(bt==="LineString")Ft.type=2,ue(gt,Zt,Ft);else if(bt==="MultiLineString")Ft.type=2,pe(gt,Zt,Ft);else if(bt==="Polygon")Ft.type=3,pe(gt,Zt,Ft,!0);else{if(bt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Ft.type=3;for(const Ut of gt)pe(Ut,Zt,Ft,!0)}return Ft}function ye([$t,ke],Be,Ye){const bt=i.aF($t);let gt=i.aJ(ke);gt=gt<0?0:gt>1?1:gt,Be.push(bt,gt),Ye.minX=Math.min(Ye.minX,bt),Ye.minY=Math.min(Ye.minY,gt),Ye.maxX=Math.max(Ye.maxX,bt),Ye.maxY=Math.max(Ye.maxY,gt)}function ue($t,ke,Be,Ye=!1,bt=!1){const gt=[];for(const Ft of $t)ye(Ft,gt,Be);ke.push(gt),Ye&&function(Ft,Zt){let Ut=0;for(let Xt=0,Ps=Ft.length,gs=Ps-2;Xt0===Zt)for(let Xt=0,Ps=Ft.length;Xt=Ft&&gs>=Ft||(Xt>=Ft?(Ps+=Math.round(xr*((Ft-Xt)/Hr)),Xt=Ft):gs>=Ft&&(vr=Ps+Math.round(xr*((Ft-Xt)/Hr)),gs=Ft),Ps>=Ft&&vr>=Ft||(Ps>=Ft?(Xt+=Math.round(Hr*((Ft-Ps)/xr)),Ps=Ft):vr>=Ft&&(gs=Xt+Math.round(Hr*((Ft-Ps)/xr)),vr=Ft),Zt&&Xt===Zt[Zt.length-1][0]&&Ps===Zt[Zt.length-1][1]||(Zt=[[Xt,Ps]],bt.push(Zt)),Zt.push([gs,vr])))))}}function Ae($t,ke,Be,Ye,bt){const gt=(Be-ie)/ke,Ft=(Ye-ie)/ke,Zt=(Be+1+ie)/ke,Ut=(Ye+1+ie)/ke;function Xt(vr,Hr){let xr=0;return vrZt&&(xr|=2),HrUt&&(xr|=8),xr}let Ps=[];for(let vr=1;vr<=8;vr*=2){let Hr=$t[$t.length-2],xr=$t[$t.length-1],Dn=!(Xt(Hr,xr)&vr);for(let On=0;On<$t.length;On+=2){const En=$t[On],_a=$t[On+1],vo=!(Xt(En,_a)&vr);vo!==Dn&&(8&vr?Ps.push(Hr+(En-Hr)*(Ut-xr)/(_a-xr),Ut):4&vr?Ps.push(Hr+(En-Hr)*(Ft-xr)/(_a-xr),Ft):2&vr?Ps.push(Zt,xr+(_a-xr)*(Zt-Hr)/(En-Hr)):1&vr&&Ps.push(gt,xr+(_a-xr)*(gt-Hr)/(En-Hr))),vo&&Ps.push(En,_a),Hr=En,xr=_a,Dn=vo}if(!($t=Ps).length||vr===8)break;Ps=[]}const gs=[];for(let vr=0;vr>31}function tt($t,ke){const{geometry:Be,type:Ye}=$t;let bt=0,gt=0;if(Ye===1){ke.writeVarint(we(1,Be.length));for(const Ft of Be){const Zt=Ft[0]-bt,Ut=Ft[1]-gt;ke.writeVarint(Le(Zt)),ke.writeVarint(Le(Ut)),bt+=Zt,gt+=Ut}}else for(const Ft of Be){ke.writeVarint(we(1,1));const Zt=Ft.length-(Ye===3?1:0);for(let Ut=0;Ut$t},fe=Math.fround||(qe=new Float32Array(1),$t=>(qe[0]=+$t,qe[0]));var qe;const at=3,et=5,Me=6;class rt{constructor(ke){this.options=Object.assign(Object.create(pt),ke),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(ke){const{log:Be,minZoom:Ye,maxZoom:bt}=this.options;Be&&console.time("total time");const gt=`prepare ${ke.length} points`;Be&&console.time(gt),this.points=ke;const Ft=[];for(let Ut=0;Ut=Ye;Ut--){const Xt=+Date.now();Zt=this.trees[Ut]=this._createTree(this._cluster(Zt,Ut)),Be&&console.log("z%d: %d clusters in %dms",Ut,Zt.numItems,+Date.now()-Xt)}return Be&&console.timeEnd("total time"),this}getClusters(ke,Be){let Ye=((ke[0]+180)%360+360)%360-180;const bt=Math.max(-90,Math.min(90,ke[1]));let gt=ke[2]===180?180:((ke[2]+180)%360+360)%360-180;const Ft=Math.max(-90,Math.min(90,ke[3]));if(ke[2]-ke[0]>=360)Ye=-180,gt=180;else if(Ye>gt){const gs=this.getClusters([Ye,bt,180,Ft],Be),vr=this.getClusters([-180,bt,gt,Ft],Be);return gs.concat(vr)}const Zt=this.trees[this._limitZoom(Be)],Ut=Zt.range(Ue(Ye),Ze(Ft),Ue(gt),Ze(bt)),Xt=Zt.data,Ps=[];for(const gs of Ut){const vr=this.stride*gs;Ps.push(Xt[vr+et]>1?He(Xt,vr,this.clusterProps):this.points[Xt[vr+at]])}return Ps}getChildren(ke){const Be=this._getOriginId(ke),Ye=this._getOriginZoom(ke),bt="No cluster with the specified id.",gt=this.trees[Ye];if(!gt)throw new Error(bt);const Ft=gt.data;if(Be*this.stride>=Ft.length)throw new Error(bt);const Zt=this.options.radius/(this.options.extent*Math.pow(2,Ye-1)),Ut=gt.within(Ft[Be*this.stride],Ft[Be*this.stride+1],Zt),Xt=[];for(const Ps of Ut){const gs=Ps*this.stride;Ft[gs+4]===ke&&Xt.push(Ft[gs+et]>1?He(Ft,gs,this.clusterProps):this.points[Ft[gs+at]])}if(Xt.length===0)throw new Error(bt);return Xt}getLeaves(ke,Be,Ye){const bt=[];return this._appendLeaves(bt,ke,Be=Be||10,Ye=Ye||0,0),bt}getTile(ke,Be,Ye){const bt=this.trees[this._limitZoom(ke)],gt=Math.pow(2,ke),{extent:Ft,radius:Zt}=this.options,Ut=Zt/Ft,Xt=(Ye-Ut)/gt,Ps=(Ye+1+Ut)/gt,gs={features:[]};return this._addTileFeatures(bt.range((Be-Ut)/gt,Xt,(Be+1+Ut)/gt,Ps),bt.data,Be,Ye,gt,gs),Be===0&&this._addTileFeatures(bt.range(1-Ut/gt,Xt,1,Ps),bt.data,gt,Ye,gt,gs),Be===gt-1&&this._addTileFeatures(bt.range(0,Xt,Ut/gt,Ps),bt.data,-1,Ye,gt,gs),gs.features.length?gs:null}getClusterExpansionZoom(ke){let Be=this._getOriginZoom(ke)-1;for(;Be<=this.options.maxZoom;){const Ye=this.getChildren(ke);if(Be++,Ye.length!==1)break;ke=Ye[0].properties.cluster_id}return Be}_appendLeaves(ke,Be,Ye,bt,gt){const Ft=this.getChildren(Be);for(const Zt of Ft){const Ut=Zt.properties;if(Ut&&Ut.cluster?gt+Ut.point_count<=bt?gt+=Ut.point_count:gt=this._appendLeaves(ke,Ut.cluster_id,Ye,bt,gt):gt1;let Ps,gs,vr;if(Xt)Ps=ct(Be,Ut,this.clusterProps),gs=Be[Ut],vr=Be[Ut+1];else{const Dn=this.points[Be[Ut+at]];Ps=Dn.properties;const[On,En]=Dn.geometry.coordinates;gs=Ue(On),vr=Ze(En)}const Hr={type:1,geometry:[[Math.round(this.options.extent*(gs*gt-Ye)),Math.round(this.options.extent*(vr*gt-bt))]],tags:Ps};let xr;xr=Xt||this.options.generateId?Be[Ut+at]:this.points[Be[Ut+at]].id,xr!==void 0&&(Hr.id=xr),Ft.features.push(Hr)}}_limitZoom(ke){return Math.max(this.options.minZoom,Math.min(Math.floor(+ke),this.options.maxZoom+1))}_cluster(ke,Be){const{radius:Ye,extent:bt,reduce:gt,minPoints:Ft}=this.options,Zt=Ye/(bt*Math.pow(2,Be)),Ut=ke.data,Xt=[],Ps=this.stride;for(let gs=0;gsBe&&(On+=Ut[_a+et])}if(On>Dn&&On>=Ft){let En,_a=vr*Dn,vo=Hr*Dn,il=-1;const ti=(gs/Ps<<5)+(Be+1)+this.points.length;for(const hl of xr){const oo=hl*Ps;if(Ut[oo+2]<=Be)continue;Ut[oo+2]=Be;const Ia=Ut[oo+et];_a+=Ut[oo]*Ia,vo+=Ut[oo+1]*Ia,Ut[oo+4]=ti,gt&&(En||(En=this._map(Ut,gs,!0),il=this.clusterProps.length,this.clusterProps.push(En)),gt(En,this._map(Ut,oo)))}Ut[gs+4]=ti,Xt.push(_a/On,vo/On,1/0,ti,-1,On),gt&&Xt.push(il)}else{for(let En=0;En1)for(const En of xr){const _a=En*Ps;if(!(Ut[_a+2]<=Be)){Ut[_a+2]=Be;for(let vo=0;vo>5}_getOriginZoom(ke){return(ke-this.points.length)%32}_map(ke,Be,Ye){if(ke[Be+et]>1){const Ft=this.clusterProps[ke[Be+Me]];return Ye?Object.assign({},Ft):Ft}const bt=this.points[ke[Be+at]].properties,gt=this.options.map(bt);return Ye&>===bt?Object.assign({},gt):gt}}function He($t,ke,Be){return{type:"Feature",id:$t[ke+at],properties:ct($t,ke,Be),geometry:{type:"Point",coordinates:[(Ye=$t[ke],360*(Ye-.5)),Qe($t[ke+1])]}};var Ye}function ct($t,ke,Be){const Ye=$t[ke+et],bt=Ye>=1e4?`${Math.round(Ye/1e3)}k`:Ye>=1e3?Math.round(Ye/100)/10+"k":Ye,gt=$t[ke+Me],Ft=gt===-1?{}:Object.assign({},Be[gt]);return Object.assign(Ft,{cluster:!0,cluster_id:$t[ke+at],point_count:Ye,point_count_abbreviated:bt})}function Ue($t){return $t/360+.5}function Ze($t){const ke=Math.sin($t*Math.PI/180),Be=.5-.25*Math.log((1+ke)/(1-ke))/Math.PI;return Be<0?0:Be>1?1:Be}function Qe($t){const ke=(180-360*$t)*Math.PI/180;return 360*Math.atan(Math.exp(ke))/Math.PI-90}function We($t,ke,Be,Ye){let bt=Ye;const gt=ke+(Be-ke>>1);let Ft,Zt=Be-ke;const Ut=$t[ke],Xt=$t[ke+1],Ps=$t[Be],gs=$t[Be+1];for(let vr=ke+3;vrbt)Ft=vr,bt=Hr;else if(Hr===bt){const xr=Math.abs(vr-gt);xrYe&&(Ft-ke>3&&We($t,ke,Ft,Ye),$t[Ft+2]=bt,Be-Ft>3&&We($t,Ft,Be,Ye))}function Je($t,ke,Be,Ye,bt,gt){let Ft=bt-Be,Zt=gt-Ye;if(Ft!==0||Zt!==0){const Ut=(($t-Be)*Ft+(ke-Ye)*Zt)/(Ft*Ft+Zt*Zt);Ut>1?(Be=bt,Ye=gt):Ut>0&&(Be+=Ft*Ut,Ye+=Zt*Ut)}return Ft=$t-Be,Zt=ke-Ye,Ft*Ft+Zt*Zt}function it($t,ke,Be,Ye){const bt={id:$t??null,type:ke,geometry:Be,tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(ke==="Point"||ke==="MultiPoint"||ke==="LineString")Dt(bt,Be);else if(ke==="Polygon")Dt(bt,Be[0]);else if(ke==="MultiLineString")for(const gt of Be)Dt(bt,gt);else if(ke==="MultiPolygon")for(const gt of Be)Dt(bt,gt[0]);return bt}function Dt($t,ke){for(let Be=0;Be0&&(Ft+=Ye?(bt*Ps-Xt*gt)/2:Math.sqrt(Math.pow(Xt-bt,2)+Math.pow(Ps-gt,2))),bt=Xt,gt=Ps}const Zt=ke.length-3;ke[2]=1,We(ke,0,Zt,Be),ke[Zt+2]=1,ke.size=Math.abs(Ft),ke.start=0,ke.end=ke.size}function Cs($t,ke,Be,Ye){for(let bt=0;bt<$t.length;bt++){const gt=[];Ts($t[bt],gt,Be,Ye),ke.push(gt)}}function cs($t){return $t/360+.5}function er($t){const ke=Math.sin($t*Math.PI/180),Be=.5-.25*Math.log((1+ke)/(1-ke))/Math.PI;return Be<0?0:Be>1?1:Be}function xt($t,ke,Be,Ye,bt,gt,Ft,Zt){if(Ye/=ke,gt>=(Be/=ke)&&Ft=Ye)return null;const Ut=[];for(const Xt of $t){const Ps=Xt.geometry;let gs=Xt.type;const vr=bt===0?Xt.minX:Xt.minY,Hr=bt===0?Xt.maxX:Xt.maxY;if(vr>=Be&&Hr=Ye)continue;let xr=[];if(gs==="Point"||gs==="MultiPoint")Es(Ps,xr,Be,Ye,bt);else if(gs==="LineString")ur(Ps,xr,Be,Ye,bt,!1,Zt.lineMetrics);else if(gs==="MultiLineString")Lr(Ps,xr,Be,Ye,bt,!1);else if(gs==="Polygon")Lr(Ps,xr,Be,Ye,bt,!0);else if(gs==="MultiPolygon")for(const Dn of Ps){const On=[];Lr(Dn,On,Be,Ye,bt,!0),On.length&&xr.push(On)}if(xr.length){if(Zt.lineMetrics&&gs==="LineString"){for(const Dn of xr)Ut.push(it(Xt.id,gs,Dn,Xt.tags));continue}gs!=="LineString"&&gs!=="MultiLineString"||(xr.length===1?(gs="LineString",xr=xr[0]):gs="MultiLineString"),gs!=="Point"&&gs!=="MultiPoint"||(gs=xr.length===3?"Point":"MultiPoint"),Ut.push(it(Xt.id,gs,xr,Xt.tags))}}return Ut.length?Ut:null}function Es($t,ke,Be,Ye,bt){for(let gt=0;gt<$t.length;gt+=3){const Ft=$t[gt+bt];Ft>=Be&&Ft<=Ye&&fn(ke,$t[gt],$t[gt+1],$t[gt+2])}}function ur($t,ke,Be,Ye,bt,gt,Ft){let Zt=Mr($t);const Ut=bt===0?ki:Ea;let Xt,Ps,gs=$t.start;for(let On=0;On<$t.length-3;On+=3){const En=$t[On],_a=$t[On+1],vo=$t[On+2],il=$t[On+3],ti=$t[On+4],hl=bt===0?En:_a,oo=bt===0?il:ti;let Ia=!1;Ft&&(Xt=Math.sqrt(Math.pow(En-il,2)+Math.pow(_a-ti,2))),hlBe&&(Ps=Ut(Zt,En,_a,il,ti,Be),Ft&&(Zt.start=gs+Xt*Ps)):hl>Ye?oo=Be&&(Ps=Ut(Zt,En,_a,il,ti,Be),Ia=!0),oo>Ye&&hl<=Ye&&(Ps=Ut(Zt,En,_a,il,ti,Ye),Ia=!0),!gt&&Ia&&(Ft&&(Zt.end=gs+Xt*Ps),ke.push(Zt),Zt=Mr($t)),Ft&&(gs+=Xt)}let vr=$t.length-3;const Hr=$t[vr],xr=$t[vr+1],Dn=bt===0?Hr:xr;Dn>=Be&&Dn<=Ye&&fn(Zt,Hr,xr,$t[vr+2]),vr=Zt.length-3,gt&&vr>=3&&(Zt[vr]!==Zt[0]||Zt[vr+1]!==Zt[1])&&fn(Zt,Zt[0],Zt[1],Zt[2]),Zt.length&&ke.push(Zt)}function Mr($t){const ke=[];return ke.size=$t.size,ke.start=$t.start,ke.end=$t.end,ke}function Lr($t,ke,Be,Ye,bt,gt){for(const Ft of $t)ur(Ft,ke,Be,Ye,bt,gt,!1)}function fn($t,ke,Be,Ye){$t.push(ke,Be,Ye)}function ki($t,ke,Be,Ye,bt,gt){const Ft=(gt-ke)/(Ye-ke);return fn($t,gt,Be+(bt-Be)*Ft,1),Ft}function Ea($t,ke,Be,Ye,bt,gt){const Ft=(gt-Be)/(bt-Be);return fn($t,ke+(Ye-ke)*Ft,gt,1),Ft}function dr($t,ke){const Be=[];for(let Ye=0;Ye<$t.length;Ye++){const bt=$t[Ye],gt=bt.type;let Ft;if(gt==="Point"||gt==="MultiPoint"||gt==="LineString")Ft=Jr(bt.geometry,ke);else if(gt==="MultiLineString"||gt==="Polygon"){Ft=[];for(const Zt of bt.geometry)Ft.push(Jr(Zt,ke))}else if(gt==="MultiPolygon"){Ft=[];for(const Zt of bt.geometry){const Ut=[];for(const Xt of Zt)Ut.push(Jr(Xt,ke));Ft.push(Ut)}}Be.push(it(bt.id,gt,Ft,bt.tags))}return Be}function Jr($t,ke){const Be=[];Be.size=$t.size,$t.start!==void 0&&(Be.start=$t.start,Be.end=$t.end);for(let Ye=0;Ye<$t.length;Ye+=3)Be.push($t[Ye]+ke,$t[Ye+1],$t[Ye+2]);return Be}function Wr($t,ke){if($t.transformed)return $t;const Be=1<<$t.z,Ye=$t.x,bt=$t.y;for(const gt of $t.features){const Ft=gt.geometry,Zt=gt.type;if(gt.geometry=[],Zt===1)for(let Ut=0;Ut0&&ke.size<(bt?Ft:Ye))return void(Be.numPoints+=ke.length/3);const Zt=[];for(let Ut=0;UtFt)&&(Be.numSimplified++,Zt.push(ke[Ut],ke[Ut+1])),Be.numPoints++;bt&&function(Ut,Xt){let Ps=0;for(let gs=0,vr=Ut.length,Hr=vr-2;gs0===Xt)for(let gs=0,vr=Ut.length;gs24)throw new Error("maxZoom should be in the 0-24 range");if(Be.promoteId&&Be.generateId)throw new Error("promoteId and generateId cannot be used together.");let bt=function(gt,Ft){const Zt=[];if(gt.type==="FeatureCollection")for(let Ut=0;Ut1&&console.time("creation"),Hr=this.tiles[vr]=Yr(ke,Be,Ye,bt,Xt),this.tileCoords.push({z:Be,x:Ye,y:bt}),Ps)){Ps>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Be,Ye,bt,Hr.numFeatures,Hr.numPoints,Hr.numSimplified),console.timeEnd("creation"));const Ia=`z${Be}`;this.stats[Ia]=(this.stats[Ia]||0)+1,this.total++}if(Hr.source=ke,gt==null){if(Be===Xt.indexMaxZoom||Hr.numPoints<=Xt.indexMaxPoints)continue}else{if(Be===Xt.maxZoom||Be===gt)continue;if(gt!=null){const Ia=gt-Be;if(Ye!==Ft>>Ia||bt!==Zt>>Ia)continue}}if(Hr.source=null,ke.length===0)continue;Ps>1&&console.time("clipping");const xr=.5*Xt.buffer/Xt.extent,Dn=.5-xr,On=.5+xr,En=1+xr;let _a=null,vo=null,il=null,ti=null,hl=xt(ke,gs,Ye-xr,Ye+On,0,Hr.minX,Hr.maxX,Xt),oo=xt(ke,gs,Ye+Dn,Ye+En,0,Hr.minX,Hr.maxX,Xt);ke=null,hl&&(_a=xt(hl,gs,bt-xr,bt+On,1,Hr.minY,Hr.maxY,Xt),vo=xt(hl,gs,bt+Dn,bt+En,1,Hr.minY,Hr.maxY,Xt),hl=null),oo&&(il=xt(oo,gs,bt-xr,bt+On,1,Hr.minY,Hr.maxY,Xt),ti=xt(oo,gs,bt+Dn,bt+En,1,Hr.minY,Hr.maxY,Xt),oo=null),Ps>1&&console.timeEnd("clipping"),Ut.push(_a||[],Be+1,2*Ye,2*bt),Ut.push(vo||[],Be+1,2*Ye,2*bt+1),Ut.push(il||[],Be+1,2*Ye+1,2*bt),Ut.push(ti||[],Be+1,2*Ye+1,2*bt+1)}}getTile(ke,Be,Ye){ke=+ke,Be=+Be,Ye=+Ye;const bt=this.options,{extent:gt,debug:Ft}=bt;if(ke<0||ke>24)return null;const Zt=1<1&&console.log("drilling down to z%d-%d-%d",ke,Be,Ye);let Xt,Ps=ke,gs=Be,vr=Ye;for(;!Xt&&Ps>0;)Ps--,gs>>=1,vr>>=1,Xt=this.tiles[Sr(Ps,gs,vr)];return Xt&&Xt.source?(Ft>1&&(console.log("found parent tile z%d-%d-%d",Ps,gs,vr),console.time("drilling down")),this.splitTile(Xt.source,Ps,gs,vr,ke,Be,Ye),Ft>1&&console.timeEnd("drilling down"),this.tiles[Ut]?Wr(this.tiles[Ut],gt):null):null}}function Sr($t,ke,Be){return 32*((1<<$t)*Be+ke)+$t}function jr($t,ke){const Be=$t.tileID.canonical;if(!this._geoJSONIndex)return void ke(null,null);const Ye=this._geoJSONIndex.getTile(Be.z,Be.x,Be.y);if(!Ye)return void ke(null,null);const bt=Xt=>Xt.tags&&"3d_elevation_id"in Xt.tags&&"source"in Xt.tags&&Xt.tags.source==="elevation",gt=Ye.features.filter(Xt=>bt(Xt));let Ft={_geojsonTileLayer:Ye.features};gt.length>0&&(Ft={_geojsonTileLayer:Ye.features.filter(Xt=>!bt(Xt)),hd_road_elevation:gt});const Zt=new X(Ft),Ut=function(Xt){const Ps=new i.bt;for(const gs of Object.keys(Xt))Ps.writeMessage(3,Ie,{name:gs,features:Xt[gs]});return Ps.finish()}(Ft).buffer;ke(null,{vectorTile:Zt,rawData:Ut})}class ea extends q{constructor(ke,Be,Ye,bt,gt,Ft,Zt){super(ke,Be,Ye,bt,gt,jr,Zt),Ft&&(this.loadGeoJSON=Ft),this._dynamicIndex=new oe}loadData(ke,Be){const Ye=ke&&ke.request,bt=Ye&&Ye.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(ke,(gt,Ft)=>{if(gt||!Ft)return Be(gt);if(typeof Ft!="object")return Be(new Error(`Input data given to '${ke.source}' is not a valid GeoJSON object.`));{try{if(ke.filter){const Ut=i.U(ke.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Ut.result==="error")throw new Error(Ut.value.map(Xt=>`${Xt.key}: ${Xt.message}`).join(", "));Ft.features=Ft.features.filter(Xt=>Ut.value.evaluate({zoom:0},Xt))}ke.dynamic?(Ft.type==="Feature"&&(Ft={type:"FeatureCollection",features:[Ft]}),ke.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Ft.features,this.loaded),ke.cluster&&(Ft.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=ke.cluster?new rt(function({superclusterOptions:Ut,clusterProperties:Xt}){if(!Xt||!Ut)return Ut;const Ps={},gs={},vr={accumulated:null,zoom:0},Hr={properties:null},xr=Object.keys(Xt);for(const Dn of xr){const[On,En]=Xt[Dn],_a=i.U(En),vo=i.U(typeof On=="string"?[On,["accumulated"],["get",Dn]]:On);Ps[Dn]=_a.value,gs[Dn]=vo.value}return Ut.map=Dn=>{Hr.properties=Dn;const On={};for(const En of xr)On[En]=Ps[En].evaluate(vr,Hr);return On},Ut.reduce=(Dn,On)=>{Hr.properties=On;for(const En of xr)vr.accumulated=Dn[En],Dn[En]=gs[En].evaluate(vr,Hr)},Ut}(ke)).load(Ft.features):ke.dynamic?this._dynamicIndex:function(Ut,Xt){return new Vn(Ut,Xt)}(Ft,ke.geojsonVtOptions)}catch(Ut){return Be(Ut)}const Zt={};if(bt){const Ut=c(Ye);Ut&&(Zt.resourceTiming={},Zt.resourceTiming[ke.source]=JSON.parse(JSON.stringify(Ut)))}Be(null,Zt)}})}reloadTile(ke,Be){const Ye=this.loaded;return Ye&&Ye[ke.uid]?ke.partial?Be(null,void 0):super.reloadTile(ke,Be):this.loadTile(ke,Be)}loadGeoJSON(ke,Be){if(ke.request)i.m(ke.request,Be);else{if(typeof ke.data!="string")return Be(new Error(`Input data given to '${ke.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return Be(null,JSON.parse(ke.data))}catch{return Be(new Error(`Input data given to '${ke.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(ke,Be){try{Be(null,this._geoJSONIndex.getClusterExpansionZoom(ke.clusterId))}catch(Ye){Be(Ye)}}getClusterChildren(ke,Be){try{Be(null,this._geoJSONIndex.getChildren(ke.clusterId))}catch(Ye){Be(Ye)}}getClusterLeaves(ke,Be){try{Be(null,this._geoJSONIndex.getLeaves(ke.clusterId,ke.limit,ke.offset))}catch(Ye){Be(Ye)}}}class Pa{constructor(ke,Be,Ye){this.tileID=new i.aQ(ke.tileID.overscaledZ,ke.tileID.wrap,ke.tileID.canonical.z,ke.tileID.canonical.x,ke.tileID.canonical.y),this.tileZoom=ke.tileZoom,this.uid=ke.uid,this.zoom=ke.zoom,this.canonical=ke.tileID.canonical,this.pixelRatio=ke.pixelRatio,this.tileSize=ke.tileSize,this.source=ke.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=ke.projection,this.brightness=Be,this.worldview=Ye}parse(ke,Be,Ye,bt){this.status="parsing";const gt=new i.aQ(Ye.tileID.overscaledZ,Ye.tileID.wrap,Ye.tileID.canonical.z,Ye.tileID.canonical.x,Ye.tileID.canonical.y),Ft=[],Zt=Be.familiesBySource[Ye.source],Ut=new i.fn(gt,Ye.promoteId);Ut.bucketLayerIDs=[],Ut.is3DTile=!0,i.fC(ke).then(Xt=>{if(!Xt)return bt(new Error("Could not parse tile"));const Ps=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Xt.json.asset.extras&&Xt.json.asset.extras.MAPBOX_mesh_features,gs=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("EXT_meshopt_compression"),vr=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Hr in Zt)for(const xr of Zt[Hr]){const Dn=xr[0];Ut.bucketLayerIDs.push(xr.map(_a=>i.B(_a.id,_a.scope))),Dn.recalculate(vr,[]);const On=i.fD(Xt,1/i.d7(Ye.tileID.canonical)),En=new i.fE(xr,On,gt,Ps,gs,this.brightness,Ut,this.worldview);Ps||(En.needsUpload=!0),Ft.push(En),En.evaluate(Dn)}this.status="done",bt(null,{buckets:Ft,featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Xt=>bt(new Error(Xt.message)))}}class Ii{constructor(ke,Be,Ye,bt,gt,Ft,Zt,Ut){this.actor=ke,this.layerIndex=Be,this.availableImages=Ye,this.availableModels=bt,this.brightness=Zt,this.loading={},this.loaded={},this.worldview=Ut}loadTile(ke,Be){const Ye=ke.uid,bt=this.loading[Ye]=new Pa(ke,this.brightness,this.worldview);i.bu(ke.request,(gt,Ft)=>{const Zt=!this.loading[Ye];return delete this.loading[Ye],Zt||gt?(bt.status="done",Zt||(this.loaded[Ye]=bt),Be(gt)):Ft&&Ft.byteLength!==0?void bt.parse(Ft,this.layerIndex,ke,(Ut,Xt)=>{bt.status="done",this.loaded=this.loaded||{},this.loaded[Ye]=bt,Ut||!Xt?Be(Ut):Be(null,Xt)}):(bt.status="done",this.loaded[Ye]=bt,Be())})}reloadTile(ke,Be){const Ye=this.loaded,bt=ke.uid;if(Ye&&Ye[bt]){const gt=Ye[bt];gt.projection=ke.projection,gt.brightness=ke.brightness;const Ft=(Zt,Ut)=>{gt.reloadCallback&&(delete gt.reloadCallback,this.loadTile(ke,Be)),Be(Zt,Ut)};gt.status==="parsing"?gt.reloadCallback=Ft:gt.status==="done"&&this.loadTile(ke,Be)}}abortTile(ke,Be){const Ye=ke.uid;this.loading[Ye]&&delete this.loading[Ye],Be()}removeTile(ke,Be){const Ye=this.loaded,bt=ke.uid;Ye&&Ye[bt]&&delete Ye[bt],Be()}}class Fo{constructor(ke){this.self=ke,this.actor=new i.fG(ke,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:q,geojson:ea,"raster-dem":U,"raster-array":V,"batched-model":Ii},this.workerSources={},this.self.registerWorkerSource=(Be,Ye)=>{if(this.workerSourceTypes[Be])throw new Error(`Worker source with name "${Be}" already registered.`);this.workerSourceTypes[Be]=Ye},this.self.registerRTLTextPlugin=Be=>{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=Be.applyArabicShaping,i.fH.processBidirectionalText=Be.processBidirectionalText,i.fH.processStyledBidirectionalText=Be.processStyledBidirectionalText;for(const Ye of this.rtlPluginParsingListeners)Ye(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(ke,Be,Ye){delete this.layerIndexes[ke],delete this.availableImages[ke],delete this.availableModels[ke],delete this.workerSources[ke],Ye()}checkIfReady(ke,Be,Ye){Ye()}setReferrer(ke,Be){this.referrer=Be}spriteLoaded(ke,Be){this.isSpriteLoaded[ke]||(this.isSpriteLoaded[ke]={});const{scope:Ye,isLoaded:bt}=Be;if(this.isSpriteLoaded[ke][Ye]=bt,this.workerSources[ke]&&this.workerSources[ke][Ye])for(const gt in this.workerSources[ke][Ye]){const Ft=this.workerSources[ke][Ye][gt];for(const Zt in Ft){const Ut=Ft[Zt];Ut instanceof q&&(Ut.isSpriteLoaded=bt,Ut.fire(new i.z("isSpriteLoaded")))}}}setImages(ke,Be,Ye){this.availableImages[ke]||(this.availableImages[ke]={});const{scope:bt,images:gt}=Be;if(this.availableImages[ke][bt]=gt,this.workerSources[ke]&&this.workerSources[ke][bt]){for(const Ft in this.workerSources[ke][bt]){const Zt=this.workerSources[ke][bt][Ft];for(const Ut in Zt)Zt[Ut].availableImages=gt}Ye()}else Ye()}setModels(ke,{scope:Be,models:Ye},bt){if(this.availableModels[ke]||(this.availableModels[ke]={}),this.availableModels[ke][Be]=Ye,this.workerSources[ke]&&this.workerSources[ke][Be]){for(const gt in this.workerSources[ke][Be]){const Ft=this.workerSources[ke][Be][gt];for(const Zt in Ft)Ft[Zt].availableModels=Ye}bt()}else bt()}setProjection(ke,Be){this.projections[ke]=i.cm(Be)}setBrightness(ke,Be,Ye){this.brightness=Be,Ye()}setWorldview(ke,Be,Ye){this.worldview=Be,Ye()}setLayers(ke,Be,Ye){this.getLayerIndex(ke,Be.scope).replace(Be.layers,Be.options),Ye()}updateLayers(ke,Be,Ye){this.getLayerIndex(ke,Be.scope).update(Be.layers,Be.removedIds,Be.options),Ye()}loadTile(ke,Be,Ye){Be.projection=this.projections[ke]||this.defaultProjection,this.getWorkerSource(ke,Be.type,Be.source,Be.scope).loadTile(Be,Ye)}decodeRasterArray(ke,Be,Ye){this.getWorkerSource(ke,Be.type,Be.source,Be.scope).decodeRasterArray(Be,Ye)}reloadTile(ke,Be,Ye){Be.projection=this.projections[ke]||this.defaultProjection,this.getWorkerSource(ke,Be.type,Be.source,Be.scope).reloadTile(Be,Ye)}abortTile(ke,Be,Ye){this.getWorkerSource(ke,Be.type,Be.source,Be.scope).abortTile(Be,Ye)}removeTile(ke,Be,Ye){this.getWorkerSource(ke,Be.type,Be.source,Be.scope).removeTile(Be,Ye)}removeSource(ke,Be,Ye){if(!(this.workerSources[ke]&&this.workerSources[ke][Be.scope]&&this.workerSources[ke][Be.scope][Be.type]&&this.workerSources[ke][Be.scope][Be.type][Be.source]))return;const bt=this.workerSources[ke][Be.scope][Be.type][Be.source];delete this.workerSources[ke][Be.scope][Be.type][Be.source],bt.removeSource!==void 0?bt.removeSource(Be,Ye):Ye()}loadWorkerSource(ke,Be,Ye){try{this.self.importScripts(Be.url),Ye()}catch(bt){Ye(bt)}}syncRTLPluginState(ke,Be,Ye){if(i.fH.isParsed())Ye(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(Ye);else try{i.fH.setState(Be);const bt=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||bt==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(bt),i.fH.isParsed()?Ye(null,!0):this.rtlPluginParsingListeners.push(Ye))}catch(bt){Ye(bt)}}setDracoUrl(ke,Be){this.dracoUrl=Be}getAvailableImages(ke,Be){this.availableImages[ke]||(this.availableImages[ke]={});let Ye=this.availableImages[ke][Be];return Ye||(Ye=[]),Ye}getAvailableModels(ke,Be){this.availableModels[ke]||(this.availableModels[ke]={});let Ye=this.availableModels[ke][Be];return Ye||(Ye={}),Ye}getLayerIndex(ke,Be){this.layerIndexes[ke]||(this.layerIndexes[ke]={});let Ye=this.layerIndexes[ke][Be];return Ye||(Ye=this.layerIndexes[ke][Be]=new f,Ye.scope=Be),Ye}getWorkerSource(ke,Be,Ye,bt){const gt=this.workerSources;return gt[ke]||(gt[ke]={}),gt[ke][bt]||(gt[ke][bt]={}),gt[ke][bt][Be]||(gt[ke][bt][Be]={}),this.isSpriteLoaded[ke]||(this.isSpriteLoaded[ke]={}),gt[ke][bt][Be][Ye]||(gt[ke][bt][Be][Ye]=new this.workerSourceTypes[Be]({send:(Ft,Zt,Ut,Xt,Ps,gs)=>this.actor.send(Ft,Zt,Ut,ke,Ps,gs),scheduler:this.actor.scheduler},this.getLayerIndex(ke,bt),this.getAvailableImages(ke,bt),this.getAvailableModels(ke,bt),this.isSpriteLoaded[ke][bt],void 0,this.brightness,this.worldview)),gt[ke][bt][Be][Ye]}rasterizeImagesWorker(ke,Be,Ye){const bt=new Map;for(const[gt,{image:Ft,imageVariant:Zt}]of Be.tasks.entries()){const Ut=this.imageRasterizer.rasterize(Zt,Ft,Be.scope,ke);bt.set(gt,Ut)}Ye(void 0,bt)}removeRasterizedImages(ke,Be,Ye){this.imageRasterizer.removeImagesFromCacheByIds(Be.imageIds,Be.scope,ke),Ye()}enforceCacheSizeLimit(ke,Be){i.fJ(Be)}getWorkerPerformanceMetrics(ke,Be,Ye){Ye(void 0,void 0)}}return i.fF(self)&&(self.worker=new Fo(self)),Fo}),o(["./shared"],function(i){var c="3.17.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},p={mark(T){performance.mark(T)},measure(T,h,y){performance.measure(T,h,y)}};function f(T){const h=T.name.split("?")[0];return i.a(h)&&h.includes("mapbox-gl.js")?"javascript":i.a(h)&&h.includes("mapbox-gl.css")?"css":i.b(h)?"fontRange":i.c(h)?"sprite":i.i(h)?"style":i.d(h)?"tilejson":"other"}var g,b={},_=function(){if(g)return b;function T(A){return!h(A)}function h(A){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var F,z,W=new Blob([""],{type:"text/javascript"}),J=URL.createObjectURL(W);try{z=new Worker(J),F=!0}catch{F=!1}return z&&z.terminate(),URL.revokeObjectURL(J),F}()?function(){var F=document.createElement("canvas");F.width=F.height=1;var z=F.getContext("2d");if(!z)return!1;var W=z.getImageData(0,0,1,1);return W&&W.width===F.width}()?(y[D=A&&A.failIfMajorPerformanceCaveat]===void 0&&(y[D]=function(F){var z,W=function(J){var ne=document.createElement("canvas"),le=Object.create(T.webGLContextAttributes);return le.failIfMajorPerformanceCaveat=J,ne.getContext("webgl2",le)}(F);if(!W)return!1;try{z=W.createShader(W.VERTEX_SHADER)}catch{return!1}return!(!z||W.isContextLost())&&(W.shaderSource(z,"void main() {}"),W.compileShader(z),W.getShaderParameter(z,W.COMPILE_STATUS)===!0)}(D)),y[D]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var D}g=1,b.supported=T,b.notSupportedReason=h;var y={};return T.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},b}();function j(T,h,y){const A=document.createElement(T);return h!=null&&(A.className=h),y&&y.appendChild(A),A}function w(T,h,y){const A=document.createElementNS("http://www.w3.org/2000/svg",T);for(const D of Object.keys(h))A.setAttributeNS(null,D,String(h[D]));return y&&y.appendChild(A),A}const N=typeof document<"u"?document.documentElement&&document.documentElement.style:null,S=N&&N.userSelect!==void 0?"userSelect":"WebkitUserSelect";let M;function L(){N&&S&&(M=N[S],N[S]="none")}function I(){N&&S&&(N[S]=M)}function O(T){T.preventDefault(),T.stopPropagation(),window.removeEventListener("click",O,!0)}function q(){window.addEventListener("click",O,!0),window.setTimeout(()=>{window.removeEventListener("click",O,!0)},0)}function U(T,h){const y=T.getBoundingClientRect();return Y(T,y,h)}function B(T,h){const y=T.getBoundingClientRect(),A=[];for(let D=0;Dthis._skuTokenExpiresAt}transformRequest(h,y){return this._transformRequestFn&&this._transformRequestFn(h,y)||{url:h}}normalizeStyleURL(h,y){if(!i.h(h))return h;const A=re(h);return A.params.push(`sdk=js-${c}`),A.path=`/styles/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||y)}normalizeGlyphsURL(h,y){if(!i.h(h))return h;const A=re(h);return A.path=`/fonts/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||y)}normalizeModelURL(h,y){if(!i.h(h))return h;const A=re(h);return A.path=`/models/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||y)}normalizeSourceURL(h,y,A,D){if(!i.h(h))return h;const F=re(h);return F.path=`/v4/${F.authority}.json`,F.params.push("secure"),A&&F.params.push(`language=${A}`),D&&F.params.push(`worldview=${D}`),this._makeAPIURL(F,this._customAccessToken||y)}normalizeIconsetURL(h,y){const A=re(h);return i.h(h)?(A.path=`/styles/v1${A.path}/iconset.pbf`,this._makeAPIURL(A,this._customAccessToken||y)):oe(A)}normalizeSpriteURL(h,y,A,D){const F=re(h);return i.h(h)?(F.path=`/styles/v1${F.path}/sprite${y}${A}`,this._makeAPIURL(F,this._customAccessToken||D)):(F.path+=`${y}${A}`,oe(F))}normalizeTileURL(h,y,A){if(this._isSkuTokenExpired()&&this._createSkuToken(),h&&!i.h(h))return h;const D=re(h);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${y||A&&D.authority!=="raster"&&A===512?"@2x":""}${i.k.supported?".webp":"$1"}`),D.authority==="raster"?D.path=`/${i.e.RASTER_URL_PREFIX}${D.path}`:D.authority==="rasterarrays"?D.path=`/${i.e.RASTERARRAYS_URL_PREFIX}${D.path}`:D.authority==="3dtiles"?D.path=`/${i.e.TILES3D_URL_PREFIX}${D.path}`:(D.path=D.path.replace(/^.+\/v4\//,"/"),D.path=`/${i.e.TILE_URL_VERSION}${D.path}`);const F=this._customAccessToken||function(z){for(const W of z){const J=W.match(/^access_token=(.*)$/);if(J)return J[1]}return null}(D.params)||i.e.ACCESS_TOKEN;return i.e.REQUIRE_ACCESS_TOKEN&&F&&this._skuToken&&D.params.push(`sku=${this._skuToken}`),this._makeAPIURL(D,F)}canonicalizeTileURL(h,y){const A=re(h);if(!A.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!A.path.match(/\.[\w]+$/))return h;let D="mapbox://";A.path.match(/^\/raster\/v1\//)?D+=`raster/${A.path.replace(`/${i.e.RASTER_URL_PREFIX}/`,"")}`:A.path.match(/^\/rasterarrays\/v1\//)?D+=`rasterarrays/${A.path.replace(`/${i.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:D+=`tiles/${A.path.replace(`/${i.e.TILE_URL_VERSION}/`,"")}`;let F=A.params;return y&&(F=F.filter(z=>!z.match(/^access_token=/))),F.length&&(D+=`?${F.join("&")}`),D}canonicalizeTileset(h,y){const A=!!y&&i.h(y),D=[];for(const F of h.tiles||[])i.j(F)?D.push(this.canonicalizeTileURL(F,A)):D.push(F);return D}_makeAPIURL(h,y){const A="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=re(i.e.API_URL);if(h.protocol=D.protocol,h.authority=D.authority,h.protocol==="http"){const F=h.params.indexOf("secure");F>=0&&h.params.splice(F,1)}if(D.path!=="/"&&(h.path=`${D.path}${h.path}`),!i.e.REQUIRE_ACCESS_TOKEN)return oe(h);if(y=y||i.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!y)throw new Error(`An API access token is required to use Mapbox GL. ${A}`);if(y[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${A}`)}return h.params=h.params.filter(F=>F.indexOf("access_token")===-1),h.params.push(`access_token=${y||""}`),oe(h)}}const ie=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function re(T){const h=T.match(ie);if(!h)throw new Error("Unable to parse URL object");return{protocol:h[1],authority:h[2],path:h[3]||"/",params:h[4]?h[4].split("&"):[]}}function oe(T){const h=T.params.length?`?${T.params.join("&")}`:"";return`${T.protocol}://${T.authority}${T.path}${h}`}const ce="mapbox.eventData";function ge(T){if(!T)return null;const h=T.split(".");if(!h||h.length!==3)return null;try{return JSON.parse(i.l(h[1]))}catch{return null}}class ye{constructor(h){this.type=h,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(h){const y=ge(i.e.ACCESS_TOKEN);let A="";return A=y&&y.u?i.f(y.u):i.e.ACCESS_TOKEN||"",h?`${ce}.${h}:${A}`:`${ce}:${A}`}fetchEventData(){const h=i.s("localStorage"),y=this.getStorageKey(),A=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(h)try{const F=localStorage.getItem(y);F&&(this.eventData=JSON.parse(F));const z=localStorage.getItem(A);z&&(this.anonId=z);const W=localStorage.getItem(D);W&&(this.anonIdTimestamp=Number(W));const J=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(y,JSON.stringify(this.eventData)),z&&localStorage.setItem(D,z.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(h){}postEvent(h,y,A,D){if(!i.e.EVENTS_URL)return;const F=re(i.e.EVENTS_URL);F.params.push(`access_token=${D||i.e.ACCESS_TOKEN||""}`);const z={event:this.type,created:new Date(h).toISOString()},W=y?Object.assign(z,y):z,J={url:oe(F),headers:{"Content-Type":"text/plain"},body:JSON.stringify([W])};this.pendingRequest=i.p(J,ne=>{this.pendingRequest=null,A(ne),this.saveEventData(),this.processRequests(D)})}queueRequest(h,y){this.queue.push(h),this.processRequests(y)}}class ue extends ye{constructor(h){super("metrics"),h&&(this.data=h)}postMetricsEvent(h){if(!i.e.EVENTS_URL||!h&&!i.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID();const y=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:y},h)}processRequests(h){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:y,payload:A}=this.queue.shift();this.postEvent(y,A,()=>{},h)}}const pe=new class extends ye{constructor(T){super("appUserTurnstile"),this._customAccessToken=T}postTurnstileEvent(T,h){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(T)&&T.some(y=>i.h(y)||i.j(y))&&this.queueRequest(Date.now(),h)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const h=ge(i.e.ACCESS_TOKEN),y=h?h.u:i.e.ACCESS_TOKEN;let A=y!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),A=!0);const D=this.queue.shift();if(this.eventData.lastSuccess){const F=new Date(this.eventData.lastSuccess),z=new Date(D),W=(D-this.eventData.lastSuccess)/864e5;A=A||W>=1||W<-1||F.getDate()!==z.getDate()}else A=!0;A?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:Q,"enabled.telemetry":!1,userId:this.anonId},F=>{F||(this.eventData.lastSuccess=D,this.eventData.tokenU=y)},T):this.processRequests()}},_e=pe.postTurnstileEvent.bind(pe),$e=new class extends ye{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(T,h,y,A){this.skuToken=h,this.errorCb=A,i.e.EVENTS_URL&&(y||i.e.ACCESS_TOKEN?this.queueRequest({id:T,timestamp:Date.now()},y):this.errorCb(new Error(ee)))}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:y}=this.queue.shift();h&&this.success[h]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(y,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:Q,skuToken:this.skuToken,userId:this.anonId},A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},T))}remove(){this.errorCb=null}},Ae=$e.postMapLoadEvent.bind($e),Ie=new class extends ye{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(T){let h=this.mapInstanceIdMap.get(T);return h||(h=i.u(),this.mapInstanceIdMap.set(T,h)),h}getEventId(T){const h=this.eventIdPerMapInstanceMap.get(T)||0;return this.eventIdPerMapInstanceMap.set(T,h+1),h}postStyleLoadEvent(T,h){const{map:y,style:A,importedStyles:D}=h;if(!i.e.EVENTS_URL||!T&&!i.e.ACCESS_TOKEN)return;const F=this.getMapInstanceId(y),z={mapInstanceId:F,eventId:this.getEventId(F),style:A};D.length&&(z.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:z},T)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,payload:y}=this.queue.shift();this.postEvent(h,y,()=>{},T)}},Ce=Ie.postStyleLoadEvent.bind(Ie),xe=new ue({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),we=xe.postMetricsEvent.bind(xe),Le=new ue({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),tt=Le.postMetricsEvent.bind(Le),Te=new class extends ye{constructor(){super("gljs.performance")}postPerformanceEvent(T,h){i.e.EVENTS_URL&&(T||i.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:h},T)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,performanceData:y}=this.queue.shift(),A=function(D){const F=performance.getEntriesByType("resource"),z=performance.getEntriesByType("mark"),W=function(Ne){const De={};if(Ne){for(const Pe in Ne)if(Pe!=="other")for(const Ge of Ne[Pe]){const Ve=`${Pe}ResolveRangeMin`,nt=`${Pe}ResolveRangeMax`,ut=`${Pe}RequestCount`,ot=`${Pe}RequestCachedCount`;De[Ve]=Math.min(De[Ve]||1/0,Ge.startTime),De[nt]=Math.max(De[nt]||-1/0,Ge.responseEnd);const Et=Nt=>{De[Nt]===void 0&&(De[Nt]=0),++De[Nt]};Ge.transferSize!==void 0&&Ge.transferSize===0&&Et(ot),Et(ut)}}return De}(function(Ne,De){const Pe={};if(Ne)for(const Ge of Ne){const Ve=De(Ge);Pe[Ve]===void 0&&(Pe[Ve]=[]),Pe[Ve].push(Ge)}return Pe}(F,f)),J=window.devicePixelRatio,ne=navigator.connection||navigator.mozConnection||navigator.webkitConnection,le=ne?ne.effectiveType:void 0,je={counters:[],metadata:[],attributes:[]},ve=(Ne,De,Pe)=>{Pe!=null&&Ne.push({name:De,value:Pe.toString()})};for(const Ne in W)ve(je.counters,Ne,W[Ne]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(ve(je.counters,"interactionRangeMin",D.interactionRange[0]),ve(je.counters,"interactionRangeMax",D.interactionRange[1])),z)for(const Ne of Object.values(u)){const De=z.find(Pe=>Pe.name===Ne);De&&ve(je.counters,Ne,De.startTime)}return ve(je.counters,"visibilityHidden",D.visibilityHidden),ve(je.attributes,"style",function(Ne){if(Ne)for(const De of Ne){const Pe=De.name.split("?")[0];if(i.i(Pe)){const Ge=Pe.split("/").slice(-2);if(Ge.length===2)return`mapbox://styles/${Ge[0]}/${Ge[1]}`}}}(F)),ve(je.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),ve(je.attributes,"fogEnabled",D.fogEnabled?"true":"false"),ve(je.attributes,"projection",D.projection),ve(je.attributes,"zoom",D.zoom),ve(je.metadata,"devicePixelRatio",J),ve(je.metadata,"connectionEffectiveType",le),ve(je.metadata,"navigatorUserAgent",navigator.userAgent),ve(je.metadata,"screenWidth",window.screen.width),ve(je.metadata,"screenHeight",window.screen.height),ve(je.metadata,"windowWidth",window.innerWidth),ve(je.metadata,"windowHeight",window.innerHeight),ve(je.metadata,"mapWidth",D.width/J),ve(je.metadata,"mapHeight",D.height/J),ve(je.metadata,"webglRenderer",D.renderer),ve(je.metadata,"webglVendor",D.vendor),ve(je.metadata,"sdkVersion",c),ve(je.metadata,"sdkIdentifier","mapbox-gl-js"),je}(y);for(const D of A.metadata);for(const D of A.counters);for(const D of A.attributes);this.postEvent(h,A,()=>{},T)}},pt=Te.postPerformanceEvent.bind(Te),fe=new class extends ye{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(T,h,y,A){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const D=re(i.e.API_URL+i.e.SESSION_PATH);D.params.push(`sku=${h||""}`),D.params.push(`access_token=${A||i.e.ACCESS_TOKEN||""}`);const F={url:oe(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(F,z=>{this.pendingRequest=null,y(z),this.saveEventData(),this.processRequests(A)})}getSessionAPI(T,h,y,A){this.skuToken=h,this.errorCb=A,i.e.SESSION_PATH&&i.e.API_URL&&(y||i.e.ACCESS_TOKEN?this.queueRequest({id:T,timestamp:Date.now()},y):this.errorCb(new Error(ee)))}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:y}=this.queue.shift();h&&this.success[h]||this.getSession(y,this.skuToken,A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},T)}remove(){this.errorCb=null}},qe=fe.getSessionAPI.bind(fe),at=new Set;function et(T,h){h?at.add(T):at.delete(T)}class Me{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(h,y){this._updatedSourceCaches[h]=y,this.setDirty()}discardSourceCacheUpdate(h){delete this._updatedSourceCaches[h]}updateLayer(h){const y=h.scope;this._updatedLayers[y]=this._updatedLayers[y]||new Set,this._updatedLayers[y].add(h.id),this.setDirty()}removeLayer(h){const y=h.scope;this._removedLayers[y]=this._removedLayers[y]||{},this._updatedLayers[y]=this._updatedLayers[y]||new Set,this._removedLayers[y][h.id]=h,this._updatedLayers[y].delete(h.id),this._updatedPaintProps.delete(h.fqid),this.setDirty()}getRemovedLayer(h){return this._removedLayers[h.scope]?this._removedLayers[h.scope][h.id]:null}discardLayerRemoval(h){this._removedLayers[h.scope]&&delete this._removedLayers[h.scope][h.id]}getLayerUpdatesByScope(){const h={};for(const y in this._updatedLayers)h[y]=h[y]||{},h[y].updatedIds=Array.from(this._updatedLayers[y].values());for(const y in this._removedLayers)h[y]=h[y]||{},h[y].removedIds=Object.keys(this._removedLayers[y]);return h}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(h){this._updatedPaintProps.add(h.fqid),this.setDirty()}getUpdatedImages(h){return this._updatedImages[h]?Array.from(this._updatedImages[h].values()):[]}updateImage(h,y){this._updatedImages[y]=this._updatedImages[y]||new Set,this._updatedImages[y].add(i.I.toString(h)),this.setDirty()}resetUpdatedImages(h){this._updatedImages[h]&&this._updatedImages[h].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function rt(T){const{userImage:h}=T;return!!(h&&h.render&&h.render())&&(T.data.replace(new Uint8Array(h.data.buffer)),!0)}class He extends i.E{constructor(h){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.dirty=!0,this.spriteFormat=h,h!=="raster"&&i.r()&&(this.imageRasterizerDispatcher=new i.D(i.t(),this,"Image Rasterizer Worker",1))}addScope(h){this.loaded.set(h,!1),this.imageProviders.set(h,new Map),this.images.set(h,new Map),this.updatedImages.set(h,new Set),this.callbackDispatchedThisFrame.set(h,new Set),this.patterns.set(h,new Map),this.atlasImage.set(h,new i.q({width:1,height:1}))}removeScope(h){this.loaded.delete(h),this.imageProviders.delete(h),this.images.delete(h),this.updatedImages.delete(h),this.callbackDispatchedThisFrame.delete(h),this.patterns.delete(h),this.atlasImage.delete(h);const y=this.atlasTexture.get(h);y&&(y.destroy(),this.atlasTexture.delete(h))}addImageProvider(h,y){this.imageProviders.has(y)||this.imageProviders.set(y,new Map),this.imageProviders.get(y).set(h.id,h)}removeImageProvider(h,y){this.imageProviders.has(y)&&this.imageProviders.get(y).delete(h)}getPendingImageProviders(){const h=[];for(const y of this.imageProviders.values())for(const A of y.values())A.hasPendingRequests()&&h.push(A);return h}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new i.x),this._imageRasterizer}isLoaded(){for(const h of this.loaded.keys())if(!this.loaded.get(h))return!1;return!0}setLoaded(h,y){if(this.loaded.get(y)!==h&&(this.loaded.set(y,h),h)){for(const{ids:A,callback:D}of this.requestors)this._notify(A,y,D);this.requestors=[]}}hasImage(h,y){return!!this.getImage(h,y)}getImage(h,y){return this.images.get(y).get(h.toString())}addImage(h,y,A){this._validate(h,A)&&this.images.get(y).set(h.toString(),A)}_validate(h,y){let A=!0;return this._validateStretch(y.stretchX,y.data&&y.data.width)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchX" value`))),A=!1),this._validateStretch(y.stretchY,y.data&&y.data.height)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchY" value`))),A=!1),this._validateContent(y.content,y)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "content" value`))),A=!1),A}_validateStretch(h,y){if(!h)return!0;let A=0;for(const D of h){if(D[0]i.I.from(y))}getImages(h,y,A){const D=[],F=[],z=this.imageProviders.get(y);for(const le of h){if(!le.iconsetId){D.push(le);continue}const je=z.get(le.iconsetId);je&&(this.getImage(le,y)?F.push(le):je.addPendingRequest(le))}if(D.length===0)return void this._notify(F,y,A);let W=!0;const J=!!this.loaded.get(y),ne=this.images.get(y);if(!J)for(const le of D)ne.has(le.toString())||(W=!1);J||W?this._notify(D,y,A):this.requestors.push({ids:D,scope:y,callback:A})}rasterizeImages(h,y){const A=new Map,{tasks:D,scope:F}=h;for(const[z,W]of D.entries()){const J=this.getImage(W.id,F);J&&A.set(z,{image:J,imageVariant:W})}this._rasterizeImages(F,A,y)}_rasterizeImages(h,y,A){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:y,scope:h},A);else{const D=new Map;for(const[F,{image:z,imageVariant:W}]of y.entries())D.set(F,this.imageRasterizer.rasterize(W,z,h,0));A(void 0,D)}}getUpdatedImages(h){return this.updatedImages.get(h)||new Set}_notify(h,y,A){const D=this.images.get(y),F=new Map;for(const z of h){if(!D.get(z.toString())){if(z.iconsetId)continue;this.fire(new i.z("styleimagemissing",{id:z.name}))}const W=D.get(z.toString());if(!W){i.w(`Image "${z.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const J={data:W.usvg?null:W.data.clone(),pixelRatio:W.pixelRatio,sdf:W.sdf,usvg:W.usvg,version:W.version,stretchX:W.stretchX,stretchY:W.stretchY,content:W.content,hasRenderCallback:!!(W.userImage&&W.userImage.render)};W.usvg&&Object.assign(J,{width:W.icon.usvg_tree.width,height:W.icon.usvg_tree.height}),F.set(i.I.toString(z),J)}A(null,F)}getPixelSize(h){const{width:y,height:A}=this.atlasImage.get(h);return{width:y,height:A}}getPattern(h,y,A){const D=h.toString(),F=this.patterns.get(y),z=F.get(D),W=this.getImage(h,y);if(!W)return null;if(z){if(z.position.version===W.version)return z.position;z.position.version=W.version}else{if(W.usvg&&!W.data){const J=this.getPatternInFlightId(D,y);if(this.patternsInFlight.has(J))return null;this.patternsInFlight.add(J);const ne=new i.A(h).scaleSelf(i.o.devicePixelRatio),le=new Map([[ne.toString(),{image:W,imageVariant:ne}]]);return this._rasterizeImages(y,le,(je,ve)=>this.storePatternImage(ne,y,W,A,ve)),null}this.storePattern(h,y,W)}return this._updatePatternAtlas(y,A),F.get(D).position}getPatternInFlightId(h,y){return i.B(h,y)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(h,y,A,D,F){const z=h.toString(),W=F?F.get(z):void 0;W&&(A.data=W,this.storePattern(h.id,y,A),this._updatePatternAtlas(y,D),this.patternsInFlight.delete(this.getPatternInFlightId(h.id.toString(),y)))}storePattern(h,y,A){const D={w:A.data.width+2*i.C,h:A.data.height+2*i.C,x:0,y:0},F=new i.F(D,A,i.C);this.patterns.get(y).set(h.toString(),{bin:D,position:F})}destroyAtlasTextures(){for(const h of this.atlasTexture.values())h&&h.destroy();this.atlasTexture.clear()}bind(h,y){const A=h.gl;let D=this.atlasTexture.get(y);D?this.dirty&&(D.update(this.atlasImage.get(y)),this.dirty=!1):(D=new i.T(h,this.atlasImage.get(y),A.RGBA8),this.atlasTexture.set(y,D)),D.bind(A.LINEAR,A.CLAMP_TO_EDGE)}_updatePatternAtlas(h,y){const A=this.patterns.get(h),D=Array.from(A.values()).map(({bin:ne})=>ne),{w:F,h:z}=i.G(D),W=this.atlasImage.get(h);W.resize({width:F||1,height:z||1});const J=this.images.get(h);for(const[ne,{bin:le,position:je}]of A.entries()){let ve=je.padding;const Ne=le.x+ve,De=le.y+ve,Pe=J.get(ne).data,Ge=Pe.width,Ve=Pe.height;ve=ve>1?ve-1:ve,i.q.copy(Pe,W,{x:0,y:0},{x:Ne,y:De},{width:Ge,height:Ve},y),i.q.copy(Pe,W,{x:0,y:Ve-ve},{x:Ne,y:De-ve},{width:Ge,height:ve},y),i.q.copy(Pe,W,{x:0,y:0},{x:Ne,y:De+Ve},{width:Ge,height:ve},y),i.q.copy(Pe,W,{x:Ge-ve,y:0},{x:Ne-ve,y:De},{width:ve,height:Ve},y),i.q.copy(Pe,W,{x:0,y:0},{x:Ne+Ge,y:De},{width:ve,height:Ve},y),i.q.copy(Pe,W,{x:Ge-ve,y:Ve-ve},{x:Ne-ve,y:De-ve},{width:ve,height:ve},y),i.q.copy(Pe,W,{x:0,y:Ve-ve},{x:Ne+Ge,y:De-ve},{width:ve,height:ve},y),i.q.copy(Pe,W,{x:0,y:0},{x:Ne+Ge,y:De+Ve},{width:ve,height:ve},y),i.q.copy(Pe,W,{x:Ge-ve,y:0},{x:Ne-ve,y:De+Ve},{width:ve,height:ve},y)}this.dirty=!0}beginFrame(){for(const h of this.images.keys())this.callbackDispatchedThisFrame.set(h,new Set)}dispatchRenderCallbacks(h,y){const A=this.images.get(y);for(const D of h){if(this.callbackDispatchedThisFrame.get(y).has(D.toString()))continue;this.callbackDispatchedThisFrame.get(y).add(D.toString());const F=A.get(D.toString());rt(F)&&this.updateImage(D,y,F)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function ct(T){const h=T.value,y=T.valueSpec,A=T.style,D=T.styleSpec,F=T.key,z=T.arrayElementValidator||dr;if(!Array.isArray(h))return[new i.V(F,h,`array expected, ${i.K(h)} found`)];if(y.length&&h.length!==y.length)return[new i.V(F,h,`array length ${y.length} expected, length ${h.length} found`)];if(y["min-length"]&&h.lengthD)return[new i.V(h,y,`${y} is greater than the maximum value ${D}`)]}return[]}function Ze(T){const h=T.key,y=T.value;if(!i.H(y))return[new i.V(h,y,`object expected, ${i.K(y)} found`)];const A=T.valueSpec,D=i.J(y.type);let F,z,W,J={};const ne=D!=="categorical"&&y.property===void 0,le=!ne,je=function(Pe){const Ge=Pe.stops;return Array.isArray(Ge)&&Array.isArray(Ge[0])&&i.H(Ge[0][0])}(y),ve=Jr({key:T.key,value:T.value,valueSpec:T.styleSpec.function,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{stops:function(Pe){if(D==="identity")return[new i.V(Pe.key,Pe.value,'identity function may not have a "stops" property')];let Ge=[];const Ve=Pe.value;return Ge=Ge.concat(ct({key:Pe.key,value:Ve,valueSpec:Pe.valueSpec,style:Pe.style,styleSpec:Pe.styleSpec,arrayElementValidator:Ne})),Array.isArray(Ve)&&Ve.length===0&&Ge.push(new i.V(Pe.key,Ve,"array must have at least one stop")),Ge},default:function(Pe){return dr({key:Pe.key,value:Pe.value,valueSpec:A,style:Pe.style,styleSpec:Pe.styleSpec})}}});return D==="identity"&&ne&&ve.push(new i.V(T.key,T.value,'missing required property "property"')),D==="identity"||y.stops||ve.push(new i.V(T.key,T.value,'missing required property "stops"')),D==="exponential"&&A.expression&&!i.M(A)&&ve.push(new i.V(T.key,T.value,"exponential functions not supported")),T.styleSpec.$version>=8&&(le&&!i.N(A)?ve.push(new i.V(T.key,T.value,"property functions not supported")):ne&&!i.O(A)&&ve.push(new i.V(T.key,T.value,"zoom functions not supported"))),D!=="categorical"&&!je||y.property!==void 0||ve.push(new i.V(T.key,T.value,'"property" property is required')),ve;function Ne(Pe){let Ge=[];const Ve=Pe.value,nt=Pe.key;if(!Array.isArray(Ve))return[new i.V(nt,Ve,`array expected, ${i.K(Ve)} found`)];if(Ve.length!==2)return[new i.V(nt,Ve,`array length 2 expected, length ${Ve.length} found`)];if(je){if(!i.H(Ve[0]))return[new i.V(nt,Ve,`object expected, ${i.K(Ve[0])} found`)];const ut=Ve[0];if(ut.zoom===void 0)return[new i.V(nt,Ve,"object stop key must have zoom")];if(ut.value===void 0)return[new i.V(nt,Ve,"object stop key must have value")];const ot=i.J(ut.zoom);if(typeof ot!="number")return[new i.V(nt,ut.zoom,"stop zoom values must be numbers")];if(W&&W>ot)return[new i.V(nt,ut.zoom,"stop zoom values must appear in ascending order")];ot!==W&&(W=ot,z=void 0,J={}),Ge=Ge.concat(Jr({key:`${nt}[0]`,value:Ve[0],valueSpec:{zoom:{}},style:Pe.style,styleSpec:Pe.styleSpec,objectElementValidators:{zoom:Ue,value:De}}))}else Ge=Ge.concat(De({key:`${nt}[0]`,value:Ve[0],style:Pe.style,styleSpec:Pe.styleSpec},Ve));return i.Q(i.S(Ve[1]))?Ge.concat([new i.V(`${nt}[1]`,Ve[1],"expressions are not allowed in function stops.")]):Ge.concat(dr({key:`${nt}[1]`,value:Ve[1],valueSpec:A,style:Pe.style,styleSpec:Pe.styleSpec}))}function De(Pe,Ge){const Ve=i.K(Pe.value),nt=i.J(Pe.value),ut=Pe.value!==null?Pe.value:Ge;if(F){if(Ve!==F)return[new i.V(Pe.key,ut,`${Ve} stop domain type must match previous stop domain type ${F}`)]}else F=Ve;if(Ve!=="number"&&Ve!=="string"&&Ve!=="boolean"&&typeof nt!="number"&&typeof nt!="string"&&typeof nt!="boolean")return[new i.V(Pe.key,ut,"stop domain value must be a number, string, or boolean")];if(Ve!=="number"&&D!=="categorical"){let ot=`number expected, ${Ve} found`;return i.N(A)&&D===void 0&&(ot+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Pe.key,ut,ot)]}return D!=="categorical"||Ve!=="number"||typeof nt=="number"&&isFinite(nt)&&Math.floor(nt)===nt?D!=="categorical"&&Ve==="number"&&typeof nt=="number"&&typeof z=="number"&&z!==void 0&&ntnew i.V(`${T.key}${A.key}`,T.value,A.message));const y=h.value.expression||h.value._styleExpression.expression;if(T.expressionContext==="property"&&T.propertyKey==="text-font"&&!y.outputDefined())return[new i.V(T.key,T.value,`Invalid data expression for "${T.propertyKey}". Output values must be contained as literals within the expression.`)];if(T.expressionContext==="property"&&T.propertyType==="layout"&&!i.Z(y))return[new i.V(T.key,T.value,'"feature-state" data expressions are not supported with layout properties.')];if(T.expressionContext==="filter")return We(y,T);if(T.expressionContext==="appearance")return Je(y,T);if(T.expressionContext&&T.expressionContext.indexOf("cluster")===0){if(!i.X(y,["zoom","feature-state"]))return[new i.V(T.key,T.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(T.expressionContext==="cluster-initial"&&!i.Y(y))return[new i.V(T.key,T.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function We(T,h){const y=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)y.delete(D);if(y.size===0)return[];const A=[];return T instanceof i._&&y.has(T.name)?[new i.V(h.key,h.value,`["${T.name}"] expression is not supported in a filter for a ${h.object.type} layer with id: ${h.object.id}`)]:(T.eachChild(D=>{A.push(...We(D,h))}),A)}function Je(T,h){const y=new Set;if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)y.add(D);if(y.size===0)return[];const A=[];return T instanceof i._&&!y.has(T.name)?[new i.V(h.key,h.value,`["${T.name}"] is not an allowed parameter`)]:(T.eachChild(D=>{A.push(...Je(D,h))}),A)}function it(T){const h=T.key,y=T.value,A=T.valueSpec,D=[];return Array.isArray(A.values)?A.values.indexOf(i.J(y))===-1&&D.push(new i.V(h,y,`expected one of [${A.values.join(", ")}], ${JSON.stringify(y)} found`)):Object.keys(A.values).indexOf(i.J(y))===-1&&D.push(new i.V(h,y,`expected one of [${Object.keys(A.values).join(", ")}], ${JSON.stringify(y)} found`)),D}function Dt(T){return i.a2(i.S(T.value))?Qe(Object.assign({},T,{expressionContext:"filter",valueSpec:T.styleSpec[`filter_${T.layerType||"fill"}`]})):Vt(T)}function Vt(T){const h=T.value,y=T.key;if(!Array.isArray(h))return[new i.V(y,h,`array expected, ${i.K(h)} found`)];if(h.length<1)return[new i.V(y,h,"filter array must have at least 1 element")];const A=T.styleSpec;let D=it({key:`${y}[0]`,value:h[0],valueSpec:A.filter_operator});const F=()=>{h.length>=2&&(i.a0(h[1])||D.push(new i.V(`${y}[1]`,h[1],`string expected, ${i.K(h[1])} found`)));for(let z=2;z":case">=":h.length>=2&&i.J(h[1])==="$type"&&D.push(new i.V(y,h,`"$type" cannot be use with operator "${h[0]}"`)),h.length!==3&&D.push(new i.V(y,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"==":case"!=":h.length!==3&&D.push(new i.V(y,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"in":case"!in":F();break;case"any":case"all":case"none":for(let z=1;z{ne in y&&h.push(new i.V(A,y[ne],`"${ne}" is prohibited for ref layers`))}),D.layers.forEach(ne=>{i.J(ne.id)===W&&(J=ne)}),J?J.ref?h.push(new i.V(A,y.ref,"ref cannot reference another ref layer")):z=i.J(J.type):typeof W=="string"&&h.push(new i.V(A,y.ref,`ref layer "${W}" not found`))}else if(z!=="background"&&z!=="sky"&&z!=="slot")if(y.source)if(i.a0(y.source)){const J=D.sources&&D.sources[y.source],ne=J&&i.J(J.type);J?ne==="vector"&&z==="raster"?h.push(new i.V(A,y.source,`layer "${y.id}" requires a raster source`)):ne==="raster"&&z!=="raster"?h.push(new i.V(A,y.source,`layer "${y.id}" requires a vector source`)):ne!=="vector"||y["source-layer"]?ne==="raster-dem"&&z!=="hillshade"?h.push(new i.V(A,y.source,"raster-dem source can only be used with layer type 'hillshade'.")):ne!=="raster-array"||["raster","raster-particle"].includes(z)?z==="line"&&y.paint&&(y.paint["line-gradient"]||y.paint["line-trim-offset"])&&ne==="geojson"&&!J.lineMetrics?h.push(new i.V(A,y,`layer "${y.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):z==="raster-particle"&&ne!=="raster-array"&&h.push(new i.V(A,y.source,`layer "${y.id}" requires a 'raster-array' source.`)):h.push(new i.V(A,y.source,"raster-array source can only be used with layer type 'raster'.")):h.push(new i.V(A,y,`layer "${y.id}" must specify a "source-layer"`)):h.push(new i.V(A,y.source,`source "${y.source}" not found`))}else h.push(new i.V(`${A}.source`,y.source,'"source" must be a string'));else h.push(new i.V(A,y,'missing required property "source"'));return h=h.concat(Jr({key:A,value:y,valueSpec:F.layer,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{"*":()=>[],type:()=>dr({key:`${A}.type`,value:y.type,valueSpec:F.layer.type,style:T.style,styleSpec:T.styleSpec,object:y,objectKey:"type"}),filter:J=>Dt(Object.assign({layerType:z},J)),layout:J=>Jr({layer:y,key:J.key,value:J.value,valueSpec:{},style:J.style,styleSpec:J.styleSpec,objectElementValidators:{"*":ne=>Cs(Object.assign({layerType:z},ne))}}),paint:J=>Jr({layer:y,key:J.key,value:J.value,valueSpec:{},style:J.style,styleSpec:J.styleSpec,objectElementValidators:{"*":ne=>Ts(Object.assign({layerType:z,layer:y},ne))}}),appearances(J){const ne=ct({key:J.key,value:J.value,valueSpec:J.valueSpec,style:J.style,styleSpec:J.styleSpec,arrayElementValidator:ve=>function(Ne){const{key:De,layer:Pe,layerType:Ge}=Ne,Ve=i.J(Ne.value),nt=i.J(Ve.name),ut=i.J(Ve.condition),ot=Jr({key:De,value:Ve,valueSpec:Ne.styleSpec.appearance,style:Ne.style,styleSpec:Ne.styleSpec,objectElementValidators:{condition:Et=>function(Nt){const Tt=[];return Tt.push(...Qe({key:Nt.key,value:Nt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),Tt}(Object.assign({layer:Pe,layerType:Ge},Et)),properties:Et=>function(Nt){const Tt=[],{styleSpec:wt,layer:yt,layerType:Ot}=Nt,Wt=wt[`paint_${Ot}`],Ht=wt[`layout_${Ot}`],es=Nt.object[Nt.objectKey];for(const ts in es){const xs=ts in Wt?"paint":ts in Ht?"layout":void 0;if(!xs){Tt.push(new i.V(Nt.key,ts,`unknown property "${ts}" for layer type "${Ot}"`));continue}const qs=Object.assign({},Nt,{key:`${Nt.key}.${ts}`,object:es,objectKey:ts,layer:yt,layerType:Ot,value:es[ts],valueSpec:xs==="paint"?Wt[ts]:Ht[ts]});Tt.push(...hs(qs,xs))}return Tt}(Object.assign({layer:Pe,layerType:Ge},Et))}});return nt!=="hidden"&&ut===void 0&&ot.push(new i.V(Ne.key,"name",'Appearance with name different than "hidden" must have a condition')),ot}(Object.assign({layerType:z,layer:y},ve))}),le=Array.isArray(J.value)?J.value:[],je=new Set;return le.forEach((ve,Ne)=>{const De=i.J(ve.name);if(De)if(je.has(De)){const Pe=i.J(y.id);ne.push(new i.V(J.key,De,`Duplicated appearance name "${De}" for layer "${Pe}"`))}else je.add(De)}),ne}}})),h}function er({key:T,value:h}){return i.a0(h)?[]:[new i.V(T,h,`string expected, ${i.K(h)} found`)]}const xt={promoteId:function T({key:h,value:y}){if(i.a0(y))return er({key:h,value:y});if(Array.isArray(y)){const D=[],F=i.S(y),z=i.U(F);return z.result==="error"&&z.value.forEach(W=>{D.push(new i.V(`${h}${W.key}`,null,`${W.message}`))}),i.X(z.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||D.push(new i.V(`${h}`,null,"promoteId expression should be only feature dependent")),D}if(!i.H(y))return[new i.V(h,y,`string, expression or object expected, "${i.K(y)}" found`)];const A=[];for(const D in y)A.push(...T({key:`${h}.${D}`,value:y[D]}));return A}};function Es(T){const h=T.value,y=T.key,A=T.styleSpec,D=T.style;if(!i.H(h))return[new i.V(y,h,`object expected, ${i.K(h)} found`)];if(!("type"in h))return[new i.V(y,h,'"type" is required')];const F=i.J(h.type);let z=[];switch(["vector","raster","raster-dem","raster-array"].includes(F)&&("url"in h||"tiles"in h||z.push(new i.a3(y,h,'Either "url" or "tiles" is required.'))),F){case"vector":case"raster":case"raster-dem":case"raster-array":return z=z.concat(Jr({key:y,value:h,valueSpec:A[`source_${F.replace("-","_")}`],style:T.style,styleSpec:A,objectElementValidators:xt})),z;case"geojson":if(z=Jr({key:y,value:h,valueSpec:A.source_geojson,style:D,styleSpec:A,objectElementValidators:xt}),"cluster"in h&&"clusterProperties"in h){if(!i.H(h.clusterProperties))return[new i.V(`${y}.clusterProperties`,h,`object expected, ${i.K(h)} found`)];for(const W in h.clusterProperties){const J=h.clusterProperties[W];if(!Array.isArray(J))return[new i.V(`${y}.clusterProperties.${W}`,J,"array expected")];const[ne,le]=J,je=typeof ne=="string"?[ne,["accumulated"],["get",W]]:ne;z.push(...Qe({key:`${y}.${W}.map`,value:le,expressionContext:"cluster-map"})),z.push(...Qe({key:`${y}.${W}.reduce`,value:je,expressionContext:"cluster-reduce"}))}}return z;case"video":return Jr({key:y,value:h,valueSpec:A.source_video,style:D,styleSpec:A});case"image":return Jr({key:y,value:h,valueSpec:A.source_image,style:D,styleSpec:A});case"canvas":return[new i.V(y,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return it({key:`${y}.type`,value:h.type,valueSpec:{values:ur(A)}})}}function ur(T){return T.source.reduce((h,y)=>{const A=T[y];return A.type.type==="enum"&&(h=h.concat(Object.keys(A.type.values||{}))),h},[])}function Mr(T){const h=T.value,y=T.styleSpec,A=y.light,D=T.style;if(h===void 0)return[];if(!i.H(h))return[new i.V("light",h,`object expected, ${i.K(h)} found`)];let F=[];for(const z in h){const W=z.match(/^(.*)-transition$/),J=z.match(/^(.*)-use-theme$/);F=F.concat(J&&A[J[1]]?dr({key:z,value:h[z],valueSpec:{type:"string"},style:D,styleSpec:y}):W&&A[W[1]]&&A[W[1]].transition?dr({key:z,value:h[z],valueSpec:y.transition,style:D,styleSpec:y}):A[z]?dr({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:y}):[new i.V(z,h[z],`unknown property "${z}"`)])}return F}function Lr(T){const h=T.value;if(!h)return[];const y=T.key;if(!i.H(h))return[new i.V(y,h,`object expected, ${i.K(h)} found`)];let A=[];const D=T.styleSpec,F=D["light-3d"],z=T.style,W=T.style.lights;for(const le of["type","id"])if(!(le in h))return A=A.concat([new i.V(y,h,`missing property "${le}"`)]),A;if(!i.a0(h.type))return A=A.concat([new i.V(`${y}.type`,h.type,"string expected")]),A;if(W)for(let le=0;le[],array:ct,boolean:function(T){const h=T.value,y=T.key;return i.$(h)?[]:[new i.V(y,h,`boolean expected, ${i.K(h)} found`)]},number:Ue,color:function({key:T,value:h}){return i.a0(h)?i.a1.parseCSSColor(h)===null?[new i.V(T,h,`color expected, "${h}" found`)]:[]:[new i.V(T,h,`color expected, ${i.K(h)} found`)]},enum:it,filter:Dt,function:Ze,layer:cs,object:Jr,source:Es,model:i.a7,light:Mr,"light-3d":Lr,terrain:fn,fog:ki,string:er,formatted:function(T){return er(T).length===0?[]:Qe(T)},resolvedImage:function(T){return er(T).length===0?[]:Qe(T)},projection:function(T){const h=T.value,y=T.styleSpec,A=y.projection,D=T.style;if(i.H(h)){let F=[];for(const z in h)F=F.concat(dr({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:y}));return F}return i.a0(h)?[]:[new i.V("projection",h,`object or string expected, ${i.K(h)} found`)]},import:function(T){const h=T.key,{value:y,styleSpec:A}=T;if(!i.H(y))return[new i.V(h,y,"import must be an object")];const{data:D,...F}=y;Object.defineProperty(F,"__line__",{value:y.__line__,enumerable:!1});let z=Jr(Object.assign({},T,{value:F,valueSpec:A.import}));return i.J(F.id)===""&&z.push(new i.V(`${T.key}.id`,F,"import id can't be an empty string")),D&&(z=z.concat(dn(D,A,{key:`${T.key}.data`}))),z},iconset:function(T){const h=T.value,y=T.key,A=T.styleSpec,D=T.style;if(!i.H(h))return[new i.V(y,h,"object expected")];if(!h.type)return[new i.V(y,h,'"type" is required')];const F=i.J(h.type);let z=[];if(z=z.concat(Jr({key:y,value:h,valueSpec:A[`iconset_${F}`],style:D,styleSpec:A})),function(W,J){return!(W!=="source"||!J.source)}(F,h)){const W=D.sources&&D.sources[h.source],J=W&&i.J(W.type);W?J!=="raster-array"&&z.push(new i.V(y,h.source,`iconset cannot be used with a source of type ${String(J)}, it only be used with a "raster-array" source type`)):z.push(new i.V(y,h.source,`source "${h.source}" not found`))}return z}};function dr(T,h=!1){const y=T.value,A=T.valueSpec,D=T.styleSpec;if(A.expression){if(i.a4(i.J(y)))return Ze(T);if(i.Q(i.S(y)))return Qe(T)}if(A.type&&Ea[A.type]){const F=Ea[A.type](T);return h===!0&&F.length>0&&Array.isArray(T.value)?Qe(T):F}return Jr(Object.assign({},T,{valueSpec:A.type?D[A.type]:A}))}function Jr(T){const h=T.key,y=T.value,A=T.valueSpec||{},D=T.objectElementValidators||{},F=T.style,z=T.styleSpec;if(!i.H(y))return[new i.V(h,y,`object expected, ${i.K(y)} found`)];let W=[];for(const J in y){const ne=J.split(".")[0];let le;D[ne]?le=D[ne]:A[ne]?le=dr:D["*"]?le=D["*"]:A["*"]&&(le=dr),le?W=W.concat(le({key:(h&&`${h}.`)+J,value:y[J],valueSpec:A[ne]||A["*"],style:F,styleSpec:z,object:y,objectKey:J},y)):W.push(new i.a3(h,y[J],`unknown property "${J}"`))}for(const J in A){if(D[J])continue;const ne=A[J];ne.required&&ne.default===void 0&&y[J]===void 0&&W.push(new i.V(h,y,`missing required property "${J}"`))}return W}function Wr({key:T,value:h}){const y=er({key:T,value:h});if(y.length)return y;const A=h;return A.indexOf("{fontstack}")===-1&&y.push(new i.V(T,h,'"glyphs" url must include a "{fontstack}" token')),A.indexOf("{range}")===-1&&y.push(new i.V(T,h,'"glyphs" url must include a "{range}" token')),y}function dn(T,h=i.a6,y={}){return Jr({key:y.key||"",value:T,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:T,objectElementValidators:{glyphs:Wr}})}function Yr(T,h=i.a6){return Be(dn(T,h))}const vi=T=>Be(Es(T)),ft=T=>Be(Mr(T)),ir=T=>Be(Lr(T)),Vn=T=>Be(fn(T)),Sr=T=>Be(ki(T)),jr=T=>Be(function(h){const y=h.value,A=h.style,D=h.styleSpec,F=D.snow;if(y===void 0)return[];if(!i.H(y))return[new i.V("snow",y,`object expected, ${i.K(y)} found`)];let z=[];for(const W in y){const J=W.match(/^(.*)-transition$/);z=z.concat(J&&F[J[1]]&&F[J[1]].transition?dr({key:W,value:y[W],valueSpec:D.transition,style:A,styleSpec:D}):F[W]?dr({key:W,value:y[W],valueSpec:F[W],style:A,styleSpec:D}):[new i.a3(W,y[W],`unknown property "${W}"`)])}return z}(T)),ea=T=>Be(function(h){const y=h.value,A=h.style,D=h.styleSpec,F=D.rain;if(y===void 0)return[];if(!i.H(y))return[new i.V("rain",y,`object expected, ${i.K(y)} found`)];let z=[];for(const W in y){const J=W.match(/^(.*)-transition$/);z=z.concat(J&&F[J[1]]&&F[J[1]].transition?dr({key:W,value:y[W],valueSpec:D.transition,style:A,styleSpec:D}):F[W]?dr({key:W,value:y[W],valueSpec:F[W],style:A,styleSpec:D}):[new i.a3(W,y[W],`unknown property "${W}"`)])}return z}(T)),Pa=T=>Be(cs(T)),Ii=T=>Be(Dt(T)),Fo=T=>Be(Ts(T)),$t=T=>Be(Cs(T)),ke=T=>Be(i.a7(T));function Be(T){return T.slice().sort((h,y)=>h.line&&y.line?h.line-y.line:0)}function Ye(T,h){let y=!1;if(h&&h.length)for(const A of h)A instanceof i.a3?i.w(A.message):(T.fire(new i.y(new Error(A.message))),y=!0);return y}const bt=i.a6.light;let gt;class Ft extends i.E{constructor(h,y="flat"){super(),this._transitionable=new i.a8(gt||(gt=new i.a9({anchor:new i.aa(bt.anchor),position:new i.ab(bt.position),color:new i.aa(bt.color),intensity:new i.aa(bt.intensity)}))),this.setLight(h,y),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,y,A={}){this._validate(ft,h,A)||(this._transitionable.setTransitionOrValue(h),this.id=y)}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}_validate(h,y,A){return(!A||A.validate!==!1)&&Ye(this,h.call(Yr,Object.assign({value:y,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Zt=i.a6.terrain;let Ut=class extends i.E{constructor(T,h,y,A,D){super(),this.scope=y,this._transitionable=new i.a8(new i.a9({source:new i.aa(Zt.source),exaggeration:new i.aa(Zt.exaggeration)}),y,A),this._transitionable.setTransitionOrValue(T,A),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=h,this.worldview=D}get(){return this._transitionable.serialize()}set(T,h){this._transitionable.setTransitionOrValue(T,h)}updateTransitions(T){this._transitioning=this._transitionable.transitioned(T,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(T){this.properties=this._transitioning.possiblyEvaluate(T)}getExaggeration(T){return this._transitioning.possiblyEvaluate(new i.ac(T,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const T=this._transitionable._values.exaggeration;if(!T)return null;const h=T.value.expression;if(!h)return null;let y=-1,A=-1,D=1;for(const F of h.zoomStops)D=h.evaluate(new i.ac(F,{worldview:this.worldview})),D>.01?(y=F,A=-1):A=F;return D<.01&&y>0&&A>y?[y,A]:null}isZoomDependent(){const T=this._transitionable._values.exaggeration;return T!=null&&T.value!=null&&T.value.expression!=null&&T.value.expression instanceof i.ad}};const Xt=45,Ps=65,gs=.05;function vr(T,h,y,A){const D=i.ah(Xt,Ps,y),[F,z]=Hr(T,A);let W=1-Math.min(1,Math.exp((h-F)/(z-F)*-6));return W*=W*W,W=Math.min(1,1.00747*W),W*D*T.alpha}function Hr(T,h){const y=.5/Math.tan(.5*h);return[T.range[0]+y,T.range[1]+y]}function xr(T,h,y,A,D){const F=i.af([],[h,y,A],D.mercatorFogMatrix);return vr(T,i.ag(F),D.pitch,D._fov)}function Dn(T,h,y,A,D,F,z){const W=[[y,A,0],[D,A,0],[D,F,0],[y,F,0]];let J=Number.MAX_VALUE,ne=-Number.MAX_VALUE;for(const le of W){const je=i.af([],le,h),ve=i.ag(je);J=Math.min(J,ve),ne=Math.max(ne,ve)}return[vr(T,J,z.pitch,z._fov),vr(T,ne,z.pitch,z._fov)]}const On=i.a6.fog;class En extends i.E{constructor(h,y,A,D){super();const F=new i.a9({range:new i.aa(On.range),color:new i.aa(On.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(On["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(On["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(On["horizon-blend"]),"star-intensity":new i.aa(On["star-intensity"]),"vertical-range":new i.aa(On["vertical-range"])});this._transitionable=new i.a8(F,A,new Map(D)),this.set(h,D),this._transitioning=this._transitionable.untransitioned(),this._transform=y,this.properties=new i.ai(F),this.scope=A}get state(){const h=this._transform,y=h.projection.name==="globe",A=i.aj(h.zoom),D=this.properties.get("range"),F=[.5,3];return{range:y?[i.ak(F[0],D[0],A),i.ak(F[1],D[1],A)]:D,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(h,y,A={}){if(this._validate(Sr,h,A))return;const D=Object.assign({},h);for(const F of Object.keys(On))D[F]===void 0&&(D[F]=On[F].default);this._options=D,this._transitionable.setTransitionOrValue(this._options,y)}getOpacity(h){if(!this._transform.projection.supportsFog)return 0;const y=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.ah(Xt,Ps,h))*y.a}getOpacityAtLatLng(h,y){return this._transform.projection.supportsFog?function(A,D,F){const z=i.ae.fromLngLat(D),W=F.elevation?F.elevation.getAtPointOrZero(z):0;return xr(A,z.x,z.y,W,F)}(this.state,h,y):0}getOpacityForTile(h){if(!this._transform.projection.supportsFog)return[1,1];const y=this._transform.calculateFogTileMatrix(h.toUnwrapped());return Dn(this.state,y,0,0,i.al,i.al,this._transform)}getOpacityForBounds(h,y,A,D,F){return this._transform.projection.supportsFog?Dn(this.state,h,y,A,D,F,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?Hr(this.state,h):[0,1]}isVisibleOnFrustum(h){if(!this._transform.projection.supportsFog)return!1;const y=[4,5,6,7];for(const A of y){const D=h.points[A];let F;if(D[2]>=0)F=D;else{const z=h.points[A-4];F=i.am(z,D,z[2]/(z[2]-D[2]))}if(xr(this.state,F[0],F[1],0,this._transform)>=gs)return!0}return!1}updateConfig(h){this._transitionable.setTransitionOrValue(this._options,new Map(h))}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}_validate(h,y,A){return(!A||A.validate!==!1)&&Ye(this,h.call(Yr,Object.assign({value:y,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let _a,vo,il,ti,hl=class extends i.E{constructor(T,h,y,A){super();const D=_a||(_a=new i.a9({density:new i.aa(i.a6.snow.density),intensity:new i.aa(i.a6.snow.intensity),color:new i.aa(i.a6.snow.color),opacity:new i.aa(i.a6.snow.opacity),vignette:new i.aa(i.a6.snow.vignette),"vignette-color":new i.aa(i.a6.snow["vignette-color"]),"center-thinning":new i.aa(i.a6.snow["center-thinning"]),direction:new i.aa(i.a6.snow.direction),"flake-size":new i.aa(i.a6.snow["flake-size"])}));this._transitionable=new i.a8(D,y,new Map(A)),this.set(T,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=y}get state(){const T=this.properties.get("opacity"),h=this.properties.get("color"),y=this.properties.get("direction"),A=i.an(y[0]),D=-Math.max(i.an(y[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette"),W=this.properties.get("vignette-color");return W.a=z,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*T),direction:F,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:W}}get(){return this._transitionable.serialize()}set(T,h,y={}){if(this._validate(jr,T,y))return;const A=Object.assign({},T),D=i.a6.snow;for(const F of Object.keys(D))A[F]===void 0&&(A[F]=D[F].default);this._options=A,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(T){this._transitionable.setTransitionOrValue(this._options,new Map(T))}updateTransitions(T){this._transitioning=this._transitionable.transitioned(T,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(T){this.properties=this._transitioning.possiblyEvaluate(T)}_validate(T,h,y){return(!y||y.validate!==!1)&&Ye(this,T.call(Yr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},oo=class extends i.E{constructor(T,h,y,A){super();const D=vo||(vo=new i.a9({density:new i.aa(i.a6.rain.density),intensity:new i.aa(i.a6.rain.intensity),color:new i.aa(i.a6.rain.color),opacity:new i.aa(i.a6.rain.opacity),vignette:new i.aa(i.a6.rain.vignette),"vignette-color":new i.aa(i.a6.rain["vignette-color"]),"center-thinning":new i.aa(i.a6.rain["center-thinning"]),direction:new i.aa(i.a6.rain.direction),"droplet-size":new i.aa(i.a6.rain["droplet-size"]),"distortion-strength":new i.aa(i.a6.rain["distortion-strength"])}));this._transitionable=new i.a8(D,y,new Map(A)),this.set(T,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=y}get state(){const T=this.properties.get("opacity"),h=this.properties.get("color"),y=this.properties.get("direction"),A=i.an(y[0]),D=-Math.max(i.an(y[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette-color");return z.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*T),direction:F,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:z}}get(){return this._transitionable.serialize()}set(T,h,y={}){if(this._validate(ea,T,y))return;const A=Object.assign({},T),D=i.a6.rain;for(const F of Object.keys(D))A[F]===void 0&&(A[F]=D[F].default);this._options=A,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(T){this._transitionable.setTransitionOrValue(this._options,new Map(T))}updateTransitions(T){this._transitioning=this._transitionable.transitioned(T,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(T){this.properties=this._transitioning.possiblyEvaluate(T)}_validate(T,h,y){return(!y||y.validate!==!1)&&Ye(this,T.call(Yr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class Ia extends i.E{constructor(h,y,A,D){super(),this.scope=A,this._options=h,this.properties=new i.ai(y),this._transitionable=new i.a8(y,A,new Map(D)),this._transitionable.setTransitionOrValue(h.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(h){this._transitionable.setTransitionOrValue(this._options.properties,new Map(h))}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(h,y){this._options=h,this._transitionable.setTransitionOrValue(h.properties,y)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}class lo{constructor(h,y,A){this.screenBounds=h,this.cameraPoint=A.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=y,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,A)}static createFromScreenPoints(h,y){let A,D;if(h instanceof i.P||typeof h[0]=="number"){const F=i.P.convert(h);A=[F],D=y.isPointAboveHorizon(F)}else{const F=i.P.convert(h[0]),z=i.P.convert(h[1]),W=F.add(z)._div(2);A=[F,z],D=i.aq(F,z).every(J=>y.isPointAboveHorizon(J))&&y.isPointAboveHorizon(W)}return new lo(A,D,y)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(h){return i.aq(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],h)}bufferedCameraGeometry(h){const y=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(y,A,0,!1);return this.cameraPoint.y>A.y&&(this.cameraPoint.x>y.x&&this.cameraPoint.x=A.x?D[2]=this.cameraPoint:this.cameraPoint.x<=y.x&&(D[3]=this.cameraPoint)),i.ar(D,h)}bufferedCameraGeometryGlobe(h){const y=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(y,A,h),F=this.cameraPoint.clone();switch(3*((F.y>y.y)+(F.y>A.y))+((F.x>y.x)+(F.x>A.x))){case 0:D[0]=F,D[4]=F.clone();break;case 1:D.splice(1,0,F);break;case 2:D[1]=F;break;case 3:D.splice(4,0,F);break;case 5:D.splice(2,0,F);break;case 6:D[3]=F;break;case 7:D.splice(3,0,F);break;case 8:D[2]=F}return D}containsTile(h,y,A,D=0){const F=Math.max(h.queryPadding,h.evaluateQueryRenderedFeaturePadding())/y._pixelsPerMercatorPixel+1,z=A?this._bufferedCameraMercator(F,y):this._bufferedScreenMercator(F,y);let W=h.tileID.wrap+(z.unwrapped?D:0);const J=z.polygon.map(Ge=>i.as(h.tileTransform,Ge,W));if(!i.at(J,0,0,i.al,i.al))return;W=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ne=this.screenGeometryMercator.polygon.map(Ge=>i.au(h.tileTransform,Ge,W)),le=ne.map(Ge=>new i.P(Ge[0],Ge[1])),je=y.getFreeCameraOptions().position||new i.ae(0,0,0),ve=i.au(h.tileTransform,je,W),Ne=ne.map(Ge=>{const Ve=i.av(Ge,Ge,ve);return i.aw(Ve,Ve),new i.ax(ve,Ve)}),De=i.ay(h,1,y.zoom)*y._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:le,tilespaceRays:Ne,bufferedTilespaceGeometry:J,bufferedTilespaceBounds:(Pe=i.az(J),Pe.min.x=i.aA(Pe.min.x,0,i.al),Pe.min.y=i.aA(Pe.min.y,0,i.al),Pe.max.x=i.aA(Pe.max.x,0,i.al),Pe.max.y=i.aA(Pe.max.y,0,i.al),Pe),tile:h,tileID:h.tileID,pixelToTileUnitsFactor:De};var Pe}_bufferedScreenMercator(h,y){const A=co(h);if(this._screenRaycastCache[A])return this._screenRaycastCache[A];{let D;return D=y.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(h),y):{polygon:this.bufferedScreenGeometry(h).map(F=>y.pointCoordinate3D(F)),unwrapped:!0},this._screenRaycastCache[A]=D,D}}_bufferedCameraMercator(h,y){const A=co(h);if(this._cameraRaycastCache[A])return this._cameraRaycastCache[A];{let D;return D=y.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(h),y):{polygon:this.bufferedCameraGeometry(h).map(F=>y.pointCoordinate3D(F)),unwrapped:!0},this._cameraRaycastCache[A]=D,D}}_projectAndResample(h,y){const A=function(F,z){const W=i.aB([],z.pixelMatrix,z.globeMatrix),J=[0,-i.aD,0,1],ne=[0,i.aD,0,1],le=[0,0,0,1];i.aC(J,J,W),i.aC(ne,ne,W),i.aC(le,le,W);const je=new i.P(J[0]/J[3],J[1]/J[3]),ve=new i.P(ne[0]/ne[3],ne[1]/ne[3]),Ne=i.aE(F,je)&&J[3]1?Ti(F.slice(0,Ge),z):[],ut=Genew i.P(ua(Tt.x),Tt.y)),ut=ut.map(Tt=>new i.P(ua(Tt.x),Tt.y));const ot=[...nt];ot.length===0&&ot.push(ut[ut.length-1]);const Et=i.ak(ot[ot.length-1].y,(ut.length===0?nt[0]:ut[0]).y,Ve);let Nt;return Nt=Ne?[new i.P(0,Et),new i.P(0,0),new i.P(1,0),new i.P(1,Et)]:[new i.P(1,Et),new i.P(1,1),new i.P(0,1),new i.P(0,Et)],ot.push(...Nt),ut.length===0?ot.push(nt[0]):ot.push(...ut),{polygon:ot.map(Tt=>new i.ae(Tt.x,Tt.y)),unwrapped:!1}}(h,y);if(A)return A;const D=function(F,z){let W=!1,J=-1/0,ne=0;for(let je=0;jeJ&&(J=F[je].x,ne=je);for(let je=0;je.5&&(Ne.x{je.x-=1}),{polygon:F,unwrapped:W}}(Ti(h,y).map(F=>new i.P(ua(F.x),F.y)),y);return{polygon:D.polygon.map(F=>new i.ae(F.x,F.y)),unwrapped:D.unwrapped}}}function Ti(T,h){return i.aG(T,y=>{const A=h.pointCoordinate3D(y);y.x=A.x,y.y=A.y},1/256)}function ua(T){return T<0?1+T%1:T%1}function co(T){return 100*T|0}function Mc(T,h,y,A,D){const F=function(W,J){if(W)return D(W);if(J){if(T.url&&J.tiles&&T.tiles&&delete T.tiles,J.variants){if(!Array.isArray(J.variants))return D(new Error("variants must be an array"));for(const le of J.variants){if(le==null||typeof le!="object"||le.constructor!==Object)return D(new Error("variant must be an object"));if(!Array.isArray(le.capabilities))return D(new Error("capabilities must be an array"));if(le.capabilities.length===1&&le.capabilities[0]==="meshopt"){J=Object.assign(J,le);break}}}const ne=i.aH(Object.assign({},J,T),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);ne.tiles=h.canonicalizeTileset(ne,T.url),D(null,ne)}},z=function(W,J,ne){if(!W)return null;if(!J&&!ne)return W;ne=ne||W.worldview_default;const le=Object.values(W.language||{});if(le.length===0)return null;const je=Object.values(W.worldview||{});if(je.length===0)return null;const ve=le.every(De=>De===J),Ne=je.every(De=>De===ne);return ve&&Ne?W:J in(W.language_options||{})||ne in(W.worldview_options||{})?null:W.language_options&&W.worldview_options?W:null}(T.data,y,A);return z?i.o.frame(()=>F(null,z)):T.url?i.m(h.transformRequest(h.normalizeSourceURL(T.url,null,y,A),i.R.Source),F):i.o.frame(()=>{const{data:W,...J}=T;F(null,J)})}function Wc(T,h){const y=Math.pow(2,h.z),A=Math.floor(i.aF(T.getWest())*y),D=Math.floor(i.aJ(T.getNorth())*y),F=Math.ceil(i.aF(T.getEast())*y),z=Math.ceil(i.aJ(T.getSouth())*y);return h.x>=A&&h.x=D&&h.ythis.maxzoom||h.z{if(this._tileJSONRequest=null,this._loaded=!0,D)y&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${y}`),A&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${A}`),this.fire(new i.y(D));else if(F){if(Object.assign(this,F),this.hasWorldviews=!!F.worldview_options,F.worldview_default&&(this.worldviewDefault=F.worldview_default),F.vector_layers){this.vectorLayers=F.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const z of F.vector_layers)this.vectorLayerIds.push(z.id),F.worldview&&F.worldview[z.source]&&this.localizableLayerIds.add(z.id)}this.tileBounds=lu.fromTileJSON(F),_e(F.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}h&&h(D)})}loaded(){return this._loaded}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(h,y){const A=h.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(A),F=this.map._requestManager.transformRequest(D,i.R.Tile),z=this.map.style?this.map.style.getLut(this.scope):null,W=z?{image:z.image.clone()}:null,J={request:F,data:void 0,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,lut:W,tileSize:this.tileSize*h.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:h.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:h.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&i.h(A)&&(J.localizableLayerIds=this.localizableLayerIds),J.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=y:h.request=h.actor.send("reloadTile",J,ne.bind(this));else if(h.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready)h.request=h.actor.send("loadTile",J,ne.bind(this),void 0,!0);else{const le=i.aL.call({deduped:this._deduped},J,(je,ve)=>{if(je||!ve)ne.call(this,je);else{const Ne=i.aM(ve.responseHeaders);J.data={rawData:ve.rawData.slice(0),expires:Ne.expires,cacheControl:Ne.cacheControl},h.actor&&h.actor.send("loadTile",J,ne.bind(this),void 0,!0)}},!0);h.request={cancel:le}}function ne(le,je){return delete h.request,h.aborted?y(null):le&&le instanceof i.aN&&le.status!==404?y(le):(je&&je.resourceTiming&&(h.resourceTiming=je.resourceTiming),this.map._refreshExpiredTiles&&je&&h.setExpiryData(je),h.loadVectorData(je,this.map.painter),i.aO(this.dispatcher),y(null,je),void(h.reloadCallback&&(this.loadTile(h,h.reloadCallback),h.reloadCallback=null)))}}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,y){h.actor&&h.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope}),h.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class zl extends i.E{constructor(h,y,A,D){super(),this.id=h,this.dispatcher=A,this.setEventedParent(D),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},y),Object.assign(this,i.aH(y,["url","scheme","tileSize"]))}load(h){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const y=this.map.getWorldview();this._tileJSONRequest=Mc(this._options,this.map._requestManager,null,y,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?this.fire(new i.y(A)):D&&(Object.assign(this,D),D.raster_layers&&(this.rasterLayers=D.raster_layers,this.rasterLayerIds=this.rasterLayers.map(F=>F.id)),this.tileBounds=lu.fromTileJSON(D),_e(D.tiles),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),h&&h(A)})}loaded(){return this._loaded}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}loadTile(h,y){const A=i.o.devicePixelRatio>=2,D=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),A,this.tileSize);h.request=i.n(this.map._requestManager.transformRequest(D,i.R.Tile),(F,z,W)=>{if(delete h.request,h.aborted)return h.state="unloaded",y(null);if(F)return h.state="errored",y(F);if(!z)return y(null);const J=i.aM(W);this.map._refreshExpiredTiles&&h.setExpiryData(J),h.setTexture(z,this.map.painter),h.state="loaded",i.aO(this.dispatcher),y(null)})}abortTile(h,y){h.request&&(h.request.cancel(),delete h.request),y&&y()}unloadTile(h,y){h.texture&&h.texture instanceof i.T?(h.destroy(!1),h.texture&&h.texture instanceof i.T&&this.map.painter.saveTileTexture(h.texture)):h.destroy(),y&&y()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function ch([T,h],y,A,{scaled:D=!0}={}){const{tileSize:F,buffer:z}=A,{x:W,y:J,z:ne}=y;if(!isFinite(W)||!isFinite(J)||!isFinite(ne))throw new Error("Invalid MRT header");const le=2**ne,je=le*i.aF(T),ve=le*i.aJ(h);return function([Ne,De],Pe,{scaled:Ge=!0}={}){if(!Pe)throw new Error("bandView is undefined");const{data:Ve,tileSize:nt,buffer:ut,offset:ot,scale:Et,dimension:Nt}=Pe;if(Ne<-ut||Ne>nt+ut||De<-ut||De>nt+ut)throw new Error(`Point (${Ne}, ${De}) out of bounds for tileSize=${nt}, buffer=${ut}`);const Tt=(De+ut)*(nt+2*ut)+(Ne+ut);if(new Uint32Array(Ve.buffer)[Tt]===4294967295)return null;let wt=[];wt=Ge?[]:new Pe.data.constructor(Nt);for(let yt=0;yt{if(delete h.request,h.aborted)return h.state="unloaded",y(null);if(W)return W.name==="AbortError"?void 0:(h.state="errored",y(W));if(this.map._refreshExpiredTiles&&J){const le=i.aM(ne);h.setExpiryData(le)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!J)return y(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=J}y(null)};h.request=this.partial?h.fetchHeader(void 0,z.bind(this)):h.actor.send("loadTile",F,z.bind(this),void 0,!0)}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,y){const A=h.texturePerLayer;if(h.flushAllQueues(),A.size){h.destroy(!1);for(const D of A.values())this.map.painter.saveTileTexture(D)}else h.destroy()}prepareTile(h,y,A,D){h._isHeaderLoaded&&(h.state!=="empty"&&(h.state="reloading"),h.fetchBandForRender(y,A,D,(F,z)=>{if(F)return h.state="errored",this.fire(new i.y(F)),void this.triggerRepaint(h);z&&(h._isHeaderLoaded=!0,h.setTexturePerLayer(A,z,this.map.painter),h.state="loaded",this.triggerRepaint(h))}))}getInitialBand(h){if(!this.rasterLayers)return 0;const y=this.rasterLayers.find(({id:F})=>F===h),A=y&&y.fields,D=A&&A.bands&&A.bands;return D?D[0]:0}getTextureDescriptor(h,y,A){if(!h)return;const D=y.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!D)return;let F=null;y instanceof i.aR?F=y.paint.get("raster-array-band"):y instanceof i.aS&&(F=y.paint.get("raster-particle-array-band"));const z=F||this.getInitialBand(D);if(z==null)return;if(!h.textureDescriptorPerLayer.get(y.id))return void this.prepareTile(h,D,y.id,z);if(h.updateNeeded(y.id,z)&&!A)return;const W=h.textureDescriptorPerLayer.get(y.id);return Object.assign({},W,{texture:h.texturePerLayer.get(y.id)})}getImages(h,y){const A=new Map;for(const D of h)for(const F of y){const[z,W]=F.split("/"),J=D.getLayer(z);if(!J||!J.hasBand(W)||!J.hasDataForBand(W))continue;const{bytes:ne,tileSize:le,buffer:je}=J.getBandView(W),ve=le+2*je,Ne={data:new i.q({width:ve,height:ve},ne),pixelRatio:2,sdf:!1,usvg:!1,version:0};A.set(F,Ne)}return A}queryRasterArrayValueByBandId(h,y,A){const D=y._mrt;return new Promise(F=>{const z={},W=new Set;for(const[J,ne]of Object.entries(D.layers)){if(A.layerName&&J!==A.layerName)continue;const le={};z[J]=le;for(const{bands:je}of ne.dataIndex)for(const ve of je)A.bands&&!A.bands.includes(ve)||(W.add(i.B(J,ve)),y.fetchBand(J,null,ve,Ne=>{i.o.frame(()=>{le[ve]=Ne?null:ch([h.lng,h.lat],D,ne.getBandView(ve)),W.delete(i.B(J,ve)),W.size===0&&F(z)})},!1))}W.size===0&&F(z)})}_loadTileForQuery(h,y){if(this._loadTileLoaded[h.uid])return void y(null,h._mrt);if(this._loadTilePending[h.uid])return void this._loadTilePending[h.uid].push(y);this._loadTilePending[h.uid]=[y];const A=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),D=this.map._requestManager.transformRequest(A,i.R.Tile);h.actor.send("loadTile",{request:D,uid:h.uid,tileID:h.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(F,z,W)=>{if(F)return this._loadTilePending[h.uid].forEach(J=>J(F,null)),void delete this._loadTilePending[h.uid];if(!z)return this._loadTilePending[h.uid].forEach(J=>J(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&z){const J=i.aM(W);h.setExpiryData(J)}h._mrt=z,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(J=>J(null,z)),this._loadTileLoaded[h.uid]=!0,delete this._loadTilePending[h.uid]},void 0,!0)}queryRasterArrayValueByAllBands(h,y,A){return new Promise((D,F)=>{this._loadTileForQuery(y,(z,W)=>{z?F(z):D(W?this.queryRasterArrayValueByBandId(h,y,A):null)})})}queryRasterArrayValue(h,y){const A=i.aT.convert(h),D=this.findLoadedParent(A);return D&&D._mrt?y.bands||!this.partial?this.queryRasterArrayValueByBandId(A,D,y):this.queryRasterArrayValueByAllBands(A,D,y):Promise.resolve(null)}findLoadedParent(h){const y=i.ae.fromLngLat(h,this.map.transform.tileSize),A=this.maxzoom+1,D=1<0&&(W[new i.aQ(T.overscaledZ,D,h.z,A,h.y-1).key]={backfilled:!1},W[new i.aQ(T.overscaledZ,T.wrap,h.z,h.x,h.y-1).key]={backfilled:!1},W[new i.aQ(T.overscaledZ,z,h.z,F,h.y-1).key]={backfilled:!1}),h.y+1{if(this._loaded=!0,this._pendingLoad=null,A)this.fire(new i.y(A));else{const F={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&D&&D.resourceTiming&&D.resourceTiming[this.id]&&(F.resourceTiming=D.resourceTiming[this.id]),T&&(this._partialReload=!0),this.fire(new i.z("data",F)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(T),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const T=i.B(this.id,this.scope);this.map.style.clearSource(T),this._updateWorkerData()}loadTile(T,h){const y=T.actor?"reloadTile":"loadTile";T.actor=this.actor;const A=this.map.style?this.map.style.getLut(this.scope):null,D=A?{image:A.image.clone()}:null,F=this._partialReload,z={type:this.type,uid:T.uid,tileID:T.tileID,tileZoom:T.tileZoom,zoom:T.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:D,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:T.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:F,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};T.request=this.actor.send(y,z,(W,J)=>F&&!J?(T.state="loaded",h(null)):(delete T.request,T.destroy(!1),T.aborted?h(null):W?h(W):(T.loadVectorData(J,this.map.painter,y==="reloadTile"),h(null))),void 0,y==="loadTile")}abortTile(T){T.request&&(T.request.cancel(),delete T.request),T.aborted=!0}unloadTile(T,h){this.actor.send("removeTile",{uid:T.uid,type:this.type,source:this.id,scope:this.scope}),T.destroy()}onRemove(T){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(T,h,y,A){super(T,h,y,A),this.roundZoom=!0,this.type="video",this.options=h}load(){this._loaded=!1;const T=this.options;this.urls=[];for(const h of T.urls)this.urls.push(this.map._requestManager.transformRequest(h,i.R.Source).url);i.aV(this.urls,(h,y)=>{this._loaded=!0,h?this.fire(new i.y(h)):y&&(this.video=y,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(T){if(this.video){const h=this.video.seekable;Th.end(0)?this.fire(new i.y(new i.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${h.start(0)} and ${h.end(0)}-second mark.`))):this.video.currentTime=T}}getVideo(){return this.video}onAdd(T){this.map||(this.map=T,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 T=this.map.painter.context,h=T.gl;this.texture?this.video.paused||(this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.texSubImage2D(h.TEXTURE_2D,0,0,0,h.RGBA,h.UNSIGNED_BYTE,this.video)):(this.texture=new i.T(T,this.video,h.RGBA8),this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(T)}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(T,h,y,A){super(),this.type="batched-model",this.id=T,this.tileSize=512,this._options=h,this.tiles=this._options.tiles,this.maxzoom=h.maxzoom||19,this.minzoom=h.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=y,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(A)}onAdd(T){this.map=T,this.load()}reload(){this.cancelTileJSONRequest();const T=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(T))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(T){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const h=Array.isArray(this.map._language)?this.map._language.join():this.map._language,y=this.map.getWorldview();this._tileJSONRequest=Mc(this._options,this.map._requestManager,h,y,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?(h&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${h}`),y&&y.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${y}`),this.fire(new i.y(A))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new lu(D.bounds,this.minzoom,this.maxzoom)),_e(D.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),T&&T(A)})}hasTransition(){return!1}hasTile(T){return!this.tileBounds||this.tileBounds.contains(T.canonical)}loaded(){return this._loaded}loadTile(T,h){const y=this.map._requestManager.normalizeTileURL(T.tileID.canonical.url(this.tiles,this.scheme)),A={request:this.map._requestManager.transformRequest(y,i.R.Tile),data:void 0,uid:T.uid,tileID:T.tileID,tileZoom:T.tileZoom,zoom:T.tileID.overscaledZ,tileSize:this.tileSize*T.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:T.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(T.actor&&T.state!=="expired")if(T.state==="loading")T.reloadCallback=h;else{if(T.buckets){const F=Object.values(T.buckets);for(const z of F)z.dirty=!0;return void(T.state="loaded")}T.request=T.actor.send("reloadTile",A,D.bind(this))}else T.actor=this.dispatcher.getActor(),T.request=T.actor.send("loadTile",A,D.bind(this),void 0,!0);function D(F,z){return T.aborted?h(null):F&&F.status!==404?h(F):(this.map._refreshExpiredTiles&&z&&T.setExpiryData(z),T.loadModelData(z,this.map.painter),T.state="loaded",void h(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(T,h,y,A){super(T,h,y,A),h.coordinates?Array.isArray(h.coordinates)&&h.coordinates.length===4&&!h.coordinates.some(D=>!Array.isArray(D)||D.length!==2||D.some(F=>typeof F!="number"))||this.fire(new i.y(new i.V(`sources.${T}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.y(new i.V(`sources.${T}`,null,'missing required property "coordinates"'))),h.animate&&typeof h.animate!="boolean"&&this.fire(new i.y(new i.V(`sources.${T}`,null,'optional "animate" property must be a boolean value'))),h.canvas?typeof h.canvas=="string"||h.canvas instanceof HTMLCanvasElement||this.fire(new i.y(new i.V(`sources.${T}`,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.${T}`,null,'missing required property "canvas"'))),this.options=h,this.animate=h.animate===void 0||h.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.y(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(T){this.map=T,this.load(),this.canvas&&this.animate&&this.play()}onRemove(T){this.pause()}prepare(){let T=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,T=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,T=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const h=this.map.painter.context;this.texture?!T&&!this._playing||this.texture instanceof i.aW||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.T(h,this.canvas,h.gl.RGBA8,{premultiply:!0}),this._prepareData(h)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const T of[this.canvas.width,this.canvas.height])if(isNaN(T)||T<=0)return!0;return!1}},custom:class extends i.E{constructor(T,h,y,A){super(),this.id=T,this.type="custom",this._dataType="raster",this._dispatcher=y,this._implementation=h,this.setEventedParent(A),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new i.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new lu(this._implementation.bounds,this.minzoom,this.maxzoom)),h.update=this._update.bind(this),h.clearTiles=this._clearTiles.bind(this),h.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,i.aH(h,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(T){this.map=T,this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(T),this.load()}onRemove(T){this._implementation.onRemove&&this._implementation.onRemove(T)}hasTile(T){if(this._implementation.hasTile){const{x:h,y,z:A}=T.canonical;return this._implementation.hasTile({x:h,y,z:A})}return!this.tileBounds||this.tileBounds.contains(T.canonical)}loadTile(T,h){const{x:y,y:A,z:D}=T.tileID.canonical,F=new AbortController;T.request=Promise.resolve(this._implementation.loadTile({x:y,y:A,z:D},{signal:F.signal})).then((function(z){return delete T.request,T.aborted?(T.state="unloaded",h(null)):z===void 0?(T.state="errored",h(null)):z===null?(this.loadTileData(T,{width:this.tileSize,height:this.tileSize,data:null}),T.state="loaded",h(null)):function(W){return W instanceof ImageData||W instanceof HTMLCanvasElement||W instanceof ImageBitmap||W instanceof HTMLImageElement}(z)?(this.loadTileData(T,z),T.state="loaded",void h(null)):(T.state="errored",h(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(z=>{z.name!=="AbortError"&&(T.state="errored",h(z))}),T.request.cancel=()=>F.abort()}loadTileData(T,h){T.setTexture(h,this.map.painter)}unloadTile(T,h){if(T.texture&&T.texture instanceof i.T?(T.destroy(!1),T.texture&&T.texture instanceof i.T&&this.map.painter.saveTileTexture(T.texture)):T.destroy(),this._implementation.unloadTile){const{x:y,y:A,z:D}=T.tileID.canonical;this._implementation.unloadTile({x:y,y:A,z:D})}h&&h()}abortTile(T,h){T.request&&T.request.cancel&&(T.request.cancel(),delete T.request),h&&h()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(T=>({x:T.canonical.x,y:T.canonical.y,z:T.canonical.z}))}_clearTiles(){const T=i.B(this.id,this.scope);this.map.style.clearSource(T)}_update(){this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}}},Bl=function(T,h,y,A){const D=new Km[h.type](T,h,y,A);if(D.id!==T)throw new Error(`Expected Source id to be ${T} instead of ${D.id}`);return i.aY(["load","abort","unload","serialize","prepare"],D),D};function Yx(T,h,y=""){return`${y}:${h.id||""}:${h.layer.id}:${function(A){if("layerId"in A)return`layer:${A.layerId}`;{const{featuresetId:D,importId:F}=A;return`featureset:${D}${F?`:import:${F}`:""}`}}(T.target)}`}function vy(T,h,y,A=""){if(T.uniqueFeatureID){const D=Yx(T,h,A);if(y.has(D))return!0;y.add(D)}return!1}function H1(T,h,y,A,D=!1){const F=h.sourceCache.transform,z=h.sourceCache.tilesIn(T,h.has3DLayers,D);z.sort(Dp);const W=[];for(const J of z){const ne=J.tile.queryRenderedFeatures(h,J,y,A,F,D);Object.keys(ne).length&&W.push({wrappedTileID:J.tile.tileID.wrapped().key,queryResults:ne})}for(const J in h.layers){const ne=h.layers[J];if(ne.styleLayer){const le=ne.styleLayer.queryRenderedFeatures(T,h.sourceCache,A);Object.keys(le).length&&W.push({wrappedTileID:0,queryResults:le})}}return W.length===0?{}:function(J){const ne={},le={};for(const je of J){const ve=je.queryResults,Ne=je.wrappedTileID,De=le[Ne]=le[Ne]||{};for(const Pe in ve){const Ge=ve[Pe],Ve=De[Pe]=De[Pe]||{},nt=ne[Pe]=ne[Pe]||[];for(const ut of Ge)Ve[ut.featureIndex]||(Ve[ut.featureIndex]=!0,nt.push(ut))}}return ne}(W)}function W1(T,h,y,A,D,F){const z={},W=A.queryRenderedSymbols(T),J=[];for(const ne of Object.keys(W).map(Number))J.push(D[ne]);J.sort(Dp);for(const ne of J){const le=ne.featureIndex.lookupSymbolFeatures(W[ne.bucketInstanceId],ne.bucketIndex,ne.sourceLayerIndex,h,y,F);for(const je in le){const ve=z[je]=z[je]||[],Ne=le[je];Ne.sort((De,Pe)=>{const Ge=ne.featureSortOrder;if(Ge){const Ve=Ge.indexOf(De.featureIndex);return Ge.indexOf(Pe.featureIndex)-Ve}return Pe.featureIndex-De.featureIndex});for(const De of Ne)ve.push(De)}}return z}function G1(T,h){const y=T.getRenderableIds().map(F=>T.getTileByID(F)),A=[],D={};for(let F=0;Fh.getLayer(F)).filter(Boolean);if(D.length!==0){A.layers=D,A.stateDependentLayerIds&&(A.stateDependentLayers=A.stateDependentLayerIds.map(F=>D.filter(z=>z.id===F)[0]));for(const F of D)y[F.fqid]=A}}return y}const cu=32,im=33,$d=new Uint16Array(8184);for(let T=0;T<2046;T++){let h=T+2,y=0,A=0,D=0,F=0,z=0,W=0;for(1&h?D=F=z=cu:y=A=W=cu;(h>>=1)>1;){const ne=y+D>>1,le=A+F>>1;1&h?(D=y,F=A,y=z,A=W):(y=D,A=F,D=z,F=W),z=ne,W=le}const J=4*T;$d[J+0]=y,$d[J+1]=A,$d[J+2]=D,$d[J+3]=F}const Cd=new Uint16Array(2178),du=new Uint8Array(1089),Rf=new Uint16Array(1089);function Ff(T){return T===0?-.03125:T===32?.03125:0}const Zm={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 Ym{constructor(h,y,A,D,F,z){this.tileID=h,this.uid=i.b2(),this.uses=0,this.tileSize=y,this.tileZoom=A,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=F,D&&D.style&&(this._lastUpdatedBrightness=D.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",D&&D.transform&&(this.projection=D.transform.projection),this.worldview=z,this._hasAppearances=null}registerFadeDuration(h){const y=h+this.timeAdded;yA)D=!1;else if(y)if(this.expirationTimeA.appearances&&A.appearances.length>0))return!0;return!1}updateBuckets(h,y){if(!this.latestFeatureIndex||!h.style)return;const A=h.style.listImages(),D=h.style.getBrightness();for(const F in this.buckets){if(!h.style.hasLayer(F))continue;const z=this.buckets[F],W=z.layers[0],J=W.sourceLayer||"_geojsonTileLayer",ne=h.style.getLayerSourceCache(W);let le={};ne&&(le=ne._state.getState(J,void 0));const je=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},ve=Object.keys(le).length>0&&!y;z.hasAppearances=z.layers.some(Pe=>Pe.appearances&&Pe.appearances.length>0);const Ne=ve?z.stateDependentLayers:z.layers;if(ve&&z.stateDependentLayers.length!==0||y){const Pe=this.latestFeatureIndex.loadVTLayers();z.update(le,Pe[J],A,je,Ne,y,D)}if(ve&&z.stateDependentLayers.length!==0||y||z.hasAppearances){const Pe={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview};z.updateAppearances(this.tileID.canonical,le,A,Pe)}(z instanceof i.ba||z instanceof i.bb)&&h._terrain&&h._terrain.enabled&&ne&&z.uploadPending()&&h._terrain._clearRenderCacheForTile(ne.id,this.tileID);const De=h&&h.style&&h.style.getOwnLayer(F);De&&(this.queryPadding=Math.max(this.queryPadding,De.queryRadius(z)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;Ge--){const Ve=4*Ge,nt=$d[Ve+0],ut=$d[Ve+1],ot=$d[Ve+2],Et=$d[Ve+3],Nt=nt+ot>>1,Tt=ut+Et>>1,wt=Nt+Tt-ut,yt=Tt+nt-Nt,Ot=ut*im+nt,Wt=Et*im+ot,Ht=Tt*im+Nt,es=Math.hypot((Cd[2*Ot+0]+Cd[2*Wt+0])/2-Cd[2*Ht+0],(Cd[2*Ot+1]+Cd[2*Wt+1])/2-Cd[2*Ht+1])>=16;du[Ht]=du[Ht]||(es?1:0),Ge<1022&&(du[Ht]=du[Ht]||du[(ut+yt>>1)*im+(nt+wt>>1)]||du[(Et+yt>>1)*im+(ot+wt>>1)])}const je=new i.b1,ve=new i.b0;let Ne=0;function De(Ge,Ve){const nt=Ve*im+Ge;return Rf[nt]===0&&(je.emplaceBack(Cd[2*nt+0],Cd[2*nt+1],Ge*i.al/cu,Ve*i.al/cu),Rf[nt]=++Ne),Rf[nt]-1}function Pe(Ge,Ve,nt,ut,ot,Et){const Nt=Ge+nt>>1,Tt=Ve+ut>>1;if(Math.abs(Ge-ot)+Math.abs(Ve-Et)>1&&du[Tt*im+Nt])Pe(ot,Et,Ge,Ve,Nt,Tt),Pe(nt,ut,ot,Et,Nt,Tt);else{const wt=De(Ge,Ve),yt=De(nt,ut),Ot=De(ot,Et);ve.emplaceBack(wt,yt,Ot)}}return Pe(0,0,cu,cu,cu,0),Pe(cu,cu,0,0,0,cu),{vertices:je,indices:ve}}(this.tileID.canonical,y);D=z.vertices,F=z.indices}else{D=new i.b1,F=new i.b0;for(const{x:W,y:J}of A)D.emplaceBack(W,J,0,0);const z=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let W=0;W0&&(J=i.bl(new Float64Array(16),y.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,y,z,J,W),this._makeGlobeTileDebugTextBuffer(h,D,y,z,J,W)}_globePoint(h,y,A,D,F,z,W){let J=i.bm(h,y,A);if(z){const ne=1<.5?Ne=-1:ve<-.5&&(Ne=1);let De=(h/i.al+A.x)/ne+Ne,Pe=(y/i.al+A.y)/ne;De=(De-le)*D._pixelsPerMercatorPixel+le,Pe=(Pe-je)*D._pixelsPerMercatorPixel+je;const Ge=[De*D.worldSize,Pe*D.worldSize,0];i.af(Ge,Ge,z),J=i.bn(J,Ge,W)}return i.af(J,J,F)}_makeGlobeTileDebugBorderBuffer(h,y,A,D,F,z){const W=new i.bd,J=new i.be,ne=new i.bo,le=(ve,Ne,De,Pe,Ge)=>{const Ve=(De-ve)/(Ge-1),nt=(Pe-Ne)/(Ge-1),ut=W.length;for(let ot=0;otje*Ne+De;for(let Ne=0;Ne{if(F)y(F);else try{const J=A.getHeaderLength(z);if(J>h)return void(this.request=this.fetchHeader(J,y));A.parseHeader(z),this._isHeaderLoaded=!0;let ne=0;for(const le of Object.values(A.layers))ne=Math.max(ne,le.dataIndex[le.dataIndex.length-1].lastByte);z.byteLength>=ne&&(this.entireBuffer=z),y(null,this.entireBuffer||z,W)}catch(J){y(J)}}),this.request}fetchBandForRender(h,y,A,D){this.fetchBand(h,y,A,F=>{if(F)return void D(F);this.updateTextureDescriptor(h,y,A);const z=this.textureDescriptorPerLayer.get(y);D(null,z?z.img:null)})}fetchBand(h,y,A,D,F=!0){const z=this._mrt;if(!this._isHeaderLoaded||!z)return void D(new Error("Tile header is not ready"));const W=this.actor;if(!W)return void D(new Error("Can't fetch tile band without an actor"));let J;const ne=i.B(String(A),i.B(this.tileID.key,h));let le=this._taskQueue.get(ne);le?le.add(D):(le=new Set,le.add(D),this._taskQueue.set(ne,le));const je=(Pe,Ge)=>{J.complete(Pe,Ge),Pe?D(Pe):(le.forEach(Ve=>Ve(null,Ge)),this._taskQueue.delete(ne))},ve=(Pe,Ge)=>{if(Pe)return D(Pe);const Ve=W.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:Ge,task:J},je,void 0,!0);if(y!==null){const nt=this._workQueuePerLayer.get(y)||[];nt.push(()=>{Ve&&Ve.cancel(),J.cancel()}),this._workQueuePerLayer.has(y)||this._workQueuePerLayer.set(y,nt)}};let Ne;try{Ne=z.getLayer(h)}catch(Pe){if(this.state==="reloading")return;throw Pe}if(!Ne)return void D(new Error(`Unknown sourceLayer "${h}"`));if(Ne.hasDataForBand(A))return le.forEach(Pe=>Pe(null,null)),void this._taskQueue.delete(ne);const De=Ne.getDataRange([A]);if(J=z.createDecodingTask(De),!J||J.tasks.length)if(y!==null&&this.flushQueues(y),this.entireBuffer)ve(null,this.entireBuffer.slice(De.firstByte,De.lastByte+1));else{const Pe=Object.assign({},this.requestParams,{headers:{Range:`bytes=${De.firstByte}-${De.lastByte}`}}),Ge=i.bu(Pe,ve);if(y!==null){const Ve=this._fetchQueuePerLayer.get(y)||[];Ve.push(()=>{Ge.cancel(),J.cancel()}),this._fetchQueuePerLayer.has(y)||this._fetchQueuePerLayer.set(y,Ve)}}}updateNeeded(h,y){return(!this.textureDescriptorPerLayer.get(h)||this.textureDescriptorPerLayer.get(h).band!==y||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(h,y,A){if(!this._mrt)return;const D=this._mrt.getLayer(h);if(!D||!D.hasBand(A)||!D.hasDataForBand(A))return;const{bytes:F,tileSize:z,buffer:W,offset:J,scale:ne}=D.getBandView(A),le=z+2*W,je=new i.q({width:le,height:le},F),ve=this.texturePerLayer.get(y);ve&&ve instanceof i.T&&ve.update(je,{premultiply:!1}),this.textureDescriptorPerLayer.set(y,{layer:h,band:A,img:je,buffer:W,offset:J,tileSize:z,format:D.pixelFormat,mix:[ne,256*ne,65536*ne,16777216*ne]})}destroy(h=!1){if(super.destroy(h),delete this._mrt,!h)for(const y of this.texturePerLayer.values())y&&y instanceof i.T&&y.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 Y0{constructor(h,y){this.max=h,this.onRemove=y,this.reset()}reset(){for(const h in this.data)for(const y of this.data[h])y.timeout&&clearTimeout(y.timeout),this.onRemove(y.value);return this.data={},this.order=[],this}add(h,y,A){const D=h.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const F={value:y,timeout:void 0};if(A!==void 0&&(F.timeout=setTimeout(()=>{this.remove(h,F)},A)),this.data[D].push(F),this.order.push(D),this.order.length>this.max){const z=this._getAndRemoveByKey(this.order[0]);z&&this.onRemove(z)}return this}has(h){return h.wrapped().key in this.data}getAndRemove(h){return this.has(h)?this._getAndRemoveByKey(h.wrapped().key):null}_getAndRemoveByKey(h){const y=this.data[h].shift();return y.timeout&&clearTimeout(y.timeout),this.data[h].length===0&&delete this.data[h],this.order.splice(this.order.indexOf(h),1),y.value}getByKey(h){const y=this.data[h];return y?y[0].value:null}get(h){return this.has(h)?this.data[h.wrapped().key][0].value:null}remove(h,y){if(!this.has(h))return this;const A=h.wrapped().key,D=y===void 0?0:this.data[A].indexOf(y),F=this.data[A][D];return this.data[A].splice(D,1),F.timeout&&clearTimeout(F.timeout),this.data[A].length===0&&delete this.data[A],this.onRemove(F.value),this.order.splice(this.order.indexOf(A),1),this}setMaxSize(h){for(this.max=h;this.order.length>this.max;){const y=this._getAndRemoveByKey(this.order[0]);y&&this.onRemove(y)}return this}filter(h){const y=[];for(const A in this.data)for(const D of this.data[A])h(D.value)||y.push(D);for(const A of y)this.remove(A.value.tileID,A)}}class Xx{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,y,A){const D=String(y);if(this.stateChanges[h]=this.stateChanges[h]||{},this.stateChanges[h][D]=this.stateChanges[h][D]||{},Object.assign(this.stateChanges[h][D],A),this.deletedStates[h]===null){this.deletedStates[h]={};for(const F in this.state[h])F!==D&&(this.deletedStates[h][F]=null)}else if(this.deletedStates[h]&&this.deletedStates[h][D]===null){this.deletedStates[h][D]={};for(const F in this.state[h][D])A[F]||(this.deletedStates[h][D][F]=null)}else for(const F in A)this.deletedStates[h]&&this.deletedStates[h][D]&&this.deletedStates[h][D][F]===null&&delete this.deletedStates[h][D][F]}removeFeatureState(h,y,A){if(this.deletedStates[h]===null)return;const D=String(y);if(this.deletedStates[h]=this.deletedStates[h]||{},A&&y!==void 0)this.deletedStates[h][D]!==null&&(this.deletedStates[h][D]=this.deletedStates[h][D]||{},this.deletedStates[h][D][A]=null);else if(y!==void 0)if(this.stateChanges[h]&&this.stateChanges[h][D])for(A in this.deletedStates[h][D]={},this.stateChanges[h][D])this.deletedStates[h][D][A]=null;else this.deletedStates[h][D]=null;else this.deletedStates[h]=null}getState(h,y){const A=this.state[h]||{},D=this.stateChanges[h]||{},F=this.deletedStates[h];if(F===null)return{};if(y!==void 0){const W=String(y),J=Object.assign({},A[W],D[W]);if(F){const ne=F[y];if(ne===null)return{};for(const le in ne)delete J[le]}return J}const z=Object.assign({},A,D);if(F)for(const W in F)delete z[W];return z}initializeTileState(h,y){h.refreshFeatureState(y)}coalesceChanges(h,y){const A={};for(const D in this.stateChanges){this.state[D]=this.state[D]||{};const F={};for(const z in this.stateChanges[D])this.state[D][z]||(this.state[D][z]={}),Object.assign(this.state[D][z],this.stateChanges[D][z]),F[z]=this.state[D][z];A[D]=F}for(const D in this.deletedStates){this.state[D]=this.state[D]||{};const F={};if(this.deletedStates[D]===null)for(const z in this.state[D])F[z]={},this.state[D][z]={};else for(const z in this.deletedStates[D]){if(this.deletedStates[D][z]===null)this.state[D][z]={};else if(this.state[D][z])for(const W of Object.keys(this.deletedStates[D][z]))delete this.state[D][z][W];F[z]=this.state[D][z]}A[D]=A[D]||{},Object.assign(A[D],F)}if(this.stateChanges={},this.deletedStates={},Object.keys(A).length!==0)for(const D in h)h[D].refreshFeatureState(y)}}class El extends i.E{constructor(h,y,A){super(),this.id=h,this._onlySymbols=A,y.on("data",D=>{D.dataType==="source"&&D.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&D.dataType==="source"&&D.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),y.on("error",()=>{this._sourceErrored=!0}),this._source=y,this._tiles={},this._cache=new Y0(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=y.minTileCacheSize,this._maxTileCacheSize=y.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Xx,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(h){this.map=h,this._minTileCacheSize=this._minTileCacheSize===void 0&&h?h._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&h?h._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const h in this._tiles)if(!this._tiles[h].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const h=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,h&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(h,y){return h.isSymbolTile=this._onlySymbols,h.isExtraShadowCaster=this._shadowCasterTiles[h.tileID.key],this._source.loadTile(h,y)}_unloadTile(h){if(this._source.unloadTile)return this._source.unloadTile(h)}_abortTile(h){if(this._source.abortTile)return this._source.abortTile(h)}serialize(){return this._source.serialize()}prepare(h){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const y in this._tiles){const A=this._tiles[y];A.upload(h,this.map?this.map.painter:void 0),A.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(h=>h.tileID).sort(K1).map(h=>h.key)}getRenderableIds(h,y){const A=[];for(const D in this._tiles)this._isIdRenderable(+D,h,y)&&A.push(this._tiles[D]);return h?A.sort((D,F)=>{const z=D.tileID,W=F.tileID,J=new i.P(z.canonical.x,z.canonical.y)._rotate(this.transform.angle),ne=new i.P(W.canonical.x,W.canonical.y)._rotate(this.transform.angle);return z.overscaledZ-W.overscaledZ||ne.y-J.y||ne.x-J.x}).map(D=>D.tileID.key):A.map(D=>D.tileID).sort(K1).map(D=>D.key)}hasRenderableParent(h){const y=this.findLoadedParent(h,0);return!!y&&this._isIdRenderable(y.tileID.key)}_isIdRenderable(h,y,A){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(y||!this._tiles[h].holdingForFade())&&(A||!this._shadowCasterTiles[h])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const h in this._tiles)this._tiles[h].state!=="errored"&&this._reloadTile(+h,"reloading")}}_reloadTile(h,y){const A=this._tiles[h];A&&(A.state!=="loading"&&(A.state=y),this._loadTile(A,this._tileLoaded.bind(this,A,h,y)))}_tileLoaded(h,y,A,D,F){if(D){if(h.state="errored",D.status!==404)this._source.fire(new i.y(D,{tile:h}));else{if(this._source.fire(new i.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:h})),!(h.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const W=this.map.painter.terrain;this.update(this.transform,W.getScaledDemTileSize(),!0),W.resetTileLookupCache(this.id)}else this.update(this.transform)}return}h.timeAdded=i.o.now(),A==="expired"&&(h.refreshedUponExpiration=!0),this._setTileReloadTimer(y,h),this._source.type==="raster-dem"&&h.dem&&this._backfillDEM(h),this._state.initializeTileState(h,this.map?this.map.painter:null);let z=new Map;F&&F.responseHeaders&&(z=F.responseHeaders),this._source.fire(new i.z("data",{dataType:"source",tile:h,coord:h.tileID,sourceCacheId:this.id,responseHeaders:z}))}_backfillDEM(h){const y=this.getRenderableIds();for(let D=0;D1||(Math.abs(z)>1&&(Math.abs(z+J)===1?z+=J:Math.abs(z-J)===1&&(z-=J)),F.dem&&D.dem&&(D.dem.backfillBorder(F.dem,z,W),D.neighboringTiles&&D.neighboringTiles[ne]&&(D.neighboringTiles[ne].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,y,A,D){for(const F in this._tiles){let z=this._tiles[F];if(D[F]||!z.hasData()||z.tileID.overscaledZ<=y||z.tileID.overscaledZ>A)continue;let W=z.tileID;for(;z&&z.tileID.overscaledZ>y+1;){const ne=z.tileID.scaledTo(z.tileID.overscaledZ-1);z=this._tiles[ne.key],z&&z.hasData()&&(W=ne)}let J=W;for(;J.overscaledZ>y;)if(J=J.scaledTo(J.overscaledZ-1),h[J.key]){D[W.key]=W;break}}}findLoadedParent(h,y){if(h.key in this._loadedParentTiles){const A=this._loadedParentTiles[h.key];return A&&A.tileID.overscaledZ>=y?A:null}for(let A=h.overscaledZ-1;A>=y;A--){const D=h.scaledTo(A),F=this._getLoadedTile(D);if(F)return F}}_getLoadedTile(h){const y=this._tiles[h.key];return y&&y.hasData()?y:this._cache.getByKey(this._source.reparseOverscaled?h.wrapped().key:h.canonical.key)}updateCacheSize(h,y){y=y||this._source.tileSize;const A=Math.ceil(h.width/y)+1,D=Math.ceil(h.height/y)+1,F=Math.floor(A*D*5),z=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,F):F,W=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,z):z;this._cache.setMaxSize(W)}handleWrapJump(h){const y=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,y){const A={};for(const D in this._tiles){const F=this._tiles[D];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+y),A[F.tileID.key]=F}this._tiles=A;for(const D in this._timers)clearTimeout(this._timers[D]),delete this._timers[D];for(const D in this._tiles)this._setTileReloadTimer(+D,this._tiles[D])}}update(h,y,A,D,F){if(this.transform=h,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!A)return;this.updateCacheSize(h,y),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const z=this._source.type==="batched-model";let W,J=this._source.maxzoom;const ne=this.map&&this.map.painter?this.map.painter._terrain:null;if(ne&&ne.sourceCache===this&&ne.attenuationRange()){const ve=ne.attenuationRange()[0],Ne=Math.floor(ve)-Math.log2(ne.getDemUpscale());J>Ne&&(J=Ne)}if(this.used||this.usedForTerrain){if(this._source.tileID)W=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(ve=>new i.aQ(ve.canonical.z,ve.wrap,ve.canonical.z,ve.canonical.x,ve.canonical.y));else if(this.tileCoverLift!==0){const ve=h.clone();ve.tileCoverLift=this.tileCoverLift,W=ve.coveringTiles({tileSize:y||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:J,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.minzoom<=1&&h.projection.name==="globe"&&(W.push(new i.aQ(1,0,1,0,0)),W.push(new i.aQ(1,0,1,1,0)),W.push(new i.aQ(1,0,1,0,1)),W.push(new i.aQ(1,0,1,1,1)))}else if(W=h.coveringTiles({tileSize:y||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:J,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.hasTile){const ve=this._source.hasTile.bind(this._source);W=W.filter(Ne=>ve(Ne))}}else W=[];if(W.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!Qx(this._source.type)){const ve=h.coveringZoomLevel({tileSize:y||this._source.tileSize,roundZoom:this._source.roundZoom&&!A}),Ne=Math.min(ve,this._source.maxzoom);if(z){const De=h.extendTileCover(W,Ne);for(const Pe of De)W.push(Pe)}else if(F){const De=h.extendTileCoverToNearPlane(W,this.transform.getFrustum(Ne),Ne);for(const Pe of De)W.push(Pe)}else if(this.castsShadows&&D){const De=h.extendTileCover(W,Ne,D,16);for(const Pe of De)this._shadowCasterTiles[Pe.key]=!0,W.push(Pe)}}const le=this._updateRetainedTiles(W);if(Qx(this._source.type)&&W.length!==0){const ve={},Ne={},De=Object.keys(le);for(const Ge of De){const Ve=le[Ge],nt=this._tiles[Ge];if(!nt||nt.fadeEndTime&&nt.fadeEndTime<=i.o.now())continue;const ut=this.findLoadedParent(Ve,Math.max(Ve.overscaledZ-El.maxOverzooming,this._source.minzoom));ut&&(this._addTile(ut.tileID),ve[ut.tileID.key]=ut.tileID),Ne[Ge]=Ve}const Pe=W[W.length-1].overscaledZ;for(const Ge in this._tiles){const Ve=this._tiles[Ge];if(le[Ge]||!Ve.hasData())continue;let nt=Ve.tileID;for(;nt.overscaledZ>Pe;){nt=nt.scaledTo(nt.overscaledZ-1);const ut=this._tiles[nt.key];if(ut&&ut.hasData()&&Ne[nt.key]){le[Ge]=Ve.tileID;break}}}for(const Ge in ve)le[Ge]||(this._coveredTiles[Ge]=!0,le[Ge]=ve[Ge])}for(const ve in le)this._tiles[ve].clearFadeHold();const je=i.bv(this._tiles,le);for(const ve of je){const Ne=this._tiles[ve];Ne.hasSymbolBuckets&&!Ne.holdingForFade()?Ne.setHoldDuration(this.map._fadeDuration):Ne.hasSymbolBuckets&&!Ne.symbolFadeFinished()||this._removeTile(+ve)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const h in this._tiles)this._tiles[h].holdingForFade()&&this._removeTile(+h)}_updateRetainedTiles(h){const y={};if(h.length===0)return y;const A={},D=h.reduce((ne,le)=>Math.min(ne,le.overscaledZ),1/0),F=h[0].overscaledZ,z=Math.max(F-El.maxOverzooming,this._source.minzoom),W=Math.max(F+El.maxUnderzooming,this._source.minzoom),J={};for(const ne of h){const le=this._addTile(ne);y[ne.key]=ne,le.hasData()||D=this._source.maxzoom){const ve=ne.children(this._source.maxzoom)[0],Ne=this.getTile(ve);if(Ne&&Ne.hasData()){y[ve.key]=ve;continue}}else{const ve=ne.children(this._source.maxzoom);if(y[ve[0].key]&&y[ve[1].key]&&y[ve[2].key]&&y[ve[3].key])continue}let je=le.wasRequested();for(let ve=ne.overscaledZ-1;ve>=z;--ve){const Ne=ne.scaledTo(ve);if(A[Ne.key]||(A[Ne.key]=!0,le=this.getTile(Ne),!le&&je&&(le=this._addTile(Ne)),le&&(y[Ne.key]=Ne,je=le.wasRequested(),le.hasData())))break}}return y}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const h in this._tiles){const y=[];let A,D=this._tiles[h].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){A=this._loadedParentTiles[D.key];break}y.push(D.key);const F=D.scaledTo(D.overscaledZ-1);if(A=this._getLoadedTile(F),A)break;D=F}for(const F of y)this._loadedParentTiles[F]=A}}_addTile(h){let y=this._tiles[h.key];if(y)return y.isExtraShadowCaster!==!0||this._shadowCasterTiles[h.key]||this._reloadTile(h.key,"reloading"),y;y=this._cache.getAndRemove(h),y&&(this._setTileReloadTimer(h.key,y),y.tileID=h,this._state.initializeTileState(y,this.map?this.map.painter:null),this._cacheTimers[h.key]&&(clearTimeout(this._cacheTimers[h.key]),delete this._cacheTimers[h.key],this._setTileReloadTimer(h.key,y)));const A=!!y;if(!A){const D=this.map?this.map.painter:null,F=this._source.tileSize*h.overscaleFactor();y=this._source.type==="raster-array"?new Md(h,F,this.transform.tileZoom,D,this._isRaster):new Ym(h,F,this.transform.tileZoom,D,this._isRaster,this._source.worldview),this._loadTile(y,this._tileLoaded.bind(this,y,h.key,y.state))}return y.uses++,this._tiles[h.key]=y,A||this._source.fire(new i.z("dataloading",{tile:y,coord:y.tileID,dataType:"source"})),y}_setTileReloadTimer(h,y){h in this._timers&&(clearTimeout(this._timers[h]),delete this._timers[h]);const A=y.getExpiryTimeout();A&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},A))}_removeTile(h){const y=this._tiles[h];y&&(y.uses--,delete this._tiles[h],this._timers[h]&&(clearTimeout(this._timers[h]),delete this._timers[h]),y.uses>0||(y.hasData()&&y.state!=="reloading"||y.state==="empty"?this._cache.add(y.tileID,y,y.getExpiryTimeout()):(y.aborted=!0,this._abortTile(y),this._unloadTile(y))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const h in this._tiles)this._removeTile(+h);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(h,y,A){const D=[],F=this.transform;if(!F)return D;const z=F.projection.name==="globe",W=i.aF(F.center.lng);for(const J in this._tiles){const ne=this._tiles[J];if(A&&ne.clearQueryDebugViz(),ne.holdingForFade())continue;let le;if(z){const je=ne.tileID.canonical;if(je.z===0){const ve=[Math.abs(i.aA(W,...Lh(je,-1))-W),Math.abs(i.aA(W,...Lh(je,1))-W)];le=[0,2*ve.indexOf(Math.min(...ve))-1]}else{const ve=[Math.abs(i.aA(W,...Lh(je,-1))-W),Math.abs(i.aA(W,...Lh(je,0))-W),Math.abs(i.aA(W,...Lh(je,1))-W)];le=[ve.indexOf(Math.min(...ve))-1]}}else le=[0];for(const je of le){const ve=h.containsTile(ne,F,y,je);ve&&D.push(ve)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(h){return this._getRenderableCoordinates(h)}_getRenderableCoordinates(h,y){const A=this.getRenderableIds(h,y).map(F=>this._tiles[F].tileID),D=this.transform.projection.name==="globe";for(const F of A)F.projMatrix=this.transform.calculateProjMatrix(F.toUnwrapped()),F.expandedProjMatrix=D?this.transform.calculateProjMatrix(F.toUnwrapped(),!1,!0):F.projMatrix;return A}sortCoordinatesByDistance(h){const y=h.slice(),A=this.transform._camera.position,D=this.transform._camera.forward(),F={};for(const z of y){const W=1/(1<F[z.key]-F[W.key]),y}hasTransition(){if(this._source.hasTransition())return!0;if(Qx(this._source.type))for(const h in this._tiles){const y=this._tiles[h];if(y.fadeEndTime!==void 0&&y.fadeEndTime>=i.o.now())return!0}return!1}setFeatureState(h,y,A){this._state.updateState(h=h||"_geojsonTileLayer",y,A)}removeFeatureState(h,y,A){this._state.removeFeatureState(h=h||"_geojsonTileLayer",y,A)}getFeatureState(h,y){return this._state.getState(h=h||"_geojsonTileLayer",y)}setDependencies(h,y,A){const D=this._tiles[h];D&&D.setDependencies(y,A)}reloadTilesForDependencies(h,y){for(const A in this._tiles)this._tiles[A].hasDependency(h,y)&&this._reloadTile(+A,"reloading");this._cache.filter(A=>!A.hasDependency(h,y))}_preloadTiles(h,y){if(!this._sourceLoaded){const J=()=>{this._sourceLoaded&&(this._source.off("data",J),this._preloadTiles(h,y))};return void this._source.on("data",J)}const A=new Map,D=Array.isArray(h)?h:[h],F=this.map.painter.terrain,z=this.usedForTerrain&&F?F.getScaledDemTileSize():this._source.tileSize;for(const J of D){const ne=J.coveringTiles({tileSize:z,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const le of ne)A.set(le.key,le);this.usedForTerrain&&J.updateElevation(!1)}const W=Array.from(A.values());i.bw(W,(J,ne)=>{const le=new Ym(J,this._source.tileSize*J.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(le,je=>{this._source.type==="raster-dem"&&le.dem&&this._backfillDEM(le),ne(je,le)})},y)}}function K1(T,h){const y=Math.abs(2*T.wrap)-+(T.wrap<0),A=Math.abs(2*h.wrap)-+(h.wrap<0);return T.overscaledZ-h.overscaledZ||A-y||h.canonical.y-T.canonical.y||h.canonical.x-T.canonical.x}function Qx(T){return T==="raster"||T==="image"||T==="video"||T==="custom"}function Lh(T,h){const y=1<0:A.type==="building"?D=!A.isHidden(h)&&A.paint.get("building-opacity")>0:A.type==="model"&&(D=!A.isHidden(h)&&A.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!D&&y.visible,y.visible=D}}updateZOffset(h,y){this.currentBuildingBuckets=[];for(const D of this.layers){const F=D.layer,z=this.style.getLayerSourceCache(F);let W=1;F.type==="fill-extrusion"?W=D.visible?F.paint.get("fill-extrusion-vertical-scale"):0:F.type==="building"&&(W=D.visible?F.paint.get("building-vertical-scale"):0);let J=z?z.getTile(y):null;if(!J&&z)for(const ne in z._tiles){const le=z._tiles[ne];if(y.canonical.isChildOf(le.tileID.canonical)){J=le;break}}this.currentBuildingBuckets.push({bucket:J?J.getBucket(F):null,tileID:J?J.tileID:y,verticalScale:W})}h.hasAnyZOffset=!1;let A=!1;for(let D=0;D{A in h&&(y[A]=h[A])}),y}function X0(T){T=T.slice();const h=Object.create(null);for(let y=0;y0?(D-z)/W:0;return this.points[F].mult(1-J).add(this.points[y].mult(J))}}class Zw{constructor(h,y,A){const D=this.boxCells=[],F=this.circleCells=[];this.xCellCount=Math.ceil(h/A),this.yCellCount=Math.ceil(y/A);for(let z=0;zthis.width||D<0||y>this.height)return!F&&[];const W=[];if(h<=0&&y<=0&&this.width<=A&&this.height<=D){if(F)return!0;for(let J=0;J0:W}_queryCircle(h,y,A,D,F){const z=h-A,W=h+A,J=y-A,ne=y+A;if(W<0||z>this.width||ne<0||J>this.height)return!D&&[];const le=[];return this._forEachCell(z,J,W,ne,this._queryCellCircle,le,{hitTest:D,circle:{x:h,y,radius:A},seenUids:{box:{},circle:{}}},F),D?le.length>0:le}query(h,y,A,D,F){return this._query(h,y,A,D,!1,F)}hitTest(h,y,A,D,F){return this._query(h,y,A,D,!0,F)}hitTestCircle(h,y,A,D){return this._queryCircle(h,y,A,!0,D)}_queryCell(h,y,A,D,F,z,W,J){const ne=W.seenUids,le=this.boxCells[F];if(le!==null){const ve=this.bboxes;for(const Ne of le)if(!ne.box[Ne]){ne.box[Ne]=!0;const De=4*Ne;if(h<=ve[De+2]&&y<=ve[De+3]&&A>=ve[De+0]&&D>=ve[De+1]&&(!J||J(this.boxKeys[Ne]))){if(W.hitTest)return z.push(!0),!0;z.push({key:this.boxKeys[Ne],x1:ve[De],y1:ve[De+1],x2:ve[De+2],y2:ve[De+3]})}}}const je=this.circleCells[F];if(je!==null){const ve=this.circles;for(const Ne of je)if(!ne.circle[Ne]){ne.circle[Ne]=!0;const De=3*Ne;if(this._circleAndRectCollide(ve[De],ve[De+1],ve[De+2],h,y,A,D)&&(!J||J(this.circleKeys[Ne]))){if(W.hitTest)return z.push(!0),!0;{const Pe=ve[De],Ge=ve[De+1],Ve=ve[De+2];z.push({key:this.circleKeys[Ne],x1:Pe-Ve,y1:Ge-Ve,x2:Pe+Ve,y2:Ge+Ve})}}}}}_queryCellCircle(h,y,A,D,F,z,W,J){const ne=W.circle,le=W.seenUids,je=this.boxCells[F];if(je!==null){const Ne=this.bboxes;for(const De of je)if(!le.box[De]){le.box[De]=!0;const Pe=4*De;if(this._circleAndRectCollide(ne.x,ne.y,ne.radius,Ne[Pe+0],Ne[Pe+1],Ne[Pe+2],Ne[Pe+3])&&(!J||J(this.boxKeys[De])))return z.push(!0),!0}}const ve=this.circleCells[F];if(ve!==null){const Ne=this.circles;for(const De of ve)if(!le.circle[De]){le.circle[De]=!0;const Pe=3*De;if(this._circlesCollide(Ne[Pe],Ne[Pe+1],Ne[Pe+2],ne.x,ne.y,ne.radius)&&(!J||J(this.circleKeys[De])))return z.push(!0),!0}}}_forEachCell(h,y,A,D,F,z,W,J){const ne=this._convertToXCellCoord(h),le=this._convertToYCellCoord(y),je=this._convertToXCellCoord(A),ve=this._convertToYCellCoord(D);for(let Ne=ne;Ne<=je;Ne++)for(let De=le;De<=ve;De++)if(F.call(this,h,y,A,D,this.xCellCount*De+Ne,z,W,J))return}_convertToXCellCoord(h){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(h*this.xScale)))}_convertToYCellCoord(h){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(h*this.yScale)))}_circlesCollide(h,y,A,D,F,z){const W=D-h,J=F-y,ne=A+z;return ne*ne>W*W+J*J}_circleAndRectCollide(h,y,A,D,F,z,W){const J=(z-D)/2,ne=Math.abs(h-(D+J));if(ne>J+A)return!1;const le=(W-F)/2,je=Math.abs(y-(F+le));if(je>le+A)return!1;if(ne<=J||je<=le)return!0;const ve=ne-J,Ne=je-le;return ve*ve+Ne*Ne<=A*A}}const jt={unknown:0,flipRequired:1,flipNotRequired:2},As=Math.tan(85*Math.PI/180);function Qs(T,h,y,A,D,F,z){const W=i.bC();if(y)if(F.name==="globe"){const J=i.bD(D,h);i.aB(W,W,J)}else{const J=i.bE([],z);W[0]=J[0],W[1]=J[1],W[4]=J[2],W[5]=J[3],A||i.bB(W,W,D.angle)}else i.aB(W,D.labelPlaneMatrix,T);return W}function xn(T,h,y,A,D,F,z){const W=Qs(T,h,y,A,D,F,z);return F.name==="globe"&&y||(W[2]=W[6]=W[10]=W[14]=0),W}function gn(T,h,y,A,D,F,z){if(y){if(F.name==="globe"){const W=Qs(T,h,y,A,D,F,z);return i.bl(W,W),i.aB(W,T,W),W}{const W=i.bz(T),J=i.bA([]);return J[0]=z[0],J[1]=z[1],J[4]=z[2],J[5]=z[3],i.aB(W,W,J),A||i.bB(W,W,-D.angle),W}}return D.glCoordMatrix}function ca(T,h,y,A){const D=[T,h,y,1];y?i.aC(D,D,A):$r(D,D,A);const F=D[3];return D[0]/=F,D[1]/=F,D[2]/=F,D}function Ur(T,h){return Math.min(.5+T/h*.5,1.5)}function uo(T,h){const y=T[0]/T[3],A=T[1]/T[3];return y>=-h[0]&&y<=h[0]&&A>=-h[1]&&A<=h[1]}function Jx(T,h,y,A,D,F,z,W,J,ne,le=1){const je=y.transform,ve=A?T.textSizeData:T.iconSizeData,Ne=i.bK(ve,y.transform.zoom,le),De=je.projection.name==="globe",Pe=[256/y.width*2+1,256/y.height*2+1],Ge=A?T.text.dynamicLayoutVertexArray:T.icon.dynamicLayoutVertexArray;Ge.clear();let Ve=null;De&&(Ve=A?T.text.globeExtVertexArray:T.icon.globeExtVertexArray);const nt=T.lineVertexArray,ut=A?T.text.placedSymbolArray:T.icon.placedSymbolArray,ot=y.transform.width/y.transform.height;let Et,Nt=!1;for(let Tt=0;TtMath.abs(y)?{useVertical:!0}:T===i.bL.vertical?A>0?{needsFlipping:!0}:null:h!==jt.unknown&&function(D,F){return D===0||Math.abs(F/D)>As}(y,A)?h===jt.flipRequired?{needsFlipping:!0}:null:y<0?{needsFlipping:!0}:null}function ev(T,h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge,Ve,nt,ut){const ot=h/24,Et=T.lineOffsetX*ot,Nt=T.lineOffsetY*ot,{lineStartIndex:Tt,glyphStartIndex:wt,numGlyphs:yt,segment:Ot,writingMode:Wt,flipState:Ht}=T,es=Tt+T.lineLength,ts=xs=>{if(le){const[as,Jt,Is]=xs.up,rr=ne.length;i.bN(le,rr+0,as,Jt,Is),i.bN(le,rr+1,as,Jt,Is),i.bN(le,rr+2,as,Jt,Is),i.bN(le,rr+3,as,Jt,Is)}const[qs,Yt,Bt]=xs.point;i.bO(ne,qs,Yt,Bt,xs.angle)};if(yt>1){const xs=Op(ot,W,Et,Nt,y,je,ve,T,J,F,Ne,Pe,!1,Ge,Ve,nt,ut);if(!xs)return{notEnoughRoom:!0};if(A&&!y){let[qs,Yt,Bt]=xs.first.point,[as,Jt,Is]=xs.last.point;[qs,Yt]=ca(qs,Yt,Bt,z),[as,Jt]=ca(as,Jt,Is,z);const rr=Zr(Wt,Ht,(as-qs)*De,Jt-Yt);if(T.flipState=rr&&rr.needsFlipping?jt.flipRequired:jt.flipNotRequired,rr)return rr}ts(xs.first);for(let qs=wt+1;qs0?as:Qm(ve,Bt,qs,1,D,void 0,Ge,Ve.canonical),Is=Zr(Wt,Ht,(Jt[0]-qs[0])*De,Jt[1]-qs[1]);if(T.flipState=Is&&Is.needsFlipping?jt.flipRequired:jt.flipNotRequired,Is)return Is}const xs=Y1(ot*W.getoffsetX(wt),Et,Nt,y,je,ve,Ot,Tt,es,J,F,Ne,Pe,!1,!1,Ge,Ve,nt,ut);if(!xs)return{notEnoughRoom:!0};ts(xs)}return{}}function tv(T,h,y,A,D){const{x:F,y:z,z:W}=A.projectTilePoint(T.x,T.y,h);if(!D)return ca(F,z,W,y);const[J,ne,le]=D.getElevation(T,D.elevation,D.elevationFeature);return ca(F+J,z+ne,W+le,y)}function Qm(T,h,y,A,D,F,z,W){const J=tv(T.sub(h)._unit()._add(T),W,D,z,F);return i.av(J,y,J),i.aw(J,J),i.bH(J,y,J,A)}function Y1(T,h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge,Ve,nt){const ut=A?T-h:T+h;let ot=ut>0?1:-1,Et=0;A&&(ot*=-1,Et=Math.PI),ot<0&&(Et+=Math.PI);let Nt=W+z+(ot>0?0:1)|0,Tt=D,wt=D,yt=0,Ot=0;const Wt=Math.abs(ut),Ht=[],es=[];let ts=F,xs=ts,qs=i.bF([]);const Yt=()=>Qm(xs,ts,wt,Wt-yt+1,le,ve,Pe,Ge.canonical);for(;yt+Ot<=Wt;){if(Nt+=ot,Nt=J)return null;if(wt=Tt,xs=ts,Ht.push(wt),Ne&&es.push(xs),ts=new i.P(ne.getx(Nt),ne.gety(Nt)),Tt=je[Nt],!Tt){const Cr=tv(ts,Ge.canonical,le,Pe,ve);Tt=Cr[3]>0?je[Nt]=Cr:Yt()}yt+=Ot;const Us=i.av([],Tt,wt),Pr=i.bG(wt,Tt);if(y&&Pr>0&&Ot>0&&i.bJ(qs,Us)/(Ot*Pr)0,ut),Tt=ne*Nt.perspectiveRatio,wt=(A.x1*y+W.x-A.padding)*Tt+Nt.point.x,yt=(A.y1*y+W.y-A.padding)*Tt+Nt.point.y,Ot=(A.x2*y+W.x+A.padding)*Tt+Nt.point.x,Wt=(A.y2*y+W.y+A.padding)*Tt+Nt.point.y,Ht=Nt.perspectiveRatio<=.55||Nt.occluded;return!this.isInsideGrid(wt,yt,Ot,Wt)||!J&&this.grid.hitTest(wt,yt,Ot,Wt,je)||Ht?{box:[],offscreen:!1,occluded:Nt.occluded}:{box:[wt,yt,Ot,Wt],offscreen:this.isOffscreen(wt,yt,Ot,Wt),occluded:!1}}placeCollisionCircles(h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge){const Ve=[],nt=this.transform.elevation,ut=h.getProjection(),ot=h.elevationType==="road",Et=!!nt||ot,Nt=i.bV.getAtTileOffsetFunc(Ge,this.transform.center.lat,this.transform.worldSize,ut),Tt=new i.P(A.tileAnchorX,A.tileAnchorY),wt=new i.P(A.tileAnchorX,A.tileAnchorY);let{x:yt,y:Ot,z:Wt}=ut.projectTilePoint(wt.x,wt.y,Ge.canonical),Ht=null;if(Et){const Pr=ot?h.getElevationFeatureForText(D):null;Ht={getElevation:Nt,elevation:nt,elevationFeature:Pr};const[Cr,hr,br]=Nt(Tt,nt,Pr);yt+=Cr,Ot+=hr,Wt+=br}const es=ut.name==="globe",ts=this.projectAndGetPerspectiveRatio(J,yt,Ot,Wt,Ge,es||!!nt||this.transform.pitch>0,ut),{perspectiveRatio:xs}=ts,qs=(ve?W/xs:W*xs)/i.bY,Yt=ca(yt,Ot,Wt,ne),Bt=A.lineOffsetX*qs,as=A.lineOffsetY*qs,Jt=i.an(h.layers[0].layout.get("text-max-angle")),Is=Math.cos(Jt),rr=ts.signedDistanceFromCamera>0?Op(qs,z,Bt,as,ot&&A.flipState===1,Yt,wt,A,F,ne,{},Et&&!ve?Ht:null,ve&&Et,ut,Ge,ve,Is):null;let yr=!1,Js=!1,Us=!0;if(rr&&!ts.occluded){const Pr=.5*De*xs+Pe,Cr=new i.P(-100,-100),hr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),br=new _y,{first:Kr,last:Pn}=rr,wa=Kr.path.length;let si=[];for(let Cn=wa-1;Cn>=1;Cn--)si.push(Kr.path[Cn]);for(let Cn=1;Cn(Et&&!es&&(Ci=Nt(biCn[3]<=0)&&(si=[]));let Ka=[];if(si.length>0){let Cn=1/0,di=-1/0,Ci=1/0,bi=-1/0;for(const Ga of si)Cn=Math.min(Cn,Ga[0]),Ci=Math.min(Ci,Ga[1]),di=Math.max(di,Ga[0]),bi=Math.max(bi,Ga[1]);di>=Cr.x&&Cn<=hr.x&&bi>=Cr.y&&Ci<=hr.y&&(Ka=[si.map(Ga=>new i.P(Ga[0],Ga[1]))],(Cnhr.x||Cihr.y)&&(Ka=i.bW(Ka,Cr.x,Cr.y,hr.x,hr.y)))}for(const Cn of Ka){br.reset(Cn,.25*Pr);let di=0;di=br.length<=.5*Pr?1:Math.ceil(br.paddedLength/Or)+1;for(let Ci=0;Ci0?(i.aC(J,J,h),this.fogState&&F&&W.name!=="globe"&&(ne=function(ve,Ne,De,Pe,Ge,Ve){const nt=Ve.calculateFogTileMatrix(Ge),ut=[Ne,De,Pe];return i.af(ut,ut,nt),vr(ve,i.ag(ut),Ve.pitch,Ve._fov)}(this.fogState,y,A,D,F.toUnwrapped(),this.transform)>.9)):$r(J,J,h);const le=J[3];return{point:new i.P((J[0]/le+1)/2*this.transform.width+Da,(-J[1]/le+1)/2*this.transform.height+Da),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(W)/le*.5,1.5),signedDistanceFromCamera:le,occluded:z&&J[2]>le||ne}}isOffscreen(h,y,A,D){return A=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(h,y,A,D){return A>=0&&h=0&&yA.collisionGroupID===y}}return this.collisionGroups[h]}}function qd(T,h,y,A,D){const{horizontalAlign:F,verticalAlign:z}=i.c1(T),W=-(F-.5)*h,J=-(z-.5)*y,ne=i.c2(T,A);return new i.P(W+ne[0]*D,J+ne[1]*D)}function _l(T,h,y,A,D){const F=new i.P(T,h);return y&&F._rotate(A?D:-D),F}class Nme{constructor(h,y,A,D,F,z){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new Si(this.transform,F),this.buildingIndex=z,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=y,this.retainedQueryData={},this.collisionGroups=new Xw(A),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(h,y,A,D,F=1){const z=A.getBucket(y),W=A.latestFeatureIndex;if(!z||!W||y.fqid!==z.layerIds[0])return;const J=z.layers[0].layout,ne=z.layers[0].paint,le=A.collisionBoxArray,je=Math.pow(2,this.transform.zoom-A.tileID.overscaledZ),ve=A.tileSize/i.al,Ne=A.tileID.toUnwrapped();this.transform.setProjection(z.projection);const De=(Pe=A.tileID,Ge=z.getProjection(),Ve=this.transform,Ge.name===this.projection?Ve.calculateProjMatrix(Pe.toUnwrapped()):Kw(Ve,Ge,Pe));var Pe,Ge,Ve;const nt=J.get("text-pitch-alignment")==="map",ut=J.get("text-rotation-alignment")==="map";y.compileFilter(y.options);const ot=y.dynamicFilter(),Et=y.dynamicFilterNeedsFeature(),Nt=this.transform.calculatePixelsToTileUnitsMatrix(A),Tt=xn(De,A.tileID.canonical,nt,ut,this.transform,z.getProjection(),Nt);let wt=null;const yt=z.getProjection().createInversionMatrix(this.transform,A.tileID.canonical);if(nt){const Bt=gn(De,A.tileID.canonical,nt,ut,this.transform,z.getProjection(),Nt);wt=i.aB([],this.transform.labelPlaneMatrix,Bt)}let Ot=null;ot&&A.latestFeatureIndex&&(Ot={unwrappedTileID:Ne,dynamicFilter:ot,dynamicFilterNeedsFeature:Et}),this.retainedQueryData[z.bucketInstanceId]=new Yw(z.bucketInstanceId,W,z.sourceLayerIndex,z.index,A.tileID);const[Wt,Ht]=z.layers[0].layout.get("text-size-scale-range"),es=i.aA(F,Wt,Ht),[ts,xs]=J.get("icon-size-scale-range"),qs=i.aA(F,ts,xs),Yt={bucket:z,layout:J,paint:ne,posMatrix:De,invMatrix:yt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:Tt,labelToScreenMatrix:wt,clippingData:Ot,scale:je,textPixelRatio:ve,holdingForFade:A.holdingForFade(),collisionBoxArray:le,partiallyEvaluatedTextSize:i.bK(z.textSizeData,this.transform.zoom,es),partiallyEvaluatedIconSize:i.bK(z.iconSizeData,this.transform.zoom,qs),collisionGroup:this.collisionGroups.get(z.sourceID),latestFeatureIndex:A.latestFeatureIndex};if(D)for(const Bt of z.sortKeyRanges){const{sortKey:as,symbolInstanceStart:Jt,symbolInstanceEnd:Is}=Bt;h.push({sortKey:as,symbolInstanceStart:Jt,symbolInstanceEnd:Is,parameters:Yt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:z.symbolInstances.length,parameters:Yt})}attemptAnchorPlacement(h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge,Ve,nt,ut,ot,Et){const{textOffset0:Nt,textOffset1:Tt,crossTileID:wt}=Pe,yt=[Nt,Tt],Ot=qd(h,z,W,yt,J),Wt=this.collisionIndex.placeCollisionBox(Ve,J,y,A,D,F,_l(Ot.x,Ot.y,ne,le,this.transform.angle),De,je,ve,Ne.predicate);if(ut){const Ht=Ve.getSymbolInstanceIconSize(Et,this.transform.zoom,Pe.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Ve,Ht,ut,A,D,F,_l(Ot.x,Ot.y,ne,le,this.transform.angle),De,je,ve,Ne.predicate).box.length===0)return}if(Wt.box.length>0){let Ht;return this.prevPlacement&&this.prevPlacement.variableOffsets[wt]&&this.prevPlacement.placements[wt]&&this.prevPlacement.placements[wt].text&&(Ht=this.prevPlacement.variableOffsets[wt].anchor),this.variableOffsets[wt]={textOffset:yt,width:z,height:W,anchor:h,textScale:J,prevAnchor:Ht},this.markUsedJustification(Ve,h,Pe,nt),Ve.allowVerticalPlacement&&(this.markUsedOrientation(Ve,nt,Pe),this.placedOrientations[wt]=nt),{shift:Ot,placedGlyphBoxes:Wt}}}placeLayerBucketPart(h,y,A,D,F=1){const{bucket:z,layout:W,paint:J,posMatrix:ne,textLabelPlaneMatrix:le,labelToScreenMatrix:je,clippingData:ve,textPixelRatio:Ne,mercatorCenter:De,invMatrix:Pe,holdingForFade:Ge,collisionBoxArray:Ve,partiallyEvaluatedTextSize:nt,partiallyEvaluatedIconSize:ut,collisionGroup:ot,latestFeatureIndex:Et}=h.parameters,Nt=W.get("text-optional"),Tt=W.get("icon-optional"),wt=W.get("text-allow-overlap"),yt=W.get("icon-allow-overlap"),Ot=W.get("text-rotation-alignment")==="map",Wt=W.get("icon-rotation-alignment")==="map",Ht=W.get("text-pitch-alignment")==="map",es=J.get("symbol-z-offset"),ts=W.get("symbol-elevation-reference")==="sea",xs=W.get("symbol-placement"),[qs,Yt]=W.get("text-size-scale-range"),[Bt,as]=W.get("icon-size-scale-range"),Jt=i.aA(F,qs,Yt),Is=i.aA(F,Bt,as),rr=W.get("text-variable-anchor"),yr=Ot&&xs!=="point",Js=Wt&&xs!=="point",Us=rr&&z.hasTextData(),Pr=z.hasIconTextFit()&&Us&&z.hasIconData();this.transform.setProjection(z.projection);const Cr=Us||yr,hr=Js||Pr;let br=wt&&(yt||!z.hasIconData()||Tt),Kr=yt&&(wt||!z.hasTextData()||Nt);const Pn=!es.isConstant();!z.collisionArrays&&Ve&&z.deserializeCollisionBoxes(Ve),A&&D&&z.updateCollisionDebugBuffers(this.transform.zoom,Ve,Jt,Is);const wa=(Or,Ka,Cn)=>{const{crossTileID:di,numVerticalGlyphVertices:Ci}=Or;let bi=null;if(ve&&ve.dynamicFilterNeedsFeature||Pn){const Lo=this.retainedQueryData[z.bucketInstanceId];bi=Et.loadFeature({featureIndex:Or.featureIndex,bucketIndex:Lo.bucketIndex,sourceLayerIndex:Lo.sourceLayerIndex,layoutVertexArrayOffset:0});const Jo=bi.properties?bi.properties.worldview:null;if(z.localizable&&z.worldview&&typeof Jo=="string")if(Jo==="all")bi.properties.$localized=!0;else{if(!Jo.split(",").includes(z.worldview))return;bi.properties.$localized=!0,bi.properties.worldview=z.worldview}}if(ve&&!(0,ve.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:z.worldview},bi,this.retainedQueryData[z.bucketInstanceId].tileID.canonical,new i.P(Or.tileAnchorX,Or.tileAnchorY),this.transform.calculateDistanceTileData(ve.unwrappedTileID)))return this.placements[di]=new pi(!1,!1,!1,!0),void y.add(di);const Ga=es.evaluate(bi,{});if(y.has(di))return;if(Ge)return void(this.placements[di]=new pi(!1,!1,!1));let Wn=!1,ii=!1,So=!0,no=!1,ui=!1,za=null,Gn={box:null,offscreen:null,occluded:null},Xi={box:null},Ho=null,_o=null,Di=null,Bu=0,Td=0,Ul=0;Cn.textFeatureIndex?Bu=Cn.textFeatureIndex:Or.useRuntimeCollisionCircles&&(Bu=Or.featureIndex),Cn.verticalTextFeatureIndex&&(Td=Cn.verticalTextFeatureIndex);const Vd=z.elevationFeatures?z.elevationFeatures[Or.elevationFeatureIndex]:void 0,Hd=Lo=>{Lo.tileID=this.retainedQueryData[z.bucketInstanceId].tileID;const Jo=this.transform.elevation;Lo.elevation=ts?Ga:Ga+i.bV.getAtTileOffset(Lo.tileID,new i.P(Lo.tileAnchorX,Lo.tileAnchorY),Jo,Vd),Lo.elevation+=Or.zOffset},od=Cn.textBox;if(od){Hd(od);const Lo=Oi=>{let ml=i.bL.horizontal;if(z.allowVerticalPlacement&&!Oi&&this.prevPlacement){const Co=this.prevPlacement.placedOrientations[di];Co&&(this.placedOrientations[di]=Co,ml=Co,this.markUsedOrientation(z,ml,Or))}return ml},Jo=(Oi,ml)=>{if(z.allowVerticalPlacement&&Ci>0&&Cn.verticalTextBox){for(const Co of z.writingModes)if(Co===i.bL.vertical?(Gn=ml(),Xi=Gn):Gn=Oi(),Gn&&Gn.box&&Gn.box.length)break}else Gn=Oi()};if(rr){let Oi=rr;if(this.prevPlacement&&this.prevPlacement.variableOffsets[di]){const wo=this.prevPlacement.variableOffsets[di];Oi.indexOf(wo.anchor)>0&&(Oi=Oi.filter(ip=>ip!==wo.anchor),Oi.unshift(wo.anchor))}const ml=(wo,ip,k2)=>{const Up=z.getSymbolInstanceTextSize(nt,Or,this.transform.zoom,Ka),S2=(wo.x2-wo.x1)*Up+2*wo.padding,bb=(wo.y2-wo.y1)*Up+2*wo.padding,Kf=Or.hasIconTextFit&&!yt?ip:null;Kf&&Hd(Kf);let mg={box:[],offscreen:!1,occluded:!1};const _b=wt?2*Oi.length:Oi.length;for(let Ry=0;Ry<_b;++Ry){const pg=this.attemptAnchorPlacement(Oi[Ry%Oi.length],wo,De,Pe,Cr,S2,bb,Up,Ot,Ht,Ne,ne,ot,Ry>=Oi.length,Or,Ka,z,k2,Kf,nt,ut);if(pg&&(mg=pg.placedGlyphBoxes,mg&&mg.box&&mg.box.length)){Wn=!0,za=pg.shift;break}}return mg};Jo(()=>ml(od,Cn.iconBox,i.bL.horizontal),()=>{const wo=Cn.verticalTextBox;return wo&&Hd(wo),z.allowVerticalPlacement&&!(Gn&&Gn.box&&Gn.box.length)&&Ci>0&&wo?ml(wo,Cn.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Gn&&(Wn=Gn.box,So=Gn.offscreen,no=Gn.occluded);const Co=Lo(!(!Gn||!Gn.box));if(!Wn&&this.prevPlacement){const wo=this.prevPlacement.variableOffsets[di];wo&&(this.variableOffsets[di]=wo,this.markUsedJustification(z,wo.anchor,Or,Co))}}else{const Oi=(ml,Co)=>{const wo=z.getSymbolInstanceTextSize(nt,Or,this.transform.zoom,Ka),ip=this.collisionIndex.placeCollisionBox(z,wo,ml,De,Pe,Cr,new i.P(0,0),wt,Ne,ne,ot.predicate);return ip&&ip.box&&ip.box.length&&(this.markUsedOrientation(z,Co,Or),this.placedOrientations[di]=Co),ip};Jo(()=>Oi(od,i.bL.horizontal),()=>{const ml=Cn.verticalTextBox;return z.allowVerticalPlacement&&Ci>0&&ml?(Hd(ml),Oi(ml,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),Lo(!!(Gn&&Gn.box&&Gn.box.length))}}if(Ho=Gn,Wn=Ho&&Ho.box&&Ho.box.length>0,So=Ho&&Ho.offscreen,no=Ho&&Ho.occluded,Or.useRuntimeCollisionCircles){const Lo=Or.centerJustifiedTextSymbolIndex>=0?Or.centerJustifiedTextSymbolIndex:Or.verticalPlacedTextSymbolIndex,Jo=z.text.placedSymbolArray.get(Lo),Oi=i.bM(z.textSizeData,nt,Jo),ml=W.get("text-padding");_o=this.collisionIndex.placeCollisionCircles(z,wt,Jo,Lo,z.lineVertexArray,z.glyphOffsetArray,Oi,ne,le,je,A,Ht,ot.predicate,Or.collisionCircleDiameter*Oi/i.bY,ml,this.retainedQueryData[z.bucketInstanceId].tileID),Wn=wt||_o.circles.length>0&&!_o.collisionDetected,So=So&&_o.offscreen,no=_o.occluded}if(Cn.iconFeatureIndex&&(Ul=Cn.iconFeatureIndex),Cn.iconBox){const Lo=Jo=>{Hd(Jo);const Oi=Or.hasIconTextFit&&za?_l(za.x,za.y,Ot,Ht,this.transform.angle):new i.P(0,0),ml=z.getSymbolInstanceIconSize(ut,this.transform.zoom,Or.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(z,ml,Jo,De,Pe,hr,Oi,yt,Ne,ne,ot.predicate)};Xi&&Xi.box&&Xi.box.length&&Cn.verticalIconBox?(Di=Lo(Cn.verticalIconBox),ii=Di.box.length>0):(Di=Lo(Cn.iconBox),ii=Di.box.length>0),So=So&&Di.offscreen,ui=Di.occluded}const hm=Nt||Or.numHorizontalGlyphVertices===0&&Ci===0,ap=Tt||Or.numIconVertices===0;if(hm||ap?ap?hm||(ii=ii&&Wn):Wn=ii&&Wn:ii=Wn=ii&&Wn,Wn&&Ho&&Ho.box&&this.collisionIndex.insertCollisionBox(Ho.box,W.get("text-ignore-placement"),z.bucketInstanceId,Xi&&Xi.box&&Td?Td:Bu,ot.ID),ii&&Di&&this.collisionIndex.insertCollisionBox(Di.box,W.get("icon-ignore-placement"),z.bucketInstanceId,Ul,ot.ID),_o&&(Wn&&this.collisionIndex.insertCollisionCircles(_o.circles,W.get("text-ignore-placement"),z.bucketInstanceId,Bu,ot.ID),A)){const Lo=z.bucketInstanceId;let Jo=this.collisionCircleArrays[Lo];Jo===void 0&&(Jo=this.collisionCircleArrays[Lo]=new LC);for(let Oi=0;Oi<_o.circles.length;Oi+=4)Jo.circles.push(_o.circles[Oi+0]),Jo.circles.push(_o.circles[Oi+1]),Jo.circles.push(_o.circles[Oi+2]),Jo.circles.push(_o.collisionDetected?1:0)}const mh=z.projection.name!=="globe";br=br&&(mh||!no),Kr=Kr&&(mh||!ui),this.placements[di]=new pi(Wn||br,ii||Kr,So||z.justReloaded),y.add(di)},si=this.retainedQueryData[z.bucketInstanceId].tileID;if(z.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(z,si),z.elevationType==="road"&&z.updateRoadElevation(si.canonical),z.updateZOffset(),z.sortFeaturesByY){const Or=z.getSortedSymbolIndexes(this.transform.angle);for(let Ka=Or.length-1;Ka>=0;--Ka){const Cn=Or[Ka];wa(z.symbolInstances.get(Cn),Cn,z.collisionArrays[Cn])}z.hasAnyZOffset&&i.w(`${z.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(z.hasAnyZOffset){const Or=z.getSortedIndexesByZOffset();for(let Ka=0;Ka=0&&(h.text.placedSymbolArray.get(F).crossTileID=je>=0&&F!==je?0:ne),z>=0&&(h.text.placedSymbolArray.get(z).crossTileID=je>=0&&z!==je?0:ne),W>=0&&(h.text.placedSymbolArray.get(W).crossTileID=je>=0&&W!==je?0:ne),J>=0&&(h.text.placedSymbolArray.get(J).crossTileID=je>=0&&J!==je?0:ne)}markUsedOrientation(h,y,A){const D=y===i.bL.horizontal||y===i.bL.horizontalOnly?y:0,F=y===i.bL.vertical?y:0,{leftJustifiedTextSymbolIndex:z,centerJustifiedTextSymbolIndex:W,rightJustifiedTextSymbolIndex:J,verticalPlacedTextSymbolIndex:ne}=A,le=h.text.placedSymbolArray;z>=0&&(le.get(z).placedOrientation=D),W>=0&&(le.get(W).placedOrientation=D),J>=0&&(le.get(J).placedOrientation=D),ne>=0&&(le.get(ne).placedOrientation=F)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const y=this.prevPlacement;let A=!1;this.prevZoomAdjustment=y?y.zoomAdjustment(this.transform.zoom):0;const D=y?y.symbolFadeChange(h):1,F=y?y.opacities:{},z=y?y.variableOffsets:{},W=y?y.placedOrientations:{};for(const J in this.placements){const ne=this.placements[J],le=F[J];le?(this.opacities[J]=new zf(le,D,ne.text,ne.icon,null,ne.clipped),A=A||ne.text!==le.text.placed||ne.icon!==le.icon.placed):(this.opacities[J]=new zf(null,D,ne.text,ne.icon,ne.skipFade,ne.clipped),A=A||ne.text||ne.icon)}for(const J in F){const ne=F[J];if(!this.opacities[J]){const le=new zf(ne,D,!1,!1);le.isHidden()||(this.opacities[J]=le,A=A||ne.text.placed||ne.icon.placed)}}for(const J in z)this.variableOffsets[J]||!this.opacities[J]||this.opacities[J].isHidden()||(this.variableOffsets[J]=z[J]);for(const J in W)this.placedOrientations[J]||!this.opacities[J]||this.opacities[J].isHidden()||(this.placedOrientations[J]=W[J]);A?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=y?y.lastPlacementChangeTime:h)}updateLayerOpacities(h,y,A,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const F=new Set;for(const z of y){const W=z.getBucket(h);W&&z.latestFeatureIndex&&h.fqid===W.layerIds[0]&&(this.updateBucketOpacities(W,F,z,z.collisionBoxArray,A,D,z.tileID,h.scope),W.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(W,z.tileID),W.elevationType==="road"&&W.updateRoadElevation(z.tileID.canonical),W.updateZOffset())}}updateBucketOpacities(h,y,A,D,F,z,W,J){h.hasTextData()&&h.text.opacityVertexArray.clear(),h.hasIconData()&&h.icon.opacityVertexArray.clear(),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexArray.clear(),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexArray.clear();const ne=h.layers[0].layout,le=h.layers[0].paint,je=!!h.layers[0].dynamicFilter(),ve=new zf(null,0,!1,!1,!0),Ne=ne.get("text-allow-overlap"),De=ne.get("icon-allow-overlap"),Pe=ne.get("text-variable-anchor"),Ge=ne.get("text-rotation-alignment")==="map",Ve=ne.get("text-pitch-alignment")==="map",nt=le.get("symbol-z-offset"),ut=ne.get("symbol-elevation-reference")==="sea",ot=!nt.isConstant(),Et=new zf(null,0,Ne&&(De||!h.hasIconData()||ne.get("icon-optional")),De&&(Ne||!h.hasTextData()||ne.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const Nt=(wt,yt,Ot)=>{for(let Wt=0;Wt0||Wt>0,rr=es>0,yr=this.placedOrientations[Ht],Js=yr===i.bL.vertical,Us=yr===i.bL.horizontal||yr===i.bL.horizontalOnly;!Is&&!rr||Jt.isHidden()||Tt++;let Pr=!1;if((Is||rr)&&z)for(const Cr of h.activeReplacements){if(i.bZ(Cr,F,i.b_.Symbol,J)||Cr.min.x>ts||ts>Cr.max.x||Cr.min.y>xs||xs>Cr.max.y)continue;const hr=i.b$(ts,xs,W.canonical,Cr.footprintTileId.canonical);if(Pr=i.c0(hr,Cr.footprint),Pr)break}if(Is){const Cr=Pr?sv:Ou(Jt.text);Nt(h.text,Ot,Js?sv:Cr),Nt(h.text,Wt,Us?sv:Cr);const hr=Jt.text.isHidden(),{leftJustifiedTextSymbolIndex:br,centerJustifiedTextSymbolIndex:Kr,rightJustifiedTextSymbolIndex:Pn,verticalPlacedTextSymbolIndex:wa}=yt,si=h.text.placedSymbolArray,Or=hr||Js?1:0;br>=0&&(si.get(br).hidden=Or),Kr>=0&&(si.get(Kr).hidden=Or),Pn>=0&&(si.get(Pn).hidden=Or),wa>=0&&(si.get(wa).hidden=hr||Us?1:0);const Ka=this.variableOffsets[Ht];Ka&&this.markUsedJustification(h,Ka.anchor,yt,yr);const Cn=this.placedOrientations[Ht];Cn&&(this.markUsedJustification(h,"left",yt,Cn),this.markUsedOrientation(h,Cn,yt))}if(rr){const Cr=Pr?sv:Ou(Jt.icon),{placedIconSymbolIndex:hr,verticalPlacedIconSymbolIndex:br}=yt,Kr=h.icon.placedSymbolArray,Pn=Jt.icon.isHidden()?1:0;hr>=0&&(Nt(h.icon,es,Js?sv:Cr),Kr.get(hr).hidden=Pn),br>=0&&(Nt(h.icon,yt.numVerticalIconVertices,Us?sv:Cr),Kr.get(br).hidden=Pn)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const Cr=h.collisionArrays[wt];if(Cr){let hr=new i.P(0,0),br=!0;if(Cr.textBox||Cr.verticalTextBox){if(Pe){const Pn=this.variableOffsets[Ht];Pn?(hr=qd(Pn.anchor,Pn.width,Pn.height,Pn.textOffset,Pn.textScale),Ge&&hr._rotate(Ve?this.transform.angle:-this.transform.angle)):br=!1}je&&(br=!Jt.clipped),Cr.textBox&&wy(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!br||Js,Bt,ut,hr.x,hr.y),Cr.verticalTextBox&&wy(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!br||Us,Bt,ut,hr.x,hr.y)}const Kr=br&&!!(!Us&&Cr.verticalIconBox);Cr.iconBox&&wy(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,Kr,Bt,ut,yt.hasIconTextFit?hr.x:0,yt.hasIconTextFit?hr.y:0),Cr.verticalIconBox&&wy(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,!Kr,Bt,ut,yt.hasIconTextFit?hr.x:0,yt.hasIconTextFit?hr.y:0)}}}if(h.fullyClipped=Tt===0,h.sortFeatures(this.transform.angle),this.retainedQueryData[h.bucketInstanceId]&&(this.retainedQueryData[h.bucketInstanceId].featureSortOrder=h.featureSortOrder),h.hasTextData()&&h.text.opacityVertexBuffer&&h.text.opacityVertexBuffer.updateData(h.text.opacityVertexArray),h.hasIconData()&&h.icon.opacityVertexBuffer&&h.icon.opacityVertexBuffer.updateData(h.icon.opacityVertexArray),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexBuffer&&h.iconCollisionBox.collisionVertexBuffer.updateData(h.iconCollisionBox.collisionVertexArray),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexBuffer&&h.textCollisionBox.collisionVertexBuffer.updateData(h.textCollisionBox.collisionVertexArray),h.bucketInstanceId in this.collisionCircleArrays){const wt=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=wt.invProjMatrix,h.placementViewportMatrix=wt.viewportMatrix,h.collisionCircleArray=wt.circles,delete this.collisionCircleArrays[h.bucketInstanceId]}}symbolFadeChange(h){return this.fadeDuration===0?1:(h-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(h){return Math.max(0,(this.transform.zoom-h)/1.5)}hasTransitions(h){return this.stale||h-this.lastPlacementChangeTimeh}isStale(){return this.stale}setStale(){this.stale=!0}}function wy(T,h,y,A,D,F,z){T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0),T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0),T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0),T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0)}const BE=Math.pow(2,25),Qw=Math.pow(2,24),DC=Math.pow(2,17),$E=Math.pow(2,16),OC=Math.pow(2,9),Du=Math.pow(2,8),eg=Math.pow(2,1);function Ou(T){if(T.opacity===0&&!T.placed)return 0;if(T.opacity===1&&T.placed)return 4294967295;const h=T.placed?1:0,y=Math.floor(127*T.opacity);return y*BE+h*Qw+y*DC+h*$E+y*OC+h*Du+y*eg+h}const sv=0;class X1{constructor(h){this._sortAcrossTiles=h.layout.get("symbol-z-order")!=="viewport-y"&&h.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(h,y,A,D,F,z){const W=this._bucketParts;for(;this._currentTileIndexJ.sortKey-ne.sortKey));this._currentPartIndex{const J=i.o.now()-z;return!this._forceFullPlacement&&J>2};for(;this._currentPlacementIndex>=0;){const J=y[h[this._currentPlacementIndex]],ne=this.placement.collisionIndex.transform.zoom;if(J.type==="symbol"&&J.visibility!=="none"&&(!J.minzoom||J.minzoom<=ne)&&(!J.maxzoom||J.maxzoom>ne)){const le=J,je=le.layout.get("symbol-z-elevate"),ve=le.layout.get("symbol-sort-key").constantOr(1)!==void 0,Ne=le.layout.get("symbol-z-order"),De=Ne==="viewport-y"||Ne==="auto"&&!(Ne!=="viewport-y"&&ve),Pe=le.layout.get("text-allow-overlap")||le.layout.get("icon-allow-overlap")||le.layout.get("text-ignore-placement")||le.layout.get("icon-ignore-placement"),Ge=De&&Pe,Ve=this._inProgressLayer=this._inProgressLayer||new X1(le),nt=i.B(J.source,J.scope);if(Ve.continuePlacement(je||Ge?D[nt]:A[nt],this.placement,this._showCollisionBoxes,J,W,F))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const Jm=512/i.al/2;class tg{constructor(h,y,A){this.tileID=h,this.bucketInstanceId=A,this.index=new i.c4(y.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const D=h.canonical.x*i.al,F=h.canonical.y*i.al;for(let z=0;zGe-Ve);for(const Ge of Pe){const Ve=this.crossTileIDs[Ge];if(this.keys[Ge]===le&&!A.has(Ve)){A.add(Ve),ne.crossTileID=Ve;break}}}}}class cc{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class qE{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(h){const y=Math.round((h-this.lng)/360);if(y!==0)for(const A in this.indexes){const D=this.indexes[A],F={};for(const z in D){const W=D[z];W.tileID=W.tileID.unwrapTo(W.tileID.wrap+y),F[W.tileID.key]=W}this.indexes[A]=F}this.lng=h}addBucket(h,y,A){if(this.indexes[h.overscaledZ]&&this.indexes[h.overscaledZ][h.key]){if(this.indexes[h.overscaledZ][h.key].bucketInstanceId===y.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(h.overscaledZ,this.indexes[h.overscaledZ][h.key])}for(let F=0;Fh.overscaledZ)for(const W in z){const J=z[W];J.tileID.isChildOf(h)&&J.findMatches(y.symbolInstances,h,D)}else{const W=z[h.scaledTo(Number(F)).key];W&&W.findMatches(y.symbolInstances,h,D)}}for(let F=0;F{y[A]=!0});for(const A in this.layerIndexes)y[A]||delete this.layerIndexes[A]}}const Bf=771;class Hn{constructor(h,y,A,D){this.blendFunction=h,this.blendColor=y.toNonPremultipliedRenderColor(null),this.mask=A,this.blendEquation=D}}Hn.Replace=[1,0,1,0],Hn.disabled=new Hn(Hn.Replace,i.ao.transparent,[!1,!1,!1,!1]),Hn.unblended=new Hn(Hn.Replace,i.ao.transparent,[!0,!0,!0,!0]),Hn.alphaBlended=new Hn([1,Bf,1,Bf],i.ao.transparent,[!0,!0,!0,!0]),Hn.alphaBlendedNonPremultiplied=new Hn([770,Bf,770,Bf],i.ao.transparent,[!0,!0,!0,!0]),Hn.multiply=new Hn([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),Hn.additive=new Hn([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Fr{constructor(h,y,A){this.func=h,this.mask=y,this.range=A}}Fr.ReadOnly=!1,Fr.ReadWrite=!0,Fr.disabled=new Fr(519,Fr.ReadOnly,[0,1]);const RC=7680;class yn{constructor(h,y,A,D,F,z){this.test=h,this.ref=y,this.mask=A,this.fail=D,this.depthFail=F,this.pass=z}}yn.disabled=new yn({func:519,mask:0},0,0,RC,RC,RC);const Q1=1029,FC=2305;class mn{constructor(h,y,A){this.enable=h,this.mode=y,this.frontFace=A}}function $f(T,h){const y=i.ca(T,3);i.cc(T,h),i.cg(T,3,y)}function UE(T,h){const y=i.c7([]);return i.c8(y,y,-h),i.c9(y,y,-T),y}function zC(T,h){const y=[T[0],T[1],0],A=[h[0],h[1],0];if(i.ag(y)>=1e-15){const z=i.aw([],y);i.c5(A,z,i.bJ(A,z)),h[0]=A[0],h[1]=A[1]}const D=i.bI([],h,T);if(i.c6(D)<1e-15)return null;const F=Math.atan2(-D[1],D[0]);return UE(Math.atan2(Math.sqrt(T[0]*T[0]+T[1]*T[1]),-T[2]),F)}mn.disabled=new mn(!1,Q1,FC),mn.backCCW=new mn(!0,Q1,FC),mn.backCW=new mn(!0,Q1,2304),mn.frontCW=new mn(!0,1028,2304),mn.frontCCW=new mn(!0,1028,FC);class Ru{constructor(h,y){this.position=h,this.orientation=y}get position(){return this._position}set position(h){if(h){const y=h instanceof i.ae?h:new i.ae(h[0],h[1],h[2]);this._renderWorldCopies&&(y.x=i.bT(y.x,0,1)),this._position=y}else this._position=null}lookAtPoint(h,y,A){if(this.orientation=null,!this.position)return;const D=this.position,F=A||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(h)):0),z=i.ae.fromLngLat(h,F),W=[z.x-D.x,z.y-D.y,z.z-D.z];y||(y=[0,0,1]),y[2]=Math.abs(y[2]),this.orientation=zC(W,y)}setPitchBearing(h,y){this.orientation=UE(i.an(h),i.an(-y))}}class BC{constructor(h,y){this._transform=i.bA([]),this.orientation=y,this.position=h}get mercatorPosition(){const h=this.position;return new i.ae(h[0],h[1],h[2])}get position(){const h=i.ca(this._transform,3);return[h[0],h[1],h[2]]}set position(h){var y;h&&i.cg(this._transform,3,[(y=h)[0],y[1],y[2],1])}get orientation(){return this._orientation}set orientation(h){this._orientation=h||i.c7([]),h&&$f(this._transform,this._orientation)}getPitchBearing(){const h=this.forward(),y=this.right();return{bearing:Math.atan2(-y[1],y[0]),pitch:Math.atan2(Math.sqrt(h[0]*h[0]+h[1]*h[1]),-h[2])}}setPitchBearing(h,y){this._orientation=UE(h,y),$f(this._transform,this._orientation)}forward(){const h=i.ca(this._transform,2);return[-h[0],-h[1],-h[2]]}up(){const h=i.ca(this._transform,1);return[-h[0],-h[1],-h[2]]}right(){const h=i.ca(this._transform,0);return[h[0],h[1],h[2]]}getCameraToWorld(h,y){const A=new Float64Array(16);return i.bl(A,this.getWorldToCamera(h,y)),A}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(h,y,A){const D=this.position;i.c5(D,D,-h);const F=new Float64Array(16);return i.bq(F,[A,A,A]),i.br(F,F,D),F[10]*=y,F}getWorldToCamera(h,y){const A=new Float64Array(16),D=new Float64Array(4),F=this.position;return i.cb(D,this._orientation),i.c5(F,F,-h),i.cc(A,D),i.br(A,A,F),A[1]*=-1,A[5]*=-1,A[9]*=-1,A[13]*=-1,A[8]*=y,A[9]*=y,A[10]*=y,A[11]*=y,A}getCameraToClipPerspective(h,y,A,D){const F=new Float64Array(16);return i.cd(F,h,y,A,D),F}getCameraToClipOrthographic(h,y,A,D,F,z){const W=new Float64Array(16);return i.ce(W,h,y,A,D,F,z),W}getDistanceToElevation(h,y=!1){const A=h===0?0:i.cf(h,y?i.a$(this.position[1]):this.position[1]),D=this.forward();return(A-this.position[2])/D[2]}clone(){return new BC([...this.position],[...this.orientation])}}const Gc={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class $C{constructor(h=0,y=0,A=0,D=0){if(isNaN(h)||h<0||isNaN(y)||y<0||isNaN(A)||A<0||isNaN(D)||D<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=h,this.bottom=y,this.left=A,this.right=D}interpolate(h,y,A){return y.top!=null&&h.top!=null&&(this.top=i.ak(h.top,y.top,A)),y.bottom!=null&&h.bottom!=null&&(this.bottom=i.ak(h.bottom,y.bottom,A)),y.left!=null&&h.left!=null&&(this.left=i.ak(h.left,y.left,A)),y.right!=null&&h.right!=null&&(this.right=i.ak(h.right,y.right,A)),this}getCenter(h,y){const A=i.aA((this.left+h-this.right)/2,0,h),D=i.aA((this.top+y-this.bottom)/2,0,y);return new i.P(A,D)}equals(h){return this.top===h.top&&this.bottom===h.bottom&&this.left===h.left&&this.right===h.right}clone(){return new $C(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const zp=15;class VE{constructor(h,y,A,D,F,z,W){this.tileSize=512,this._renderWorldCopies=F===void 0||F,this._minZoom=h||0,this._maxZoom=y||22,this._minPitch=A??0,this._maxPitch=D??60,this.setProjection(z),this.setMaxBounds(W),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 $C,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new BC,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1}clone(){const h=new VE(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return h._elevation=this._elevation,h._centerAltitude=this._centerAltitude,h._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,h.tileSize=this.tileSize,h.mercatorFromTransition=this.mercatorFromTransition,h.width=this.width,h.height=this.height,h.cameraElevationReference=this.cameraElevationReference,h._center=this._center,h._setZoom(this.zoom),h._seaLevelZoom=this._seaLevelZoom,h.angle=this.angle,h._fov=this._fov,h._pitch=this._pitch,h._nearZ=this._nearZ,h._farZ=this._farZ,h._averageElevation=this._averageElevation,h._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,h._unmodified=this._unmodified,h._edgeInsets=this._edgeInsets.clone(),h._camera=this._camera.clone(),h._calcMatrices(),h.freezeTileCoverage=this.freezeTileCoverage,h.frustumCorners=this.frustumCorners,h._allowWorldUnderZoom=this._allowWorldUnderZoom,h}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||h===Number.NEGATIVE_INFINITY&&(!y||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const A=this._elevation;y||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&A.exaggeration()&&this._centerAltitudeValidForExaggeration!==A.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*A.exaggeration(),this._centerAltitudeValidForExaggeration=A.exaggeration()):(this._centerAltitude=h||0,this._centerAltitudeValidForExaggeration=A.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const h=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(h)}sampleAverageElevation(){if(!this._elevation)return 0;const h=this._elevation,y=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],A=this.horizonLineFromTop();let D=0,F=0;for(let z=0;z{const Ge=i.cY(ve,je,Ne,De,Pe);J.has(Ge)||(F.push(new i.aQ(je,ve,Ne,De,Pe)),J.add(Ge))};for(let je=0;jeve.canonical.z)continue;const Ne=ve.canonical,De=ve.overscaledZ,Pe=ve.wrap,Ge=1<0,ut=Ne.y+10,Et=ve.wrap-(nt?0:1),Nt=ve.wrap+(Ve?0:1),Tt=nt?Ne.x-1:Ge-1,wt=Ve?Ne.x+1:0;if(z)A[0]<0?(ne(De,Nt,Ne.z,wt,Ne.y),A[1]<0&&ut&&(ne(De,Pe,Ne.z,Ne.x,Ne.y+1),ne(De,Nt,Ne.z,wt,Ne.y+1)),A[1]>0&&ot&&(ne(De,Pe,Ne.z,Ne.x,Ne.y-1),ne(De,Nt,Ne.z,wt,Ne.y-1))):A[0]>0?(ne(De,Et,Ne.z,Tt,Ne.y),A[1]<0&&ut&&(ne(De,Pe,Ne.z,Ne.x,Ne.y+1),ne(De,Et,Ne.z,Tt,Ne.y+1)),A[1]>0&&ot&&(ne(De,Pe,Ne.z,Ne.x,Ne.y-1),ne(De,Et,Ne.z,Tt,Ne.y-1))):A[1]<0&&ut?ne(De,Pe,Ne.z,Ne.x,Ne.y+1):ot&&ne(De,Pe,Ne.z,Ne.x,Ne.y-1);else{const yt=ve.visibleQuadrants;1&yt&&(ne(De,Et,Ne.z,Tt,Ne.y),ot&&(ne(De,Pe,Ne.z,Ne.x,Ne.y-1),ne(De,Et,Ne.z,Tt,Ne.y-1))),2&yt&&(ne(De,Nt,Ne.z,wt,Ne.y),ot&&(ne(De,Pe,Ne.z,Ne.x,Ne.y-1),ne(De,Nt,Ne.z,wt,Ne.y-1))),4&yt&&(ne(De,Et,Ne.z,Tt,Ne.y),ut&&(ne(De,Pe,Ne.z,Ne.x,Ne.y+1),ne(De,Et,Ne.z,Tt,Ne.y+1))),8&yt&&(ne(De,Nt,Ne.z,wt,Ne.y),ut&&(ne(De,Pe,Ne.z,Ne.x,Ne.y+1),ne(De,Nt,Ne.z,wt,Ne.y+1)))}}const le=[];for(const je of F)F.some(ve=>je.isChildOf(ve))||le.push(je);if(F=le.filter(je=>!h.some(ve=>!!(je.overscaledZ{const Ve=Ge.canonical.x+.5-Ne[0],nt=Ge.canonical.y+.5-Ne[1];return Ve*Ve+nt*nt{const Tt=i.cY(ut,nt,ot,Et,Nt);F.has(Tt)||(D.push(new i.aQ(nt,ut,ot,Et,Nt)),F.add(Tt))},W=h.reduce((nt,ut)=>Math.max(nt,ut.overscaledZ),A),J=1<{const ot=Math.floor(nt[0]),Et=Math.floor(nt[1]),Nt=(nt[0]-ot)*i.al,Tt=(nt[1]-Et)*i.al,wt=Math.floor(ut[0]),yt=Math.floor(ut[1]),Ot=(ut[0]-wt)*i.al,Wt=(ut[1]-yt)*i.al;for(let Ht=-1;Ht<=1;Ht++){const es=ot+Ht;if(!(es<0||es>=J)){le.x=Nt-Ht*i.al,je.x=Ot-(es-wt)*i.al;for(let ts=-1;ts<=1;ts++){const xs=Et+ts;le.y=Tt-ts*i.al,je.y=Wt-(xs-yt)*i.al,i.cZ(le,je,ne)&&z(W,0,A,es,xs)}}}},Ne=y.points,De=Ne[i.cv],Pe=Ne[i.cw],Ge=this._projectToGround(De,Ne[i.cx]),Ve=this._projectToGround(Pe,Ne[i.cy]);return ve(De,Ge),ve(Pe,Ve),D}_projectToGround(h,y){return i.cz(i.cA(),h,y,h[2]/(h[2]-y[2]))}coveringTiles(h){let y=this.coveringZoomLevel(h);const A=y,D=this.elevation&&this.elevation.exaggeration(),F=D&&!h.isTerrainDEM,z=this.projection.name==="mercator";if(h.minzoom!==void 0&&yh.maxzoom&&(y=h.maxzoom);const W=this.locationCoordinate(this.center),J=this.center.lat,ne=1<{const Jt=new i.ae(Bt.x+25e-6,Bt.y,Bt.z),Is=new i.ae(Bt.x,Bt.y+25e-6,Bt.z),rr=Bt.toLngLat(),yr=Jt.toLngLat(),Js=Is.toLngLat(),Us=this.locationCoordinate(rr),Pr=this.locationCoordinate(yr),Cr=this.locationCoordinate(Js),hr=Math.hypot(Pr.x-Us.x,Pr.y-Us.y),br=Math.hypot(Cr.x-Us.x,Cr.y-Us.y);return Math.sqrt(hr*br)*Tt/25e-6},yt=Bt=>{const as=Et,Jt=Nt;return{aabb:i.cF(this,ne,0,0,0,Bt,Jt,as,this.projection),zoom:0,x:0,y:0,minZ:Jt,maxZ:as,wrap:Bt,fullyVisible:!1}},Ot=[];let Wt=[];const Ht=y,es=h.reparseOverscaled?A:y,ts=(Ge-this._centerAltitude)*Pe,xs=Bt=>{if(!this._elevation||!Bt.tileID||!z)return;const as=this._elevation.getMinMaxForTile(Bt.tileID),Jt=Bt.aabb;as?(Jt.min[2]=as.min,Jt.max[2]=as.max,Jt.center[2]=(Jt.min[2]+Jt.max[2])/2):(Bt.shouldSplit=Yt(Bt),Bt.shouldSplit||(Jt.min[2]=Jt.max[2]=Jt.center[2]=this._centerAltitude))},qs=(Bt,as)=>{if(.707*as{if(Bt.zoom=.9)return!0}else if(F&&(Is=Bt.aabb.distanceZ(Ve)*Pe),this.projection.isReprojectedInTileSpace&&A<=5){const br=Math.pow(2,Bt.zoom),Kr=wt(new i.ae((Bt.x+.5)/br,(Bt.y+.5)/br));rr=Kr>.85?1:Kr}if(!z&&!je){const br=Math.sqrt(as*as+Jt*Jt+Is*Is);let Kr=(1<0;){const Bt=Ot.pop(),as=Bt.x,Jt=Bt.y;let Is=Bt.fullyVisible;const rr=()=>this.projection.name==="globe"&&(Bt.y===0||Bt.y===(1<>1),Pr={aabb:z?Bt.aabb.quadrant(yr):i.cF(this,ne,Bt.zoom+1,Js,Us,Bt.wrap,Bt.minZ,Bt.maxZ,this.projection),zoom:Bt.zoom+1,x:Js,y:Us,wrap:Bt.wrap,fullyVisible:Is,tileID:void 0,shouldSplit:void 0,minZ:Bt.minZ,maxZ:Bt.maxZ};F&&!je&&(Pr.tileID=new i.aQ(Bt.zoom+1===Ht?es:Bt.zoom+1,Bt.wrap,Bt.zoom+1,Js,Us),xs(Pr)),Ot.push(Pr)}else{const yr=Bt.zoom===Ht?es:Bt.zoom;if(h.minzoom&&h.minzoom>yr)continue;let Js=0;if(!Is){let hr=nt?Bt.aabb.intersectsPrecise(Ne):Bt.aabb.intersectsPreciseFlat(Ne);if(hr===0&&rr()){const br=new i.cD(Bt.zoom,as,Jt);hr=i.cE(this,ne,br,!0).intersectsPrecise(Ne)}if(hr===0)continue;if(h.calculateQuadrantVisibility)if(Ne.containsPoint(Bt.aabb.center))Js=15;else for(let br=0;br<4;br++)Bt.aabb.quadrant(br).intersects(Ne)!==0&&(Js|=1<{const Is=[0,0,0,1],rr=[i.al,i.al,0,1],yr=this.calculateFogTileMatrix(Jt.tileID.toUnwrapped());i.aC(Is,Is,yr),i.aC(rr,rr,yr);const Js=i.cG([],Is,rr),Us=i.cH([],Is,rr),Pr=i.c$(Js,Us);if(Pr===0)return!0;let Cr=!1;const hr=this._elevation;if(hr&&Pr>Bt&&as!==0){const br=this.calculateProjMatrix(Jt.tileID.toUnwrapped());let Kr;h.isTerrainDEM||(Kr=hr.getMinMaxForTile(Jt.tileID)),Kr||(Kr={min:Nt,max:Et});const Pn=i.cI(this.rotation),wa=[Pn[0]*i.al,Pn[1]*i.al,Kr.max];i.af(wa,wa,br),Cr=(1-wa[1])*this.height*.5Bt.distanceSq-as.distanceSq).map(Bt=>Bt.tileID)}resize(h,y){this.width=h,this.height=y,this.pixelsToGLUnits=[2/h,-2/y],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(h){return Math.pow(2,h)}scaleZoom(h){return Math.log2(h)}project(h){const y=i.aA(h.lat,-i.cJ,i.cJ),A=this.projection.project(h.lng,y);return new i.P(A.x*this.worldSize,A.y*this.worldSize)}unproject(h){return this.projection.unproject(h.x/this.worldSize,h.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/i.cf(1,this.center.lat)/this.worldSize}setLocationAtPoint(h,y){let A,D;const F=this.centerPoint;if(this.projection.name==="globe"){const W=this.worldSize;A=(y.x-F.x)/W,D=(y.y-F.y)/W}else{const W=this.pointCoordinate(y),J=this.pointCoordinate(F);A=W.x-J.x,D=W.y-J.y}const z=this.locationCoordinate(h);this.setLocation(new i.ae(z.x-A,z.y-D))}setLocation(h){this.center=this.coordinateLocation(h),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(h,y){return this.projection.locationPoint(this,h,y)}locationPoint3D(h,y){return this.projection.locationPoint(this,h,y,!0)}pointLocation(h){return this.coordinateLocation(this.pointCoordinate(h))}pointLocation3D(h,y){return this.coordinateLocation(this.pointCoordinate3D(h,y))}locationCoordinate(h,y){const A=y?i.cf(y,h.lat):void 0,D=this.projection.project(h.lng,h.lat);return new i.ae(D.x,D.y,A)}coordinateLocation(h){return this.projection.unproject(h.x,h.y)}pointRayIntersection(h,y){const A=y??this._centerAltitude,D=[h.x,h.y,0,1],F=[h.x,h.y,1,1];i.aC(D,D,this.pixelMatrixInverse),i.aC(F,F,this.pixelMatrixInverse);const z=F[3];i.cK(D,D,1/D[3]),i.cK(F,F,1/z);const W=D[2],J=F[2];return{p0:D,p1:F,t:W===J?0:(A-W)/(J-W)}}screenPointToMercatorRay(h){const y=[h.x,h.y,0,1],A=[h.x,h.y,1,1];return i.aC(y,y,this.pixelMatrixInverse),i.aC(A,A,this.pixelMatrixInverse),i.cK(y,y,1/y[3]),i.cK(A,A,1/A[3]),y[2]=i.cf(y[2],this._center.lat)*this.worldSize,A[2]=i.cf(A[2],this._center.lat)*this.worldSize,i.cK(y,y,1/this.worldSize),i.cK(A,A,1/this.worldSize),new i.ax([y[0],y[1],y[2]],i.aw([],i.av([],A,y)))}rayIntersectionCoordinate(h){const{p0:y,p1:A,t:D}=h,F=i.cf(y[2],this._center.lat),z=i.cf(A[2],this._center.lat);return new i.ae(i.ak(y[0],A[0],D)/this.worldSize,i.ak(y[1],A[1],D)/this.worldSize,i.ak(F,z,D))}pointCoordinate(h,y=this._centerAltitude){return this.projection.pointCoordinate(this,h.x,h.y,y)}pointCoordinate3D(h,y){if(!this.elevation)return this.pointCoordinate(h,y);let A=this.projection.pointCoordinate3D(this,h.x,h.y);if(A)return new i.ae(A[0],A[1],A[2]);let D=0,F=this.horizonLineFromTop();if(h.y>F)return this.pointCoordinate(h,y);const z=.02*F,W=h.clone();for(let J=0;J<10&&F-D>z;J++){W.y=i.ak(D,F,.66);const ne=this.projection.pointCoordinate3D(this,W.x,W.y);ne?(F=W.y,A=ne):D=W.y}return A?new i.ae(A[0],A[1],A[2]):this.pointCoordinate(h)}isPointAboveHorizon(h){return this.projection.isPointAboveHorizon(this,h)}isPointOnSurface(h){if(h.y<0||h.y>this.height||h.x<0||h.x>this.width)return!1;if(this.elevation||this.zoom>=i.cL)return!this.isPointAboveHorizon(h);const y=this.pointCoordinate(h);return y.y>=0&&y.y<=1}_coordinatePoint(h,y){const A=y&&this.elevation?this.elevation.getAtPointOrZero(h,this._centerAltitude):this._centerAltitude,D=[h.x*this.worldSize,h.y*this.worldSize,A+h.toAltitude(),1];return i.aC(D,D,this.pixelMatrix),D[3]>0?new i.P(D[0]/D[3],D[1]/D[3]):new i.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:h,left:y}=this._edgeInsets,A=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,F=this.pointLocation3D(new i.P(y,h)),z=this.pointLocation3D(new i.P(D,h)),W=this.pointLocation3D(new i.P(D,A)),J=this.pointLocation3D(new i.P(y,A));let ne=Math.min(F.lng,z.lng,W.lng,J.lng),le=Math.max(F.lng,z.lng,W.lng,J.lng),je=Math.min(F.lat,z.lat,W.lat,J.lat),ve=Math.max(F.lat,z.lat,W.lat,J.lat);const Ne=Math.pow(2,-this.zoom)/16*270,De=this.projection.name==="globe"?1:4,Pe=(Ge,Ve,nt,ut,ot)=>{const Et=(Ge+nt)/2,Nt=(Ve+ut)/2,Tt=new i.P(Et,Nt),{lng:wt,lat:yt}=this.pointLocation3D(Tt),Ot=Math.max(0,ne-wt,je-yt,wt-le,yt-ve);ne=Math.min(ne,wt),le=Math.max(le,wt),je=Math.min(je,yt),ve=Math.max(ve,yt),(otNe)&&(Pe(Ge,Ve,Et,Nt,ot+1),Pe(Et,Nt,nt,ut,ot+1))};if(Pe(y,h,D,h,1),Pe(D,h,D,A,1),Pe(D,A,y,A,1),Pe(y,A,y,h,1),this.projection.name==="globe"){const[Ge,Ve]=i.cM(this);Ge?(ve=90,le=180,ne=-180):Ve&&(je=-90,le=180,ne=-180)}return new i.aI(new i.aT(ne,je),new i.aT(le,ve))}_getBoundsRectangular(h,y){const{top:A,left:D}=this._edgeInsets,F=this.height-this._edgeInsets.bottom,z=this.width-this._edgeInsets.right,W=new i.P(D,A),J=new i.P(z,A),ne=new i.P(z,F),le=new i.P(D,F);let je=this.pointCoordinate(W,h),ve=this.pointCoordinate(J,h);const Ne=this.pointCoordinate(ne,y),De=this.pointCoordinate(le,y),Pe=(Ge,Ve)=>(Ve.y-Ge.y)/(Ve.x-Ge.x);return je.y>1&&ve.y>=0?je=new i.ae((1-De.y)/Pe(De,je)+De.x,1):je.y<0&&ve.y<=1&&(je=new i.ae(-De.y/Pe(De,je)+De.x,0)),ve.y>1&&je.y>=0?ve=new i.ae((1-Ne.y)/Pe(Ne,ve)+Ne.x,1):ve.y<0&&je.y<=1&&(ve=new i.ae(-Ne.y/Pe(Ne,ve)+Ne.x,0)),new i.aI().extend(this.coordinateLocation(je)).extend(this.coordinateLocation(ve)).extend(this.coordinateLocation(De)).extend(this.coordinateLocation(Ne))}_getBoundsRectangularTerrain(){const h=this.elevation;if(!h.visibleDemTiles.length||h.isUsingMockSource())return this._getBoundsRectangular(0,0);const y=h.visibleDemTiles.reduce((A,D)=>{if(D.dem){const F=D.dem.tree;A.min=Math.min(A.min,F.minimums[0]),A.max=Math.max(A.max,F.maximums[0])}return A},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(y.min*h.exaggeration(),y.max*h.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(h=!0){const y=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,A=this.height/2-y*(1-this._horizonShift);return h?Math.max(0,A):A}getMaxBounds(){return this.maxBounds}setMaxBounds(h){this.maxBounds=h,this.minLat=-i.cJ,this.maxLat=i.cJ,this.minLng=-180,this.maxLng=180,h&&(this.minLat=h.getSouth(),this.maxLat=h.getNorth(),this.minLng=h.getWest(),this.maxLng=h.getEast(),this.maxLngje&&(W=je-ne),je-leNe&&(z=Ne-J),Ne-ve{for(let Yt=0;Yt<16;Yt++)es[Yt]=i.ak(ts[Yt],xs[Yt],qs)})(W,W,J,i.d0(this.pitch>=zp?1:this.pitch/zp))}else W=J;const ne=i.cP([],J,z);let le=i.cP([],W,z);if(this.projection.isReprojectedInTileSpace){const yt=this.locationCoordinate(this.center),Ot=i.bA([]);i.br(Ot,Ot,[yt.x*this.worldSize,yt.y*this.worldSize,0]),i.aB(Ot,Ot,i.cQ(this)),i.br(Ot,Ot,[-yt.x*this.worldSize,-yt.y*this.worldSize,0]),i.aB(le,le,Ot),i.aB(ne,ne,Ot),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],le,[this.worldSize,this.worldSize,this.worldSize/F,1]),this.projMatrix=le,this.invProjMatrix=i.bl(new Float64Array(16),this.projMatrix),y){const yt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);yt[8]=2*-h.x/this.width,yt[9]=2*h.y/this.height,this.expandedFarZProjMatrix=i.cP([],yt,z)}else this.expandedFarZProjMatrix=this.projMatrix;const je=i.bl([],W);this.frustumCorners=i.cT.fromInvProjectionMatrix(je,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!y);const ve=new Float32Array(16);i.bA(ve),i.cS(ve,ve,[1,-1,1]),i.cU(ve,ve,this._pitch),i.bB(ve,ve,this.angle);const Ne=i.cd(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.bz(Ne);const De=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;Ne[8]=2*-h.x/this.width,Ne[9]=2*(h.y+De)/this.height,this.skyboxMatrix=i.aB(ve,Ne,ve);const Pe=this.point,Ge=Pe.x,Ve=Pe.y,nt=this.width%2/2,ut=this.height%2/2,ot=Math.cos(this.angle),Et=Math.sin(this.angle),Nt=Ge-Math.round(Ge)+ot*nt+Et*ut,Tt=Ve-Math.round(Ve)+ot*ut+Et*nt,wt=new Float64Array(le);if(i.br(wt,wt,[Nt>.5?Nt-1:Nt,Tt>.5?Tt-1:Tt,0]),this.alignedProjMatrix=wt,le=i.bC(),i.cS(le,le,[this.width/2,-this.height/2,1]),i.br(le,le,[1,-1,0]),this.labelPlaneMatrix=le,le=i.bC(),i.cS(le,le,[1,-1,1]),i.br(le,le,[-1,-1,0]),i.cS(le,le,[2/this.width,2/this.height,1]),this.glCoordMatrix=le,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,ne),this._calcFogMatrices(),this._distanceTileDataCache={},le=i.bl(new Float64Array(16),this.pixelMatrix),!le)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=le,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cV(this);const yt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(yt,yt,z),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=le;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const h=this.cameraWorldSizeForFog,y=this.cameraPixelsPerMeter,A=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,F=[h,h,y];i.c5(F,F,D),i.c5(A,A,-1),i.cW(A,A,F);const z=i.bC();i.br(z,z,A),i.cS(z,z,F),this.mercatorFogMatrix=z,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(h,y,D)}_computeCameraPosition(h){const y=(h=h||this.pixelsPerMeter)/this.pixelsPerMeter,A=this._camera.forward(),D=this.point,F=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*y-h/this.worldSize*this._centerAltitude;return[D.x/this.worldSize-A[0]*F,D.y/this.worldSize-A[1]*F,h/this.worldSize*this._centerAltitude-A[2]*F]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(h){const y=this._maxCameraBoundsDistance()*Math.cos(this._pitch),A=this._camera.position[2],D=h[2];let F=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(F=Math.min((y-A)/D,1)),this._camera.position=i.bH([],this._camera.position,h,F),this._updateStateFromCamera()}_updateStateFromCamera(){const h=this._camera.position,y=this._camera.forward(),{pitch:A,bearing:D}=this._camera.getPitchBearing(),F=i.cf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,z=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.an(this._maxPitch)),W=Math.max((h[2]-F)/Math.cos(A),z),J=this._zoomFromMercatorZ(W);i.bH(h,h,y,W),this._pitch=i.aA(A,i.an(this.minPitch),i.an(this.maxPitch)),this.angle=i.bT(D,-Math.PI,Math.PI),this._setZoom(i.aA(J,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.ae(h[0],h[1],h[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(h){return Math.pow(2,h)*this.tileSize}_mercatorZfromZoom(h){return this.cameraToCenterDistance/this._worldSizeFromZoom(h)}_minimumHeightOverTerrain(){const h=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(h)}_zoomFromMercatorZ(h){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,h)*this.tileSize))}zoomFromMercatorZAdjusted(h){let y=0,A=i.cL,D=0,F=1/0;for(;A-y>1e-6&&A>y;){const z=y+.5*(A-y),W=this.tileSize*Math.pow(2,z),J=this.getCameraToCenterDistance(this.projection,z,W),ne=this.scaleZoom(J/(Math.max(0,h)*this.tileSize)),le=Math.abs(z-ne);lene||ve.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.cX(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.P(0,0),new i.P(this.width,this.height))}zoomDeltaToMovement(h,y){const A=i.ag(i.av([],this._camera.position,h)),D=this._zoomFromMercatorZ(A)+y;return A-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const h=function([y,A,D],F){const z=[y,A,D,1];i.aC(z,z,F);const W=z[3]=Math.max(z[3],1e-6);return z[0]/=W,z[1]/=W,z[2]/=W,z}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.P(h[0],h[1])}{const h=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.P(0,h))}}getCameraToCenterDistance(h,y=this.zoom,A=this.worldSize){const D=i.cO(h,y,this.width,this.height,1024),F=h.pixelSpaceConversion(this.center.lat,A,D);let z=.5/Math.tan(.5*this._fov)*this.height*F;return this.isOrthographic&&(z=i.ak(1,z,i.d0(this.pitch>=zp?1:this.pitch/zp))),z}getWorldToCameraMatrix(){const h=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.aB(h,h,this.globeMatrix),h}getFrustum(h){return i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,h,this.projection.zAxisUnit==="meters")}}const jy=(T,h)=>{if(h>0&&T.terrain&&i.w("Cutoff is currently disabled on terrain"),h<=0||T.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const y=T.transform,A=Math.max(Math.abs(y._zoom-(T.minCutoffZoom-1)),1),D=y.isLODDisabled(!1)?i.ah(60,45,y.pitch):i.ah(30,15,y.pitch),F=y._farZ-y._nearZ,z=h*y.height,W=((1-(J=D))*y.cameraToCenterDistance+J*(y._farZ+z))*A;var J;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[y._nearZ,y._farZ,(W-y._nearZ)/F,(W-z-y._nearZ)/F]}}},ep=2048;class Jw{constructor(h,y){this.aabb=h,this.lastCascade=y}}class kme{add(h,y){const A=this.receivers[h.key];A!==void 0?(A.aabb.min[0]=Math.min(A.aabb.min[0],y.min[0]),A.aabb.min[1]=Math.min(A.aabb.min[1],y.min[1]),A.aabb.min[2]=Math.min(A.aabb.min[2],y.min[2]),A.aabb.max[0]=Math.max(A.aabb.max[0],y.max[0]),A.aabb.max[1]=Math.max(A.aabb.max[1],y.max[1]),A.aabb.max[2]=Math.max(A.aabb.max[2],y.max[2])):this.receivers[h.key]=new Jw(y,null)}clear(){this.receivers={}}get(h){return this.receivers[h.key]}computeRequiredCascades(h,y,A){const D=i.d9.fromPoints(h.points);let F=0;for(const z in this.receivers){const W=this.receivers[z];if(!W||!D.intersectsAabb(W.aabb))continue;W.aabb.min=D.closestPoint(W.aabb.min),W.aabb.max=D.closestPoint(W.aabb.max);const J=W.aabb.getCorners();for(let ne=0;ne1||ve[1]<-1||ve[1]>1){le=!1;break}}if(W.lastCascade=ne,F=Math.max(F,ne),le)break}}return F+1}}class J1{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new kme,this._depthMode=new Fr(h.context.gl.LEQUAL,Fr.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1}destroy(){for(const h of this._cascades)h.texture.destroy(),h.framebuffer.destroy();this._cascades=[]}updateShadowParameters(h,y){const A=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!y||!y.properties)return;const D=y.properties.get("shadow-intensity");if(!y.shadowsEnabled()||D<=0||(this._shadowLayerCount=A.style.order.reduce((De,Pe)=>{const Ge=A.style._mergedLayers[Pe];return De+(Ge.hasShadowPass()&&!Ge.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const F=A.context,z=ep,W=ep;if(this._cascades.length===0||ep!==this._cascades[0].texture.size[0]){this._cascades=[];for(let De=0;De<2;++De){const Pe=A._shadowMapDebug,Ge=F.gl,Ve=F.createFramebuffer(z,W,Pe?1:0,"texture"),nt=new i.T(F,{width:z,height:W,data:null},Ge.DEPTH_COMPONENT16);if(Ve.depthAttachment.set(nt.texture),Pe){const ut=new i.T(F,{width:z,height:W,data:null},Ge.RGBA8);Ve.colorAttachment0.set(ut.texture)}this._cascades.push({framebuffer:Ve,texture:nt,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=t2(y);let J=0;if(h.elevation){const De=h.elevation,Pe=[1e4,-1e4];De.visibleDemTiles.filter(Ge=>Ge.dem).forEach(Ge=>{const Ve=Ge.dem.tree;Pe[0]=Math.min(Pe[0],Ve.minimums[0]),Pe[1]=Math.max(Pe[1],Ve.maximums[0])}),Pe[0]!==1e4&&(J=(Pe[1]-Pe[0])*De.exaggeration())}const ne=1.5*h.cameraToCenterDistance,le=3*ne,je=new Float64Array(16);for(let De=0;De=0)return{};const F=function(J,ne,le){const je=le/(1<0&&(i.d8(F[1],F[1],[D[0]*z,0,0]),i.d8(F[2],F[2],[D[0]*z,0,0])),D[1]<0?(i.d8(F[0],F[0],[0,D[1]*z,0]),i.d8(F[1],F[1],[0,D[1]*z,0])):D[1]>0&&(i.d8(F[2],F[2],[0,D[1]*z,0]),i.d8(F[3],F[3],[0,D[1]*z,0]));const W={};return W.vertices=F,W.planes=[e2(F[1],F[0],F[4]),e2(F[2],F[1],F[5]),e2(F[3],F[2],F[6]),e2(F[0],F[3],F[7])],W}addShadowReceiver(h,y,A){this._receivers.add(h,i.d9.fromTileIdAndHeight(h,y,A))}getMaxCascadeForTile(h){const y=this._receivers.get(h);return y&&y.lastCascade?y.lastCascade:0}}function e2(T,h,y){const A=i.av([],y,h),D=i.av([],T,h),F=i.bI([],A,D),z=i.ag(F);return z===0?[0,0,1,0]:(i.c5(F,F,1/z),[F[0],F[1],F[2],-i.bJ(F,h)])}function t2(T){const h=T.properties.get("direction"),y=i.d4(h.x,h.y,h.z);y[2]=i.aA(y[2],0,75);const A=i.d6([y[0],y[1],y[2]]);return i.d5(A.x,A.y,A.z)}function sg(T,h,y){const A=h.properties.get("color-use-theme")==="none",D=h.properties.get("color"),F=h.properties.get("intensity"),z=h.properties.get("direction"),W=[z.x,z.y,z.z],J=y.properties.get("color-use-theme")==="none",ne=y.properties.get("color"),le=y.properties.get("intensity"),je=Math.max(i.bJ([0,0,1],W),0),ve=[0,0,0];i.c5(ve,ne.toPremultipliedRenderColor(J?null:T.getLut(h.scope)).toArray01Linear().slice(0,3),le);const Ne=[0,0,0];return i.c5(Ne,D.toPremultipliedRenderColor(A?null:T.getLut(y.scope)).toArray01Linear().slice(0,3),je*F),i.db([ve[0]>0?ve[0]/(ve[0]+Ne[0]):0,ve[1]>0?ve[1]/(ve[1]+Ne[1]):0,ve[2]>0?ve[2]/(ve[2]+Ne[2]):0])}function Ny(T,h,y,A,D,F){const z=T.zoom,W=T.scale,J=T.worldSize,ne=1/J,le=T.aspect,je=Math.sqrt(1+le*le)*Math.tan(.5*T.fovX),ve=je*je,Ne=A-y,De=A+y;let Pe,Ge;ve>Ne/De?(Pe=A,Ge=A*je):(Pe=.5*De*(1+ve),Ge=.5*Math.sqrt(Ne*Ne+2*(A*A+y*y)*ve+De*De*ve*ve));const Ve=T.projection.pixelsPerMeter(T.center.lat,J),nt=T._camera.getCameraToWorldMercator(),ut=[0,0,-Pe*ne];i.af(ut,ut,nt);let ot=Ge*ne;const Et=T._edgeInsets;if(!(Et.left===0&&Et.top===0&&Et.right===0&&Et.bottom===0||Et.left===Et.right&&Et.top===Et.bottom)){const Is=T._camera.getWorldToCamera(T.worldSize,T.projection.zAxisUnit==="meters"?Ve:1),rr=T._camera.getCameraToClipPerspective(T._fov,T.width/T.height,y,A);rr[8]=2*-T.centerOffset.x/T.width,rr[9]=2*T.centerOffset.y/T.height;const yr=new Float64Array(16);i.cP(yr,rr,Is);const Js=new Float64Array(16);i.bl(Js,yr);const Us=i.cB.fromInvProjectionMatrix(Js,J,z,!0);for(const Pr of Us.points){const Cr=((Nt=Pr)[0]/=W,Nt[1]/=W,Nt[2]=i.cf(Nt[2],T._center.lat),Nt);ot=Math.max(ot,i.c6(i.da([],ut,Cr)))}}var Nt;ot*=D/(D-1);const Tt=Math.acos(h[2]),wt=Math.atan2(-h[0],-h[1]),yt=new BC;yt.position=ut,yt.setPitchBearing(Tt,wt);const Ot=yt.getWorldToCamera(J,Ve),Wt=ot*J,Ht=Math.min(T._mercatorZfromZoom(17)*J*-2,-2*Wt),es=yt.getCameraToClipOrthographic(-Wt,Wt,-Wt,Wt,Ht,(Wt+F*Ve)/h[2]),ts=new Float64Array(16);i.aB(ts,es,Ot);const xs=i.d5(Math.floor(1e6*ut[0])/1e6*J,Math.floor(1e6*ut[1])/1e6*J,0),qs=.5*D,Yt=[0,0,0];i.af(Yt,xs,ts),i.c5(Yt,Yt,qs);const Bt=[Math.floor(Yt[0]),Math.floor(Yt[1]),Math.floor(Yt[2])],as=[0,0,0];i.av(as,Yt,Bt),i.c5(as,as,-1/qs);const Jt=new Float64Array(16);return i.bA(Jt),i.br(Jt,Jt,as),i.aB(ts,Jt,ts),[ts,Wt]}class Sme extends i.E{constructor(h){super(),this.requestManager=h,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(h,y){return i.dc(this.requestManager.transformRequest(y,i.R.Model).url).then(A=>{if(!A)return;const D=i.dd(A),F=new i.de(h,y,void 0,void 0,D);return F.computeBoundsAndApplyParent(),F}).catch(A=>{if(A&&A.status===404)return null;this.fire(new i.y(new Error(`Could not load model ${h} from ${y}: ${A.message}`)))})}load(h,y,A={forceReload:!1}){this.models[y]||(this.models[y]={});const D=Object.keys(h),F=[],z=[];for(const W of D){const J=h[W];this.hasURLBeenRequested(J)&&!A.forceReload||(this.modelByURL[J]={modelId:W,scope:y},F.push(this.loadModel(W,J)),z.push(W)),this.models[y][W]||(this.models[y][W]={model:null,numReferences:1})}this.numModelsLoading[y]=(this.numModelsLoading[y]||0)+z.length,Promise.allSettled(F).then(W=>{for(let J=0;J{this.fire(new i.y(new Error(`Could not load models: ${W.message}`)))})}isLoaded(){for(const h in this.numModelsLoading)if(this.numModelsLoading[h]>0)return!1;return!0}hasModel(h,y,A={exactIdMatch:!1}){return!!(A.exactIdMatch?this.getModel(h,y):this.getModelByURL(this.modelUris[y][h]))}getModel(h,y){return this.models[y]||(this.models[y]={}),this.models[y][h]?this.models[y][h].model:void 0}getModelByURL(h){if(!h)return null;const y=this.modelByURL[h];return y?this.models[y.scope][y.modelId].model:null}hasModelBeenAdded(h,y){return this.models[y]&&this.models[y][h]!==void 0}getModelURIs(h){return this.modelUris[h]||{}}addModel(h,y,A){this.models[A]||(this.models[A]={}),this.modelUris[A]||(this.modelUris[A]={});const D=this.requestManager.normalizeModelURL(y);if((this.hasModel(h,A,{exactIdMatch:!0})||this.hasModelBeenAdded(h,A))&&this.modelUris[A][h]===D)this.models[A][h].numReferences++;else if(this.hasURLBeenRequested(D)){const{scope:F,modelId:z}=this.modelByURL[D];this.models[F][z].numReferences++}else this.modelUris[A][h]=D,this.load({[h]:this.modelUris[A][h]},A)}addModelURLs(h,y){this.models[y]||(this.models[y]={}),this.modelUris[y]||(this.modelUris[y]={});const A=this.modelUris[y];for(const D in h)A[D]=this.requestManager.normalizeModelURL(h[D])}reloadModels(h){this.load(this.modelUris[h],h,{forceReload:!0})}addModelsFromBucket(h,y){this.models[y]||(this.models[y]={}),this.modelUris[y]||(this.modelUris[y]={});const A={};for(const D of h)this.hasModel(D,y,{exactIdMatch:!0})||this.hasURLBeenRequested(D)?this.models[y][D].numReferences++:this.modelUris[y][D]&&!this.hasURLBeenRequested(D)?A[D]=this.modelUris[y][D]:!this.hasURLBeenRequested(D)&&i.df(D,!1)&&(this.modelUris[y][D]=this.requestManager.normalizeModelURL(D),A[D]=this.modelUris[y][D]);this.load(A,y)}hasURLBeenRequested(h){return this.modelByURL[h]!==void 0}removeModel(h,y,A=!1,D=!1){if(this.models[y]&&this.models[y][h]&&(this.models[y][h].numReferences--,this.models[y][h].numReferences===0||D)){const F=this.modelUris[y][h];A||delete this.modelUris[y][h],delete this.modelByURL[F];const z=this.models[y][h].model;if(!z)return;delete this.models[y][h],z.destroy()}}destroy(){for(const h of Object.keys(this.models))for(const y of Object.keys(this.models[h])){const A=this.models[h][y].model;delete this.models[h][y],A&&A.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(h){return this.models[h]||(this.models[h]={}),Object.keys(this.models[h])}upload(h,y){this.models[y]||(this.models[y]={});for(const A in this.models[y])this.models[y][A].model&&this.models[y][A].model.upload(h.context)}}const HE=i.a6.colorTheme,Cme=new i.a9({data:new i.aa(HE.data)});function MR(T){if(!T.metadata||!T.metadata.content_area)return;const h=i.o.devicePixelRatio,{left:y,top:A,width:D,height:F}=T.metadata.content_area,z=y*h,W=A*h;return[z,W,z+D*h,W+F*h]}function TR(T){if(T)return T.map(([h,y])=>[h*i.o.devicePixelRatio,y*i.o.devicePixelRatio])}class WE{constructor(h,y,A){this.id=h,this.scope=y,this.sourceCache=A,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(h){this.missingRequests.has(h.name)||this.pendingRequests.has(h.name)||this.pendingRequests.add(h.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const h=new Map;if(!this.sourceCache.loaded())return h;const y=this.sourceCache.getVisibleCoordinates();if(y.length===0)return h;const A=this.sourceCache.getSource();if(!(A instanceof Sd))return h;const D=y.map(z=>this.sourceCache.getTile(z)),F=A.getImages(D,Array.from(this.pendingRequests));for(const[z,W]of F)h.set(i.I.from({name:z,iconsetId:this.id}),W),this.pendingRequests.delete(z);for(const z of this.pendingRequests)this.missingRequests.add(z);return this.pendingRequests.clear(),h}}const ky=(T,h)=>Ye(T,h&&h.filter(y=>y.identifier!=="source.canvas")),AR=i.aH(La,["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"]),ER=i.aH(La,["setCenter","setZoom","setBearing","setPitch"]),qC=new Set(["background","sky","slot","custom"]),Sy={version:8,layers:[],sources:{}},s2={duration:300,delay:0};class tp extends i.E{constructor(h,y={}){super(),this.map=h,this.scope=y.scope||"",this.globalId=null,this.fragments=[],this.importDepth=y.importDepth||0,this.importsCache=y.importsCache||new Map,this.resolvedImports=y.resolvedImports||new Set,this.transition=Object.assign({},s2),this._buildingIndex=new Ww(this),this.crossTileSymbolIndex=new Fp,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=y.styleChanges||new Me,this._hasDataDrivenEmissive=!1,this.dispatcher=y.dispatcher?y.dispatcher:new i.D(i.dh(),this),y.imageManager?this.imageManager=y.imageManager:(this.imageManager=new He(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=y.glyphManager?y.glyphManager:new i.di(h._requestManager,y.localFontFamily?i.dj.all:y.localIdeographFontFamily?i.dj.ideographs:i.dj.none,y.localFontFamily||y.localIdeographFontFamily),y.modelManager?this.modelManager=y.modelManager:(this.modelManager=new Sme(h._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=y.configOptions?y.configOptions:new Map,this._configDependentLayers=y.configDependentLayers?y.configDependentLayers:new Set,this._indoorDependentLayers=y.indoorDependentLayers?y.indoorDependentLayers:new Set,this._config=y.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:y.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=y.initialConfig,this.dispatcher.broadcast("setReferrer",i.dk());const A=this;this._rtlTextPluginCallback=tp.registerForPluginStateChange(D=>{A.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(F,z)=>{if(i.dl(F),z&&z.every(W=>W))for(const W in A._sourceCaches){const J=A._sourceCaches[W],ne=J.getSource().type;ne!=="vector"&&ne!=="geojson"||J.reload()}})}),this.on("data",D=>{if(D.dataType!=="source"||D.sourceDataType!=="metadata")return;const F=this.getOwnSource(D.sourceId);if(F&&F.vectorLayerIds)for(const z in this._layers){const W=this._layers[z];W.source===F.id&&this._validateLayer(W)}})}load(h){return h?(typeof h=="string"?this.loadURL(h):this.loadJSON(h),this):this}_getGlobalId(h){if(!h)return null;if(typeof h=="string"){if(i.h(h))return h;const y=i.dm(h);if(!y.startsWith("http"))try{return new URL(y,location.href).toString()}catch{return y}return y}return`json://${i.dn(JSON.stringify(h))}`}_diffStyle(h,y,A){this.globalId=this._getGlobalId(h);const D=(F,z)=>{try{z(null,this.setState(F,A))}catch(W){z(W,!1)}};if(typeof h=="string"){const F=this.map._requestManager.normalizeStyleURL(h),z=this.map._requestManager.transformRequest(F,i.R.Style);i.m(z,(W,J)=>{W?this.fire(new i.y(W)):J&&D(J,y)})}else typeof h=="object"&&D(h,y)}loadURL(h,y={}){this.fire(new i.z("dataloading",{dataType:"style"}));const A=typeof y.validate=="boolean"?y.validate:!i.h(h);this.globalId=this._getGlobalId(h),h=this.map._requestManager.normalizeStyleURL(h,y.accessToken),this.resolvedImports.add(h);const D=this.importsCache.get(h);if(D)return this._load(D,A);const F=this.map._requestManager.transformRequest(h,i.R.Style);this._request=i.m(F,(z,W)=>{if(this._request=null,z)this.fire(new i.y(z));else if(W)return this.importsCache.set(h,W),this._load(W,A)})}loadJSON(h,y={}){this.fire(new i.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(h),this._request=i.o.frame(()=>{this._request=null,this._load(h,y.validate!==!1)})}loadEmpty(){this.fire(new i.z("dataloading",{dataType:"style"})),this._load(Sy,!1)}_loadImports(h,y,A){if(this.importDepth>=4)return i.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const D=[];for(const F of h){const z=this._createFragmentStyle(F),W=new Promise(le=>{z.once("style.import.load",le),z.once("error",le)}).then(()=>this.mergeAll());if(D.push(W),this.resolvedImports.has(F.url)){z.loadEmpty();continue}const J=F.data||this.importsCache.get(F.url);J?(z.loadJSON(J,{validate:y}),this._isInternalStyle(J)&&(z.globalId=null)):F.url?z.loadURL(F.url,{validate:y}):z.loadEmpty();const ne={style:z,id:F.id,config:F.config};if(A){const le=this.fragments.findIndex(({id:je})=>je===A);this.fragments=this.fragments.slice(0,le).concat(ne).concat(this.fragments.slice(le))}else this.fragments.push(ne)}return Promise.allSettled(D)}getImportGlobalIds(h=this,y=new Set){for(const A of h.fragments)A.style.globalId&&y.add(A.style.globalId),this.getImportGlobalIds(A.style,y);return[...y.values()]}_createFragmentStyle(h){const y=this.scope?i.B(h.id,this.scope):h.id;let A;const D=this._initialConfig&&this._initialConfig[y];(h.config||D)&&(A=Object.assign({},h.config,D));const F=new tp(this.map,{scope:y,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:A,configOptions:this.options,colorThemeOverride:h["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return F.setEventedParent(this.map,{style:F}),F}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(h){return this.isRootStyle()&&(h.fragment||!!h.schema&&h.fragment!==!1)}_load(h,y){if(this._isInternalStyle(h)){const F=Object.assign({},Sy,{imports:[{id:"basemap",data:h,url:""}]},h.center?{center:h.center}:{},h.bearing?{bearing:h.bearing}:{},h.pitch?{pitch:h.pitch}:{},h.zoom?{zoom:h.zoom}:{},h.light?{light:h.light}:{});return this._importedAsBasemap=!0,void this._load(F,y)}if(this.updateConfig(this._config,h.schema),y&&ky(this,Yr(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const A=()=>{for(const J in h.sources)this.addSource(J,h.sources[J],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const J in h.iconsets)this.addIconset(J,h.iconsets[J]);h.sprite?this._loadIconset(h.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&h.glyphs&&this.glyphManager.setURL(h.glyphs);const F=X0(this.stylesheet.layers);if(this._order=F.map(J=>J.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 J=this.stylesheet.lights[0];this.light=new Ft(J.properties,J.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Ft(this.stylesheet.light)),this._layers={};for(const J of F){const ne=i.du(J,this.scope,this._styleColorTheme.lut,this.options);ne.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(ne.fqid),ne.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(ne.fqid),this._hasAppearances=this._hasAppearances||ne.getAppearances().length!==0,ne.setEventedParent(this,{layer:{id:ne.id}}),this._layers[ne.id]=ne;const le=this.getOwnLayerSourceCache(ne),je=!!this.directionalLight&&this.directionalLight.shadowsEnabled();le&&ne.canCastShadows()&&je&&(le.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const z=this.stylesheet.terrain;z&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(z,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new i.z("data",{dataType:"style"}));const W=this.isRootStyle();h.imports?this._loadImports(h.imports,y).then(()=>{this._reloadImports(),this.fire(new i.z(W?"style.load":"style.import.load"))}).catch(J=>{this.fire(new i.y(new Error("Failed to load imports",J))),this.fire(new i.z(W?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(W?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const D=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(D){const F=this._evaluateColorThemeData(D);this._loadColorTheme(F).then(()=>{A()}).catch(z=>{i.w(`Couldn't load color theme from the stylesheet: ${z}`),A()})}else this._styleColorTheme.lut=null,A()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(h=>h.style.hasAppearances())}mergeAll(){let h,y,A,D,F,z,W,J,ne,le;const je={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(ve=>{if(ve.stylesheet){if(ve.light!=null&&(h=ve.light),ve.stylesheet.lights)for(const Ne of ve.stylesheet.lights)Ne.type==="ambient"&&ve.ambientLight!=null&&(y=ve.ambientLight),Ne.type==="directional"&&ve.directionalLight!=null&&(A=ve.directionalLight);D=this._prioritizeTerrain(D,ve.terrain,ve.stylesheet.terrain),ve.stylesheet.fog&&ve.fog!=null&&(F=ve.fog),ve.stylesheet.snow&&ve.snow!=null&&(z=ve.snow),ve.stylesheet.rain&&ve.rain!=null&&(W=ve.rain),ve.stylesheet.camera!=null&&(le=ve.stylesheet.camera),ve.stylesheet.projection!=null&&(J=ve.stylesheet.projection),ve.stylesheet.transition!=null&&(ne=ve.stylesheet.transition),je[ve.scope]=ve._styleColorTheme}}),this.light=h,this.ambientLight=y,this.directionalLight=A,this.fog=F,this.snow=z,this.rain=W,this._styleColorThemeForScope=je,D===null?delete this.terrain:this.terrain=D,this.camera=le||{"camera-projection":"perspective"},this.projection=J||{name:"mercator"},this.transition=Object.assign({},s2,ne),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(h){const y=A=>{for(const D of A.fragments)y(D.style);h(A)};y(this)}_prioritizeTerrain(h,y,A){const D=h&&h.drapeRenderMode===0;return A===null?y&&y.drapeRenderMode===0?y:D?h:null:y!=null&&(!h||D||y&&y.drapeRenderMode===1)?y:h}mergeTerrain(){let h;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(y=>{h=this._prioritizeTerrain(h,y.terrain,y.stylesheet.terrain)}),h===null?delete this.terrain:this.terrain=h}mergeProjection(){let h;this.forEachFragmentStyle(y=>{y.stylesheet.projection!=null&&(h=y.stylesheet.projection)}),this.projection=h||{name:"mercator"}}mergeSources(){const h={},y={},A={};this.forEachFragmentStyle(D=>{for(const F in D._sourceCaches){const z=i.B(F,D.scope);h[z]=D._sourceCaches[F]}for(const F in D._otherSourceCaches){const z=i.B(F,D.scope);y[z]=D._otherSourceCaches[F]}for(const F in D._symbolSourceCaches){const z=i.B(F,D.scope);A[z]=D._symbolSourceCaches[F]}}),this._mergedSourceCaches=h,this._mergedOtherSourceCaches=y,this._mergedSymbolSourceCaches=A}mergeIndoor(){this.forEachFragmentStyle(h=>{if(h.stylesheet&&h.stylesheet.indoor)for(const y of Object.values(h.stylesheet.indoor)){const A=y,D=i.B(A.sourceId,h.scope);this._mergedIndoor[D]=new Set(A.sourceLayers||[])}})}mergeLayers(){const h={},y=[],A={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(z=>{for(const W of z._order){const J=z._layers[W];if(J.type==="slot"){const ne=i.dq(W);if(h[ne])continue;h[ne]=[]}J.slot&&h[J.slot]?h[J.slot].push(J):y.push(J)}}),this._mergedOrder=[];let D=-1;const F=(z=[])=>{for(const W of z)if(W.type==="slot"){const J=i.dq(W.id);h[J]&&F(h[J]),this._mergedSlots.push(J)}else{const J=i.B(W.id,W.scope);this._mergedOrder.push(J),A[J]=W,W.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),W.type==="circle"&&(this._hasCircleLayers=!0),W.type==="symbol"&&(this._hasSymbolLayers=!0),W.type==="clip"&&(this._clipLayerPresent=!0)}};if(F(y),this._has3DLayers){const z={};for(let W=0;Wz[W]-z[J])}this._mergedLayers=A,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(h){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,h),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(h){return h.data?function(y,A,D,F){const z=Object.assign({},A);for(const J of Object.keys(HE))z[J]===void 0&&(z[J]=HE[J].default);const W=new i.a8(Cme,y,new Map(D));return W.setTransitionOrValue(z,D),W.untransitioned().possiblyEvaluate(new i.ac(0,{worldview:void 0}))}(this.scope,h,this.options).get("data"):null}_loadColorTheme(h){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const y=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((A,D)=>{const F="data:image/png;base64,";if(!h||h.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void A();let z=h;z.startsWith(F)||(z=F+z);const W=i.I.from("mapbox-reserved-lut"),J=new Image;J.src=z,J.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},J.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==y)return void A();this._styleColorTheme.lutLoading=!1;const{width:ne,height:le,data:je}=i.o.getImageData(J);if(le>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(ne!==le*le)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(W)&&this.removeImage(W),this.addImage(W,{data:new i.q({width:ne,height:le},je),pixelRatio:1,sdf:!1,usvg:!1,version:0});const ve=this.imageManager.getImage(W,this.scope);ve?(this._styleColorTheme.lut={image:ve.data,data:h},A()):D(new Error("Missing LUT image."))}})}getLut(h){const y=this._styleColorThemeForScope[h];return y?y.lut:null}setProjection(h){h?this.stylesheet.projection=h:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(h){this._spriteRequest=function(y,A,D){let F,z,W;const J=i.o.devicePixelRatio>1?"@2x":"";let ne=i.m(A.transformRequest(A.normalizeSpriteURL(y,J,".json"),i.R.SpriteJSON),(ve,Ne)=>{ne=null,W||(W=ve,F=Ne,je())}),le=i.n(A.transformRequest(A.normalizeSpriteURL(y,J,".png"),i.R.SpriteImage),(ve,Ne)=>{le=null,W||(W=ve,z=Ne,je())});function je(){if(W)D(W);else if(F&&z){const ve=i.o.getImageData(z),Ne={};for(const De in F){const{width:Pe,height:Ge,x:Ve,y:nt,sdf:ut,pixelRatio:ot,stretchX:Et,stretchY:Nt,content:Tt}=F[De],wt=new i.q({width:Pe,height:Ge});i.q.copy(ve,wt,{x:Ve,y:nt},{x:0,y:0},{width:Pe,height:Ge},null),Ne[De]={data:wt,pixelRatio:ot!==void 0?ot:1,sdf:ut!==void 0&&ut,stretchX:Et,stretchY:Nt,content:Tt,usvg:!1,version:0}}D(null,Ne)}}return{cancel(){ne&&(ne.cancel(),ne=null),le&&(le.cancel(),le=null)}}}(h,this.map._requestManager,(y,A)=>{if(this._spriteRequest=null,y)this.fire(new i.y(y));else if(A){const D=new Map;for(const F in A)D.set(i.I.from(F),A[F]);this.addImages(D)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))})}addIconset(h,y){if(y.type==="sprite")return void this._loadSprite(y.url);const A=this.getOwnSourceCache(y.source);if(!A)return void this.fire(new i.y(new Error(`Source "${y.source}" as specified by iconset "${h}" does not exist and cannot be used as an iconset source`)));const D=A.getSource();if(D.type!=="raster-array")return void this.fire(new i.y(new Error(`Source "${y.source}" as specified by iconset "${h}" is not a "raster-array" source and cannot be used as an iconset source`)));D.partial=!1;const F=new WE(h,this.scope,A);this.imageManager.addImageProvider(F,this.scope)}removeIconset(h){this.imageManager.removeImageProvider(h,this.scope)}_loadIconset(h){if(!i.h(h)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(h);const y=this.map._spriteFormat==="auto";var A,D;this._spriteRequest=(D=(F,z)=>{if(this._spriteRequest=null,F)y?this._loadSprite(h):this.fire(new i.y(F));else if(z){const W=new Map;for(const J in z)W.set(i.I.from(J),z[J]);this.addImages(W)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))},i.bu((A=this.map._requestManager).transformRequest(A.normalizeIconsetURL(h),i.R.Iconset),(F,z)=>{if(F)return void D(F);const W={},J=i.dg(new i.bt(z));for(const ne of J.icons){const le={version:1,pixelRatio:i.o.devicePixelRatio,content:MR(ne),stretchX:ne.metadata?TR(ne.metadata.stretch_x_areas):void 0,stretchY:ne.metadata?TR(ne.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:ne};W[ne.name]=le}D(null,W)}))}_validateLayer(h){const y=this.getOwnSource(h.source);if(!y)return;const A=h.sourceLayer;A&&(y.type==="geojson"||y.vectorLayerIds&&y.vectorLayerIds.indexOf(A)===-1)&&this.fire(new i.y(new Error(`Source layer "${A}" does not exist on source "${y.id}" as specified by style layer "${h.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const h in this._sourceCaches)if(!this._sourceCaches[h].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:h}of this.fragments)if(!h.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((h,y)=>{const A=this.fragments[y];return A&&A.style&&(h.data=A.style.serialize()),h})}_serializeSources(){const h={};for(const y in this._sourceCaches){const A=this._sourceCaches[y].getSource();h[A.id]||(h[A.id]=A.serialize())}return h}_serializeLayers(h){const y=[];for(const A of h){const D=this._layers[A];D&&D.type!=="custom"&&y.push(D.serialize())}return y}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(const h in this._sourceCaches)if(this._sourceCaches[h].hasTransition())return!0;for(const h in this._layers)if(this._layers[h].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const h in this._mergedLayers){const y=this._mergedLayers[h];if(y._transitionablePaint&&y._transitionablePaint._values){const A=y._transitionablePaint._values["line-emissive-strength"];if(A&&A.value&&A.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(h){return h?this.order:this._mergedOrder}isLayerDraped(h){return!!this.terrain&&h.isDraped(this.getLayerSourceCache(h))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(h){const y=this.getOwnLayer(h);if(y)return y;this.fire(new i.y(new Error(`The layer '${h}' does not exist in the map's style.`)))}_checkSource(h){const y=this.getOwnSource(h);if(y)return y;this.fire(new i.y(new Error(`The source '${h}' does not exist in the map's style.`)))}precompilePrograms(h,y){const A=this.map.painter;if(A)for(let D=h.minzoom||0;D<(h.maxzoom||25.5);D++){const F=h.getProgramIds();if(F)for(const z of F){const W=h.getDefaultProgramParams(z,y.zoom,this._styleColorTheme.lut);W&&(A.style=this,this.fog&&(A._fogVisible=!0,W.overrideFog=!0,A.getOrCreateProgram(z,W)),A._fogVisible=!1,W.overrideFog=!1,A.getOrCreateProgram(z,W),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(W.overrideRtt=!0,A.getOrCreateProgram(z,W)))}}}update(h){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(h),this.directionalLight&&this.directionalLight.recalculate(h);const y=this.calculateLightsBrightness();h.brightness=y||0,y!==this._brightness&&(this._brightness=y,this.dispatcher.broadcast("setBrightness",y)),h.worldview!==this._worldview&&(this._worldview=h.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const A=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const W=this._changes.getLayerUpdatesByScope();for(const J in W){const{updatedIds:ne,removedIds:le}=W[J];(ne||le)&&(this._updateWorkerLayers(J,ne,le),D=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(h),this.light&&this.light.updateTransitions(h),this.ambientLight&&this.ambientLight.updateTransitions(h),this.directionalLight&&this.directionalLight.updateTransitions(h),this.fog&&this.fog.updateTransitions(h),this.snow&&this.snow.updateTransitions(h),this.rain&&this.rain.updateTransitions(h),this._changes.reset()}const F={};for(const W in this._mergedSourceCaches){const J=this._mergedSourceCaches[W];F[W]=J.used,J.used=!1,J.tileCoverLift=0}for(const W of this._mergedOrder){const J=this._mergedLayers[W];if(J.visibility!=="none"&&J.recalculate(h,this._availableImages),!J.isHidden(h.zoom)){const ne=this.getLayerSourceCache(J);ne&&(ne.used=!0,ne.tileCoverLift=Math.max(ne.tileCoverLift,J.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(J,h)}):this.precompilePrograms(J,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const z=this.imageManager.getPendingImageProviders();for(const W of z)W.sourceCache.used=!0;for(const W in F){const J=this._mergedSourceCaches[W];F[W]!==J.used&&J.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:J.getSource().id}))}this.light&&this.light.recalculate(h),this.terrain&&this.terrain.recalculate(h),this.fog&&this.fog.recalculate(h),this.snow&&this.snow.recalculate(h),this.rain&&this.rain.recalculate(h),this.z=h.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),A&&this.fire(new i.z("data",{dataType:"style"}))}updateImageProviders(){const h=this.imageManager.getPendingImageProviders();for(const y of h){const A=y.resolvePendingRequests(),D=this.getFragmentStyle(y.scope);D&&D.addImages(A)}}_updateTilesForChangedImages(){const h={};for(const y in this._mergedSourceCaches){const A=this._mergedSourceCaches[y].getSource().scope;h[A]=h[A]||this._changes.getUpdatedImages(A),h[A].length!==0&&this._mergedSourceCaches[y].reloadTilesForDependencies(["icons","patterns"],h[A])}for(const y in h)this._changes.resetUpdatedImages(y)}_updateWorkerLayers(h,y,A){const D=this.getFragmentStyle(h);D&&this.dispatcher.broadcast("updateLayers",{layers:y?D._serializeLayers(y):[],scope:h,removedIds:A||[],options:D.options})}setState(h,y){if(this._checkLoaded(),ky(this,Yr(h)))return!1;(h=i.dp(h)).layers=X0(h.layers);const A=function(z,W){if(!z)return[{command:La.setStyle,args:[W]}];let J=[];try{if(!i.by(z.version,W.version))return[{command:La.setStyle,args:[W]}];if(i.by(z.center,W.center)||J.push({command:La.setCenter,args:[W.center]}),i.by(z.zoom,W.zoom)||J.push({command:La.setZoom,args:[W.zoom]}),i.by(z.bearing,W.bearing)||J.push({command:La.setBearing,args:[W.bearing]}),i.by(z.pitch,W.pitch)||J.push({command:La.setPitch,args:[W.pitch]}),i.by(z.sprite,W.sprite)||J.push({command:La.setSprite,args:[W.sprite]}),i.by(z.glyphs,W.glyphs)||J.push({command:La.setGlyphs,args:[W.glyphs]}),i.by(z.imports,W.imports)||function(Ne=[],De=[],Pe){De=De||[];const Ge=(Ne=Ne||[]).map(Q0),Ve=De.map(Q0),nt=Ne.reduce(J0,{}),ut=De.reduce(J0,{}),ot=Ge.slice();let Et,Nt,Tt,wt;for(Et=0,Nt=0;Et{Ne.source&&ne[Ne.source]?J.push({command:La.removeLayer,args:[Ne.id]}):je.push(Ne)});let ve=z.terrain;ve&&ne[ve.source]&&(J.push({command:La.setTerrain,args:[void 0]}),ve=void 0),J=J.concat(le),i.by(ve,W.terrain)||J.push({command:La.setTerrain,args:[W.terrain]}),function(Ne,De,Pe){De=De||[];const Ge=(Ne=Ne||[]).map(Q0),Ve=De.map(Q0),nt=Ne.reduce(J0,{}),ut=De.reduce(J0,{}),ot=Ge.slice(),Et=Object.create(null);let Nt,Tt,wt,yt,Ot,Wt,Ht;for(Nt=0,Tt=0;Nt!(z.command in ER));if(A.length===0)return!1;const D=A.filter(z=>!(z.command in AR));if(D.length>0)throw new Error(`Unimplemented: ${D.map(z=>z.command).join(", ")}.`);const F=[];return A.forEach(z=>{F.push(this[z.command](...z.args))}),y&&Promise.all(F).then(y).catch(y),this.stylesheet=h,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(h){if(h.size===0)return this;for(const[y,A]of h.entries()){if(this.getImage(y))return this.fire(new i.y(new Error(`An image with the name "${y.name}" already exists.`)));this.imageManager.addImage(y,this.scope,A),this._changes.updateImage(y,this.scope)}return this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this}addImage(h,y){return this.getImage(h)?this.fire(new i.y(new Error(`An image with the name "${h.name}" already exists.`))):(this.imageManager.addImage(h,this.scope,y),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this)}updateImage(h,y,A=!1){this.imageManager.updateImage(h,this.scope,y),A&&(this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})))}getImage(h){return this.imageManager.getImage(h,this.scope)}removeImage(h){return this.getImage(h)?(this.imageManager.removeImage(h,this.scope),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this):this.fire(new i.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(h){return this.modelManager.addModelURLs(h,this.getActualScope()),this._updateWorkerModels(),this.fire(new i.z("data",{dataType:"style"})),this}addModel(h,y,A={}){return this._checkLoaded(),this._validate(ke,`models.${h}`,y,null,A)||(this.modelManager.addModel(h,y,this.getActualScope()),this.fire(new i.z("data",{dataType:"style"}))),this}hasModel(h){return this.modelManager.hasModel(h,this.getActualScope())}removeModel(h){return this.hasModel(h)?(this.modelManager.removeModel(h,this.getActualScope(),!1,!0),this.fire(new i.z("data",{dataType:"style"})),this):this.fire(new i.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(h,y,A={}){if(this._checkLoaded(),this.getOwnSource(h)!==void 0)throw new Error(`There is already a source with ID "${h}".`);if(!y.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(y).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(y.type)>=0&&this._validate(vi,`sources.${h}`,y,null,A))return;this.map&&this.map._collectResourceTiming&&(y.collectResourceTiming=!0);const D=Bl(h,y,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const F=z=>{const W=(z?"symbol:":"other:")+D.id,J=i.B(W,this.scope),ne=this._sourceCaches[W]=new El(J,D,z);(z?this._symbolSourceCaches:this._otherSourceCaches)[D.id]=ne,ne.onAdd(this.map)};F(!1),y.type!=="vector"&&y.type!=="geojson"||F(!0),D.onAdd&&D.onAdd(this.map),A.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(h){this._checkLoaded();const y=this.getOwnSource(h);if(!y)throw new Error("There is no source with this ID");for(const D in this._layers)if(this._layers[D].source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while layer "${D}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const D=Object.entries(this.stylesheet.iconsets).find(([F,z])=>z.type==="source"&&z.source===h);if(D)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while iconset "${D[0]}" is using it.`)))}const A=this.getOwnSourceCaches(h);for(const D of A){const F=i.dq(D.id);delete this._sourceCaches[F],this._changes.discardSourceCacheUpdate(D.id),D.fire(new i.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:D.getSource().id})),D.setEventedParent(null),D.clearTiles()}return delete this._otherSourceCaches[h],delete this._symbolSourceCaches[h],this.mergeSources(),y.setEventedParent(null),y.onRemove&&y.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(h,y){this._checkLoaded(),this.getOwnSource(h).setData(y),this._changes.setDirty()}getOwnSource(h){const y=this.getOwnSourceCache(h);return y&&y.getSource()}getOwnSources(){const h=[];for(const y in this._otherSourceCaches){const A=this.getOwnSourceCache(y);A&&h.push(A.getSource())}return h}areTilesLoaded(){const h=this._mergedSourceCaches;for(const y in h){const A=h[y]._tiles;for(const D in A){const F=A[D];if(F.state!=="loaded"&&F.state!=="errored")return!1}}return!0}setLights(h){if(this._checkLoaded(),!h)return delete this.ambientLight,void delete this.directionalLight;const y=this._getTransitionParameters();for(const F of h){if(this._validate(ir,"lights",F))return;switch(F.type){case"ambient":if(this.ambientLight){const z=this.ambientLight;z.set(F),z.updateTransitions(y)}else this.ambientLight=new Ia(F,il||(il=new i.a9({color:new i.aa(i.a6.properties_light_ambient.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const z=this.directionalLight;z.set(F),z.updateTransitions(y)}else this.directionalLight=new Ia(F,ti||(ti=new i.a9({direction:new i.ap(i.a6.properties_light_directional.direction),color:new i.aa(i.a6.properties_light_directional.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_directional.intensity),"cast-shadows":new i.aa(i.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new i.aa(i.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new i.aa(i.a6.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const A=Object.assign(y,{worldview:this.map.getWorldview()}),D=new i.ac(this.z||0,A);this.ambientLight&&this.ambientLight.recalculate(D),this.directionalLight&&this.directionalLight.recalculate(D),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const h=this.directionalLight,y=this.ambientLight;if(!h||!y)return;const A=ve=>.2126*(ve[0]<=.03928?ve[0]/12.92:Math.pow((ve[0]+.055)/1.055,2.4))+.7152*(ve[1]<=.03928?ve[1]/12.92:Math.pow((ve[1]+.055)/1.055,2.4))+.0722*(ve[2]<=.03928?ve[2]/12.92:Math.pow((ve[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),F=h.properties.get("intensity"),z=h.properties.get("direction"),W=1-i.d4(z.x,z.y,z.z)[2]/90,J=A(D)*F*W,ne=y.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),le=y.properties.get("intensity"),je=A(ne)*le;return Number(((J+je)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const h=[];return this.directionalLight&&h.push(this.directionalLight.get()),this.ambientLight&&h.push(this.ambientLight.get()),h}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(h){if(h==null||h===""&&this.isRootStyle())return this;if(i.dr(h)){const y=i.ds(h),A=this.fragments.find(({id:F})=>F===y);if(!A)return;const D=i.dq(h);return A.style.getFragmentStyle(D)}{const y=this.fragments.find(({id:A})=>A===h);return y?y.style:void 0}}setFeaturesetSelectors(h){if(!h)return;const y={},A=(D,F="")=>`${D}::${F}`;this._featuresetSelectors={};for(const D in h){const F=this._featuresetSelectors[D]=[];for(const z of h[D].selectors){if(z.featureNamespace){const J=this.getOwnLayer(z.layer);if(!J){i.w(`Layer is undefined for selector: ${z.layer}`);continue}const ne=A(J.source,J.sourceLayer);if(ne in y&&y[ne]!==z.featureNamespace){i.w(`"featureNamespace ${z.featureNamespace} of featureset ${D}'s selector is not associated to the same source, skip this selector`);continue}y[ne]=z.featureNamespace}let W;if(z.properties)for(const J in z.properties){const ne=i.U(z.properties[J]);ne.result==="success"&&(W=W||{},W[J]=ne.value)}F.push({layerId:z.layer,namespace:z.featureNamespace,properties:W,uniqueFeatureID:z._uniqueFeatureID})}}}getFeaturesetDescriptors(h){const y=this.getFragmentStyle(h);if(!y||!y.stylesheet.featuresets)return[];const A=[];for(const D in y.stylesheet.featuresets)A.push({featuresetId:D,importId:y.scope?y.scope:void 0});return A}getFeaturesetLayers(h,y){const A=this.getFragmentStyle(y),D=A.stylesheet.featuresets;if(!D||!D[h])return this.fire(new i.y(new Error(`The featureset '${h}' does not exist in the map's style and cannot be queried.`))),[];const F=[];for(const z of D[h].selectors){const W=A.getOwnLayer(z.layer);W&&F.push(W)}return F}getConfigProperty(h,y){const A=this.getFragmentStyle(h);if(!A)return null;const D=i.B(y,A.scope),F=A.options.get(D),z=F?F.value||F.default:null;return z?z.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(h,y){const A=i.B(h,y);return this._mergedIndoor[A]}setIndoorData(h,y){this.map.indoor.setIndoorData(y)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(h,y,A){const D=this.getFragmentStyle(h);if(!D)return;const F=D.stylesheet.schema;if(!F||!F[y])return;const z=i.U(A);if(z.result!=="success")return void ky(this,z.value);const W=z.value.expression,J=i.B(y,D.scope),ne=D.options.get(J);if(!ne)return;let le;const{minValue:je,maxValue:ve,stepValue:Ne,type:De,values:Pe}=F[y],Ge=i.U(F[y].default);Ge.result==="success"&&(le=Ge.value.expression),le?(this.options.set(J,Object.assign({},ne,{value:W,default:le,minValue:je,maxValue:ve,stepValue:Ne,type:De,values:Pe})),this.updateConfigDependencies(y)):this.fire(new i.y(new Error(`No schema defined for the config option "${y}" in the "${h}" fragment.`)))}getConfig(h){const y=this.getFragmentStyle(h);if(!y)return null;const A=y.stylesheet.schema;if(!A)return null;const D={};for(const F in A){const z=i.B(F,y.scope),W=y.options.get(z),J=W?W.value||W.default:null;D[F]=J?J.serialize():null}return D}setConfig(h,y){const A=this.getFragmentStyle(h);A&&(A.updateConfig(y,A.stylesheet.schema),this.updateConfigDependencies())}getSchema(h){const y=this.getFragmentStyle(h);return y?y.stylesheet.schema:null}setSchema(h,y){const A=this.getFragmentStyle(h);A&&(A.stylesheet.schema=y,A.updateConfig(A._config,y),this.updateConfigDependencies())}updateConfig(h,y){if(this._config=h,h||y)if(y)for(const A in y){let D,F;const z=i.U(y[A].default);if(z.result==="success"&&(D=z.value.expression),h&&h[A]!==void 0){const ve=i.U(h[A]);ve.result==="success"&&(F=ve.value.expression)}const{minValue:W,maxValue:J,stepValue:ne,type:le,values:je}=y[A];if(D){const ve=i.B(A,this.scope);this.options.set(ve,{default:D,value:F,minValue:W,maxValue:J,stepValue:ne,type:le,values:je})}else this.fire(new i.y(new Error(`No schema defined for config option "${A}".`)))}else this.fire(new i.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(h,y=()=>!0){for(const A of h){const D=this.getLayer(A);D&&y(D)&&(D.possiblyEvaluateVisibility(),this._updateLayer(D),this._changes.setDirty())}}updateConfigDependencies(h){this._updateLayers(this._configDependentLayers,y=>!h||y.expressionDependencies.configDependencies.has(h)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(y=>{const A=y._styleColorTheme.colorThemeOverride?y._styleColorTheme.colorThemeOverride:y._styleColorTheme.colorTheme;if(A){const D=y._evaluateColorThemeData(A);(!y._styleColorTheme.lut&&D!==""||y._styleColorTheme.lut&&D!==y._styleColorTheme.lut.data)&&y.setColorTheme(A)}}),this._changes.setDirty()}addLayer(h,y,A={}){this._checkLoaded();const D=h.id;if(this._layers[D])return void this.fire(new i.y(new Error(`Layer with id "${D}" already exists on this map`)));let F;if(h.type==="custom"){if(ky(this,i.dt(h)))return;F=i.du(h,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof h.source=="object"&&(this.addSource(D,h.source),h=i.dp(h),h=Object.assign(h,{source:D})),this._validate(Pa,`layers.${D}`,h,{arrayIndex:-1},A))return;F=i.du(h,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(F),F.setEventedParent(this,{layer:{id:D}})}const z=i.B(F.source,F.scope);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z);let W=this._order.length;if(y){const je=this._order.indexOf(y);if(je===-1)return void this.fire(new i.y(new Error(`Layer with id "${y}" does not exist on this map.`)));F.slot===this._layers[y].slot?W=je:i.w(`Layer with id "${y}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(W,0,D),this._layerOrderChanged=!0,this._layers[D]=F;const J=this.getOwnLayerSourceCache(F),ne=!!this.directionalLight&&this.directionalLight.shadowsEnabled();J&&F.canCastShadows()&&ne&&(J.castsShadows=!0);const le=this._changes.getRemovedLayer(F);if(le&&F.source&&J&&F.type!=="custom"){this._changes.discardLayerRemoval(F);const je=i.B(F.source,F.scope);le.type!==F.type?this._changes.updateSourceCache(je,"clear"):(this._changes.updateSourceCache(je,"reload"),J.pause())}this._updateLayer(F),F.onAdd&&F.onAdd(this.map),F.scope=this.scope,this.mergeLayers()}moveLayer(h,y){this._checkLoaded();const A=this._checkLayer(h);if(!A||h===y)return;const D=this._order.indexOf(h);this._order.splice(D,1);let F=this._order.length;if(y){const z=this._order.indexOf(y);if(z===-1)return void this.fire(new i.y(new Error(`Layer with id "${y}" does not exist on this map.`)));A.slot===this._layers[y].slot?F=z:i.w(`Layer with id "${y}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(F,0,h),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(h){this._checkLoaded();const y=this._checkLayer(h);if(!y)return;y.setEventedParent(null);const A=this._order.indexOf(h);this._order.splice(A,1),delete this._layers[h],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(y.fqid),this._indoorDependentLayers.delete(y.fqid),this._changes.removeLayer(y);const D=this.getOwnLayerSourceCache(y);if(D&&D.castsShadows){let F=!1;for(const z in this._layers)if(this._layers[z].source===y.source&&this._layers[z].canCastShadows()){F=!0;break}D.castsShadows=F}y.onRemove&&y.onRemove(this.map),this.mergeLayers()}getOwnLayer(h){return this._layers[h]}hasLayer(h){return h in this._mergedLayers}hasLayerType(h){for(const y in this._layers)if(this._layers[y].type===h)return!0;return!1}setLayerZoomRange(h,y,A){this._checkLoaded();const D=this._checkLayer(h);D&&(D.minzoom===y&&D.maxzoom===A||(y!=null&&(D.minzoom=y),A!=null&&(D.maxzoom=A),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(h,y){this._checkLoaded();const A=this._checkLayer(h);A&&A.slot!==y&&(A.slot=y,this._updateLayer(A))}setFilter(h,y,A={}){this._checkLoaded();const D=this._checkLayer(h);if(D&&!i.by(D.filter,y))return y==null?(D.filter=void 0,void this._updateLayer(D)):void(this._validate(Ii,`layers.${D.id}.filter`,y,{layerType:D.type},A)||(D.filter=i.dp(y),this._updateLayer(D)))}getFilter(h){const y=this._checkLayer(h);if(y)return i.dp(y.filter)}setLayoutProperty(h,y,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(F&&!i.by(F.getLayoutProperty(y),A)){if(A!=null&&(!D||D.validate!==!1)&&ky(F,$t.call(Yr,{key:`layers.${h}.layout.${y}`,layerType:F.type,objectKey:y,value:A,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;F.setLayoutProperty(y,A),F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),this._updateLayer(F)}}setLayerProperty(h,y,A,D={}){this._checkLoaded();const F=this._checkLayer(h);F&&(y==="appearances"?(F.setAppearances(A),this._changes.setDirty()):F.isPaintProperty(y)?this.setPaintProperty(h,y,A,D):this.setLayoutProperty(h,y,A,D))}getLayoutProperty(h,y){const A=this._checkLayer(h);if(A)return A.getLayoutProperty(y)}setPaintProperty(h,y,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(!F||i.by(F.getPaintProperty(y),A)||A!=null&&(!D||D.validate!==!1)&&ky(F,Fo.call(Yr,{key:`layers.${h}.paint.${y}`,layerType:F.type,objectKey:y,value:A,styleSpec:i.a6})))return;const z=F.setPaintProperty(y,A);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),z&&this._updateLayer(F),this._changes.updatePaintProperties(F)}getPaintProperty(h,y){const A=this._checkLayer(h);if(A)return A.getPaintProperty(y)}setFeatureState(h,y){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:J,importId:ne}=h.target,le=this.getFragmentStyle(ne),je=le.getFeaturesetLayers(J);for(const{source:ve,sourceLayer:Ne}of je)le.setFeatureState({id:h.id,source:ve,sourceLayer:Ne},y)}else if("layerId"in h.target){const{layerId:J}=h.target,ne=this.getLayer(J);this.setFeatureState({id:h.id,source:ne.source,sourceLayer:ne.sourceLayer},y)}return}const A=h.source,D=h.sourceLayer,F=this._checkSource(A);if(!F)return;const z=F.type;if(z==="geojson"&&D)return void this.fire(new i.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(z==="vector"&&!D)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided.")));const W=this.getOwnSourceCaches(A);for(const J of W)J.setFeatureState(D,h.id,y)}removeFeatureState(h,y){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:J,importId:ne}=h.target,le=this.getFragmentStyle(ne),je=le.getFeaturesetLayers(J);for(const{source:ve,sourceLayer:Ne}of je)le.removeFeatureState({id:h.id,source:ve,sourceLayer:Ne},y)}else if("layerId"in h.target){const{layerId:J}=h.target,ne=this.getLayer(J);this.removeFeatureState({id:h.id,source:ne.source,sourceLayer:ne.sourceLayer},y)}return}const A=h.source,D=this._checkSource(A);if(!D)return;const F=D.type,z=F==="vector"?h.sourceLayer:void 0;if(F==="vector"&&!z)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(y&&typeof h.id!="string"&&typeof h.id!="number")return void this.fire(new i.y(new Error("A feature id is required to remove its specific state property.")));const W=this.getOwnSourceCaches(A);for(const J of W)J.removeFeatureState(z,h.id,y)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let F;if("featuresetId"in h.target){const{featuresetId:z,importId:W}=h.target,J=this.getFragmentStyle(W),ne=J.getFeaturesetLayers(z);for(const{source:le,sourceLayer:je}of ne){const ve=J.getFeatureState({id:h.id,source:le,sourceLayer:je});if(ve&&!F)F=ve;else if(!i.by(F,ve))return void this.fire(new i.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in h.target){const{layerId:z}=h.target,W=this.getLayer(z);F=this.getFeatureState({id:h.id,source:W.source,sourceLayer:W.sourceLayer})}return F}const y=h.source,A=h.sourceLayer,D=this._checkSource(y);if(D){if(D.type!=="vector"||A)return h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(y)[0].getFeatureState(A,h.id);this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(h){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,h),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const h=this.getTerrain(),y=h&&this.terrain&&this.terrain.scope===this.scope?h:this.stylesheet.terrain;return i.dv({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:y,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},A=>A!==void 0)}_updateFilteredLayers(h){for(const y of Object.values(this._mergedLayers))h(y)&&this._updateLayer(y)}_updateLayer(h){this._changes.updateLayer(h);const y=this.getLayerSourceCache(h),A=i.B(h.source,h.scope),D=this._changes.getUpdatedSourceCaches();h.source&&!D[A]&&y&&y.getSource().type!=="raster"&&(this._changes.updateSourceCache(A,"reload"),y.pause()),h.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(h){const y=W=>this._mergedLayers[W].is3D(!!this.terrain),A=this.order,D={},F=[];for(let W=A.length-1;W>=0;W--){const J=A[W];if(y(J)){D[J]=W;for(const ne of h){const le=ne[J];if(le)for(const je of le)F.push(je)}}}F.sort((W,J)=>J.intersectionZ-W.intersectionZ);const z=[];for(let W=A.length-1;W>=0;W--){const J=A[W];if(y(J))for(let ne=F.length-1;ne>=0;ne--){const le=F[ne].feature;if(le.layer&&D[le.layer.id]{if(qC.has(le.type))return;const je=this.getOwnLayerSourceCache(le),ve=F[je.id]=F[je.id]||{sourceCache:je,layers:{},has3DLayers:!1};le.is3D(!!this.terrain)&&(ve.has3DLayers=!0),ve.layers[le.fqid]=ve.layers[le.fqid]||{styleLayer:le,targets:[]},ve.layers[le.fqid].targets.push({filter:D})};if(y&&y.layers){if(!Array.isArray(y.layers))return this.fire(new i.y(new Error("parameters.layers must be an Array."))),[];for(const le of y.layers){const je=this._layers[le];if(!je)return this.fire(new i.y(new Error(`The layer '${le}' does not exist in the map's style and cannot be queried for features.`))),[];z(je)}}else for(const le in this._layers)z(this._layers[le]);const W=this._queryRenderedFeatures(h,F,A),J=this._flattenAndSortRenderedFeatures(W),ne=[];for(const le of J)i.dw(le.layer.id)===this.scope&&ne.push(le);return ne}queryRenderedFeatureset(h,y,A){let D;y&&!Array.isArray(y)&&y.filter&&(this._validate(Ii,"queryRenderedFeatures.filter",y.filter,null,y),D=i.b6(y.filter));const F="mock",z=[];if(y&&y.target)z.push(Object.assign({},y,{targetId:F,filter:D}));else{const le=this.getFeaturesetDescriptors();for(const je of le)z.push({targetId:F,filter:D,target:je});for(const{style:je}of this.fragments){const ve=je.getFeaturesetDescriptors();for(const Ne of ve)z.push({targetId:F,filter:D,target:Ne})}}const W=this.queryRenderedTargets(h,z,A),J=[],ne=new Set;for(const le of W)for(const je of le.variants[F])vy(je,le,ne)||J.push(new i.dx(le,je));return J}queryRenderedTargets(h,y,A){const D={},F=(W,J,ne,le)=>{const je=D[J.id]=D[J.id]||{sourceCache:J,layers:{},has3DLayers:!1};if(je.layers[W.fqid]=je.layers[W.fqid]||{styleLayer:W,targets:[]},W.is3D(!!this.terrain)&&(je.has3DLayers=!0),!le)return ne.uniqueFeatureID=!1,void je.layers[W.fqid].targets.push(ne);je.layers[W.fqid].targets.push(Object.assign({},ne,{namespace:le.namespace,properties:le.properties,uniqueFeatureID:le.uniqueFeatureID}))};for(const W of y)if("featuresetId"in W.target){const{featuresetId:J,importId:ne}=W.target,le=this.getFragmentStyle(ne);if(!le||!le._featuresetSelectors)continue;const je=le._featuresetSelectors[J];if(!je){this.fire(new i.y(new Error(`The featureset '${J}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const ve of je){const Ne=le.getOwnLayer(ve.layerId);Ne&&!qC.has(Ne.type)&&F(Ne,le.getOwnLayerSourceCache(Ne),W,ve)}}else if("layerId"in W.target){const{layerId:J}=W.target,ne=this.getLayer(J);if(!ne||qC.has(ne.type))continue;F(ne,this.getLayerSourceCache(ne),W)}const z=this._queryRenderedFeatures(h,D,A);return this._flattenAndSortRenderedFeatures(z)}_queryRenderedFeatures(h,y,A){const D=[],F=!!this.map._showQueryGeometry,z=lo.createFromScreenPoints(h,A);for(const W in y){const J=H1(z,y[W],this._availableImages,A,F);Object.keys(J).length&&D.push(J)}if(this.placement)for(const W in y){if(!y[W].sourceCache._onlySymbols)continue;const J=W1(z.screenGeometry,y[W],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(J).length&&D.push(J)}return D}querySourceFeatures(h,y){const A=y&&y.filter;A&&this._validate(Ii,"querySourceFeatures.filter",A,null,y);let D=[];const F=this.getOwnSourceCaches(h);for(const z of F)D=D.concat(G1(z,y));return D}addSourceType(h,y,A){return tp.getSourceType(h)?A(new Error(`A source type called "${h}" already exists.`)):(tp.setSourceType(h,y),y.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:h,url:y.workerSourceURL},A):A(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(h,y,A={}){this._checkLoaded();const D=this.light.getLight();let F=!1;for(const W in h)if(!i.by(h[W],D[W])){F=!0;break}if(!F)return;const z=this._getTransitionParameters();this.light.setLight(h,y,A),this.light.updateTransitions(z)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=i.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&i.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(h,y=1){if(this._checkLoaded(),!h)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),y===0&&delete this.terrain,h===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let A=h;const D=!("source"in h)||h.source==null;if(y===1){if(this.disableElevatedTerrain)return;if("source"in A&&typeof A.source=="object"){const W="terrain-dem-src";this.addSource(W,A.source),A=i.dp(A),A=Object.assign(A,{source:W})}const F=Object.assign({},A),z={};if(this.terrain&&D){F.source=this.terrain.get().source;const W=this.terrain?this.getFragmentStyle(this.terrain.scope):null;W&&(z.style=W.serialize())}if(this._validate(Vn,"terrain",F,z))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&y!==this.terrain.drapeRenderMode){if(!A)return;this._createTerrain(A,y),this.fire(new i.z("data",{dataType:"style"}))}else{const F=this.terrain,z=F.get();for(const W of Object.keys(i.a6.terrain))!A.hasOwnProperty(W)&&i.a6.terrain[W].default&&(A[W]=i.a6.terrain[W].default);for(const W in h)if(!i.by(h[W],z[W])){F.set(h,this.options),this.stylesheet.terrain=h;const J=this._getTransitionParameters({duration:0});F.updateTransitions(J),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(h){const y=this.fog=new En(h,this.map.transform,this.scope,this.options);this.stylesheet.fog=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}_createSnow(h){const y=this.snow=new hl(h,this.map.transform,this.scope,this.options);this.stylesheet.snow=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}_createRain(h){const y=this.rain=new oo(h,this.map.transform,this.scope,this.options);this.stylesheet.rain=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const h of this.map._markers)h._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(h){if(this._checkLoaded(),!h)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const y=this.fog;if(!i.by(y.get(),h)){y.set(h,this.options),this.stylesheet.fog=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}}else this._createFog(h);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(h){if(this._checkLoaded(),!h)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const y=this.snow;if(!i.by(y.get(),h)){y.set(h,this.options),this.stylesheet.snow=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}}else this._createSnow(h);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(h){if(this._checkLoaded(),!h)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const y=this.rain;if(!i.by(y.get(),h)){y.set(h,this.options),this.stylesheet.rain=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}}else this._createRain(h);this._markersNeedUpdate=!0}_reloadColorTheme(){const h=()=>{for(const D in this._layers)this._layers[D].lut=this._styleColorTheme.lut;for(const D in this._sourceCaches)this._sourceCaches[D].clearTiles()},y=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!y)return this._styleColorTheme.lut=null,void h();const A=this._evaluateColorThemeData(y);this._loadColorTheme(A).then(()=>{this.fire(new i.z("colorthemeset")),h()}).catch(D=>{i.w(`Couldn't set color theme: ${D}`)})}setColorTheme(h){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&i.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=h,this._reloadColorTheme()}setImportColorTheme(h,y){const A=this.getFragmentStyle(h);A&&(A._styleColorTheme.colorThemeOverride=y,A._reloadColorTheme())}_getTransitionParameters(h){return{now:i.o.now(),transition:Object.assign(this.transition,h)}}updateDrapeFirstLayers(){if(!this.terrain)return;const h=[],y=[];for(const A of this._mergedOrder)this.isLayerDraped(this._mergedLayers[A])?h.push(A):y.push(A);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...h),this._drapedFirstOrder.push(...y)}_createTerrain(h,y){const A=this.terrain=new Ut(h,y,this.scope,this.options,this.map.getWorldview());y===1&&(this.stylesheet.terrain=h),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const D=this._getTransitionParameters({duration:0});A.updateTransitions(D)}_force3DLayerUpdate(){for(const h in this._layers){const y=this._layers[h];y.type==="fill-extrusion"&&this._updateLayer(y)}}_forceSymbolLayerUpdate(){for(const h in this._layers){const y=this._layers[h];y.type==="symbol"&&this._updateLayer(y)}}_validate(h,y,A,D,F={}){if(F&&F.validate===!1)return!1;const z=Object.assign({},this.serialize());return ky(this,h.call(Yr,Object.assign({key:y,style:z,value:A,styleSpec:i.a6},D)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.dy.off("pluginStateChange",this._rtlTextPluginCallback);for(const h in this._mergedLayers)this._mergedLayers[h].setEventedParent(null);for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles(),this._mergedSourceCaches[h].setEventedParent(null);this.imageManager.removeScope(this.scope),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(h){const y=this.getSourceCaches(h);for(const A of y)A.clearTiles()}clearSources(){for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles()}clearLayers(){for(const h in this._mergedLayers){const y=this._mergedLayers[h];y._clear&&y._clear()}}reloadSource(h){const y=this.getSourceCaches(h);for(const A of y)A.resume(),A.reload()}reloadSources(){for(const h of this.getSources())h.reload&&h.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(h=>{h.modelManager.reloadModels(h.scope)})}updateSources(h){let y;this.directionalLight&&(y=t2(this.directionalLight));const A=new Set,D=new Set;for(const F in this._mergedLayers){const z=this._mergedLayers[F];z.type==="building"&&A.add(z.source),z.hasElevation()&&!D.has(z.source)&&D.add(z.source)}for(const F in this._mergedSourceCaches){const z=this._mergedSourceCaches[F],W=D.has(z._source.id);A.has(z._source.id)&&(z._source.reparseOverscaled=!1),z.update(h,void 0,void 0,y,W)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const y=this._sourceCaches[h];y.resume(),y.reload()}}_updatePlacement(h,y,A,D,F,z,W=!1){let J=!1,ne=!1;const le={},je={};for(const Pe of this._mergedOrder){const Ge=this._mergedLayers[Pe];if(Ge.type!=="symbol")continue;const Ve=i.B(Ge.source,Ge.scope);let nt=le[Ve];if(!nt){const ot=this.getLayerSourceCache(Ge);if(!ot)continue;const Et=ot.getRenderableIds(!0).map(Nt=>ot.getTileByID(Nt));je[Ve]=Et.slice(),nt=le[Ve]=Et.sort((Nt,Tt)=>Tt.tileID.overscaledZ-Nt.tileID.overscaledZ||(Nt.tileID.isLessThan(Tt.tileID)?-1:1))}const ut=this.crossTileSymbolIndex.addLayer(Ge,nt,y.center.lng,y.projection);J=J||ut}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),W=W||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const ve=!!(this.placement&&!y.equals(this.placement.transform)),Ne=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),De=(ve||Ne||J||this.placement&&this.placement.isStale())&&D===0;if((W||!this.pauseablePlacement||De||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),y.zoom))&&(this.pauseablePlacement=new Tc(y,this._mergedOrder,W||D===0,A,D,F,this.placement,this.fog&&y.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,le,je,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),ne=!0),J&&this.pauseablePlacement.placement.setStale()),ne||J){this._buildingIndex.onNewFrame(y.zoom);for(let Pe=0;PeF===h.id)!==-1)return void this.fire(new i.y(new Error(`Import with id '${h.id}' already exists in the map's style.`)));if(!y)return A.push(h),this._loadImports([h],!0);const D=A.findIndex(({id:F})=>F===y);return D===-1&&this.fire(new i.y(new Error(`Import with id "${y}" does not exist on this map.`))),this.stylesheet.imports=A.slice(0,D).concat(h).concat(A.slice(D)),this._loadImports([h],!0,y)}updateImport(h,y){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);return D===-1?this:typeof y=="string"?(this.setImportUrl(h,y),this):(y.url&&y.url!==A[D].url&&this.setImportUrl(h,y.url),i.by(y.config,A[D].config)||this.setImportConfig(h,y.config,y.data.schema),i.by(y.data,A[D].data)||this.setImportData(h,y.data),this)}moveImport(h,y){this._checkLoaded();let A=this.stylesheet.imports||[];const D=this.getImportIndex(h);if(D===-1)return this;const F=this.getImportIndex(y);if(F===-1)return this;const z=A[D],W=this.fragments[D];return A=A.filter(({id:J})=>J!==h),this.fragments=this.fragments.filter(({id:J})=>J!==h),this.stylesheet.imports=A.slice(0,F).concat(z).concat(A.slice(F)),this.fragments=this.fragments.slice(0,F).concat(W).concat(this.fragments.slice(F)),this.mergeLayers(),this}setImportUrl(h,y){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);if(D===-1)return this;A[D].url=y;const F=this.fragments[D];return F.style=this._createFragmentStyle(A[D]),F.style.on("style.import.load",()=>this.mergeAll()),F.style.loadURL(y),this}setImportData(h,y){this._checkLoaded();const A=this.getImportIndex(h),D=this.stylesheet.imports||[];return A===-1?this:y?(this.fragments[A].style.setState(y),this._reloadImports(),this):(delete D[A].data,this.setImportUrl(h,D[A].url))}setImportConfig(h,y,A){this._checkLoaded();const D=this.getImportIndex(h),F=this.stylesheet.imports||[];if(D===-1)return this;y?F[D].config=y:delete F[D].config;const z=this.fragments[D];A&&z.style.stylesheet&&(z.style.stylesheet.schema=A);const W=z.style.stylesheet&&z.style.stylesheet.schema;return z.config=y,z.style.updateConfig(y,W),this.updateConfigDependencies(),this}removeImport(h){this._checkLoaded();const y=this.stylesheet.imports||[],A=this.getImportIndex(h);A!==-1&&(y.splice(A,1),this.fragments[A].style._remove(),this.fragments.splice(A,1),this._reloadImports())}getImportIndex(h){const y=(this.stylesheet.imports||[]).findIndex(A=>A.id===h);return y===-1&&this.fire(new i.y(new Error(`Import '${h}' does not exist in the map's style and cannot be updated.`))),y}getLayer(h){return this._mergedLayers[h]}getSources(){const h=[];for(const y in this._mergedOtherSourceCaches){const A=this._mergedOtherSourceCaches[y];A&&h.push(A.getSource())}return h}getSource(h,y){const A=this.getSourceCache(h,y);return A&&A.getSource()}getLayerSource(h){const y=this.getLayerSourceCache(h);return y&&y.getSource()}getSourceCache(h,y){const A=i.B(h,y);return this._mergedOtherSourceCaches[A]}getLayerSourceCache(h){const y=i.B(h.source,h.scope);return h.type==="symbol"?this._mergedSymbolSourceCaches[y]:this._mergedOtherSourceCaches[y]}getSourceCaches(h){if(h==null)return Object.values(this._mergedSourceCaches);const y=[];return this._mergedOtherSourceCaches[h]&&y.push(this._mergedOtherSourceCaches[h]),this._mergedSymbolSourceCaches[h]&&y.push(this._mergedSymbolSourceCaches[h]),y}updateSourceCaches(){const h=this._changes.getUpdatedSourceCaches();for(const y in h){const A=h[y];A==="reload"?this.reloadSource(y):A==="clear"&&this.clearSource(y)}}updateLayers(h){const y=this._changes.getUpdatedPaintProperties();for(const A of y){const D=this.getLayer(A);D&&D.updateTransitions(h)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(h){this.stylesheet.glyphs=h,this.glyphManager.setURL(h)}getImages(h,y,A){this.imageManager.getImages(y.images,y.scope,A),this._updateTilesForChangedImages();const D=z=>{if(z){const W=y.images.map(J=>i.I.toString(J));z.setDependencies(y.tileID.key,y.type,W)}},F=i.B(y.source,y.scope);D(this._mergedOtherSourceCaches[F]),D(this._mergedSymbolSourceCaches[F]),y.images.some(z=>z.iconsetId)&&this.fire(new i.z("data",{dataType:"style"}))}rasterizeImages(h,y,A){this.imageManager.rasterizeImages(y,A)}getGlyphs(h,y,A){this.glyphManager.getGlyphs(y.stacks,A)}getResource(h,y,A){return i.dz(y,A)}getOwnSourceCache(h){return this._otherSourceCaches[h]}getOwnLayerSourceCache(h){return h.type==="symbol"?this._symbolSourceCaches[h.source]:this._otherSourceCaches[h.source]}getOwnSourceCaches(h){const y=[];return this._otherSourceCaches[h]&&y.push(this._otherSourceCaches[h]),this._symbolSourceCaches[h]&&y.push(this._symbolSourceCaches[h]),y}_isSourceCacheLoaded(h){const y=this.getOwnSourceCaches(h);return y.length===0?(this.fire(new i.y(new Error(`There is no source with ID '${h}'`))),!1):y.every(A=>A.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(h,y){if(!this._clipLayerPresent&&h.type!=="fill-extrusion"&&h.type!=="building")return!1;const A=h.type==="fill-extrusion"&&(h.sourceLayer==="building"||h.sourceLayer==="procedural_buildings"),D=h.type==="building";if(h.is3D(!!this.terrain)){if(A||D||y&&y.type==="batched-model"||h.type==="model")return!0}else if(h.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(h=>{h.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}tp.getSourceType=function(T){return Km[T]},tp.setSourceType=function(T,h){Km[T]=h},tp.registerForPluginStateChange=i.dA;class PR extends i.E{constructor(h){super(),this._style=h,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},i.aY(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(h){h===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=h,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(h){this._activeFloorsVisible=h,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(h){for(const[y,A]of Object.entries(h.buildings))if(this._buildings[y])for(const D of A.floorIds)this._buildings[y].floors[D]||(this._buildings[y].floors[D]=A.floors[D]);else this._buildings[y]=A;for(const y of h.activeFloors)this._activeFloors.add(y);this._updateIndoorSelector()}getIndoorTileOptions(h,y){const A=this._style.getIndoorSourceLayers(h,y);return A&&this._indoorState?{sourceLayers:A,indoorState:this._indoorState}:null}_updateUI(h,y,A){const D=function(F,z,W,J){let ne=null,le=Number.MAX_SAFE_INTEGER;if(J<16)return null;for(const[je,ve]of Object.entries(F)){const Ne=ve.center;if(Ne){const De=z.distanceTo(i.aT.convert(Ne));De({id:z,name:A.floors[z].name,zIndex:A.floors[z].zIndex})).sort((z,W)=>W.zIndex-z.zIndex);this.fire(new i.z("selector-update",{selectedFloorId:D,activeFloorsVisible:this._activeFloorsVisible,floors:F}))}_updateActiveFloors(){const h=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:h,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var eb=` #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`,tb=` #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;}`,GE=` #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`,UC="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;}",lm=` #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`,VC=`#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`,tr=`#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`,KE=`#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`,HC=`#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;}`,WC=`#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`,ZE=`#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 r2=/#include\s+"([^"]+)"/g,qf=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,YE=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,rv=new Set(["ifdef","ifndef","elif","if","defined"]),nv=new Set;My(eb,nv),My(GE,nv),My(tb,nv);const Cy={"_prelude_fog.vertex.glsl":VC,"_prelude_terrain.vertex.glsl":lm,"_prelude_shadow.vertex.glsl":WC,"_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":tr,"_prelude_shadow.fragment.glsl":ZE,"_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":KE,"_prelude_raster_particle.glsl":HC},GC={};Fa("",lm),Fa(tr,VC),Fa(ZE,WC),Fa(KE,""),Fa(HC,"");const IR=Fa(tb,GE),KC=eb,Mme=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",KC,IR.fragmentSource].join(` `),LR=["precision highp float;",KC,IR.vertexSource].join(` `);var XE={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 }`,UC),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 }`,UC),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 My(T,h){const y=T.split(` `);for(let A of y){if(A=A.trimStart(),A[0]!=="#"||!A.includes("if")||A.startsWith("#endif"))continue;const D=A.match(YE);if(D)for(const F of D)rv.has(F)||h.add(F)}}function Fa(T,h){const y=new Set,A=[],D=[];T=T.replace(r2,(z,W)=>(D.push(W),"")),h=h.replace(r2,(z,W)=>(A.push(W),""));let F=new Set(nv);My(T,F),My(h,F);for(const z of[...A,...D])GC[z]||(GC[z]=new Set,My(Cy[z],GC[z])),F=new Set([...F,...GC[z]]);return{fragmentSource:T=T.replace(qf,(z,W,J,ne,le)=>(y.add(le),W==="define"?` #ifndef HAS_UNIFORM_u_${le} in ${J} ${ne} ${le}; #else uniform ${J} ${ne} u_${le}; #endif `:W==="initialize"?` #ifdef HAS_UNIFORM_u_${le} ${J} ${ne} ${le} = u_${le}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${J} ${ne} ${le}; #endif `:W==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace(qf,(z,W,J,ne,le)=>{const je=`MATERIAL_ATTRIBUTE_OFFSET_${le}`,ve=ne==="float"?"vec2":ne,Ne=`GET_ATTRIBUTE_${ve}(a_${le}, materialInfo, ${je})`,De=le.match(/color/)?"color":ve;return W==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${J} ${ne} a_${le}; #endif `:y.has(le)?W==="define"?` #ifndef HAS_UNIFORM_u_${le} uniform lowp float u_${le}_t; #if !defined(${je}) in ${J} ${ve} a_${le}; #endif out ${J} ${ne} ${le}; #else uniform ${J} ${ne} u_${le}; #endif `:W==="initialize"?De==="vec4"?` #ifndef HAS_UNIFORM_u_${le} ${le} = a_${le}; #else ${J} ${ne} ${le} = u_${le}; #endif `:` #if !defined(HAS_UNIFORM_u_${le}) #ifdef ${je} ${le} = unpack_mix_${De}(${Ne}, u_${le}_t); #else ${le} = unpack_mix_${De}(a_${le}, u_${le}_t); #endif #else ${J} ${ne} ${le} = u_${le}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${J} ${ne} a_${le}; out ${J} ${ne} ${le}; #endif `:W==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} ${le} = a_${le}; #endif `:void 0:W==="define"?` #ifndef HAS_UNIFORM_u_${le} uniform lowp float u_${le}_t; #if !defined(${je}) in ${J} ${ve} a_${le}; #endif #else uniform ${J} ${ne} u_${le}; #endif `:W==="define-instanced"?De==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${le}0; in vec4 a_${le}1; in vec4 a_${le}2; in vec4 a_${le}3; #else uniform ${J} ${ne} u_${le}; #endif `:` #ifdef INSTANCED_ARRAYS in ${J} ${ve} a_${le}; #else uniform ${J} ${ne} u_${le}; #endif `:W==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${le} ${J} ${ne} ${le} = a_${le}; #endif `:De==="vec4"?` #ifndef HAS_UNIFORM_u_${le} #ifdef ${je} ${J} ${ne} ${le} = ${Ne}; #else ${J} ${ne} ${le} = a_${le}; #endif #else ${J} ${ne} ${le} = u_${le}; #endif `:` #ifndef HAS_UNIFORM_u_${le} #ifdef ${je} ${J} ${ne} ${le} = unpack_mix_${De}(${Ne}, u_${le}_t); #else ${J} ${ne} ${le} = unpack_mix_${De}(a_${le}, u_${le}_t); #endif #else ${J} ${ne} ${le} = u_${le}; #endif `}),usedDefines:F,vertexIncludes:A,fragmentIncludes:D}}class Tme{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(h,y,A,D,F,z,W,J){this.context=h;let ne=this.boundPaintVertexBuffers.length!==D.length;for(let je=0;!ne&&je{const Et=ut.paint.get("hillshade-shadow-color"),Nt=ut.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",Tt=ut.paint.get("hillshade-highlight-color"),wt=ut.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",yt=ut.paint.get("hillshade-accent-color"),Ot=ut.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Wt=ut.paint.get("hillshade-emissive-strength");let Ht=i.an(ut.paint.get("hillshade-illumination-direction"));if(ut.paint.get("hillshade-illumination-anchor")==="viewport")Ht-=Ve.transform.angle;else if(Ve.style&&Ve.style.enable3dLights()&&Ve.style.directionalLight){const ts=Ve.style.directionalLight.properties.get("direction"),xs=i.d4(ts.x,ts.y,ts.z);Ht=i.an(xs[1])}const es=!Ve.options.moving;return{u_matrix:ot||Ve.transform.calculateProjMatrix(nt.tileID.toUnwrapped(),es),u_image:0,u_latrange:Ame(0,nt.tileID),u_light:[ut.paint.get("hillshade-exaggeration"),Ht],u_shadow:Et.toPremultipliedRenderColor(Nt?null:ut.lut),u_highlight:Tt.toPremultipliedRenderColor(wt?null:ut.lut),u_emissive_strength:Wt,u_accent:yt.toPremultipliedRenderColor(Ot?null:ut.lut)}})(T,y,A,T.terrain?h.projMatrix:null);T.uploadCommonUniforms(W,ve,h.toUnwrapped());const{tileBoundsBuffer:De,tileBoundsIndexBuffer:Pe,tileBoundsSegments:Ge}=T.getTileBoundsBuffers(y);ve.draw(T,J.TRIANGLES,D,F,z,mn.disabled,Ne,A.id,De,Pe,Ge)}function QE(T,h,y){if(!h.needsDEMTextureUpload)return;const A=T.context,D=A.gl;A.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||T.getTileTexture(y.stride);const F=y.getPixels();h.demTexture?h.demTexture.update(F,{premultiply:!1}):h.demTexture=new i.T(A,F,D.R32F,{premultiply:!1}),h.needsDEMTextureUpload=!1}function Pme(T,h,y){const A=T.context,D=A.gl;if(!h.dem)return;const F=h.dem;if(A.activeTexture.set(D.TEXTURE1),QE(T,h,F),!h.demTexture)return;h.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const z=F.dim;A.activeTexture.set(D.TEXTURE0);let W=h.hillshadeFBO;if(!W){const ve=new i.T(A,{width:z,height:z,data:null},D.RGBA8);ve.bind(D.LINEAR,D.CLAMP_TO_EDGE),W=h.hillshadeFBO=A.createFramebuffer(z,z,1,"renderbuffer"),W.colorAttachment0.set(ve.texture)}A.bindFramebuffer.set(W.framebuffer),A.viewport.set([0,0,z,z]);const{tileBoundsBuffer:J,tileBoundsIndexBuffer:ne,tileBoundsSegments:le}=T.getMercatorTileBoundsBuffers(),je=[];T.linearFloatFilteringSupported()&&je.push("TERRAIN_DEM_FLOAT_FORMAT"),T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&je.push("USE_MRT1"),T.getOrCreateProgram("hillshadePrepare",{defines:je}).draw(T,D.TRIANGLES,Fr.disabled,yn.disabled,Hn.unblended,mn.disabled,((ve,Ne)=>{const De=Ne.stride,Pe=i.bC();return i.ce(Pe,0,i.al,-i.al,0,0,1),i.br(Pe,Pe,[0,-i.al,0]),{u_matrix:Pe,u_image:1,u_dimension:[De,De],u_zoom:ve.overscaledZ}})(h.tileID,F),y.id,J,ne,le),h.needsHillshadePrepare=!1}class ho{constructor(h){this.gl=h.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(h){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Ime extends ho{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const y=this.current;(h.r!==y.r||h.g!==y.g||h.b!==y.b||h.a!==y.a||this.dirty)&&(this.gl.clearColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class DR extends ho{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class JE extends ho{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class ZC extends ho{getDefault(){return[!0,!0,!0,!0]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||h[3]!==y[3]||this.dirty)&&(this.gl.colorMask(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class e6 extends ho{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class av extends ho{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class sb extends ho{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(h){const y=this.current;(h.func!==y.func||h.ref!==y.ref||h.mask!==y.mask||this.dirty)&&(this.gl.stencilFunc(h.func,h.ref,h.mask),this.current=h,this.dirty=!1)}}class n2 extends ho{getDefault(){const h=this.gl;return[h.KEEP,h.KEEP,h.KEEP]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||this.dirty)&&(this.gl.stencilOp(h[0],h[1],h[2]),this.current=h,this.dirty=!1)}}class rb extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.STENCIL_TEST):y.disable(y.STENCIL_TEST),this.current=h,this.dirty=!1}}class OR extends ho{getDefault(){return[0,1]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||this.dirty)&&(this.gl.depthRange(h[0],h[1]),this.current=h,this.dirty=!1)}}class t6 extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.DEPTH_TEST):y.disable(y.DEPTH_TEST),this.current=h,this.dirty=!1}}class RR extends ho{getDefault(){return this.gl.LESS}set(h){(h!==this.current||this.dirty)&&(this.gl.depthFunc(h),this.current=h,this.dirty=!1)}}class nb extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.BLEND):y.disable(y.BLEND),this.current=h,this.dirty=!1}}class YC extends ho{getDefault(){const h=this.gl;return[h.ONE,h.ZERO,h.ONE,h.ZERO]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||h[3]!==y[3]||this.dirty)&&(this.gl.blendFuncSeparate(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class XC extends ho{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const y=this.current;(h.r!==y.r||h.g!==y.g||h.b!==y.b||h.a!==y.a||this.dirty)&&(this.gl.blendColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class s6 extends ho{getDefault(){return this.gl.FUNC_ADD}set(h){(h!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(h,h),this.current=h,this.dirty=!1)}}class QC extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.CULL_FACE):y.disable(y.CULL_FACE),this.current=h,this.dirty=!1}}class a2 extends ho{getDefault(){return this.gl.BACK}set(h){(h!==this.current||this.dirty)&&(this.gl.cullFace(h),this.current=h,this.dirty=!1)}}class FR extends ho{getDefault(){return this.gl.CCW}set(h){(h!==this.current||this.dirty)&&(this.gl.frontFace(h),this.current=h,this.dirty=!1)}}let zR=class extends ho{getDefault(){return null}set(T){(T!==this.current||this.dirty)&&(this.gl.useProgram(T),this.current=T,this.dirty=!1)}};class BR extends ho{getDefault(){return this.gl.TEXTURE0}set(h){(h!==this.current||this.dirty)&&(this.gl.activeTexture(h),this.current=h,this.dirty=!1)}}class ab extends ho{getDefault(){const h=this.gl;return[0,0,h.drawingBufferWidth,h.drawingBufferHeight]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||h[3]!==y[3]||this.dirty)&&(this.gl.viewport(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class $R extends ho{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindFramebuffer(y.FRAMEBUFFER,h),this.current=h,this.dirty=!1}}class Lme extends ho{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindRenderbuffer(y.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class Dme extends ho{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindTexture(y.TEXTURE_2D,h),this.current=h,this.dirty=!1}}class Ome extends ho{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindBuffer(y.ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class r6 extends ho{getDefault(){return null}set(h){const y=this.gl;y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class n6 extends ho{getDefault(){return null}set(h){this.gl&&(h!==this.current||this.dirty)&&(this.gl.bindVertexArray(h),this.current=h,this.dirty=!1)}}class a6 extends ho{getDefault(){return 4}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.pixelStorei(y.UNPACK_ALIGNMENT,h),this.current=h,this.dirty=!1}}class i6 extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h),this.current=h,this.dirty=!1}}class qR extends ho{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.pixelStorei(y.UNPACK_FLIP_Y_WEBGL,h),this.current=h,this.dirty=!1}}class JC extends ho{constructor(h,y){super(h),this.context=h,this.parent=y}getDefault(){return null}}class e3 extends JC{constructor(h,y,A=0){super(h,y),this.attachmentPoint=h.gl.COLOR_ATTACHMENT0+A}setDirty(){this.dirty=!0}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const y=this.gl;y.framebufferTexture2D(y.FRAMEBUFFER,this.attachmentPoint,y.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class ib extends JC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const y=this.gl;y.framebufferRenderbuffer(y.FRAMEBUFFER,this.attachment(),y.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class i2 extends JC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const y=this.gl;y.framebufferTexture2D(y.FRAMEBUFFER,this.attachment(),y.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class UR extends ib{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const cm=(T,h,y,A)=>({u_matrix:T,u_image0:0,u_image1:1,u_skirt_height:h,u_ground_shadow_factor:y,u_emissive_texture_available:A}),t3=(T,h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge)=>({u_proj_matrix:Float32Array.from(T),u_globe_matrix:h,u_normalize_matrix:Float32Array.from(A),u_merc_matrix:y,u_zoom_transition:D,u_merc_center:F,u_image0:0,u_image1:1,u_frustum_tl:z,u_frustum_tr:W,u_frustum_br:J,u_frustum_bl:ne,u_globe_pos:le,u_globe_radius:je,u_viewport:ve,u_grid_matrix:Ge?Float32Array.from(Ge):new Float32Array(9),u_skirt_height:Ne,u_far_z_cutoff:De,u_emissive_texture_available:Pe});function o2(T,h){return T!=null&&h!=null&&!(!T.hasData()||!h.hasData())&&T.demTexture!=null&&h.demTexture!=null&&T.tileID.key!==h.tileID.key}const rg=new class{constructor(){this.operations={}}newMorphing(T,h,y,A,D){if(T in this.operations){const F=this.operations[T];F.to.tileID.key!==y.tileID.key&&(F.queued=y)}else this.operations[T]={startTime:A,phase:0,duration:D,from:h,to:y,queued:null}}getMorphValuesForProxy(T){if(!(T in this.operations))return null;const h=this.operations[T];return{from:h.from,to:h.to,phase:h.phase}}update(T){for(const h in this.operations){const y=this.operations[h];for(y.phase=(T-y.startTime)/y.duration;y.phase>=1||!this._validOp(y);)if(!this._nextOp(y,T)){delete this.operations[h];break}}}_nextOp(T,h){return!!T.queued&&(T.from=T.to,T.to=T.queued,T.queued=null,T.phase=0,T.startTime=h,!0)}_validOp(T){return T.from.hasData()&&T.to.hasData()}},s3={0:null,1:"TERRAIN_VERTEX_MORPHING"};function r3(T,h,y){if(h===0)return 0;const A=h<1&&y===514?.25/h:1;return 6*Math.pow(1.5,22-T)*Math.max(h,1)*A}function o6(T,h){const y=1<({u_matrix:T});function c2(T,h,y,A,D){if(D>0){const F=i.o.now(),z=(F-T.timeAdded)/D,W=h?(F-h.timeAdded)/D:-1,J=y.getSource(),ne=A.coveringZoomLevel({tileSize:J.tileSize,roundZoom:J.roundZoom}),le=!h||Math.abs(h.tileID.overscaledZ-ne)>Math.abs(T.tileID.overscaledZ-ne),je=le&&T.refreshedUponExpiration?1:i.aA(le?z:1-W,0,1);return h?{opacity:1,mix:1-je,isFading:z<1}:{opacity:je,mix:0,isFading:z<1}}return{opacity:1,mix:0,isFading:!1}}class n3 extends El{constructor(h){const y=Bl("mock-dem",{type:"raster-dem",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("mock-dem",y,!1),y.setEventedParent(this),this._sourceLoaded=!0}_loadTile(h,y){h.state="loaded",y(null)}}class l6 extends El{constructor(h){const y=Bl("proxy",{type:"geojson",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("proxy",y,!1),y.setEventedParent(this),this.map=this.getSource().map=h,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(h,y,A){if(h.freezeTileCoverage)return;this.transform=h;const D=h.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((F,z)=>{if(F[z.key]="",!this._tiles[z.key]){const W=new Ym(z,this._source.tileSize*z.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);W.state="loaded",this._tiles[z.key]=W}return F},{});for(const F in this._tiles)F in D||(this.freeFBO(F),this._tiles[F].unloadVectorData(),delete this._tiles[F])}freeFBO(h){const y=this.proxyCachedFBO[h];if(y!==void 0){const A=Object.values(y);this.renderCachePool.push(...A),delete this.proxyCachedFBO[h]}}deallocRenderCache(){this.renderCache.forEach(h=>h.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class c6 extends i.aQ{constructor(h,y,A){super(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y),this.proxyTileKey=y,this.projMatrix=A}}class d6 extends i.bV{constructor(h,y){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=h,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[A,D,F]=function(J){const ne=new i.bd,le=new i.b0,je=131;ne.reserve(17161),le.reserve(33800);const ve=i.al/128,Ne=i.al+ve/2,De=Ne+ve;for(let Ge=-ve;GeNe||Ge<0||Ge>Ne?24575:0,ut=i.aA(Math.round(Ve),0,i.al),ot=i.aA(Math.round(Ge),0,i.al);ne.emplaceBack(ut+nt,ot)}const Pe=(Ge,Ve)=>{const nt=Ve*je+Ge;le.emplaceBack(nt+1,nt,nt+je),le.emplaceBack(nt+je,nt+je+1,nt+1)};for(let Ge=1;Ge<129;Ge++)for(let Ve=1;Ve<129;Ve++)Pe(Ve,Ge);return[0,129].forEach(Ge=>{for(let Ve=0;Ve<130;Ve++)Pe(Ve,Ge),Pe(Ge,Ve)}),[ne,le,32768]}(),z=h.context;this.gridBuffer=z.createVertexBuffer(A,i.bf.members),this.gridIndexBuffer=z.createIndexBuffer(D),this.gridSegments=i.bg.simpleSegment(0,0,A.length,D.length),this.gridNoSkirtSegments=i.bg.simpleSegment(0,0,A.length,F),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new l6(y.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 W=z.gl;this._overlapStencilMode=new yn({func:W.GEQUAL,mask:255},0,255,W.KEEP,W.KEEP,W.REPLACE),this._previousZoom=h.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=y,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new n3(y.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(h){h.on("data",this._onStyleDataEvent.bind(this)),this._style=h,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(h,y,A){if(h&&h.terrain){this._style!==h&&(this.style=h,this._evaluationZoom=void 0);const D=h.terrain.properties,F=h.terrain.drapeRenderMode===0,z=h.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const W=h.terrain&&h.terrain.scope,J=D.get("source"),ne=F?this._mockSourceCache:h.getSourceCache(J,W);if(!ne)return void i.w(`Couldn't find terrain source "${J}".`);if(this.sourceCache=ne,this._attenuationRange=h.terrain.getAttenuationRange(),this._exaggeration=z?this.calculateExaggeration(y):D.get("exaggeration"),!y.projection.requiresDraping&&z&&this._exaggeration===0)return void this._disable();this.enabled=!0;const le=()=>{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 je=this.getScaledDemTileSize();this.sourceCache.update(y,je,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,le(),this._initializing=!0),le(),y.updateElevation(!0,A),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(y),this._emptyDEMTextureDirty=!0,this._previousZoom=y.zoom}else this._disable()}calculateExaggeration(h){if(this._attenuationRange&&h.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(h.zoom);const y=this._previousCameraAltitude,A=h.getFreeCameraOptions().position.z/h.pixelsPerMeter*h.worldSize;this._previousCameraAltitude=A;const D=y!=null?A-y:Number.MAX_VALUE;if(Math.abs(D)<2)return this._exaggeration;const F=h.zoom,z=this._style.terrain;if(!this._previousUpdateTimestamp)return z.getExaggeration(F);let W=F-this._previousZoom;const J=this._previousUpdateTimestamp;let ne=F;this._evaluationZoom!=null&&(ne=this._evaluationZoom,Math.abs(F-ne)>.5&&(W=.5*(F-ne+W)),W*D<0&&(ne+=W)),this._evaluationZoom=ne;const le=z.getExaggeration(ne),je=le===z.getExaggeration(Math.max(0,ne-.1));if(je&&Math.abs(le-this._exaggeration)<.01)return le;let ve=Math.min(.1,.00375*(this._updateTimestamp-J));return(je||le<.1||Math.abs(W)<1e-4)&&(ve=Math.min(.2,4*ve)),i.ak(this._exaggeration,le,ve)}resetTileLookupCache(h){this._findCoveringTileCache[h]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(h){h.dataType==="source"&&h.coord?this._clearRenderCacheForTile(h.sourceCacheId,h.coord):h.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const h in this._style._mergedSourceCaches)this._style._mergedSourceCaches[h].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(h=>h.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const h=2*this.proxySourceCache.getSource().tileSize;return[h,h]}set useVertexMorphing(h){this._useVertexMorphing=h}updateTileBinding(h){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const y=this.proxySourceCache,A=this.painter.transform;this._initializing&&(this._initializing=A._centerAltitude===0&&this.getAtPointOrZero(i.ae.fromLngLat(A.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const D=this.proxyCoords=y.getIds().map(J=>{const ne=y.getTileByID(J).tileID;return ne.projMatrix=A.calculateProjMatrix(ne.toUnwrapped()),ne});(function(J,ne){const le=ne.transform.pointCoordinate(ne.transform.getCameraPoint()),je=new i.P(le.x,le.y);J.sort((ve,Ne)=>{if(Ne.overscaledZ-ve.overscaledZ)return Ne.overscaledZ-ve.overscaledZ;const De=new i.P(ve.canonical.x+(1<{this.proxyToSource[J.key]={}}),this.terrainTileForTile={};const z=this._style._mergedSourceCaches;for(const J in z){const ne=z[J];if(!ne.used||(ne!==this.sourceCache&&this.resetTileLookupCache(ne.id),this._setupProxiedCoordsForOrtho(ne,h[J],F),ne.usedForTerrain))continue;const le=h[J];ne.getSource().reparseOverscaled&&this._assignTerrainTiles(le)}this.proxiedCoords[y.id]=D.map(J=>new c6(J,J.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(F),this.renderingToTexture=!1;const W={};this._visibleDemTiles=[];for(const J of this.proxyCoords){const ne=this.terrainTileForTile[J.key];if(!ne)continue;const le=ne.tileID.key;le in W||(this._visibleDemTiles.push(ne),W[le]=le)}}_assignTerrainTiles(h){this._initializing||h.forEach(y=>{if(this.terrainTileForTile[y.key])return;const A=this._findTileCoveringTileID(y,this.sourceCache);A&&(this.terrainTileForTile[y.key]=A)})}_prepareDEMTextures(){const h=this.painter.context,y=h.gl;for(const A in this.terrainTileForTile){const D=this.terrainTileForTile[A],F=D.dem;!F||D.demTexture&&!D.needsDEMTextureUpload||(h.activeTexture.set(y.TEXTURE1),QE(this.painter,D,F))}}_prepareDemTileUniforms(h,y,A,D){if(!y||y.demTexture==null)return!1;const F=h.tileID.canonical,z=Math.pow(2,y.tileID.canonical.z-F.z),W=D||"";return A[`u_dem_tl${W}`]=[F.x*z%1,F.y*z%1],A[`u_dem_scale${W}`]=z,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let h=0;const y=this._visibleDemTiles.reduce((A,D)=>{if(!D.dem)return A;const F=D.dem.tree.minimums[0];return F>0&&h++,A+F},0);return h?y/h:0}_updateEmptyDEMTexture(){const h=this.painter.context,y=h.gl;h.activeTexture.set(y.TEXTURE2);const A=this._getLoadedAreaMinimum(),D=new i.dL({width:1,height:1},new Float32Array([A]));this._emptyDEMTextureDirty=!1;let F=this._emptyDEMTexture;return F?F.update(D,{premultiply:!1}):F=this._emptyDEMTexture=new i.T(h,D,y.R32F,{premultiply:!1}),F}setupElevationDraw(h,y,A){const D=this.painter.context,F=D.gl,z={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};z.u_exaggeration=this.exaggeration();let W=null,J=null,ne=1;if(A&&A.morphing&&this._useVertexMorphing){const Ne=A.morphing.srcDemTile,De=A.morphing.dstDemTile;ne=A.morphing.phase,Ne&&De&&(this._prepareDemTileUniforms(h,Ne,z,"_prev")&&(J=Ne),this._prepareDemTileUniforms(h,De,z)&&(W=De))}const le=Ne=>Ne&&Ne.demTexture&&this.painter.linearFloatFilteringSupported()?F.LINEAR:F.NEAREST;let je=null;var ve;if(this.enabled?J&&W?(je=W.demTexture,D.activeTexture.set(F.TEXTURE4),J.demTexture.bind(le(J),F.CLAMP_TO_EDGE),z.u_dem_lerp=ne):(W=this.terrainTileForTile[h.tileID.key],je=this._prepareDemTileUniforms(h,W,z)?W.demTexture:this.emptyDEMTexture):je=this.emptyDEMTexture,D.activeTexture.set(F.TEXTURE2),je&&(z.u_dem_size=(ve=je).size[0]===1?1:ve.size[0]-2,je.bind(le(W),F.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(A&&A.useDepthForOcclusion,y,z),A&&A.useMeterToDem&&W){const Ne=(1<{if(Ve===ts)return;const xs=[s3[ts],"PROJECTION_GLOBE_VIEW"];ut&&xs.push("CUSTOM_ANTIALIASING");const qs=ne.isTileAffectedByFog(es);Ge=ne.getOrCreateProgram("globeRaster",{defines:xs,overrideFog:qs}),Ve=ts},Et=ne.colorModeForRenderPass(),Nt=new Fr(Pe.LEQUAL,Fr.ReadWrite,ne.depthRangeFor3D);rg.update(Ne);const Tt=i.dF(nt),wt=[i.aF(nt.center.lng),i.aJ(nt.center.lat)],yt=ne.globeSharedBuffers,Ot=[nt.width*i.o.devicePixelRatio,nt.height*i.o.devicePixelRatio],Wt=Float32Array.from(nt.globeMatrix),Ht={useDenormalizedUpVectorScale:!0};{const es=ne.transform,ts=r3(es.zoom,le.exaggeration(),le.sourceCache._source.tileSize);Ve=-1;const xs=Pe.TRIANGLES;for(const qs of ve){const Yt=je.getTile(qs),Bt=yn.disabled,as=le.prevTerrainTileForTile[qs.key],Jt=le.terrainTileForTile[qs.key];o2(as,Jt)&&rg.newMorphing(qs.key,as,Jt,Ne,250),ob(ne,Yt.emissiveTexture),De.activeTexture.set(Pe.TEXTURE0),Yt.texture&&Yt.texture.bind(Pe.LINEAR,Pe.CLAMP_TO_EDGE);const Is=rg.getMorphValuesForProxy(qs.key),rr=Is?1:0;Is&&Object.assign(Ht,{morphing:{srcDemTile:Is.from,dstDemTile:Is.to,phase:i.dD(Is.phase)}});const yr=i.dG(qs.canonical),Js=i.dH(yr.getCenter().lat),Us=i.dI(qs.canonical,yr,Js,es.worldSize/es._pixelsPerMercatorPixel),Pr=i.bk(i.dJ(qs.canonical)),Cr=ne.emissiveMode==="mrt-fallback"?1:0,hr=t3(es.expandedFarZProjMatrix,Wt,Tt,Pr,i.aj(es.zoom),wt,es.frustumCorners.TL,es.frustumCorners.TR,es.frustumCorners.BR,es.frustumCorners.BL,es.globeCenterInViewSpace,es.globeRadius,Ot,ts,es._farZ,Cr,Us);if(ot(qs,rr),Ge&&(le.setupElevationDraw(Yt,Ge,Ht),ne.uploadCommonUniforms(De,Ge,qs.toUnwrapped()),yt)){const[br,Kr,Pn]=yt.getGridBuffers(Js,ts!==0);Ge.draw(ne,xs,Nt,Bt,Et,mn.backCCW,hr,"globe_raster",br,Kr,Pn)}}}if(yt&&(ne.renderDefaultNorthPole||ne.renderDefaultSouthPole)){const es=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];ut&&es.push("CUSTOM_ANTIALIASING"),Ge=ne.getOrCreateProgram("globeRaster",{defines:es});for(const ts of ve){const{x:xs,y:qs,z:Yt}=ts.canonical,Bt=qs===0,as=qs===(1<br.draw(ne,Pe.TRIANGLES,Nt,yn.disabled,Et,mn.disabled,t3(nt.expandedFarZProjMatrix,Us,Us,Pr,0,wt,nt.frustumCorners.TL,nt.frustumCorners.TR,nt.frustumCorners.BR,nt.frustumCorners.BL,nt.globeCenterInViewSpace,nt.globeRadius,Ot,0,nt._farZ,Cr),"globe_pole_raster",Kr,rr,yr);le.setupElevationDraw(Js,Ge,Ht),ne.uploadCommonUniforms(De,Ge,ts.toUnwrapped()),Bt&&ne.renderDefaultNorthPole&&hr(Ge,Jt),as&&ne.renderDefaultSouthPole&&(Us=i.cS(i.bC(),Us,[1,-1,1]),hr(Ge,Is))}}}})(D,F,z,W,J);else{const ne=D.context,le=ne.gl;let je,ve;const Ne=D.shadowRenderer,De=jy(D,D.longestCutoffRange),Pe=Et=>{if(ve===Et)return;const Nt=[];Nt.push(s3[Et]),De.shouldRenderCutoff&&Nt.push("RENDER_CUTOFF"),Ne&&(Nt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Ne.useNormalOffset&&Nt.push("NORMAL_OFFSET")),je=D.getOrCreateProgram("terrainRaster",{defines:Nt}),ve=Et},Ge=D.colorModeForRenderPass(),Ve=new Fr(le.LEQUAL,Fr.ReadWrite,D.depthRangeFor3D);rg.update(J);const nt=D.transform,ut=r3(nt.zoom,F.exaggeration(),F.sourceCache._source.tileSize);let ot=[0,0,0];if(Ne){const Et=D.style.directionalLight,Nt=D.style.ambientLight;Et&&Nt&&(ot=sg(D.style,Et,Nt))}{ve=-1;const Et=le.TRIANGLES,[Nt,Tt]=[F.gridIndexBuffer,F.gridSegments];for(const wt of W){const yt=z.getTile(wt),Ot=yn.disabled,Wt=F.prevTerrainTileForTile[wt.key],Ht=F.terrainTileForTile[wt.key];o2(Wt,Ht)&&rg.newMorphing(wt.key,Wt,Ht,J,250),ob(D,yt.emissiveTexture),ne.activeTexture.set(le.TEXTURE0),yt.texture&&yt.texture.bind(le.LINEAR,le.CLAMP_TO_EDGE);const es=rg.getMorphValuesForProxy(wt.key),ts=es?1:0;let xs;es&&(xs={morphing:{srcDemTile:es.from,dstDemTile:es.to,phase:i.dD(es.phase)}});const qs=D.emissiveMode==="mrt-fallback"?1:0,Yt=cm(wt.projMatrix,o6(wt.canonical,nt.renderWorldCopies)?ut/10:ut,ot,qs);if(Pe(ts),!je)continue;F.setupElevationDraw(yt,je,xs);const Bt=wt.toUnwrapped();Ne&&Ne.setupShadows(Bt,je),D.uploadCommonUniforms(ne,je,Bt,null,De),je.draw(D,Et,Ve,Ot,Ge,mn.backCCW,Yt,"terrain_raster",F.gridBuffer,Nt,Tt)}}}}(y,this,this.proxySourceCache,h,this._updateTimestamp),this.renderingToTexture=!0,y.gpuTimingDeferredRenderEnd(),h.splice(0,h.length))}renderBatch(h){if(this._drapedRenderBatches.length===0)return h+1;this.renderingToTexture=!0;const y=this.painter,A=this.painter.context,D=this.proxySourceCache,F=this.proxiedCoords[D.id],z=this._drapedRenderBatches.shift(),W=y.style.order,J=[];this._updateFBOs(y.emissiveMode==="mrt-fallback");let ne=0;for(const le of F){const je=D.getTileByID(le.proxyTileKey),ve=D.proxyCachedFBO[le.key]?D.proxyCachedFBO[le.key][h]:void 0,Ne=ve!==void 0?D.renderCache[ve]:this.pool[ne++],De=ve!==void 0;if(je.texture=Ne.tex,je.emissiveTexture=Ne.emissiveTex,De&&!Ne.dirty){J.push(je.tileID);continue}A.bindFramebuffer.set(Ne.fb.framebuffer);const Pe=A.gl;let Ge;Pe.drawBuffers(y.emissiveMode==="mrt-fallback"?[Pe.COLOR_ATTACHMENT0,Pe.COLOR_ATTACHMENT1]:[Pe.COLOR_ATTACHMENT0]),this.renderedToTile=!1,Ne.dirty&&(A.clear({color:i.ao.transparent,stencil:0}),Ne.dirty=!1);for(let Ve=z.start;Ve<=z.end;++Ve){const nt=y.style._mergedLayers[W[Ve]];if(nt.isHidden(y.transform.zoom))continue;const ut=y.style.getLayerSourceCache(nt),ot=ut?this.proxyToSource[le.key][ut.id]:[le];if(!ot)continue;const Et=ot;A.viewport.set([0,0,Ne.fb.width,Ne.fb.height]),Ge!==(ut?ut.id:null)&&(this._setupStencil(Ne,ot,nt,ut),Ge=ut?ut.id:null),y.renderLayer(y,ut,nt,Et)}if(Pe.drawBuffers([Pe.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Ve of this._pendingGroundEffectLayers){const nt=y.style._mergedLayers[W[Ve]];if(nt.isHidden(y.transform.zoom))continue;const ut=y.style.getLayerSourceCache(nt),ot=ut?this.proxyToSource[le.key][ut.id]:[le];if(!ot)continue;const Et=ot;A.viewport.set([0,0,Ne.fb.width,Ne.fb.height]),Ge!==(ut?ut.id:null)&&(this._setupStencil(Ne,ot,nt,ut),Ge=ut?ut.id:null),y.renderLayer(y,ut,nt,Et)}this.renderedToTile?(Ne.dirty=!0,J.push(je.tileID)):De||--ne,ne===5&&(ne=0,this.renderToBackBuffer(J))}return this.renderToBackBuffer(J),this.renderingToTexture=!1,A.bindFramebuffer.set(null),A.viewport.set([0,0,y.width,y.height]),z.end+1}postRender(){}isLayerOrderingCorrect(h){const y=h.order.length;let A=-1,D=y;for(let F=0;FA}getMinElevationBelowMSL(){let h=0;return this._visibleDemTiles.filter(y=>y.dem).forEach(y=>{h=Math.min(h,y.dem.tree.minimums[0])}),h===0?h:(h-30)*this._exaggeration}raycast(h,y,A){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(F=>F.dem).map(F=>{const z=F.tileID,W=1<(F.t!==null?F.t:Number.MAX_VALUE)-(z.t!==null?z.t:Number.MAX_VALUE));for(const F of D){if(F.t==null)return null;const z=F.tile.dem.tree.raycast(F.minx,F.miny,F.maxx,F.maxy,h,y,A);if(z!=null)return z}return null}_createFBO(){const h=this.painter.context,y=h.gl,A=this.drapeBufferSize;h.activeTexture.set(y.TEXTURE0);const D=new i.T(h,{width:A[0],height:A[1],data:null},y.RGBA8);D.bind(y.LINEAR,y.CLAMP_TO_EDGE);const F=h.createFramebuffer(A[0],A[1],1,null);let z;return F.colorAttachment0.set(D.texture),this._emissiveTexture&&(z=new i.T(h,{width:A[0],height:A[1],data:null},y.R8),z.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.createColorAttachment(h,1),F.colorAttachment1.set(z.texture)),F.depthAttachment=new UR(h,F.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=h.createRenderbuffer(h.gl.DEPTH_STENCIL,A[0],A[1]),this._stencilRef=0,F.depthAttachment.set(this._sharedDepthStencil),h.clear({stencil:0})):F.depthAttachment.set(this._sharedDepthStencil),h.extTextureFilterAnisotropic&&y.texParameterf(y.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax),{fb:F,tex:D,emissiveTex:z,dirty:!1}}_updateFBOs(h){if(this._emissiveTexture!==h){for(const y of this.pool)this._updateFBO(y,h);for(const y of this.proxySourceCache.renderCache)this._updateFBO(y,h);this._emissiveTexture=h}}_updateFBO(h,y){const A=h.fb,D=this.painter.context,F=D.gl,z=this.drapeBufferSize;if(y){const W=new i.T(D,{width:z[0],height:z[1],data:null},F.R8);W.bind(F.LINEAR,F.CLAMP_TO_EDGE),h.emissiveTex=W,A.createColorAttachment(D,1),A.colorAttachment1.set(W.texture)}else h.emissiveTex=void 0,A.removeColorAttachment(D,1);h.dirty=!0}_initFBOPool(){for(;this.pool.length{const y=this._style._mergedLayers[h],A=y.isHidden(this.painter.transform.zoom);return y.type==="hillshade"||y.type==="custom"?!A&&y.shouldRedrape():!A&&y.hasTransition()})}_clearLineLayersFromRenderCache(){let h=!1;for(const A of this._style.getSources())if(A instanceof Of){h=!0;break}if(!h)return;const y={};for(let A=0;AJ>W.end)||i.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=A}_setupRenderCache(h){const y=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,y.renderCache.length>y.renderCachePool.length){const z=Object.values(y.proxyCachedFBO);y.proxyCachedFBO={};for(let W=0;W=0;z--){const W=A[z];if(y.getTileByID(W.key),y.proxyCachedFBO[W.key]!==void 0){const J=h[W.key],ne=this.proxyToSource[W.key];let le=0;for(const je in ne){const ve=ne[je],Ne=J[je];if(!Ne||Ne.length!==ve.length||ve.some((De,Pe)=>De!==Ne[Pe]||D[je]&&D[je].hasOwnProperty(De.key))){le=-1;break}++le}for(const je in y.proxyCachedFBO[W.key])y.renderCache[y.proxyCachedFBO[W.key][je]].dirty=le<0||le!==Object.values(J).length}}const F=[...this._drapedRenderBatches];F.sort((z,W)=>W.end-W.start-(z.end-z.start));for(const z of F)for(const W of A){if(y.proxyCachedFBO[W.key])continue;let J=y.renderCachePool.pop();J===void 0&&y.renderCache.length<50&&(J=y.renderCache.length,y.renderCache.push(this._createFBO())),J!==void 0&&(y.proxyCachedFBO[W.key]={},y.proxyCachedFBO[W.key][z.start]=J,y.renderCache[J].dirty=!0)}this._tilesDirty={}}_setupStencil(h,y,A,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const F=this.painter.context,z=F.gl;if(y.length<=1)return void(this._overlapStencilType=!1);let W;if(A.isTileClipped())W=y.length,this._overlapStencilMode.test={func:z.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(y[0].overscaledZ>y[y.length-1].overscaledZ))return void(this._overlapStencilType=!1);W=1,this._overlapStencilMode.test={func:z.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+W>255&&(F.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=W,this._overlapStencilMode.ref=this._stencilRef,A.isTileClipped()&&this._renderTileClippingMasks(y,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(h){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[h.key]),this._overlapStencilMode):yn.disabled}_renderTileClippingMasks(h,y){const A=this.painter,D=this.painter.context,F=D.gl;A._tileClippingMaskIDs={},D.setColorMode(Hn.disabled),D.setDepthMode(Fr.disabled);const z=A.getOrCreateProgram("clippingMask");for(const W of h){const J=A._tileClippingMaskIDs[W.key]=--y;z.draw(A,F.TRIANGLES,Fr.disabled,new yn({func:F.ALWAYS,mask:0},J,255,F.KEEP,F.KEEP,F.REPLACE),Hn.disabled,mn.disabled,l2(W.projMatrix),"$clipping",A.tileExtentBuffer,A.quadTriangleIndexBuffer,A.tileExtentSegments)}}pointCoordinate(h){const y=this.painter.transform;if(h.x<0||h.x>y.width||h.y<0||h.y>y.height)return null;const A=[h.x,h.y,1,1];i.aC(A,A,y.pixelMatrixInverse),i.cK(A,A,1/A[3]),A[0]/=y.worldSize,A[1]/=y.worldSize;const D=y._camera.position,F=i.cf(1,y.center.lat),z=[D[0],D[1],D[2]/F,0],W=i.da([],A.slice(0,3),z);i.aw(W,W);const J=this.raycast(z,W,this._exaggeration);return J!==null&&J?(i.bH(z,z,W,J),z[3]=z[2],z[2]*=F,z):null}_setupProxiedCoordsForOrtho(h,y,A){if(h.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(h,y,A);this._findCoveringTileCache[h.id]=this._findCoveringTileCache[h.id]||{};const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords;for(let J=0;Jle.overscaledZ-ne.overscaledZ)}_setupProxiedCoordsForImageSource(h,y,A){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords,z=h.getSource(),W=z.tileID;if(!W)return;const J=new i.P(W.x,W.y)._div(1<(je.min.x=Math.min(je.min.x,ve.x-J.x),je.min.y=Math.min(je.min.y,ve.y-J.y),je.max.x=Math.max(je.max.x,ve.x-J.x),je.max.y=Math.max(je.max.y,ve.y-J.y),je),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),le=(je,ve)=>{const Ne=je.wrap+je.canonical.x/(1<Ge+ne.max.x||De+PeVe+ne.max.y};for(let je=0;jez.key===y.tileID.key);if(F)return F}if(y.tileID.key!==h.key){const F=h.canonical.z-y.tileID.canonical.z;let z,W,J;D=i.bC();const ne=y.tileID.wrap-h.wrap<0?(z=i.al>>F,W=z*((y.tileID.canonical.x<=je){const ve=h.canonical.z-je;y.getSource().reparseOverscaled?(W=Math.max(h.canonical.z+2,y.transform.tileZoom),z=new i.aQ(W,h.wrap,je,h.canonical.x>>ve,h.canonical.y>>ve)):ve!==0&&(W=je,z=new i.aQ(W,h.wrap,je,h.canonical.x>>ve,h.canonical.y>>ve))}z.key!==h.key&&(ne.push(z.key),A=y.getTile(z))}const le=je=>{ne.forEach(ve=>{D[ve]=je}),ne.length=0};for(W-=1;W>=J&&(!A||!A.hasData());W--){A&&le(A.tileID.key);const je=z.calculateScaledKey(W);if(A=y.getTileByID(je),A&&A.hasData())break;const ve=D[je];if(ve===null)break;ve===void 0?ne.push(je):A=y.getTileByID(ve)}return le(A?A.tileID.key:null),A&&A.hasData()?A:null}findDEMTileFor(h){return this.enabled?this._findTileCoveringTileID(h,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(h,y){let A=this._tilesDirty[h];A||(A=this._tilesDirty[h]={}),A[y.key]=!0}}function lb(T,h,y){const A=function(W,J,ne){const le=i.bJ(J,W),je=i.bJ(ne,[.2126,.7152,.0722]),ve=(De,Pe,Ge)=>(1-Ge)*De+Ge*Pe,Ne=ve(1-.3*Math.min(je,1),1,Math.min(le+1,1));return ve(.92,1,Math.asin(i.aA(J[2],-1,1))/Math.PI+.5)*Ne}(T,[0,0,1],h),D=[0,0,0];i.c5(D,y.slice(0,3),A);const F=[0,0,0];i.c5(F,h.slice(0,3),T[2]);const z=[0,0,0];return i.d8(z,D,F),i.db(z)}const Rme=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Fme=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class VR{static cacheKey(h,y,A,D){const F=[y];D&&F.push(D.cacheKey);for(const z of A)h.usedDefines.has(z)&&F.push(z);return F.join("/")}constructor(h,y,A,D,F,z){const W=h.gl;this.program=W.createProgram(),this.configuration=D,this.name=y,this.fixedDefines=[...z];const J=`#version 300 es ${(D?D.defines():[]).concat(z.map(Pe=>`#define ${Pe}`)).join(` `)}`,ne=[J,Mme];for(const Pe of A.fragmentIncludes)ne.push(Cy[Pe]);ne.push(A.fragmentSource);const le=ne.join(` `),je=[J,LR];for(const Pe of A.vertexIncludes)je.push(Cy[Pe]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&A.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&je.push("uniform int u_instanceID;"),je.push(A.vertexSource);let ve=je.join(` `);this.forceManualRenderingForInstanceIDShaders&&(ve=ve.replaceAll("gl_InstanceID","u_instanceID"));const Ne=W.createShader(W.FRAGMENT_SHADER);if(W.isContextLost())return void(this.failedToCreate=!0);W.shaderSource(Ne,le),W.compileShader(Ne),W.attachShader(this.program,Ne);const De=W.createShader(W.VERTEX_SHADER);W.isContextLost()?this.failedToCreate=!0:(W.shaderSource(De,ve),W.compileShader(De),W.attachShader(this.program,De),this.attributes={},W.linkProgram(this.program),W.deleteShader(De),W.deleteShader(Ne),this.fixedUniforms=F(h),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(h):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Pe=>({u_instanceID:new i.ch(Pe)}))(h)),(z.includes("TERRAIN")||y.includes("symbol")||y.includes("circle"))&&(this.terrainUniforms=(Pe=>({u_dem:new i.ch(Pe),u_dem_prev:new i.ch(Pe),u_dem_tl:new i.ck(Pe),u_dem_scale:new i.cj(Pe),u_dem_tl_prev:new i.ck(Pe),u_dem_scale_prev:new i.cj(Pe),u_dem_size:new i.cj(Pe),u_dem_lerp:new i.cj(Pe),u_exaggeration:new i.cj(Pe),u_depth:new i.ch(Pe),u_depth_size_inv:new i.ck(Pe),u_depth_range_unpack:new i.ck(Pe),u_occluder_half_size:new i.cj(Pe),u_occlusion_depth_offset:new i.cj(Pe),u_meter_to_dem:new i.cj(Pe),u_label_plane_matrix_inv:new i.cl(Pe)}))(h)),z.includes("GLOBE")&&(this.globeUniforms=(Pe=>({u_tile_tl_up:new i.ci(Pe),u_tile_tr_up:new i.ci(Pe),u_tile_br_up:new i.ci(Pe),u_tile_bl_up:new i.ci(Pe),u_tile_up_scale:new i.cj(Pe)}))(h)),z.includes("FOG")&&(this.fogUniforms=(Pe=>({u_fog_matrix:new i.cl(Pe),u_fog_range:new i.ck(Pe),u_fog_color:new i.d3(Pe),u_fog_horizon_blend:new i.cj(Pe),u_fog_vertical_limit:new i.ck(Pe),u_fog_temporal_offset:new i.cj(Pe),u_frustum_tl:new i.ci(Pe),u_frustum_tr:new i.ci(Pe),u_frustum_br:new i.ci(Pe),u_frustum_bl:new i.ci(Pe),u_globe_pos:new i.ci(Pe),u_globe_radius:new i.cj(Pe),u_globe_transition:new i.cj(Pe),u_is_globe:new i.ch(Pe),u_viewport:new i.ck(Pe)}))(h)),z.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Pe=>({u_cutoff_params:new i.d3(Pe)}))(h)),z.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Pe=>({u_lighting_ambient_color:new i.ci(Pe),u_lighting_directional_dir:new i.ci(Pe),u_lighting_directional_color:new i.ci(Pe),u_ground_radiance:new i.ci(Pe)}))(h)),z.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Pe=>({u_light_matrix_0:new i.cl(Pe),u_light_matrix_1:new i.cl(Pe),u_fade_range:new i.ck(Pe),u_shadow_normal_offset:new i.ci(Pe),u_shadow_intensity:new i.cj(Pe),u_shadow_texel_size:new i.cj(Pe),u_shadow_map_resolution:new i.cj(Pe),u_shadow_direction:new i.ci(Pe),u_shadow_bias:new i.ci(Pe),u_shadowmap_0:new i.ch(Pe),u_shadowmap_1:new i.ch(Pe)}))(h)))}getAttributeLocation(h,y){let A=this.attributes[y];return A===void 0&&(A=this.attributes[y]=h.getAttribLocation(this.program,y)),A}setTerrainUniformValues(h,y){if(!this.terrainUniforms)return;const A=this.terrainUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D]&&A[D].set(this.program,D,y[D])}}setGlobeUniformValues(h,y){if(!this.globeUniforms)return;const A=this.globeUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D]&&A[D].set(this.program,D,y[D])}}setFogUniformValues(h,y){if(!this.fogUniforms)return;const A=this.fogUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}}setCutoffUniformValues(h,y){if(!this.cutoffUniforms)return;const A=this.cutoffUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}}setLightsUniformValues(h,y){if(!this.lightsUniforms)return;const A=this.lightsUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}}setShadowUniformValues(h,y){if(this.failedToCreate||!this.shadowUniforms)return;const A=this.shadowUniforms;h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}_drawDebugWireframe(h,y,A,D,F,z,W,J,ne,le){const je=h.options.wireframe;if(je.terrain===!1&&je.layers2D===!1&&je.layers3D===!1)return;const ve=h.context;if(!(!(!je.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!je.layers2D||h._terrain&&h._terrain.renderingToTexture||!Rme.includes(this.name))||!(!je.layers3D||!Fme.includes(this.name))))return;const Ne=ve.gl,De=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,F,ve);if(!De)return;const Pe=[...this.fixedDefines,"DEBUG_WIREFRAME"],Ge=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Pe});ve.program.set(Ge.program);const Ve=(ot,Et,Nt)=>{if(Et[ot]&&Nt[ot])for(const Tt in Et[ot])Nt[ot][Tt]&&Nt[ot][Tt].set(Nt.program,Tt,Et[ot][Tt].current)};ne&&ne.setUniforms(Ge.program,ve,Ge.binderUniforms,W,{zoom:J}),Ve("fixedUniforms",this,Ge),Ve("terrainUniforms",this,Ge),Ve("globeUniforms",this,Ge),Ve("fogUniforms",this,Ge),Ve("lightsUniforms",this,Ge),Ve("shadowUniforms",this,Ge),De.bind(),ve.setColorMode(new Hn([Ne.ONE,Ne.ONE_MINUS_SRC_ALPHA,Ne.ZERO,Ne.ONE],i.ao.transparent,[!0,!0,!0,!1])),ve.setDepthMode(new Fr(y.func===Ne.LESS?Ne.LEQUAL:y.func,Fr.ReadOnly,y.range)),ve.setStencilMode(yn.disabled);const nt=3*z.primitiveLength*2,ut=3*z.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const ot=le||1;for(let Et=0;Et1?Ne.drawElementsInstanced(Ne.LINES,nt,Ne.UNSIGNED_SHORT,ut,le):Ne.drawElements(Ne.LINES,nt,Ne.UNSIGNED_SHORT,ut);F.bind(),ve.program.set(this.program),ve.setDepthMode(y),ve.setStencilMode(A),ve.setColorMode(D)}checkUniforms(h,y,A){if(this.fixedDefines.includes(y)){for(const D of Object.keys(A))if(!A[D].initialized)throw new Error(`Program '${this.name}', from draw '${h}': uniform ${D} not set but required by ${y} being defined`)}}draw(h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge){const Ve=h.context,nt=Ve.gl;if(this.failedToCreate)return;Ve.program.set(this.program),Ve.setDepthMode(A),Ve.setStencilMode(D),Ve.setColorMode(F),Ve.setCullFace(z);for(const[wt,yt]of this.fixedUniformsEntries)yt.set(this.program,wt,W[wt]);De&&De.setUniforms(this.program,Ve,this.binderUniforms,ve,{zoom:Ne});const ut={[nt.POINTS]:1,[nt.LINES]:2,[nt.TRIANGLES]:3,[nt.LINE_STRIP]:1}[y];this.checkUniforms(J,"RENDER_SHADOWS",this.shadowUniforms);const ot=Pe||[],Et=De?De.getPaintVertexBuffers():[],Nt=y===nt.TRIANGLES&&le,Tt=Ge&&Ge>0?1:void 0;for(const wt of je.get()){const yt=wt.vaos||(wt.vaos={});if((yt[J]||(yt[J]=new Tme)).bind(Ve,this,ne,Et,le,wt.vertexOffset,ot,Tt),this.forceManualRenderingForInstanceIDShaders){const Ot=Ge||1;for(let Wt=0;Wt1?nt.drawElementsInstanced(y,wt.primitiveLength*ut,nt.UNSIGNED_SHORT,wt.primitiveOffset*ut*2,Ge):le?nt.drawElements(y,wt.primitiveLength*ut,nt.UNSIGNED_SHORT,wt.primitiveOffset*ut*2):nt.drawArrays(y,wt.vertexOffset,wt.vertexLength);Nt&&this._drawDebugWireframe(h,A,D,F,le,wt,ve,Ne,De,Ge)}}}function HR(T,h,y=0){const A=Math.pow(2,h.tileID.overscaledZ),D=h.tileSize*Math.pow(2,T.transform.tileZoom)/A,F=D*(h.tileID.canonical.x+h.tileID.wrap*A),z=D*h.tileID.canonical.y;return{u_image:0,u_texsize:h.imageAtlasTexture?h.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/i.ay(h,1,T.transform.tileZoom),u_pixel_coord_upper:[F>>16,z>>16],u_pixel_coord_lower:[65535&F,65535&z],u_pattern_transition:y}}const a3={terrain:0,flat:1},zme=i.bC(),i3=(T,h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge,Ve)=>{const nt=h.style.light,ut=nt.properties.get("position"),ot=[ut.x,ut.y,ut.z],Et=i.dO();nt.properties.get("anchor")==="viewport"&&(i.dP(Et,-h.transform.angle),i.dQ(ot,ot,Et));const Nt=nt.properties.get("color").toPremultipliedRenderColor(null),Tt=h.transform,wt={u_matrix:T,u_lightpos:ot,u_lightintensity:nt.properties.get("intensity"),u_lightcolor:[Nt.r,Nt.g,Nt.b],u_vertical_gradient:+y,u_opacity:A,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:zme,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:a3[ne],u_base_type:a3[le],u_ao:D,u_edge_radius:F,u_width_scale:z,u_flood_light_color:De,u_vertical_scale:Pe,u_flood_light_intensity:Ge,u_ground_shadow_factor:Ve};return Tt.projection.name==="globe"&&(wt.u_tile_id=[W.canonical.x,W.canonical.y,1<({u_matrix:T,u_edge_radius:h,u_width_scale:y,u_vertical_scale:A,u_height_type:a3[D],u_base_type:a3[F]}),WR=(T,h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge,Ve)=>{const nt=i3(T,h,y,A,D,F,z,W,ne,le,je,ve,Ne,De,Pe,Ge,1,[0,0,0]),ut={u_height_factor:-Math.pow(2,W.overscaledZ)/J.tileSize/8};return Object.assign(nt,HR(h,J,Ve),ut)},cb=(T,h,y,A,D,F,z,W,J,ne,le)=>({u_matrix:h,u_opacity:y,u_ao_pass:A?1:0,u_meter_to_tile:D,u_ao:F,u_flood_light_intensity:z,u_flood_light_color:W,u_attenuation:J,u_edge_radius:ne,u_fb:0,u_fb_size:le,u_dynamic_offset:1}),h6=(T,h,y)=>({u_matrix:T,u_emissive_strength:h,u_ground_shadow_factor:y}),m6=(T,h,y,A,D,F=0)=>Object.assign(h6(T,h,D),HR(y,A,F)),GR=(T,h,y,A)=>({u_matrix:T,u_world:y,u_emissive_strength:h,u_ground_shadow_factor:A}),p6=(T,h,y,A,D,F,z=0)=>Object.assign(m6(T,h,y,A,F,z),{u_world:D}),Ty=(T,h)=>({u_matrix:T,u_ground_shadow_factor:h}),iv=(T,h,y,A,D)=>({u_matrix:T,u_camera_pos:[h[0],h[1],h[2]],u_depth_bias:y,u_height_scale:A,u_reset_depth:D}),o3=(T,h,y,A,D,F,z,W,J)=>({u_matrix:T,u_normal_matrix:h,u_opacity:y,u_faux_facade_ao_intensity:A,u_camera_pos:D,u_tile_to_meter:F,u_facade_emissive_chance:z,u_flood_light_color:W,u_flood_light_intensity:J}),KR=T=>({u_matrix:T}),Ay=T=>({u_matrix:T}),f6=(T,h,y,A,D,F,z,W)=>{const J=i.al/F.tileSize;return{u_matrix:T,u_inv_rot_matrix:h,u_camera_to_center_distance:y.getCameraToCenterDistance(W),u_extrude_scale:[y.pixelsToGLUnits[0]/J,y.pixelsToGLUnits[1]/J],u_zoom_transition:A,u_tile_id:z,u_merc_center:D}},d2=(T,h,y=1)=>({u_matrix:T,u_color:h,u_overlay:0,u_overlay_scale:y}),ZR=i.bC(),YR=(T,h,y,A,D,F,z)=>{const W=T.transform,J=W.projection.name==="globe",ne=J?i.dR(W.zoom,h.canonical)*W._pixelsPerMercatorPixel:i.ay(y,1,F),le={u_matrix:h.projMatrix,u_extrude_scale:ne,u_intensity:z,u_inv_rot_matrix:ZR,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(J){le.u_inv_rot_matrix=A,le.u_merc_center=D,le.u_tile_id=[h.canonical.x,h.canonical.y,1<({u_matrix:T,u_normalize_matrix:h,u_globe_matrix:y,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ne,u_fade_t:le.mix,u_opacity:le.opacity*je.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:je.paint.get("raster-brightness-min"),u_brightness_high:je.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(je.paint.get("raster-saturation")),u_contrast_factor:i.dS(je.paint.get("raster-contrast")),u_spin_weights:QR(je.paint.get("raster-hue-rotate")),u_perspective_transform:ve,u_raster_elevation:Ne,u_zoom_transition:z,u_merc_center:W,u_cutoff_params:J,u_colorization_mix:l3(i.dU,Pe,Ve),u_colorization_offset:c3(i.dU,Ge,Ve),u_color_ramp:De,u_texture_offset:[ut/(nt+2*ut),nt/(nt+2*ut)],u_texture_res:[nt+2*ut,nt+2*ut],u_emissive_strength:ot});function QR(T){T*=Math.PI/180;const h=Math.sin(T),y=Math.cos(T);return[(2*y+1)/3,(-Math.sqrt(3)*h-y+1)/3,(Math.sqrt(3)*h-y+1)/3]}const Uf=.05,Bme=(T,h,y,A,D,F,z,W,J,ne,le,je)=>({u_matrix:T,u_normalize_matrix:h,u_globe_matrix:y,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ne,u_fade_t:le.mix,u_opacity:le.opacity,u_image0:0,u_image1:1,u_raster_elevation:je,u_zoom_transition:z,u_merc_center:W,u_cutoff_params:J}),$me=(T,h,y,A,D,F,z,W,J,ne)=>({u_particle_texture:T,u_particle_texture_side_len:h,u_tile_offset:y,u_velocity:A,u_color_ramp:F,u_velocity_res:D,u_max_speed:z,u_uv_offset:W,u_data_scale:[255*J[0],255*J[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Uf,Uf]}),JR=(T,h,y,A,D,F,z,W,J,ne)=>({u_particle_texture:T,u_particle_texture_side_len:h,u_velocity:y,u_velocity_res:A,u_max_speed:D,u_speed_factor:F,u_reset_rate:z,u_rand_seed:Math.random(),u_uv_offset:W,u_data_scale:[255*J[0],255*J[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Uf,Uf]}),eF=i.bC(),d3=(T,h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge,Ve,nt,ut,ot,Et,Nt,Tt)=>{const wt=D.transform,yt={u_is_size_zoom_constant:+(T==="constant"||T==="source"),u_is_size_feature_constant:+(T==="constant"||T==="camera"),u_size_t:h?h.uSizeT:0,u_size:h?h.uSize:0,u_camera_to_center_distance:wt.getCameraToCenterDistance(nt),u_rotate_symbol:+y,u_aspect_ratio:wt.width/wt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:F,u_label_plane_matrix:z,u_coord_matrix:W,u_is_text:+ne,u_elevation_from_sea:J?1:0,u_pitch_with_map:+A,u_texsize:le,u_texsize_icon:je,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:eF,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:eF,u_up_vector:[0,-1,0],u_color_adj_mat:Et,u_icon_transition:Nt||0,u_gamma_scale:A?D.transform.getCameraToCenterDistance(nt)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:Tt||1,u_ground_shadow_factor:ut,u_inv_matrix:i.bl(i.bC(),z),u_normal_scale:ot,u_lutTexture:Gc.LUT};return nt.name==="globe"&&(yt.u_tile_id=[Ne.canonical.x,Ne.canonical.y,1<({u_matrix:T,u_emissive_strength:h,u_opacity:y,u_color:A}),Ey=(T,h,y,A,D,F,z,W,J)=>Object.assign(function(ne,le,je,ve,Ne,De){const{width:Pe,height:Ge}=ve.imageManager.getPixelSize(le),Ve=Math.pow(2,De.tileID.overscaledZ),nt=De.tileSize*Math.pow(2,ve.transform.tileZoom)/Ve,ut=nt*(De.tileID.canonical.x+De.tileID.wrap*Ve),ot=nt*De.tileID.canonical.y;return{u_image:0,u_pattern_tl:je.tl,u_pattern_br:je.br,u_texsize:[Pe,Ge],u_pattern_size:je.displaySize,u_pattern_units_to_pixels:Ne?[ve.transform.width,-1*ve.transform.height]:[1/i.ay(De,1,ve.transform.tileZoom),1/i.ay(De,1,ve.transform.tileZoom)],u_pixel_coord_upper:[ut>>16,ot>>16],u_pixel_coord_lower:[65535&ut,65535&ot]}}(0,F,z,A,W,J),{u_matrix:T,u_emissive_strength:h,u_opacity:y}),db=new Float32Array(i.bA([])),ov=(T,h,y,A,D,F,z,W,J,ne,le,je,ve,Ne=[0,0,0],De,Pe,Ge)=>{const Ve=D.style.light,nt=Ve.properties.get("position"),ut=[-nt.x,-nt.y,nt.z],ot=i.dO();Ve.properties.get("anchor")==="viewport"&&(i.dP(ot,-D.transform.angle),i.dQ(ut,ut,ot));const Et=le.alphaMode==="MASK",Nt=Ve.properties.get("color").toNonPremultipliedRenderColor(null),Tt=ve.paint.get("model-ambient-occlusion-intensity"),wt=ve.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return wt.a=ve.paint.get("model-color-mix-intensity").constantOr(0),Ge&&(wt.r=Ge[0],wt.g=Ge[1],wt.b=Ge[2],wt.a=Ge[3]),Pe&&(wt.r=Pe.color.r,wt.g=Pe.color.g,wt.b=Pe.color.b,wt.a=Pe.colorMix,je=Pe.emissionStrength,F*=Pe.opacity),{u_matrix:T,u_lighting_matrix:h,u_normal_matrix:y,u_node_matrix:A||db,u_lightpos:ut,u_lightintensity:Ve.properties.get("intensity"),u_lightcolor:[Nt.r,Nt.g,Nt.b],u_camera_pos:Ne,u_opacity:F,u_baseTextureIsAlpha:0,u_alphaMask:+Et,u_alphaCutoff:le.alphaCutoff,u_baseColorFactor:z.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:W.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:J,u_roughnessFactor:ne,u_baseColorTexture:Gc.BaseColor,u_metallicRoughnessTexture:Gc.MetallicRoughness,u_normalTexture:Gc.Normal,u_occlusionTexture:Gc.Occlusion,u_emissionTexture:Gc.Emission,u_lutTexture:Gc.LUT,u_color_mix:wt.toArray01(),u_aoIntensity:Tt,u_emissive_strength:je,u_occlusionTextureTransform:De||[0,0,0,0]}},x6=(T,h=db,y=db)=>({u_matrix:T,u_instance:h,u_node_matrix:y}),u3={fillExtrusion:T=>({u_matrix:new i.cl(T),u_lightpos:new i.ci(T),u_lightintensity:new i.cj(T),u_lightcolor:new i.ci(T),u_vertical_gradient:new i.cj(T),u_opacity:new i.cj(T),u_edge_radius:new i.cj(T),u_width_scale:new i.cj(T),u_ao:new i.ck(T),u_height_type:new i.ch(T),u_base_type:new i.ch(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_up_dir:new i.ci(T),u_height_lift:new i.cj(T),u_flood_light_color:new i.ci(T),u_vertical_scale:new i.cj(T),u_flood_light_intensity:new i.cj(T),u_ground_shadow_factor:new i.ci(T)}),fillExtrusionDepth:T=>({u_matrix:new i.cl(T),u_edge_radius:new i.cj(T),u_width_scale:new i.cj(T),u_vertical_scale:new i.cj(T),u_height_type:new i.ch(T),u_base_type:new i.ch(T)}),fillExtrusionPattern:T=>({u_matrix:new i.cl(T),u_lightpos:new i.ci(T),u_lightintensity:new i.cj(T),u_lightcolor:new i.ci(T),u_vertical_gradient:new i.cj(T),u_height_factor:new i.cj(T),u_edge_radius:new i.cj(T),u_width_scale:new i.cj(T),u_ao:new i.ck(T),u_height_type:new i.ch(T),u_base_type:new i.ch(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_up_dir:new i.ci(T),u_height_lift:new i.cj(T),u_image:new i.ch(T),u_texsize:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_tile_units_to_pixels:new i.cj(T),u_opacity:new i.cj(T),u_pattern_transition:new i.cj(T)}),fillExtrusionGroundEffect:T=>({u_matrix:new i.cl(T),u_opacity:new i.cj(T),u_ao_pass:new i.cj(T),u_meter_to_tile:new i.cj(T),u_ao:new i.ck(T),u_flood_light_intensity:new i.cj(T),u_flood_light_color:new i.ci(T),u_attenuation:new i.cj(T),u_edge_radius:new i.cj(T),u_fb:new i.ch(T),u_fb_size:new i.cj(T),u_dynamic_offset:new i.cj(T)}),fill:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_ground_shadow_factor:new i.ci(T)}),fillPattern:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_image:new i.ch(T),u_texsize:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_tile_units_to_pixels:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_pattern_transition:new i.cj(T)}),fillOutline:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_world:new i.ck(T),u_ground_shadow_factor:new i.ci(T)}),fillOutlinePattern:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_world:new i.ck(T),u_image:new i.ch(T),u_texsize:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_tile_units_to_pixels:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_pattern_transition:new i.cj(T)}),building:T=>({u_matrix:new i.cl(T),u_normal_matrix:new i.cl(T),u_opacity:new i.cj(T),u_faux_facade_ao_intensity:new i.cj(T),u_camera_pos:new i.ci(T),u_tile_to_meter:new i.cj(T),u_facade_emissive_chance:new i.cj(T),u_flood_light_color:new i.ci(T),u_flood_light_intensity:new i.cj(T)}),buildingBloom:T=>({u_matrix:new i.cl(T)}),buildingDepth:T=>({u_matrix:new i.cl(T)}),elevatedStructuresDepth:T=>({u_matrix:new i.cl(T),u_depth_bias:new i.cj(T)}),elevatedStructures:T=>({u_matrix:new i.cl(T),u_ground_shadow_factor:new i.ci(T)}),elevatedStructuresDepthReconstruct:T=>({u_matrix:new i.cl(T),u_camera_pos:new i.ci(T),u_depth_bias:new i.cj(T),u_height_scale:new i.cj(T),u_reset_depth:new i.cj(T)}),circle:i.dY,collisionBox:T=>({u_matrix:new i.cl(T),u_inv_rot_matrix:new i.cl(T),u_camera_to_center_distance:new i.cj(T),u_extrude_scale:new i.ck(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_tile_id:new i.ci(T)}),collisionCircle:T=>({u_matrix:new i.cl(T),u_inv_matrix:new i.cl(T),u_camera_to_center_distance:new i.cj(T),u_viewport_size:new i.ck(T)}),debug:T=>({u_color:new i.dB(T),u_matrix:new i.cl(T),u_overlay:new i.ch(T),u_overlay_scale:new i.cj(T)}),clippingMask:T=>({u_matrix:new i.cl(T)}),heatmap:T=>({u_extrude_scale:new i.cj(T),u_intensity:new i.cj(T),u_matrix:new i.cl(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_up_dir:new i.ci(T)}),heatmapTexture:T=>({u_image:new i.ch(T),u_color_ramp:new i.ch(T),u_opacity:new i.cj(T)}),hillshade:T=>({u_matrix:new i.cl(T),u_image:new i.ch(T),u_latrange:new i.ck(T),u_light:new i.ck(T),u_shadow:new i.dB(T),u_highlight:new i.dB(T),u_emissive_strength:new i.cj(T),u_accent:new i.dB(T)}),hillshadePrepare:T=>({u_matrix:new i.cl(T),u_image:new i.ch(T),u_dimension:new i.ck(T),u_zoom:new i.cj(T)}),line:i.dX,linePattern:i.dW,raster:T=>({u_matrix:new i.cl(T),u_normalize_matrix:new i.cl(T),u_globe_matrix:new i.cl(T),u_merc_matrix:new i.cl(T),u_grid_matrix:new i.dC(T),u_tl_parent:new i.ck(T),u_scale_parent:new i.cj(T),u_fade_t:new i.cj(T),u_opacity:new i.cj(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_brightness_low:new i.cj(T),u_brightness_high:new i.cj(T),u_saturation_factor:new i.cj(T),u_contrast_factor:new i.cj(T),u_spin_weights:new i.ci(T),u_perspective_transform:new i.ck(T),u_raster_elevation:new i.cj(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_cutoff_params:new i.d3(T),u_colorization_mix:new i.d3(T),u_colorization_offset:new i.cj(T),u_color_ramp:new i.ch(T),u_texture_offset:new i.ck(T),u_texture_res:new i.ck(T),u_emissive_strength:new i.cj(T)}),rasterParticle:T=>({u_matrix:new i.cl(T),u_normalize_matrix:new i.cl(T),u_globe_matrix:new i.cl(T),u_merc_matrix:new i.cl(T),u_grid_matrix:new i.dC(T),u_tl_parent:new i.ck(T),u_scale_parent:new i.cj(T),u_fade_t:new i.cj(T),u_opacity:new i.cj(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_raster_elevation:new i.cj(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_cutoff_params:new i.d3(T)}),rasterParticleTexture:T=>({u_texture:new i.ch(T),u_opacity:new i.cj(T)}),rasterParticleDraw:T=>({u_particle_texture:new i.ch(T),u_particle_texture_side_len:new i.cj(T),u_tile_offset:new i.ck(T),u_velocity:new i.ch(T),u_color_ramp:new i.ch(T),u_velocity_res:new i.ck(T),u_max_speed:new i.cj(T),u_uv_offset:new i.ck(T),u_data_scale:new i.ck(T),u_data_offset:new i.cj(T),u_particle_pos_scale:new i.cj(T),u_particle_pos_offset:new i.ck(T)}),rasterParticleUpdate:T=>({u_particle_texture:new i.ch(T),u_particle_texture_side_len:new i.cj(T),u_velocity:new i.ch(T),u_velocity_res:new i.ck(T),u_max_speed:new i.cj(T),u_speed_factor:new i.cj(T),u_reset_rate:new i.cj(T),u_rand_seed:new i.cj(T),u_uv_offset:new i.ck(T),u_data_scale:new i.ck(T),u_data_offset:new i.cj(T),u_particle_pos_scale:new i.cj(T),u_particle_pos_offset:new i.ck(T)}),symbol:T=>({u_is_size_zoom_constant:new i.ch(T),u_is_size_feature_constant:new i.ch(T),u_size_t:new i.cj(T),u_size:new i.cj(T),u_camera_to_center_distance:new i.cj(T),u_rotate_symbol:new i.ch(T),u_aspect_ratio:new i.cj(T),u_fade_change:new i.cj(T),u_matrix:new i.cl(T),u_label_plane_matrix:new i.cl(T),u_coord_matrix:new i.cl(T),u_is_text:new i.ch(T),u_elevation_from_sea:new i.ch(T),u_pitch_with_map:new i.ch(T),u_texsize:new i.ck(T),u_texsize_icon:new i.ck(T),u_texture:new i.ch(T),u_texture_icon:new i.ch(T),u_gamma_scale:new i.cj(T),u_device_pixel_ratio:new i.cj(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_camera_forward:new i.ci(T),u_tile_matrix:new i.cl(T),u_up_vector:new i.ci(T),u_ecef_origin:new i.ci(T),u_is_halo:new i.ch(T),u_icon_transition:new i.cj(T),u_color_adj_mat:new i.cl(T),u_scale_factor:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_inv_matrix:new i.cl(T),u_normal_scale:new i.cj(T),u_lutTexture:new i.ch(T)}),background:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_opacity:new i.cj(T),u_color:new i.dB(T)}),backgroundPattern:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_opacity:new i.cj(T),u_image:new i.ch(T),u_pattern_tl:new i.ck(T),u_pattern_br:new i.ck(T),u_texsize:new i.ck(T),u_pattern_size:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_pattern_units_to_pixels:new i.ck(T)}),terrainRaster:T=>({u_matrix:new i.cl(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_skirt_height:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_emissive_texture_available:new i.cj(T)}),skybox:T=>({u_matrix:new i.cl(T),u_sun_direction:new i.ci(T),u_cubemap:new i.ch(T),u_opacity:new i.cj(T),u_temporal_offset:new i.cj(T)}),skyboxGradient:T=>({u_matrix:new i.cl(T),u_color_ramp:new i.ch(T),u_center_direction:new i.ci(T),u_radius:new i.cj(T),u_opacity:new i.cj(T),u_temporal_offset:new i.cj(T)}),skyboxCapture:T=>({u_matrix_3f:new i.dC(T),u_sun_direction:new i.ci(T),u_sun_intensity:new i.cj(T),u_color_tint_r:new i.d3(T),u_color_tint_m:new i.d3(T),u_luminance:new i.cj(T)}),globeRaster:T=>({u_proj_matrix:new i.cl(T),u_globe_matrix:new i.cl(T),u_normalize_matrix:new i.cl(T),u_merc_matrix:new i.cl(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_grid_matrix:new i.dC(T),u_skirt_height:new i.cj(T),u_far_z_cutoff:new i.cj(T),u_frustum_tl:new i.ci(T),u_frustum_tr:new i.ci(T),u_frustum_br:new i.ci(T),u_frustum_bl:new i.ci(T),u_globe_pos:new i.ci(T),u_globe_radius:new i.cj(T),u_viewport:new i.ck(T),u_emissive_texture_available:new i.cj(T)}),globeAtmosphere:T=>({u_frustum_tl:new i.ci(T),u_frustum_tr:new i.ci(T),u_frustum_br:new i.ci(T),u_frustum_bl:new i.ci(T),u_horizon:new i.cj(T),u_transition:new i.cj(T),u_fadeout_range:new i.cj(T),u_atmosphere_fog_color:new i.d3(T),u_high_color:new i.d3(T),u_space_color:new i.d3(T),u_temporal_offset:new i.cj(T),u_horizon_angle:new i.cj(T)}),model:T=>({u_matrix:new i.cl(T),u_lighting_matrix:new i.cl(T),u_normal_matrix:new i.cl(T),u_node_matrix:new i.cl(T),u_lightpos:new i.ci(T),u_lightintensity:new i.cj(T),u_lightcolor:new i.ci(T),u_camera_pos:new i.ci(T),u_opacity:new i.cj(T),u_baseColorFactor:new i.d3(T),u_emissiveFactor:new i.d3(T),u_metallicFactor:new i.cj(T),u_roughnessFactor:new i.cj(T),u_baseTextureIsAlpha:new i.ch(T),u_alphaMask:new i.ch(T),u_alphaCutoff:new i.cj(T),u_baseColorTexture:new i.ch(T),u_metallicRoughnessTexture:new i.ch(T),u_normalTexture:new i.ch(T),u_occlusionTexture:new i.ch(T),u_emissionTexture:new i.ch(T),u_lutTexture:new i.ch(T),u_color_mix:new i.d3(T),u_aoIntensity:new i.cj(T),u_emissive_strength:new i.cj(T),u_occlusionTextureTransform:new i.d3(T)}),modelDepth:T=>({u_matrix:new i.cl(T),u_instance:new i.cl(T),u_node_matrix:new i.cl(T)}),groundShadow:T=>({u_matrix:new i.cl(T),u_ground_shadow_factor:new i.ci(T)}),stars:T=>({u_matrix:new i.cl(T),u_up:new i.ci(T),u_right:new i.ci(T),u_intensity_multiplier:new i.cj(T)}),snowParticle:T=>({u_modelview:new i.cl(T),u_projection:new i.cl(T),u_time:new i.cj(T),u_cam_pos:new i.ci(T),u_velocityConeAperture:new i.cj(T),u_velocity:new i.cj(T),u_horizontalOscillationRadius:new i.cj(T),u_horizontalOscillationRate:new i.cj(T),u_boxSize:new i.cj(T),u_billboardSize:new i.cj(T),u_simpleShapeParameters:new i.ck(T),u_screenSize:new i.ck(T),u_thinningCenterPos:new i.ck(T),u_thinningShape:new i.ci(T),u_thinningAffectedRatio:new i.cj(T),u_thinningParticleOffset:new i.cj(T),u_particleColor:new i.d3(T),u_direction:new i.ci(T)}),rainParticle:T=>({u_modelview:new i.cl(T),u_projection:new i.cl(T),u_time:new i.cj(T),u_cam_pos:new i.ci(T),u_texScreen:new i.ch(T),u_velocityConeAperture:new i.cj(T),u_velocity:new i.cj(T),u_boxSize:new i.cj(T),u_rainDropletSize:new i.ck(T),u_distortionStrength:new i.cj(T),u_rainDirection:new i.ci(T),u_color:new i.d3(T),u_screenSize:new i.ck(T),u_thinningCenterPos:new i.ck(T),u_thinningShape:new i.ci(T),u_thinningAffectedRatio:new i.cj(T),u_thinningParticleOffset:new i.cj(T),u_shapeDirectionalPower:new i.cj(T),u_shapeNormalPower:new i.cj(T),u_mode:new i.cj(T)}),vignette:T=>({u_vignetteShape:new i.ci(T),u_vignetteColor:new i.d3(T)}),occlusion:T=>({u_matrix:new i.cl(T),u_anchorPos:new i.ci(T),u_screenSizePx:new i.ck(T),u_occluderSizePx:new i.ck(T),u_color:new i.d3(T)})};class Bp{constructor(h,y,A,D){this.id=Bp.uniqueIdxCounter,Bp.uniqueIdxCounter++,this.context=h;const F=h.gl;this.buffer=F.createBuffer(),this.dynamicDraw=!!A,this.context.unbindVAO(),h.bindElementBuffer.set(this.buffer),F.bufferData(F.ELEMENT_ARRAY_BUFFER,y.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||D||y.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){this.id=Bp.uniqueIdxCounter,Bp.uniqueIdxCounter++;const y=this.context.gl;this.context.unbindVAO(),this.bind(),y.bufferSubData(y.ELEMENT_ARRAY_BUFFER,0,h.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Bp.uniqueIdxCounter=0;const g6={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class tF{constructor(h,y,A,D,F,z){this.length=y.length,this.attributes=A,this.itemSize=y.bytesPerElement,this.dynamicDraw=D,this.instanceCount=z,this.context=h;const W=h.gl;this.buffer=W.createBuffer(),h.bindVertexBuffer.set(this.buffer),W.bufferData(W.ARRAY_BUFFER,y.arrayBuffer,this.dynamicDraw?W.DYNAMIC_DRAW:W.STATIC_DRAW),this.dynamicDraw||F||y.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(h){const y=this.context.gl;this.bind(),y.bufferSubData(y.ARRAY_BUFFER,0,h.arrayBuffer)}enableAttributes(h,y){for(let A=0;A0&&h.vertexAttribDivisor(F,A)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class sF{constructor(h,y,A,D,F){this.context=h,this.width=y,this.height=A;const z=this.framebuffer=h.gl.createFramebuffer();D>0&&(this.colorAttachment0=new e3(h,z,0)),D>1&&(this.colorAttachment1=new e3(h,z,1)),F&&(this.depthAttachmentType=F,this.depthAttachment=F==="renderbuffer"?new ib(h,z):new i2(h,z))}createColorAttachment(h,y){y===0?this.colorAttachment0=new e3(h,this.framebuffer,0):y===1&&(this.colorAttachment1=new e3(h,this.framebuffer,1))}removeColorAttachment(h,y){const A=this.context.gl;let D;y===0?(D=this.colorAttachment0.get(),this.colorAttachment0=void 0):y===1&&(D=this.colorAttachment1.get(),this.colorAttachment1=void 0),D&&A.deleteTexture(D)}destroy(){const h=this.context.gl;if(this.colorAttachment0){const y=this.colorAttachment0.get();y&&h.deleteTexture(y)}if(this.colorAttachment1){const y=this.colorAttachment1.get();y&&h.deleteTexture(y)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const y=this.depthAttachment.get();y&&h.deleteRenderbuffer(y)}else{const y=this.depthAttachment.get();y&&h.deleteTexture(y)}h.deleteFramebuffer(this.framebuffer)}}class ub{constructor(h,y){this.gl=h,this.clearColor=new Ime(this),this.clearDepth=new DR(this),this.clearStencil=new JE(this),this.colorMask=new ZC(this),this.depthMask=new e6(this),this.stencilMask=new av(this),this.stencilFunc=new sb(this),this.stencilOp=new n2(this),this.stencilTest=new rb(this),this.depthRange=new OR(this),this.depthTest=new t6(this),this.depthFunc=new RR(this),this.blend=new nb(this),this.blendFunc=new YC(this),this.blendColor=new XC(this),this.blendEquation=new s6(this),this.cullFace=new QC(this),this.cullFaceSide=new a2(this),this.frontFace=new FR(this),this.program=new zR(this),this.activeTexture=new BR(this),this.viewport=new ab(this),this.bindFramebuffer=new $R(this),this.bindRenderbuffer=new Lme(this),this.bindTexture=new Dme(this),this.bindVertexBuffer=new Ome(this),this.bindElementBuffer=new r6(this),this.bindVertexArrayOES=new n6(this),this.pixelStoreUnpack=new a6(this),this.pixelStoreUnpackPremultiplyAlpha=new i6(this),this.pixelStoreUnpackFlipY=new qR(this),this.options=y?Object.assign({},y):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=h.getExtension("EXT_texture_filter_anisotropic")||h.getExtension("MOZ_EXT_texture_filter_anisotropic")||h.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=h.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=h.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=h.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=h.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=y&&!!y.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=h.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=h.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=h.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=h.getParameter(h.MAX_TEXTURE_SIZE),this.extBlendFuncExtended=h.getExtension("WEBGL_blend_func_extended")}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(h,y,A){return new Bp(this,h,y,A)}createVertexBuffer(h,y,A,D,F){return new tF(this,h,y,A,D,F)}createRenderbuffer(h,y,A){const D=this.gl,F=D.createRenderbuffer();return this.bindRenderbuffer.set(F),D.renderbufferStorage(D.RENDERBUFFER,h,y,A),this.bindRenderbuffer.set(null),F}createFramebuffer(h,y,A,D){return new sF(this,h,y,A,D)}clear({color:h,depth:y,stencil:A,colorMask:D}){const F=this.gl;let z=0;h&&(z|=F.COLOR_BUFFER_BIT,this.clearColor.set(h.toNonPremultipliedRenderColor(null)),this.colorMask.set(D||[!0,!0,!0,!0])),y!==void 0&&(z|=F.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(y),this.depthMask.set(!0)),A!==void 0&&(z|=F.STENCIL_BUFFER_BIT,this.clearStencil.set(A),this.stencilMask.set(255)),F.clear(z)}setCullFace(h){h.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(h.mode),this.frontFace.set(h.frontFace))}setDepthMode(h){h.func!==this.gl.ALWAYS||h.mask?(this.depthTest.set(!0),this.depthFunc.set(h.func),this.depthMask.set(h.mask),this.depthRange.set(h.range)):this.depthTest.set(!1)}setStencilMode(h){h.test.func!==this.gl.ALWAYS||h.mask?(this.stencilTest.set(!0),this.stencilMask.set(h.mask),this.stencilOp.set([h.fail,h.depthFail,h.pass]),this.stencilFunc.set({func:h.test.func,ref:h.ref,mask:h.test.mask})):this.stencilTest.set(!1)}setColorMode(h){i.by(h.blendFunction,Hn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(h.blendFunction),this.blendColor.set(h.blendColor),h.blendEquation?this.blendEquation.set(h.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(h.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let lv;function kr(T,h,y,A,D,F,z){const W=T.context,J=W.gl,ne=T.transform,le=[i.aF(ne.center.lng),i.aJ(ne.center.lat)],je=y.layout.get("symbol-placement"),ve=y.layout.get("text-variable-anchor"),Ne=y.layout.get("icon-rotation-alignment")==="map",De=y.layout.get("text-rotation-alignment")==="map",Pe=je!=="point",Ge=[];let Ve=0,nt=0;for(let yt=0;yt0){const hr=i.bC(),br=Js;i.cP(hr,Ht.placementInvProjMatrix,ne.glCoordMatrix),i.cP(hr,hr,Ht.placementViewportMatrix),Ge.push({circleArray:Pr,circleOffset:nt,transform:br,invTransform:hr,projection:Ht.getProjection()}),Ve+=Pr.length/4,nt=Ve}if(!Us)continue;T.terrain&&T.terrain.setupElevationDraw(Wt,yr);const Cr=Is?[Ot.canonical.x,Ot.canonical.y,1<=0&&(Ne[ut.associatedIconIndex]={x:Ht,y:es,z:ts,angle:as})}else Rp(Nt,je)}if(ne){ve.clear();const nt=T.icon.placedSymbolArray;for(let ut=0;ut{let za=[0,0,0];if(ui){const Gn=T.style.directionalLight,Xi=T.style.ambientLight;Gn&&Xi&&(za=sg(T.style,Gn,Xi))}return za},Ka=ui=>{yt.depthOcclusionForSymbolsAndCircles&&(y.hasOcclusionOpacityProperties||T.terrain)&&(ui.push("DEPTH_D24"),ui.push("DEPTH_OCCLUSION"))},Cn=ui=>{y.lut&&!Nt&&(y.lut.texture||(y.lut.texture=new i.d$(T.context,y.lut.image,[y.lut.image.height,y.lut.image.height,y.lut.image.height],Tt.gl.RGBA8)),Tt.activeTexture.set(Tt.gl.TEXTURE0+Gc.LUT),y.lut.texture&&y.lut.texture.bind(Tt.gl.LINEAR,Tt.gl.CLAMP_TO_EDGE),ui.push("APPLY_LUT_ON_GPU"))},di=()=>{const ui=Ot&&y.layout.get("symbol-placement")!=="point",za=[];Ka(za),Cn(za);const Gn=ui||Pn,Xi=Us.elevationType==="road",Ho=T.shadowRenderer,_o=Xi&&Ht&&!!Ho&&Ho.enabled,Di=Or(_o),Bu=Xi&&Ht&&!T.terrain?Yt:qs,Td=y.paint.get("icon-image-cross-fade");T.terrainRenderModeElevated()&&Ht&&za.push("PITCH_WITH_MAP_TERRAIN"),Pr&&(za.push("PROJECTION_GLOBE_VIEW"),Gn&&za.push("PROJECTED_POS_ON_VIEWPORT")),Td>0&&Us.hasAnySecondaryIcon&&za.push("ICON_TRANSITION"),!Us.icon.zOffsetVertexBuffer||Xi&&T.terrain||za.push("Z_OFFSET"),Ve===0&&nt===0&&ut===0&&ot===1||za.push("COLOR_ADJUSTMENT"),Us.sdfIcons&&za.push("RENDER_SDF"),_o&&za.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Xi&&Ht&&!T.terrain&&Us.icon.orientationVertexBuffer&&za.push("ELEVATED_ROADS");const Ul=Us.icon.programConfigurations.get(y.id),Vd=T.getOrCreateProgram("symbol",{config:Ul,defines:za}),Hd=Js.imageAtlasTexture?Js.imageAtlasTexture.size:[0,0],od=Us.iconSizeData,hm=i.bK(od,yt.zoom),ap=Ht||!yt.isOrthographic,mh=Qs(hr,Js.tileID.canonical,Ht,Ot,yt,Us.getProjection(),br),Lo=gn(hr,Js.tileID.canonical,Ht,Ot,yt,Us.getProjection(),br),Jo=T.translatePosMatrix(Lo,Js,W,ne,!0),Oi=T.translatePosMatrix(hr,Js,W,ne),ml=Gn?h2:mh,Co=Ot&&!Ht&&!ui;let wo=rr;!Jt&&!yt.mercatorFromTransition||Ot||(wo=ng(yt));const ip=Pr?wo:rr,k2=y.getColorAdjustmentMatrix(Ve,nt,ut,ot),Up=d3(od.kind,hm,Co,Ht,T,Oi,ml,Jo,Et,!1,Hd,[0,0],0,yr,Cr,Bt,wa,ip,Us.getProjection(),Di,si,k2,Td,null),S2=Js.imageAtlasTexture?Js.imageAtlasTexture:null,bb=y.layout.get("icon-size").constantOr(0)!==1||Us.iconsNeedLinear,Kf=Us.sdfIcons||T.options.rotating||T.options.zooming||bb||ap?wt.LINEAR:wt.NEAREST,mg=Us.sdfIcons&&y.paint.get("icon-halo-width").constantOr(1)!==0,_b=T.terrain&&Ht&&ui?i.bl(i.bC(),mh):h2;if(ui&&Us.icon){const Ry=i.bV.getAtTileOffsetFunc(yr,yt.center.lat,yt.worldSize,Us.getProjection()),pg=xn(hr,Js.tileID.canonical,Ht,Ot,yt,Us.getProjection(),br),Vp=y.layout.get("icon-size-scale-range"),fg=i.aA(T.scaleFactor,Vp[0],Vp[1]);Jx(Us,hr,T,!1,pg,Lo,Ht,Pe,Ry,yr,fg)}return{program:Vd,buffers:Us.icon,uniformValues:Up,atlasTexture:S2,atlasTextureIcon:null,atlasInterpolation:Kf,atlasInterpolationIcon:null,isSDF:Us.sdfIcons,hasHalo:mg,depthMode:Bu,tile:Js,renderWithShadows:_o,labelPlaneMatrixInv:_b}},Ci=()=>{const ui=Wt&&y.layout.get("symbol-placement")!=="point",za=[],Gn=ui||as||Pn,Xi=Us.elevationType==="road",Ho=T.shadowRenderer,_o=Xi&&es&&!!Ho&&Ho.enabled,Di=Or(_o),Bu=Xi&&es&&!T.terrain?Yt:qs;T.terrainRenderModeElevated()&&es&&za.push("PITCH_WITH_MAP_TERRAIN"),Pr&&(za.push("PROJECTION_GLOBE_VIEW"),Gn&&za.push("PROJECTED_POS_ON_VIEWPORT")),!Us.text.zOffsetVertexBuffer||Xi&&T.terrain||za.push("Z_OFFSET"),Us.iconsInText&&za.push("RENDER_TEXT_AND_SYMBOL"),za.push("RENDER_SDF"),_o&&za.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Xi&&es&&!T.terrain&&Us.text.orientationVertexBuffer&&za.push("ELEVATED_ROADS"),Ka(za);const Td=Us.text.programConfigurations.get(y.id),Ul=T.getOrCreateProgram("symbol",{config:Td,defines:za});let Vd,Hd=[0,0],od=null;const hm=Us.textSizeData;Us.iconsInText&&(Hd=Js.imageAtlasTexture?Js.imageAtlasTexture.size:[0,0],od=Js.imageAtlasTexture?Js.imageAtlasTexture:null,Vd=es||!yt.isOrthographic||T.options.rotating||T.options.zooming||hm.kind==="composite"||hm.kind==="camera"?wt.LINEAR:wt.NEAREST);const ap=Js.glyphAtlasTexture?Js.glyphAtlasTexture.size:[0,0],mh=y.layout.get("text-size-scale-range"),Lo=i.aA(T.scaleFactor,mh[0],mh[1]),Jo=i.bK(hm,yt.zoom,Lo),Oi=Qs(hr,Js.tileID.canonical,es,Wt,yt,Us.getProjection(),br),ml=gn(hr,Js.tileID.canonical,es,Wt,yt,Us.getProjection(),br),Co=T.translatePosMatrix(ml,Js,J,le,!0),wo=T.translatePosMatrix(hr,Js,J,le),ip=Gn?h2:Oi,k2=Wt&&!es&&!ui;let Up=rr;!Jt&&!yt.mercatorFromTransition||Wt||(Up=ng(yt));const S2=d3(hm.kind,Jo,k2,es,T,wo,ip,Co,Et,!0,ap,Hd,0,yr,Cr,Bt,wa,Pr?Up:rr,Us.getProjection(),Di,si,null,null,Lo),bb=Js.glyphAtlasTexture?Js.glyphAtlasTexture:null,Kf=wt.LINEAR,mg=y.paint.get("text-halo-width").constantOr(1)!==0,_b=T.terrain&&es&&ui?i.bl(i.bC(),Oi):h2;if(ui&&Us.text){const Ry=i.bV.getAtTileOffsetFunc(yr,yt.center.lat,yt.worldSize,Us.getProjection()),pg=xn(hr,Js.tileID.canonical,es,Wt,yt,Us.getProjection(),br);Jx(Us,hr,T,!0,pg,ml,es,Ge,Ry,yr,Lo)}return{program:Ul,buffers:Us.text,uniformValues:S2,atlasTexture:bb,atlasTextureIcon:od,atlasInterpolation:Kf,atlasInterpolationIcon:Vd,isSDF:!0,hasHalo:mg,depthMode:Bu,tile:Js,renderWithShadows:_o,labelPlaneMatrixInv:_b}},bi=Us.icon.segments.get().length,Ga=Us.text.segments.get().length,Wn=bi&&!z.onlyText?di():null,ii=Ga&&!z.onlyIcons?Ci():null,So=y.paint.get("icon-opacity").constantOr(1),no=y.paint.get("text-opacity").constantOr(1);if(ts&&Us.canOverlap){xs=!0;const ui=So&&!z.onlyText?Us.icon.segments.get():[],za=no&&!z.onlyIcons?Us.text.segments.get():[];for(const Gn of ui)Is.push({segments:new i.bg([Gn]),sortKey:Gn.sortKey,state:Wn});for(const Gn of za)Is.push({segments:new i.bg([Gn]),sortKey:Gn.sortKey,state:ii})}else z.onlyText||Is.push({segments:So?Us.icon.segments:new i.bg([]),sortKey:0,state:Wn}),z.onlyIcons||Is.push({segments:no?Us.text.segments:new i.bg([]),sortKey:0,state:ii})}xs&&Is.sort((yr,Js)=>yr.sortKey-Js.sortKey);for(const yr of Is){const Js=yr.state;if(Js)if(T.terrain?T.terrain.setupElevationDraw(Js.tile,Js.program,{useDepthForOcclusion:yt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Js.labelPlaneMatrixInv}):T.setupDepthForOcclusion(yt.depthOcclusionForSymbolsAndCircles,Js.program),Tt.activeTexture.set(wt.TEXTURE0),Js.atlasTexture&&Js.atlasTexture.bind(Js.atlasInterpolation,wt.CLAMP_TO_EDGE,!0),Js.atlasTextureIcon&&(Tt.activeTexture.set(wt.TEXTURE1),Js.atlasTextureIcon&&Js.atlasTextureIcon.bind(Js.atlasInterpolationIcon,wt.CLAMP_TO_EDGE,!0)),Js.renderWithShadows&&T.shadowRenderer.setupShadows(Js.tile.tileID.toUnwrapped(),Js.program,"vector-tile"),T.uploadCommonLightUniforms(T.context,Js.program),Js.hasHalo){const Us=Js.uniformValues;Us.u_is_halo=1,y6(Js.buffers,yr.segments,y,T,Js.program,Js.depthMode,D,F,Us,2),Us.u_is_halo=0}else{if(Js.isSDF){const Us=Js.uniformValues;Js.hasHalo&&(Us.u_is_halo=1,y6(Js.buffers,yr.segments,y,T,Js.program,Js.depthMode,D,F,Us,1)),Us.u_is_halo=0}y6(Js.buffers,yr.segments,y,T,Js.program,Js.depthMode,D,F,Js.uniformValues,1)}}}function y6(T,h,y,A,D,F,z,W,J,ne){const le=[T.dynamicLayoutVertexBuffer,T.opacityVertexBuffer,T.iconTransitioningVertexBuffer,T.globeExtVertexBuffer,T.zOffsetVertexBuffer,T.orientationVertexBuffer];D.draw(A,A.context.gl.TRIANGLES,F,z,W,mn.disabled,J,y.id,T.layoutVertexBuffer,T.indexBuffer,h,y.paint,A.transform.zoom,T.programConfigurations.get(y.id),le,ne)}function rF(T,h){const y=1<=zp?1:Ne.pitch/zp))),2*De}(T.transform),ne=T.transform.getFreeCameraOptions().position,le="elevatedStructuresDepthReconstruct",je=T.getOrCreateProgram(le,{defines:["DEPTH_RECONSTRUCTION"]}),ve=T.getOrCreateProgram(le);for(const Ne of A){const De=h.getTile(Ne),Pe=De.getBucket(y);if(!Pe)continue;const Ge=Pe.elevatedStructures;if(!Ge)continue;const Ve=Pe.elevationBufferData.heightRange,nt=rF(Ne.toUnwrapped(),ne),ut=T.translatePosMatrix(Ne.projMatrix,De,y.paint.get("fill-translate"),y.paint.get("fill-translate-anchor"));let ot,Et,Nt,Tt;if(D==="initialize"){if(!Ve||Ve.min>=1||Ge.depthSegments.segments[0].primitiveLength===0)continue;ot=iv(ut,nt,J,1,0),Et=z,Nt=Ge.depthSegments,Tt=je}else if(D==="reset"){if(!Ve||Ve.min>=0||Ge.maskSegments.segments[0].primitiveLength===0)continue;ot=iv(ut,nt,0,0,1),Et=W,Nt=Ge.maskSegments,Tt=je}else if(D==="geometry"){if(Ge.depthSegments.segments[0].primitiveLength===0)continue;ot=iv(ut,nt,J,1,0),Et=z,Nt=Ge.depthSegments,Tt=ve}Tt.draw(T,F.TRIANGLES,Et,yn.disabled,Hn.disabled,mn.disabled,ot,y.id,Ge.vertexBuffer,Ge.indexBuffer,Nt,y.paint,T.transform.zoom)}}function m3(T,h,y,A){const{painter:D,sourceCache:F,layer:z,coords:W,colorMode:J,elevationType:ne,terrainEnabled:le,pass:je}=T,ve=D.context.gl,Ne=z.paint.get("fill-pattern"),De=z.paint.get("fill-pattern-cross-fade"),Pe=Ne.constantOr(null);let Ge=ne;ne!=="road"||h&&!le||(Ge="none");const Ve=Ge==="road",nt=T.painter.shadowRenderer,ut=Ve&&!!nt&&nt.enabled,ot=new Fr(D.context.gl.LEQUAL,Fr.ReadOnly,D.depthRangeFor3D);let Et=[0,0,0];if(ut){const yt=D.style.directionalLight,Ot=D.style.ambientLight;yt&&Ot&&(Et=sg(D.style,yt,Ot))}const Nt=Ne&&Ne.constantOr(1),Tt=D.terrain&&D.terrain.renderingToTexture,wt=(yt,Ot)=>{let Wt,Ht,es,ts,xs;Ot?(Wt=Nt&&!z.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",es=ve.LINES):(Wt=Nt?"fillPattern":"fill",es=ve.TRIANGLES);for(const qs of W){const Yt=F.getTile(qs);if(Nt&&!Yt.patternsLoaded())continue;const Bt=Yt.getBucket(z);if(!Bt)continue;const as=h?Bt.elevationBufferData:Bt.bufferData;if(as.isEmpty())continue;D.prepareDrawTile();const Jt=as.programConfigurations.get(z.id),Is=D.isTileAffectedByFog(qs),rr=[],yr=[];Ve&&(rr.push("ELEVATED_ROADS"),yr.push(as.elevatedLayoutVertexBuffer)),ut&&rr.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Tt&&y&&rr.push("USE_MRT1"),Nt&&(D.context.activeTexture.set(ve.TEXTURE0),Yt.imageAtlasTexture&&Yt.imageAtlasTexture.bind(ve.LINEAR,ve.CLAMP_TO_EDGE),Jt.updatePaintBuffers());let Js=!1;if(Pe&&Yt.imageAtlas){const br=Yt.imageAtlas,Kr=i.e3.from(Pe),Pn=Kr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),wa=Kr.getSecondary(),si=br.patternPositions.get(Pn),Or=wa?br.patternPositions.get(wa.scaleSelf(i.o.devicePixelRatio).toString()):null;Js=!!si&&!!Or,si&&Jt.setConstantPatternPositions(si,Or)}De>0&&(Js||Jt.getPatternTransitionVertexBuffer("fill-pattern"))&&rr.push("FILL_PATTERN_TRANSITION");const Us=D.getOrCreateProgram(Wt,{config:Jt,overrideFog:Is,defines:rr}),Pr=D.translatePosMatrix(qs.projMatrix,Yt,z.paint.get("fill-translate"),z.paint.get("fill-translate-anchor"));ut&&nt.setupShadows(Yt.tileID.toUnwrapped(),Us,"vector-tile");const Cr=z.paint.get("fill-emissive-strength");if(Ot){ts=as.lineIndexBuffer,xs=as.lineSegments;const br=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[ve.drawingBufferWidth,ve.drawingBufferHeight];Ht=Wt==="fillOutlinePattern"&&Nt?p6(Pr,Cr,D,Yt,br,Et,De):GR(Pr,Cr,br,Et)}else ts=as.indexBuffer,xs=as.triangleSegments,Ht=Nt?m6(Pr,Cr,D,Yt,Et,De):h6(Pr,Cr,Et);D.uploadCommonUniforms(D.context,Us,qs.toUnwrapped());let hr=yt;(ne==="road"&&!le||ne==="offset")&&(hr=ot),Us.draw(D,es,hr,A||D.stencilModeForClipping(qs),J,mn.disabled,Ht,z.id,as.layoutVertexBuffer,ts,xs,z.paint,D.transform.zoom,Jt,yr)}};D.renderPass===je&&wt(D.depthModeForSublayer(1,D.renderPass==="opaque"?Fr.ReadWrite:Fr.ReadOnly),!1),Ge==="none"&&D.renderPass==="translucent"&&z.paint.get("fill-antialias")&&wt(D.depthModeForSublayer(z.getPaintProperty("fill-outline-color")?2:0,Fr.ReadOnly),!0)}function p3(T,h,y,A,D,F,z,W){y.resetLayerRenderingStats(T);const J=T.context,ne=J.gl,le=T.transform,je=y.paint.get("fill-extrusion-pattern"),ve=y.paint.get("fill-extrusion-pattern-cross-fade"),Ne=je.constantOr(null),De=je.constantOr(1),Pe=y.paint.get("fill-extrusion-opacity"),Ge=T.style.enable3dLights(),Ve=y.paint.get(Ge&&!De?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),nt=[y.paint.get("fill-extrusion-ambient-occlusion-intensity"),Ve],ut=y.layout.get("fill-extrusion-edge-radius"),ot=ut>0&&!y.paint.get("fill-extrusion-rounded-roof"),Et=ot?0:ut,Nt=le.projection.name==="globe"?i.eb():0,Tt=le.projection.name==="globe",wt=Tt?i.aj(le.zoom):0,yt=[i.aF(le.center.lng),i.aJ(le.center.lat)],Ot=y.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Wt=y.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Ot?null:y.lut).toArray01().slice(0,3),Ht=y.paint.get("fill-extrusion-flood-light-intensity"),es=y.paint.get("fill-extrusion-vertical-scale"),ts=y.paint.get("fill-extrusion-line-width").constantOr(1)!==0,xs=y.paint.get("fill-extrusion-height-alignment"),qs=y.paint.get("fill-extrusion-base-alignment"),Yt=jy(T,y.paint.get("fill-extrusion-cutoff-fade-range")),Bt=[];let as;Tt&&Bt.push("PROJECTION_GLOBE_VIEW"),nt[0]>0&&Bt.push("FAUX_AO"),ot&&Bt.push("ZERO_ROOF_RADIUS"),W&&Bt.push("HAS_CENTROID"),Ht>0&&Bt.push("FLOOD_LIGHT"),Yt.shouldRenderCutoff&&Bt.push("RENDER_CUTOFF"),ts&&Bt.push("RENDER_WALL_MODE");const Jt=T.renderPass==="shadow",Is=T.shadowRenderer,rr=Jt&&!!Is,yr=Jt?mn.disabled:mn.backCCW;T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0);let Js=[0,0,0];if(Is){const Cr=T.style.directionalLight,hr=T.style.ambientLight;Cr&&hr&&(Js=sg(T.style,Cr,hr)),Jt||(Bt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Is.useNormalOffset&&Bt.push("NORMAL_OFFSET")),as=Bt.concat(["SHADOWS_SINGLE_CASCADE"])}const Us=rr?"fillExtrusionDepth":De?"fillExtrusionPattern":"fillExtrusion",Pr=y.getLayerRenderingStats();for(const Cr of A){const hr=h.getTile(Cr),br=hr.getBucket(y);if(!br||br.projection.name!==le.projection.name)continue;let Kr=!1;Is&&(Kr=Is.getMaxCascadeForTile(Cr.toUnwrapped())===0);const Pn=T.isTileAffectedByFog(Cr),wa=br.programConfigurations.get(y.id);let si=!1;if(Ne&&hr.imageAtlas){const Ga=hr.imageAtlas,Wn=i.e3.from(Ne),ii=Wn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),So=Wn.getSecondary(),no=Ga.patternPositions.get(ii),ui=So?Ga.patternPositions.get(So.scaleSelf(i.o.devicePixelRatio).toString()):null;si=!!no&&!!ui,no&&wa.setConstantPatternPositions(no,ui)}ve>0&&(si||wa.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Bt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Or=T.getOrCreateProgram(Us,{config:wa,defines:Kr?as:Bt,overrideFog:Pn});if(T.terrain&&T.terrain.setupElevationDraw(hr,Or,{useMeterToDem:!0}),!br.centroidVertexBuffer){const Ga=Or.getAttributeLocation(ne,"a_centroid_pos");Ga!==-1&&ne.vertexAttrib2f(Ga,0,0)}!Jt&&Is&&Is.setupShadows(hr.tileID.toUnwrapped(),Or,"vector-tile"),De&&(T.context.activeTexture.set(ne.TEXTURE0),hr.imageAtlasTexture&&hr.imageAtlasTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),wa.updatePaintBuffers());const Ka=y.paint.get("fill-extrusion-vertical-gradient"),Cn=1/br.tileToMeter;let di;if(Jt&&Is){if(ig(hr.tileID,br.maxHeight,T))continue;const Ga=Is.calculateShadowPassMatrixFromTile(hr.tileID.toUnwrapped());di=u6(Ga,Et,Cn,es,xs,qs)}else{const Ga=T.translatePosMatrix(Cr.expandedProjMatrix,hr,y.paint.get("fill-extrusion-translate"),y.paint.get("fill-extrusion-translate-anchor")),Wn=le.projection.createInversionMatrix(le,Cr.canonical);di=De?WR(Ga,T,Ka,Pe,nt,Et,Cn,Cr,hr,Nt,xs,qs,wt,yt,Wn,Wt,es,ve):i3(Ga,T,Ka,Pe,nt,Et,Cn,Cr,Nt,xs,qs,wt,yt,Wn,Wt,es,Ht,Js)}T.uploadCommonUniforms(J,Or,Cr.toUnwrapped(),null,Yt);let Ci=br.segments;if(le.projection.name==="mercator"&&!Jt&&(Ci=br.getVisibleSegments(hr.tileID,T.terrain,T.transform.getFrustum(0)),!Ci.get().length))continue;if(Pr)if(Jt)for(const Ga of Ci.get())Pr.numRenderedVerticesInShadowPass+=Ga.primitiveLength;else for(const Ga of Ci.get())Pr.numRenderedVerticesInTransparentPass+=Ga.primitiveLength;const bi=[];(T.terrain||W)&&bi.push(br.centroidVertexBuffer),Tt&&bi.push(br.layoutVertexExtBuffer),ts&&bi.push(br.wallVertexBuffer),Or.draw(T,J.gl.TRIANGLES,D,F,z,yr,di,y.id,br.layoutVertexBuffer,br.indexBuffer,Ci,y.paint,T.transform.zoom,wa,bi)}T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!1)}class v6{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function ag(T,h,y,A,D,F,z,W,J,ne,le,je,ve,Ne,De,Pe,Ge,Ve,nt,ut){const ot=h.context,Et=ot.gl,Nt=h.transform,Tt=h.transform.zoom,wt=[],yt=T.translate,Ot=T.translateAnchor,Wt=T.edgeRadius,Ht=jy(h,T.cutoffFadeRange);le==="clear"?(wt.push("CLEAR_SUBPASS"),ut&&(wt.push("CLEAR_FROM_TEXTURE"),ot.activeTexture.set(Et.TEXTURE0),ut.bind(Et.LINEAR,Et.CLAMP_TO_EDGE))):le==="sdf"?wt.push("SDF_SUBPASS"):le==="emissive"&&(wt.push("USE_MRT1"),ot.activeTexture.set(Et.TEXTURE0),ut.bind(Et.LINEAR,Et.CLAMP_TO_EDGE)),Ve&&wt.push("HAS_CENTROID"),Ht.shouldRenderCutoff&&wt.push("RENDER_CUTOFF");const es=(ts,xs,qs,Yt,Bt)=>{let as=wt;xs.groundRadiusBuffer!=null&&(as=wt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Jt=xs.programConfigurations.get(A.id),Is=h.isTileAffectedByFog(ts),rr=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:Jt,defines:as,overrideFog:Is}),yr=cb(h,Yt,je,ne,Bt,[ve,Ne*Bt],De,Pe,Ge,Tt>=17?0:Wt*Bt,ut?ut.size[0]:0),Js=[];Ve&&Js.push(xs.hiddenByLandmarkVertexBuffer),xs.groundRadiusBuffer!=null&&Js.push(xs.groundRadiusBuffer),h.uploadCommonUniforms(ot,rr,ts.toUnwrapped(),null,Ht),rr.draw(h,ot.gl.TRIANGLES,F,z,W,J,yr,A.id,xs.vertexBuffer,xs.indexBuffer,qs,A.paint,Tt,Jt,Js)};for(const ts of D){const xs=y.getTile(ts),qs=xs.getBucket(A);if(!qs||qs.projection.name!==Nt.projection.name||!qs.groundEffect||qs.groundEffect&&!qs.groundEffect.hasData())continue;const Yt=qs.groundEffect,Bt=1/qs.tileToMeter;{const as=h.translatePosMatrix(ts.projMatrix,xs,yt,Ot),Jt=Yt.getDefaultSegment();es(ts,Yt,Jt,as,Bt)}if(nt)for(let as=0;as<4;as++){const Jt=i.e9[as](ts),Is=y.getTile(Jt);if(!Is)continue;const rr=Is.getBucket(A);if(!rr||rr.projection.name!==Nt.projection.name||!rr.groundEffect||rr.groundEffect&&!rr.groundEffect.hasData())continue;const yr=rr.groundEffect;let Js,Us;as===0?(Js=[-i.al,0,0],Us=1):as===1?(Js=[i.al,0,0],Us=0):as===2?(Js=[0,-i.al,0],Us=3):(Js=[0,i.al,0],Us=2);const Pr=yr.regionSegments[Us];if(!Pr)continue;const Cr=new Float32Array(16);i.br(Cr,ts.projMatrix,Js),es(ts,yr,Pr,h.translatePosMatrix(Cr,xs,yt,Ot),Bt)}}}function qme(T,h,y,A,D,F,z){A.centroidVertexArray.length===0&&A.createCentroidsBuffer();const W=F?F.findDEMTileFor(y):null;if(!(W&&W.dem||z))return;F&&W&&W.dem&&A.selfDEMTileTimestamp!==W.dem._timestamp&&(A.borderDoneWithNeighborZ=[-1,-1,-1,-1],A.selfDEMTileTimestamp=W.dem._timestamp);const J=Ve=>new i.P(Math.ceil((Ve+i.ed)*i.ee),0),ne=Ve=>{const nt=h.getSource().minzoom,ut=Et=>{const Nt=h.getTileByID(Et);if(Nt&&Nt.hasData())return Nt.getBucket(D)},ot=[0,-1,1];for(const Et of ot){if(Ve.overscaledZ+Et(le[0]=Math.min(Ve.min.y,nt.min.y),le[1]=Math.max(Ve.max.y,nt.max.y),le[2]=i.al-nt.min.x>Ve.max.x?nt.min.x-i.al:Ve.max.x,le),ve=(Ve,nt)=>(le[0]=Math.min(Ve.min.x,nt.min.x),le[1]=Math.max(Ve.max.x,nt.max.x),le[2]=i.al-nt.min.y>Ve.max.y?nt.min.y-i.al:Ve.max.y,le),Ne=[(Ve,nt)=>je(Ve,nt),(Ve,nt)=>je(nt,Ve),(Ve,nt)=>ve(Ve,nt),(Ve,nt)=>ve(nt,Ve)],De=(Ve,nt,ut,ot,Et,Nt,Tt)=>{if(!F)return 0;const wt=[[Nt?ut:Ve,Nt?Ve:ut,0],[Nt?ut:nt,Nt?nt:ut,0]],yt=Tt<0?i.al+Tt:Tt,Ot=[Nt?yt:(Ve+nt)/2,Nt?(Ve+nt)/2:yt,0];return ut===0&&Tt<0||ut!==0&&Tt>0?F.getForTilePoints(Et,[Ot],!0,ot):wt.push(Ot),F.getForTilePoints(y,wt,!0,W),Math.max(wt[0][2],wt[1][2],Ot[2])/F.exaggeration()};for(let Ve=0;Ve<4;Ve++){const nt=A.borderFeatureIndices[Ve];if(nt.length===0)continue;const ut=i.e9[Ve](y),ot=ne(ut);if(!(ot&&ot instanceof i.ea))continue;const Et=F?F.findDEMTileFor(ut):null;if(!(Et&&Et.dem||z)||(F&&Et&&Et.dem&&A.borderDEMTileTimestamp[Ve]!==Et.dem._timestamp&&(A.borderDoneWithNeighborZ[Ve]=-1,A.borderDEMTileTimestamp[Ve]=Et.dem._timestamp),A.borderDoneWithNeighborZ[Ve]===ot.canonical.z))continue;ot.centroidVertexArray.length===0&&ot.createCentroidsBuffer();const Nt=(Ve<2?1:5)-Ve,Tt=ot.borderDoneWithNeighborZ[Nt]!==A.canonical.z,wt=ot.borderFeatureIndices[Nt];let yt=0;if(A.canonical.z!==ot.canonical.z){for(const Ot of nt)A.showCentroid(A.featuresOnBorder[Ot]);if(Tt)for(const Ot of wt)ot.showCentroid(ot.featuresOnBorder[Ot]);A.borderDoneWithNeighborZ[Ve]=ot.canonical.z,ot.borderDoneWithNeighborZ[Nt]=A.canonical.z}for(const Ot of nt){const Wt=A.featuresOnBorder[Ot],Ht=A.centroidData[Wt.centroidDataIndex],es=Wt.borders[Ve];let ts;for(;ytes[0]+3||xs[0]>es[0]-3)break;ot.showCentroid(ts),yt++}if(ts&&ytes[1]-3)&&(qs++,++yt!==wt.length);)ts=ot.featuresOnBorder[wt[yt]];ts=ot.featuresOnBorder[wt[xs]];let Yt=!1;if(qs>=1){const Jt=ts.borders[Nt];Math.abs(es[0]-Jt[0])<3&&Math.abs(es[1]-Jt[1])<3&&(qs=1,Yt=!0,yt=xs+1)}else if(qs===0){A.showCentroid(Wt);continue}const Bt=ot.centroidData[ts.centroidDataIndex];z&&Yt&&(((Pe=Ht).flags|(Ge=Bt).flags)&i.ec?(Pe.flags|=i.ec,Ge.flags|=i.ec):(Pe.flags&=~i.ec,Ge.flags&=~i.ec));const as=Wt.intersectsCount()>1||ts.intersectsCount()>1;if(qs>1)yt=xs,Ht.centroidXY=Bt.centroidXY=new i.P(0,0);else if(Et&&Et.dem&&!as){const Jt=Ne[Ve](Ht,Bt),Is=Ve%2?i.al-1:0,rr=De(Jt[0],Math.min(i.al-1,Jt[1]),Is,Et,ut,Ve<2,Jt[2]);Ht.centroidXY=Bt.centroidXY=J(rr)}else as?Ht.centroidXY=Bt.centroidXY=new i.P(0,0):(Ht.centroidXY=A.encodeBorderCentroid(Wt),Bt.centroidXY=ot.encodeBorderCentroid(ts));A.writeCentroidToBuffer(Ht),ot.writeCentroidToBuffer(Bt)}else A.showCentroid(Wt)}A.borderDoneWithNeighborZ[Ve]=ot.canonical.z,ot.borderDoneWithNeighborZ[Nt]=A.canonical.z}var Pe,Ge;(A.needsCentroidUpdate||!A.centroidVertexBuffer&&A.centroidVertexArray.length!==0)&&A.uploadCentroid(T)}const Dh=[1,0,0],b6=[0,1,0],Fu=[0,0,1];function ig(T,h,y){const A=y.transform,D=y.shadowRenderer;if(!D)return!0;const F=T.toUnwrapped(),z=A.tileSize*D._cascades[y.currentShadowCascade].scale;let W=h;if(A.elevation){const Pe=A.elevation.getMinMaxForTile(T);Pe&&(W+=Pe.max)}const J=[...D.shadowDirection];J[2]=-J[2];const ne=D.computeSimplifiedTileShadowVolume(F,W,z,J);if(!ne)return!1;const le=[Dh,b6,Fu,J,[J[0],0,J[2]],[0,J[1],J[2]]],je=A.projection.name==="globe",ve=A.scaleZoom(z),Ne=i.cB.fromInvProjectionMatrix(A.invProjMatrix,A.worldSize,ve,!je),De=D.getCurrentCascadeFrustum();return Ne.intersectsPrecise(ne.vertices,ne.planes,le)===0||De.intersectsPrecise(ne.vertices,ne.planes,le)===0}function p2(T){const{painter:h,source:y,layer:A,coords:D}=T;let F=T.defines;const z=h.context,W=h.renderPass==="shadow",J=h.renderPass==="light-beam",ne=h.shadowRenderer,le=i.ef(h.transform.center.lat,h.transform.zoom),je=jy(h,A.paint.get("building-cutoff-fade-range"));je.shouldRenderCutoff&&(F=F.concat("RENDER_CUTOFF")),T.floodLightIntensity>0&&(F=F.concat("FLOOD_LIGHT"));for(const ve of D){const Ne=y.getTile(ve),De=Ne.getBucket(A);if(!De)continue;ne&&ne.getMaxCascadeForTile(ve.toUnwrapped())===0&&(F=F.concat("SHADOWS_SINGLE_CASCADE"));const Pe=De.programConfigurations.get(A.id);let Ge,Ve,nt,ut=h.translatePosMatrix(ve.expandedProjMatrix,Ne,[0,0],"map");if(ut=i.cS(i.bC(),ut,[1,1,T.verticalScale]),W&&ne){if(ig(Ne.tileID,De.maxHeight*le,h))continue;let Et=ne.calculateShadowPassMatrixFromTile(Ne.tileID.toUnwrapped());Et=i.cS(i.bC(),Et,[1,1,T.verticalScale]),nt=Ay(Et),Ge=Ve=h.getOrCreateProgram("buildingDepth",{config:Pe,defines:F,overrideFog:!1})}else if(J)Ge=Ve=h.getOrCreateProgram("buildingBloom",{config:Pe,defines:F,overrideFog:!1}),nt=KR(ut);else{const Et=h.transform.calculatePosMatrix(ve.toUnwrapped(),h.transform.worldSize);i.cS(Et,Et,[1,1,T.verticalScale]);const Nt=i.bC();i.cS(Nt,Et,[1,-1,1/le]),i.bl(Nt,Nt),i.eg(Nt,Nt);const Tt=h.transform.getFreeCameraOptions().position,wt=1<{if(J){const Tt=Et.entranceBloom;Nt.draw(h,z.gl.TRIANGLES,T.depthMode,yn.disabled,T.blendMode,mn.disabled,nt,A.id,Tt.layoutVertexBuffer,Tt.indexBuffer,Tt.segmentsBucket,A.paint,h.transform.zoom,Pe,[Tt.layoutAttenuationBuffer,Tt.layoutColorBuffer])}else{const Tt=Et.segmentsBucket;let wt=[Et.layoutNormalBuffer,Et.layoutCentroidBuffer,Et.layoutColorBuffer,Et.layoutFloodLightDataBuffer];Et.layoutFacadePaintBuffer&&(wt=wt.concat([Et.layoutFacadeDataBuffer,Et.layoutFacadeVerticalRangeBuffer,Et.layoutFacadePaintBuffer])),Nt.draw(h,z.gl.TRIANGLES,T.depthMode,yn.disabled,T.blendMode,W?mn.disabled:mn.backCW,nt,A.id,Et.layoutVertexBuffer,Et.indexBuffer,Tt,A.paint,h.transform.zoom,Pe,wt)}};h.uploadCommonUniforms(z,Ve,ve.toUnwrapped(),null,je),De.buildingWithoutFacade&&ot(De.buildingWithoutFacade,Ve),De.buildingWithFacade&&(Ge!==Ve&&h.uploadCommonUniforms(z,Ge,ve.toUnwrapped(),null,je),ot(De.buildingWithFacade,Ge))}}function f3(T,h,y,A,D,F,z,W,J,ne,le,je,ve){const Ne=T.context.gl,De=T.depthModeForSublayer(1,Fr.ReadOnly,Ne.LEQUAL,!0),Pe=.1*(1-(Ge=le))+3*Ge;var Ge;const Ve=T._showOverdrawInspector,nt=je,ut=new v6;Ve||ag(ut,T,h,y,A,De,new yn({func:Ne.ALWAYS,mask:255},255,255,Ne.KEEP,Ne.KEEP,Ne.REPLACE),new Hn([Ne.ONE,Ne.ONE,Ne.ONE,Ne.ONE],i.ao.transparent,[!1,!1,!1,!0],Ne.MIN),mn.disabled,D,"sdf",F,z,W,J,ne,Pe,nt,!1);{const ot=Ve?yn.disabled:new yn({func:Ne.EQUAL,mask:255},255,255,Ne.KEEP,Ne.DECR,Ne.DECR),Et=Ve?T.colorModeForRenderPass():new Hn([Ne.ONE_MINUS_DST_ALPHA,Ne.DST_ALPHA,Ne.ONE,Ne.ONE],i.ao.transparent,[!0,!0,!0,!0]);ag(ut,T,h,y,A,De,ot,Et,mn.disabled,D,"color",F,z,W,J,ne,Pe,nt,!1)}}function x3(T){return[T[0]*i.eh,T[1]*i.eh,T[2]*i.eh,0]}function f2(T,h,y,A,D,F,z,W,J){const ne=A.getSource(),le=y.globeSharedBuffers;if(!le)return;let je,ve,Ne;if(h&&(je=A.getTile(h)),ne instanceof i.aU?(ve=ne.texture,Ne=i.dK(0,0,y.transform)):je&&h&&(ve=je.texture,Ne=i.dK(h.canonical.z,h.canonical.x,y.transform)),!ve||!Ne)return;T||(Ne=i.cS(i.bC(),Ne,[1,-1,1]));const De=y.context,Pe=De.gl,Ge=D.paint.get("raster-resampling")==="nearest"?Pe.NEAREST:Pe.LINEAR,Ve=y.colorModeForDrapableLayerRenderPass(F),nt=z.defines;nt.push("GLOBE_POLES");const ut=new Fr(Pe.LEQUAL,Fr.ReadWrite,y.depthRangeFor3D),ot=Float32Array.from(y.transform.expandedFarZProjMatrix),Et=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));y.terrain&&y.terrain.prepareDrawTile(),De.activeTexture.set(Pe.TEXTURE0),ve.bind(Ge,Pe.CLAMP_TO_EDGE),De.activeTexture.set(Pe.TEXTURE1),ve.bind(Ge,Pe.CLAMP_TO_EDGE),"useMipmap"in ve&&De.extTextureFilterAnisotropic&&y.transform.pitch>20&&Pe.texParameterf(Pe.TEXTURE_2D,De.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,De.extTextureFilterAnisotropicMax);const[Nt,Tt,wt,yt]=h?le.getPoleBuffers(h.canonical.z,!1):le.getPoleBuffers(0,!0),Ot=D.paint.get("raster-elevation");let Wt;T?(Wt=Nt,y.renderDefaultNorthPole=Ot!==0):(Wt=Tt,y.renderDefaultSouthPole=Ot!==0);const Ht=x3(z.mix),es=((xs,qs,Yt,Bt,as,Jt,Is,rr,yr,Js,Us,Pr,Cr)=>XR(xs,qs,Yt,new Float32Array(16),new Float32Array(9),[0,0],Bt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Jt,[0,0],rr,2,Js,Us,Pr,1,0,Cr))(ot,Et,Ne,i.aj(y.transform.zoom),0,D,0,Ot,0,Ht,z.offset,z.range,F),ts=y.getOrCreateProgram("raster",{defines:nt});y.uploadCommonUniforms(De,ts,null),ts.draw(y,Pe.TRIANGLES,ut,J,Ve,W,es,D.id,Wt,wt,yt)}function nF(T){const h=T._nearZ,y=T.projection.farthestPixelDistance(T),A=y-h,D=.2*T.height,F=h+D;return[h,y,(F-D-h)/A,(F-h)/A]}function og(T,h,y,A){if(T)return h instanceof Sd&&T instanceof Md?h.getTextureDescriptor(T,y,!0):{texture:T.texture,mix:x3(A.mix),offset:A.offset,buffer:0,tileSize:1}}var Ki=i.ei([{name:"a_index",type:"Int16",components:1}]);class g3{constructor(h,y,A,D){const F={width:A[0],height:A[1],data:null},z=h.gl;this.targetColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.context=h,this.updateParticleTexture(y,D),this.lastInvalidatedAt=0}updateParticleTexture(h,y){if(this.particleTextureDimension===y.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const A=this.context.gl,D=y.width*y.height;this.particleTexture0=new i.T(this.context,y,A.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,y,A.RGBA8,{premultiply:!1,useMipmap:!1});const F=new i.ej;F.reserve(D);for(let z=0;z0){const Ht=i.bj(y.canonical,J),es=i.el(Ht);ve=i.aB(new Float32Array(16),J.globeMatrix,es),i.aB(ve,J.projMatrix,ve)}const Ne=i.bC();Ne[12]+=2*D/(i.o.devicePixelRatio*J.width),Ne[13]+=2*F/(i.o.devicePixelRatio*J.height),i.aB(ve,Ne,ve);const De=T.getOrCreateProgram("debug",{defines:je}),Pe=h.getTileByID(y.key);T.terrain&&T.terrain.setupElevationDraw(Pe,De);const Ge=Fr.disabled,Ve=yn.disabled,nt=T.colorModeForRenderPass(),ut="$debug";W.activeTexture.set(ne.TEXTURE0),T.emptyTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),le?Pe._makeGlobeTileDebugBuffers(T.context,J):Pe._makeDebugTileBoundsBuffers(T.context,J.projection);const ot=Pe._tileDebugBuffer||T.debugBuffer,Et=Pe._tileDebugIndexBuffer||T.debugIndexBuffer,Nt=Pe._tileDebugSegments||T.debugSegments;if(De.draw(T,ne.LINE_STRIP,Ge,Ve,nt,mn.disabled,d2(ve,A.toPremultipliedRenderColor(null)),ut,ot,Et,Nt,null,null,null,[Pe._globeTileDebugBorderBuffer]),z){const Ht=Pe.latestRawTileData,es=Math.floor((Ht&&Ht.byteLength||0)/1024);let ts=y.canonical.toString();y.overscaledZ!==y.canonical.z&&(ts+=` => ${y.overscaledZ}`),ts+=` ${Pe.state}`,ts+=` ${es}kb`,function(xs,qs){xs.initDebugOverlayCanvas();const Yt=xs.debugOverlayCanvas,Bt=xs.context.gl,as=xs.debugOverlayCanvas.getContext("2d");as.clearRect(0,0,Yt.width,Yt.height),as.shadowColor="white",as.shadowBlur=2,as.lineWidth=1.5,as.strokeStyle="white",as.textBaseline="top",as.font="bold 36px Open Sans, sans-serif",as.fillText(qs,5,5),as.strokeText(qs,5,5),xs.debugOverlayTexture.update(Yt),xs.debugOverlayTexture.bind(Bt.LINEAR,Bt.CLAMP_TO_EDGE)}(T,ts)}const Tt=h.getTile(y).tileSize,wt=512/Math.min(Tt,512)*(y.overscaledZ/J.zoom)*.5,yt=Pe._tileDebugTextBuffer||T.debugBuffer,Ot=Pe._tileDebugTextIndexBuffer||T.quadTriangleIndexBuffer,Wt=Pe._tileDebugTextSegments||T.debugSegments;De.draw(T,ne.TRIANGLES,Ge,Ve,Hn.alphaBlended,mn.disabled,d2(ve,i.ao.transparent.toPremultipliedRenderColor(null),wt),ut,yt,Ot,Wt,null,null,null,[Pe._globeTileDebugTextBuffer])}function uv(T,h,y,A){Kt(T,0,h+y/2,T.transform.width,y,A)}function Io(T,h,y,A){Kt(T,h-y/2,0,y,T.transform.height,A)}function Kt(T,h,y,A,D,F){const z=T.context,W=z.gl;W.enable(W.SCISSOR_TEST),W.scissor(h*i.o.devicePixelRatio,y*i.o.devicePixelRatio,A*i.o.devicePixelRatio,D*i.o.devicePixelRatio),z.clear({color:F}),W.disable(W.SCISSOR_TEST)}const cF=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:y3}=cF;function Vf(T,h,y,A){T.emplaceBack(h,y,A)}class v3{constructor(h){this.vertexArray=new i.em,this.indices=new i.b0,Vf(this.vertexArray,-1,-1,1),Vf(this.vertexArray,1,-1,1),Vf(this.vertexArray,-1,1,1),Vf(this.vertexArray,1,1,1),Vf(this.vertexArray,-1,-1,-1),Vf(this.vertexArray,1,-1,-1),Vf(this.vertexArray,-1,1,-1),Vf(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=h.createVertexBuffer(this.vertexArray,y3),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function hv(T,h,y,A,D,F){const z=T.context.gl,W=h.paint.get("sky-atmosphere-color"),J=h.paint.get("sky-atmosphere-halo-color"),ne=h.paint.get("sky-atmosphere-sun-intensity"),le=((je,ve,Ne,De,Pe)=>({u_matrix_3f:je,u_sun_direction:ve,u_sun_intensity:Ne,u_color_tint_r:[De.r,De.g,De.b,De.a],u_color_tint_m:[Pe.r,Pe.g,Pe.b,Pe.a],u_luminance:5e-5}))(i.eo(i.dO(),A),D,ne,W.toPremultipliedRenderColor(null),J.toPremultipliedRenderColor(null));z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+F,h.skyboxTexture,0),y.draw(T,z.TRIANGLES,Fr.disabled,yn.disabled,Hn.unblended,mn.frontCW,le,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const dF=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class hb{constructor(h){const y=new i.ep;y.emplaceBack(-1,1,1,0,0),y.emplaceBack(1,1,1,1,0),y.emplaceBack(1,-1,1,1,1),y.emplaceBack(-1,-1,1,0,1);const A=new i.b0;A.emplaceBack(0,1,2),A.emplaceBack(2,3,0),this.vertexBuffer=h.createVertexBuffer(y,dF.members),this.indexBuffer=h.createIndexBuffer(A),this.segments=i.bg.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Ume=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 Vme{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class uF{constructor(h){this.colorModeAlphaBlendedWriteRGB=new Hn([1,Bf,1,Bf],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Hn([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new Vme,this.updateNeeded=!0}update(h){const y=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new hb(y);const A=this.params.sizeRange,D=this.params.intensityRange,F=function(le){const je=i.eq(30),ve=[];for(let Ne=0;Ne{const wt=F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Tt&&wt.push("ALPHA_PASS");const yt=h.getOrCreateProgram("globeAtmosphere",{defines:wt}),Ot=((Ht,es,ts,xs,qs,Yt,Bt,as,Jt,Is,rr,yr)=>({u_frustum_tl:Ht,u_frustum_tr:es,u_frustum_br:ts,u_frustum_bl:xs,u_horizon:qs,u_transition:Yt,u_fadeout_range:Bt,u_atmosphere_fog_color:as.toArray01(),u_high_color:Jt.toArray01(),u_space_color:Is.toArray01(),u_temporal_offset:rr,u_horizon_angle:yr}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,W,Ge,le,ve,De,nt,Et);h.uploadCommonUniforms(A,yt);const Wt=this.atmosphereBuffer;Wt&&yt.draw(h,D.TRIANGLES,z,yn.disabled,Tt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,mn.backCW,Ot,Tt?"atmosphere_glow_alpha":"atmosphere_glow",Wt.vertexBuffer,Wt.indexBuffer,Wt.segments)};Nt(!1),Nt(!0)}drawStars(h,y){const A=i.aA(y.properties.get("star-intensity"),0,1);if(A===0)return;const D=h.context,F=D.gl,z=h.transform,W=h.getOrCreateProgram("stars"),J=i.c7([]);i.c9(J,J,-z._pitch),i.c8(J,J,-z.angle),i.c9(J,J,i.an(z._center.lat)),i.et(J,J,-i.an(z._center.lng));const ne=i.cc(new Float32Array(16),J),le=i.aB([],z.starsProjMatrix,ne),je=i.eo([],ne),ve=i.eu([],je),Ne=[0,1,0];i.dQ(Ne,Ne,ve),i.c5(Ne,Ne,this.params.sizeMultiplier);const De=[1,0,0];i.dQ(De,De,ve),i.c5(De,De,this.params.sizeMultiplier);const Pe=(Ge=Ne,Ve=De,nt=A,{u_matrix:Float32Array.from(le),u_up:Ge,u_right:Ve,u_intensity_multiplier:nt});var Ge,Ve,nt;h.uploadCommonUniforms(D,W),this.starsVx&&this.starsIdx&&W.draw(h,F.TRIANGLES,Fr.disabled,yn.disabled,this.colorModeAlphaBlendedWriteRGB,mn.disabled,Pe,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class b3{constructor(){this.visibleTiles=[]}updateBorders(h,y){const A=[],D=[],F=h._getRenderableCoordinates(!1,!0);for(const J of F){const ne=h.getTile(J);if(!ne.hasData())continue;const le=ne.getBucket(y);le&&(le.isEmpty()||(A.push(J.key),D.push({bucket:le,tileID:J.canonical})))}let z=A.length!==this.visibleTiles.length;if(!z){A.sort();for(let J=0;JJ.tileID.z-ne.tileID.z||J.tileID.x-ne.tileID.x||J.tileID.y-ne.tileID.y);for(const J of D){const ne=new Array,le=new Array,je=J.bucket;for(const ve of je.featuresOnBorder)W.has(ve.featureId)?le.push(ve.footprintIndex):(W.add(ve.featureId),ne.push(ve.footprintIndex));je.updateFootprintHiddenFlags(ne,i.ev,!1),je.updateFootprintHiddenFlags(le,i.ev,!0)}}}function _3(T,h){const y=[...T],A=h.cameraWorldSizeForFog/h.worldSize,D=i.bA([]);return i.cS(D,D,[A,A,1]),i.aB(y,D,y),i.aB(y,h.worldToFogMatrix,y),y}function w3(T,h,y,A,D){const F=y.material,z=A.context,{baseColorTexture:W,metallicRoughnessTexture:J}=F.pbrMetallicRoughness,{normalTexture:ne,occlusionTexture:le,emissionTexture:je}=F;function ve(De,Pe,Ge){if(De&&(T.push(Pe),z.activeTexture.set(z.gl.TEXTURE0+Ge),De.gfxTexture)){const{minFilter:Ve,magFilter:nt,wrapS:ut,wrapT:ot}=De.sampler;De.gfxTexture.bindExtraParam(Ve,nt,ut,ot)}}ve(W,"HAS_TEXTURE_u_baseColorTexture",Gc.BaseColor),ve(J,"HAS_TEXTURE_u_metallicRoughnessTexture",Gc.MetallicRoughness),ve(ne,"HAS_TEXTURE_u_normalTexture",Gc.Normal),ve(le,"HAS_TEXTURE_u_occlusionTexture",Gc.Occlusion),ve(je,"HAS_TEXTURE_u_emissionTexture",Gc.Emission),D&&(D.texture||(D.texture=new i.d$(A.context,D.image,[D.image.height,D.image.height,D.image.height],z.gl.RGBA8)),z.activeTexture.set(z.gl.TEXTURE0+Gc.LUT),D.texture&&D.texture.bind(z.gl.LINEAR,z.gl.CLAMP_TO_EDGE),T.push("APPLY_LUT_ON_GPU")),y.texcoordBuffer&&(T.push("HAS_ATTRIBUTE_a_uv_2f"),h.push(y.texcoordBuffer)),y.colorBuffer&&(T.push(y.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),h.push(y.colorBuffer)),y.normalBuffer&&(T.push("HAS_ATTRIBUTE_a_normal_3f"),h.push(y.normalBuffer)),y.pbrBuffer&&(T.push("HAS_ATTRIBUTE_a_pbr"),T.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),h.push(y.pbrBuffer)),F.alphaMode!=="OPAQUE"&&F.alphaMode!=="MASK"||T.push("UNPREMULT_TEXTURE_IN_SHADER"),F.defined||T.push("DIFFUSE_SHADED");const Ne=A.shadowRenderer;Ne&&(T.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Ne.useNormalOffset&&T.push("NORMAL_OFFSET"))}function j3(T,h,y,A,D,F){const z=T.modelOpacity,W=h.context,J=new Fr(h.context.gl.LEQUAL,T.isLightMesh?Fr.ReadOnly:Fr.ReadWrite,h.depthRangeFor3D),ne=h.transform,le=T.mesh,je=le.material,ve=je.pbrMetallicRoughness,Ne=h.style.fog;let De;De=h.transform.projection.zAxisUnit==="pixels"?[...T.nodeModelMatrix]:i.aB([],A.zScaleMatrix,T.nodeModelMatrix),i.aB(De,A.negCameraPosMatrix,De);const Pe=i.bl([],De);i.eg(Pe,Pe);const Ge=y.paint.get("model-color-use-theme").constantOr("default")==="none",Ve=y.paint.get("model-emissive-strength").constantOr(0),nt=ov(new Float32Array(T.worldViewProjection),new Float32Array(De),new Float32Array(Pe),null,h,z,ve.baseColorFactor,je.emissiveFactor,ve.metallicFactor,ve.roughnessFactor,je,Ve,y,void 0,void 0,T.materialOverride,T.modelColor),ut={defines:[]},ot=[],Et=h.shadowRenderer;Et&&(Et.useNormalOffset=!1),w3(ut.defines,ot,le,h,Ge?null:y.lut);let Nt=null;if(Ne){const yt=_3(T.nodeModelMatrix,h.transform);if(Nt=new Float32Array(yt),ne.projection.name!=="globe"){const Ot=le.aabb.min,Wt=le.aabb.max,[Ht,es]=Ne.getOpacityForBounds(yt,Ot[0],Ot[1],Wt[0],Wt[1]);ut.overrideFog=Ht>=gs||es>=gs}}const Tt=jy(h,y.paint.get("model-cutoff-fade-range"));Tt.shouldRenderCutoff&&ut.defines.push("RENDER_CUTOFF");const wt=h.getOrCreateProgram("model",ut);h.uploadCommonUniforms(W,wt,null,Nt,Tt),h.renderPass!=="shadow"&&Et&&Et.setupShadowsFromMatrix(T.nodeModelMatrix,wt),wt.draw(h,W.gl.TRIANGLES,J,D,F,le.material.doubleSided?mn.disabled:mn.backCCW,nt,y.id,le.vertexBuffer,le.indexBuffer,le.segments,y.paint,h.transform.zoom,void 0,ot)}function x2(T,h){return T.style._importedAsBasemap?"basemap":h.scope}function mv(T,h,y,A,D,F,z,W,J,ne){const le=T.transform,je=!!h.isGeometryBloom&&h.isGeometryBloom;if(je&&T.renderPass==="shadow")return;const ve=le.projection.name==="globe"?i.eD(y,le):[...y];i.aB(ve,ve,h.globalMatrix);const Ne=i.aB([],A,ve);if(h.meshes)for(const De of h.meshes){const Pe=W.get(De.material.name);if(Pe&&Pe.opacity<=0)continue;if(De.material.alphaMode!=="BLEND"){z.push({mesh:De,depth:0,modelIndex:D,worldViewProjection:Ne,nodeModelMatrix:ve,isLightMesh:je,materialOverride:Pe,modelOpacity:J,modelColor:ne});continue}const Ge=i.af([],De.centroid,Ne);!le.isOrthographic&&Ge[2]<=0||F.push({mesh:De,depth:Ge[2],modelIndex:D,worldViewProjection:Ne,nodeModelMatrix:ve,isLightMesh:je,materialOverride:Pe,modelOpacity:J,modelColor:ne})}if(h.children)for(const De of h.children)mv(T,De,y,A,D,F,z,W,J,ne)}function $p(T,h,y,A){const D=y.shadowRenderer;if(!D)return;const F=D.getShadowPassDepthMode(),z=D.getShadowPassColorMode(),W=D.calculateShadowPassMatrixFromMatrix(h),J=x6(W);y.getOrCreateProgram("modelDepth",{defines:y._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(y,y.context.gl.TRIANGLES,F,yn.disabled,z,mn.disabled,J,A.id,T.vertexBuffer,T.indexBuffer,T.segments,A.paint,y.transform.zoom,void 0,void 0)}function hF(T,h,y,A,D,F){for(const z of D){const W=Object.assign({},A);W.part=z;const J={type:"Unknown",id:h,properties:W},ne={orientation:T.paint.get("model-rotation").evaluate(J,y)};F.set(z,ne)}}function mF(T,h,y,A,D,F){for(const z of D){const W=Object.assign({},A);W.part=z;const J={type:"Unknown",id:h,properties:W},ne={color:T.paint.get("model-color").evaluate(J,y),colorMix:T.paint.get("model-color-mix-intensity").evaluate(J,y),opacity:T.paint.get("model-opacity").evaluate(J,y),emissionStrength:T.paint.get("model-emissive-strength").evaluate(J,y)};F.set(z,ne)}}function pF(T,h,y,A,D){let F=!1;for(const W of A)W.modelOpacity!==1&&(j3(W,T,h,D[W.modelIndex],yn.disabled,Hn.disabled),F=!0);for(const W of A)j3(W,T,h,D[W.modelIndex],W.modelOpacity!==1?T.stencilModeFor3D():yn.disabled,T.colorModeForRenderPass());F&&T.resetStencilClippingMasks();const z=Hn.additive;for(const W of y)j3(W,T,h,D[W.modelIndex],yn.disabled,W.isLightMesh?z:T.colorModeForRenderPass())}function fF(T,h,y){const A=h.updateZoomBasedPaintProperties(),D=function(F,z,W){let J,ne,le,je=F.terrain?F.terrain.exaggeration():0;if(F.terrain&&je>0){const ve=F.terrain,Ne=ve.findDEMTileFor(W);Ne&&Ne.dem?J=i.eF.create(ve,W,Ne):je=0}if(je===0&&(z.terrainElevationMin=0,z.terrainElevationMax=0),je===z.validForExaggeration&&(je===0||J&&J._demTile&&J._demTile.tileID===z.validForDEMTile.id&&J._dem._timestamp===z.validForDEMTile.timestamp))return!1;for(const ve in z.instancesPerModel){const Ne=z.instancesPerModel[ve];for(let De=0;Dene&&(ne=Ne.max)}const le=i.aA(A.x,F,z)-A.x,je=i.aA(A.y,W,J)-A.y,ve=i.cf(ne,h.center.lat)-A.z;return h._zoomFromMercatorZ(Math.sqrt(le*le+je*je+ve*ve))}function xF(T,h,y,A,D,F,z){const W=T.context,J=T.renderPass==="shadow",ne=T.shadowRenderer,le=J&&ne?ne.getShadowPassDepthMode():new Fr(W.gl.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D),je=T.isTileAffectedByFog(F),ve=T.transform.projection.name==="globe";if(y.meshes)for(const Ne of y.meshes){const De=ve?[]:["MODEL_POSITION_ON_GPU"],Pe=[];let Ge,Ve,nt;const ut=!ve&&A.instancedDataArray.length>20;ut&&De.push("INSTANCED_ARRAYS");const ot=jy(T,h.paint.get("model-cutoff-fade-range"));if(ot.shouldRenderCutoff&&De.push("RENDER_CUTOFF"),J&&ne)Ge=T.getOrCreateProgram("modelDepth",{defines:De}),Ve=x6(z.shadowTileMatrix,z.shadowTileMatrix,Float32Array.from(y.globalMatrix)),nt=ne.getShadowPassColorMode();else{w3(De,Pe,Ne,T,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),Ge=T.getOrCreateProgram("model",{defines:De,overrideFog:je});const Nt=Ne.material,Tt=Nt.pbrMetallicRoughness,wt=h.paint.get("model-opacity").constantOr(1),yt=h.paint.get("model-emissive-strength").constantOr(0);Ve=ov(F.expandedProjMatrix,Float32Array.from(y.globalMatrix),new Float32Array(16),null,T,wt,Tt.baseColorFactor,Nt.emissiveFactor,Tt.metallicFactor,Tt.roughnessFactor,Nt,yt,h,D),ne&&(z.shadowUniformsInitialized?Ge.setShadowUniformValues(W,ne.getShadowUniformValues()):(ne.setupShadows(F.toUnwrapped(),Ge,"model-tile"),z.shadowUniformsInitialized=!0)),nt=ot.shouldRenderCutoff||wt<1||Nt.alphaMode!=="OPAQUE"?Hn.alphaBlended:Hn.unblended}T.uploadCommonUniforms(W,Ge,F.toUnwrapped(),null,ot);const Et=Ne.material.doubleSided?mn.disabled:mn.backCCW;if(ut)Pe.push(A.instancedDataBuffer),Ge.draw(T,W.gl.TRIANGLES,le,yn.disabled,nt,Et,Ve,h.id,Ne.vertexBuffer,Ne.indexBuffer,Ne.segments,h.paint,T.transform.zoom,void 0,Pe,A.instancedDataArray.length);else{const Nt=J?"u_instance":"u_normal_matrix";for(let Tt=0;TtJ[1]?z:J,F[0]=y.max[0],z=i.aC(i.eG(),F,D),W=z[1]J[1]?z:J,F[1]=y.min[1],z=i.aC(i.eG(),F,D),W=z[1]J[1]?z:J;const ne=i.aA(A[0],0,1),le=100*h.pixelsPerMeter*i.aA(A[1],0,1),je=i.aA(A[2],0,1),ve=i.eH(i.eG(),W,J,ne),Ne=Math.tan(.5*h.fovX),De=-ve[2]*Ne;if(le===0)return ve[1]<-Math.abs(De)?je:1;const Pe=(-Math.abs(De)-ve[1])/le,Ge=(nt,ut,ot)=>(1-ot)*nt+ot*ut,Ve=i.aA(Ge(1,je,Pe),je,1);return Ge(1,Ve,i.aA((h.pitch-20)/20,0,1))}class gF{}class Iy{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,y,A){{const je=this._storage.get(y.id);if(je)return je.lastUsedFrameIdx=h,je.buf}const D=A.gl,F=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),z=new ArrayBuffer(F),W=new Int16Array(z);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(z));const J=new i.eJ;for(let je=0;je30&&(A.buf.destroy(),this._storage.delete(y))}destroy(){for(const[h,y]of this._storage)y.buf.destroy(),this._storage.delete(h)}}class mb{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const pb=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 lg{constructor(h){this.revealStart=11,this.revealRange=2}}const w6=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class j6{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(h,y){const A=h.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const z=new i.eK,W=new i.b0;z.emplaceBack(-1,-1),z.emplaceBack(1,-1),z.emplaceBack(1,1),z.emplaceBack(-1,1),W.emplaceBack(0,1,2),W.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(z,w6.members),this.vignetteIdx=h.context.createIndexBuffer(W)}const D=i.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){h.uploadCommonUniforms(h.context,A);const z={u_vignetteShape:(F={vignetteShape:[y.start,y.range,Math.pow(10,y.fadePower)],vignetteColor:[y.color.r,y.color.g,y.color.b,y.color.a*y.strength]}).vignetteShape,u_vignetteColor:F.vignetteColor};A.draw(h,h.context.gl.TRIANGLES,Fr.disabled,yn.disabled,Hn.alphaBlended,mn.disabled,z,"vignette",this.vignetteVx,this.vignetteIdx,D)}var F}}class N6{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(h,y){const A=h.getFreeCameraOptions().position,D=A.toAltitude(),F=A.toLngLat(),z=i.an(F.lng),W=i.an(F.lat),J=h.pixelsPerMeter/y,ne=z*i.eM,le=i.eM*Math.log(Math.tan(Math.PI/4+W/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 je=-this._offsetYPrev+le,ve=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ne)*J,this._accumulatedOffsetY+=je*J,this._accumulatedElevation+=ve*J,this._offsetXPrev=ne,this._offsetYPrev=le,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function N3(T,h){return[-(T[0]-Math.floor(T[0]/h)*h),-(T[1]-Math.floor(T[1]/h)*h),-(T[2]-Math.floor(T[2]/h)*h)]}function dm(T){const h=i.eq(1323123451230),y=[];for(let A=0;A Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(h){const y=h.context;if(!this.particlesVx){const A=dm(this.particlesCount),D=new i.eN,F=new i.b0;let z=0;const W=i.eq(1323123451230);for(let J=0;JA)return;const D=uh(0,1,y.revealStart,y.revealStart+y.revealRange,A);if(!this.particlesVx||!this.particlesIdx)return;const F=structuredClone(this._params);let z=[-F.direction.x,F.direction.y,-100];i.aw(z,z);const W=structuredClone(this._vignetteParams);W.strength*=D,F.overrideStyleParameters||(F.intensity=h.style.rain.state.density,F.timeFactor=h.style.rain.state.intensity,F.color=structuredClone(h.style.rain.state.color),z=structuredClone(h.style.rain.state.direction),F.screenThinning.intensity=h.style.rain.state.centerThinning,F.dropletSizeX=h.style.rain.state.dropletSize[0],F.dropletSizeYScale=h.style.rain.state.dropletSize[1]/h.style.rain.state.dropletSize[0],F.distortionStrength=100*h.style.rain.state.distortionStrength,W.strength=1,W.color=structuredClone(h.style.rain.state.vignetteColor));const J=this.updateOnRender(h,F.timeFactor),ne=h.context,le=ne.gl,je=h.transform;this.screenTexture&&this.screenTexture.size[0]===h.width&&this.screenTexture.size[1]===h.height||(this.screenTexture=new i.T(ne,{width:h.width,height:h.height,data:null},le.RGBA8)),F.distortionStrength>0&&(ne.activeTexture.set(le.TEXTURE0),this.screenTexture.bind(le.LINEAR,le.CLAMP_TO_EDGE),le.copyTexSubImage2D(le.TEXTURE_2D,0,0,0,0,0,h.width,h.height));const ve=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(ne,ve),ne.activeTexture.set(le.TEXTURE0),this.screenTexture.bind(le.LINEAR,le.CLAMP_TO_EDGE);const Ne=[F.color.r,F.color.g,F.color.b,F.color.a],De=(Pe,Ge)=>{const Ve=N3(this._movement.getPosition(),Pe),nt=F.dropletSizeX,ut=F.dropletSizeX*F.dropletSizeYScale,ot=h.width/2,Et=h.height/2,Nt=uh(0,F.screenThinning.start,0,1,F.screenThinning.intensity),Tt=uh(.001,F.screenThinning.range,0,1,F.screenThinning.intensity),wt=uh(0,F.screenThinning.particleOffset,0,1,F.screenThinning.intensity),yt=(Ot={modelview:J.modelviewMatrix,projection:J.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Ve,velocityConeAperture:F.velocityConeAperture,velocity:F.velocity,boxSize:Pe,rainDropletSize:[nt,ut],distortionStrength:F.distortionStrength,rainDirection:z,color:Ne,screenSize:[je.width,je.height],thinningCenterPos:[ot,Et],thinningShape:[Nt,Tt,Math.pow(10,F.screenThinning.fadePower)],thinningAffectedRatio:F.screenThinning.affectedRatio,thinningParticleOffset:wt,shapeDirectionalPower:F.shapeDirPower,shapeNormalPower:F.shapeNormalPower,mode:Ge?0:1},{u_modelview:Float32Array.from(Ot.modelview),u_projection:Float32Array.from(Ot.projection),u_time:Ot.time,u_cam_pos:Ot.camPos,u_texScreen:0,u_velocityConeAperture:Ot.velocityConeAperture,u_velocity:Ot.velocity,u_boxSize:Ot.boxSize,u_rainDropletSize:Ot.rainDropletSize,u_distortionStrength:Ot.distortionStrength,u_rainDirection:Ot.rainDirection,u_color:Ot.color,u_screenSize:Ot.screenSize,u_thinningCenterPos:Ot.thinningCenterPos,u_thinningShape:Ot.thinningShape,u_thinningAffectedRatio:Ot.thinningAffectedRatio,u_thinningParticleOffset:Ot.thinningParticleOffset,u_shapeDirectionalPower:Ot.shapeDirectionalPower,u_shapeNormalPower:Ot.shapeNormalPower,u_mode:Ot.mode});var Ot;const Wt=Math.round(F.intensity*this.particlesCount),Ht=i.bg.simpleSegment(0,0,4*Wt,2*Wt);ve.draw(h,le.TRIANGLES,Fr.disabled,yn.disabled,Hn.alphaBlended,mn.disabled,yt,"rain_particles",this.particlesVx,this.particlesIdx,Ht)};F.distortionStrength>0&&De(F.boxSize,!0),De(F.boxSize,!1),this._vignette.draw(h,W)}}const k6=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 S6 extends pv{constructor(h){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new lg("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(h){const y=h.context;if(!this.particlesVx){const A=dm(this.particlesCount),D=new i.eO,F=new i.b0;let z=0;const W=i.eq(1323123451230);for(let J=0;Jz)return;const W=uh(0,1,F.revealStart,F.revealStart+F.revealRange,z);D.strength*=W,y.overrideStyleParameters||(y.intensity=h.style.snow.state.density,y.timeFactor=h.style.snow.state.intensity,y.color=structuredClone(h.style.snow.state.color),A=structuredClone(h.style.snow.state.direction),y.screenThinning.intensity=h.style.snow.state.centerThinning,y.billboardSize=2.79*h.style.snow.state.flakeSize,D.strength=1,D.color=structuredClone(h.style.snow.state.vignetteColor));const J=this.updateOnRender(h,y.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ne=h.context,le=ne.gl,je=h.transform,ve=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(ne,ve),((Ne,De,Pe)=>{const Ge=N3(this._movement.getPosition(),Ne),Ve=je.width/2,nt=je.height/2,ut=uh(0,Pe.screenThinning.start,0,1,Pe.screenThinning.intensity),ot=uh(.001,Pe.screenThinning.range,0,1,Pe.screenThinning.intensity),Et=uh(0,Pe.screenThinning.particleOffset,0,1,Pe.screenThinning.intensity),Nt=(Tt={modelview:J.modelviewMatrix,projection:J.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Ge,velocityConeAperture:Pe.velocityConeAperture,velocity:Pe.velocity,horizontalOscillationRadius:Pe.horizontalOscillationRadius,horizontalOscillationRate:Pe.horizontalOscillationRate,boxSize:Ne,billboardSize:1*Pe.billboardSize,simpleShapeParameters:[Pe.shapeFadeStart,Pe.shapeFadePower],screenSize:[je.width,je.height],thinningCenterPos:[Ve,nt],thinningShape:[ut,ot,Math.pow(10,Pe.screenThinning.fadePower)],thinningAffectedRatio:Pe.screenThinning.affectedRatio,thinningParticleOffset:Et,color:[Pe.color.r,Pe.color.g,Pe.color.b,Pe.color.a],direction:A},{u_modelview:Float32Array.from(Tt.modelview),u_projection:Float32Array.from(Tt.projection),u_time:Tt.time,u_cam_pos:Tt.camPos,u_velocityConeAperture:Tt.velocityConeAperture,u_velocity:Tt.velocity,u_horizontalOscillationRadius:Tt.horizontalOscillationRadius,u_horizontalOscillationRate:Tt.horizontalOscillationRate,u_boxSize:Tt.boxSize,u_billboardSize:Tt.billboardSize,u_simpleShapeParameters:Tt.simpleShapeParameters,u_screenSize:Tt.screenSize,u_thinningCenterPos:Tt.thinningCenterPos,u_thinningShape:Tt.thinningShape,u_thinningAffectedRatio:Tt.thinningAffectedRatio,u_thinningParticleOffset:Tt.thinningParticleOffset,u_particleColor:Tt.color,u_direction:Tt.direction});var Tt;const wt=Math.round(Pe.intensity*this.particlesCount),yt=i.bg.simpleSegment(0,0,4*wt,2*wt);this.particlesVx&&this.particlesIdx&&ve.draw(h,le.TRIANGLES,Fr.disabled,yn.disabled,Hn.alphaBlended,mn.disabled,Nt,"snow_particles",this.particlesVx,this.particlesIdx,yt)})(y.boxSize,0,y),this._vignette.draw(h,D)}}const Ly={symbol:function(T,h,y,A,D){if(T.renderPass!=="translucent")return;const F=yn.disabled,z=T.colorModeForRenderPass(),W=y.layout.get("text-variable-anchor"),J=y.layout.get("text-size-scale-range"),ne=i.aA(T.scaleFactor,J[0],J[1]);W&&function(ve,Ne,De,Pe,Ge,Ve,nt,ut){const ot=Ne.transform,Et=Ge==="map",Nt=Ve==="map";for(const Tt of ve){const wt=Pe.getTile(Tt),yt=wt.getBucket(De);if(!yt||!yt.text||!yt.text.segments.get().length)continue;const Ot=i.bK(yt.textSizeData,ot.zoom,ut),Wt=Xm(Tt,yt.getProjection(),ot),Ht=ot.calculatePixelsToTileUnitsMatrix(wt),es=Qs(Wt,wt.tileID.canonical,Nt,Et,ot,yt.getProjection(),Ht),ts=yt.hasIconTextFit()&&yt.hasIconData();Ot&&en(yt,Et,Nt,nt,ot,es,Tt,Math.pow(2,ot.zoom-wt.tileID.overscaledZ),Ot,ts)}}(A,T,y,h,y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),D,ne);const le=y.paint.get("icon-opacity").constantOr(1)!==0,je=y.paint.get("text-opacity").constantOr(1)!==0;y.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(le||je)?m2(T,h,y,A,F,z):(le&&m2(T,h,y,A,F,z,{onlyIcons:!0}),je&&m2(T,h,y,A,F,z,{onlyText:!0})),h.map.showCollisionBoxes&&(kr(T,h,y,A,y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),!0),kr(T,h,y,A,y.paint.get("icon-translate"),y.paint.get("icon-translate-anchor"),!1))},circle:function(T,h,y,A){if(T.renderPass!=="translucent")return;const D=y.paint.get("circle-opacity"),F=y.paint.get("circle-stroke-width"),z=y.paint.get("circle-stroke-opacity"),W=y.layout.get("circle-sort-key").constantOr(1)!==void 0,J=y.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(F.constantOr(1)===0||z.constantOr(1)===0))return;const ne=T.context,le=ne.gl,je=T.transform,ve=!(!T.terrain||!T.terrain.enabled),Ne=y.layout.get("circle-elevation-reference"),De=T.depthModeForSublayer(0,Fr.ReadOnly),Pe=new Fr(T.context.gl.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D),Ge=Ne==="none"||ve?De:Pe,Ve=yn.disabled,nt=T.colorModeForDrapableLayerRenderPass(J),ut=je.projection.name==="globe",ot=[i.aF(je.center.lng),i.aJ(je.center.lat)],Et=[];for(let Tt=0;TtTt.sortKey-wt.sortKey);const Nt={useDepthForOcclusion:je.depthOcclusionForSymbolsAndCircles};for(const Tt of Et){const{programConfiguration:wt,program:yt,layoutVertexBuffer:Ot,dynamicBuffers:Wt,indexBuffer:Ht,uniformValues:es,tile:ts}=Tt.state,xs=Tt.segments;T.terrain&&T.terrain.setupElevationDraw(ts,yt,Nt),T.uploadCommonUniforms(ne,yt,ts.tileID.toUnwrapped()),yt.draw(T,le.TRIANGLES,Ge,Ve,nt,mn.disabled,es,y.id,Ot,Ht,xs,y.paint,je.zoom,wt,Wt)}},heatmap:function(T,h,y,A){if(y.paint.get("heatmap-opacity")!==0)if(T.renderPass==="offscreen"){const D=T.context,F=D.gl,z=yn.disabled,W=new Hn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(Ne,De,Pe,Ge){const Ve=Ne.gl,nt=De.width*Ge,ut=De.height*Ge;Ne.activeTexture.set(Ve.TEXTURE1),Ne.viewport.set([0,0,nt,ut]);let ot=Pe.heatmapFbo;if(!ot||ot&&(ot.width!==nt||ot.height!==ut)){ot&&ot.destroy();const Et=Ve.createTexture();Ve.bindTexture(Ve.TEXTURE_2D,Et),Ve.texParameteri(Ve.TEXTURE_2D,Ve.TEXTURE_WRAP_S,Ve.CLAMP_TO_EDGE),Ve.texParameteri(Ve.TEXTURE_2D,Ve.TEXTURE_WRAP_T,Ve.CLAMP_TO_EDGE),Ve.texParameteri(Ve.TEXTURE_2D,Ve.TEXTURE_MIN_FILTER,Ve.LINEAR),Ve.texParameteri(Ve.TEXTURE_2D,Ve.TEXTURE_MAG_FILTER,Ve.LINEAR),ot=Pe.heatmapFbo=Ne.createFramebuffer(nt,ut,1,null),function(Nt,Tt,wt,yt,Ot,Wt){const Ht=Nt.gl;Ht.texImage2D(Ht.TEXTURE_2D,0,Nt.extRenderToTextureHalfFloat?Ht.RGBA16F:Ht.RGBA,Ot,Wt,0,Ht.RGBA,Nt.extRenderToTextureHalfFloat?Ht.HALF_FLOAT:Ht.UNSIGNED_BYTE,null),yt.colorAttachment0.set(wt)}(Ne,0,Et,ot,nt,ut)}else Ve.bindTexture(Ve.TEXTURE_2D,ot.colorAttachment0.get()),Ne.bindFramebuffer.set(ot.framebuffer)})(D,T,y,T.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const J=T.transform,ne=J.projection.name==="globe",le=ne?["PROJECTION_GLOBE_VIEW"]:[],je=ne?mn.frontCCW:mn.disabled,ve=[i.aF(J.center.lng),i.aJ(J.center.lat)];for(let Ne=0;Ne({u_image:0,u_color_ramp:1,u_opacity:je.paint.get("heatmap-opacity")}))(0,F),F.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,F.paint,D.transform.zoom)}(T,y))},line:function(T,h,y,A){if(T.renderPass!=="translucent")return;const D=y.paint.get("line-opacity"),F=y.paint.get("line-width");if(D.constantOr(1)===0||F.constantOr(1)===0)return;const z=y.paint.get("line-emissive-strength").isConstant(),W=y.paint.get("line-emissive-strength").constantOr(0),J=y.paint.get("line-occlusion-opacity"),ne=y.layout.get("line-elevation-reference"),le=y.layout.get("line-width-unit")==="meters",je=ne==="sea",ve=!(!T.terrain||!T.terrain.enabled),Ne=T.context,De=Ne.gl;if(y.hasElevatedBuckets&&T.transform.projection.name==="globe")return;const Pe=y.layout.get("line-cross-slope"),Ge=Pe!==void 0,Ve=Pe<1,nt=T.colorModeForDrapableLayerRenderPass(z?W:null),ut=T.terrain&&T.terrain.renderingToTexture,ot=ut?1:i.o.devicePixelRatio,Et=y.paint.get("line-dasharray"),Nt=Et.constantOr(1),Tt=y.layout.get("line-cap"),wt=Et.constantOr(null),yt=Tt.constantOr(null),Ot=y.paint.get("line-pattern"),Wt=Ot.constantOr(1),Ht=y.paint.get("line-pattern-cross-fade"),es=Ot.constantOr(null),ts=y.paint.get("line-opacity").constantOr(1);let xs=!Wt&&ts!==1||T.depthOcclusion&&J>0&&J<1;const qs=y.paint.get("line-gradient"),Yt=Wt?"linePattern":"line",Bt=i.e2(y);let as;if(ut&&T.terrain&&T.terrain.clipOrMaskOverlapStencilType()&&(xs=!1),J!==0&&T.depthOcclusion){const yr=y.paint._values["line-opacity"];yr&&yr.value&&yr.value.kind==="constant"?as=yr.value:i.w(`Occlusion opacity for layer ${y.id} is supported only when line-opacity isn't data-driven.`)}F.value.kind!=="constant"&&F.value.isLineProgressConstant===!1&&Bt.push("VARIABLE_LINE_WIDTH"),ut&&(T.emissiveMode!=="dual-source-blending"||z?T.emissiveMode==="mrt-fallback"&&Bt.push("USE_MRT1"):Bt.push("DUAL_SOURCE_BLENDING"));const Jt=(yr,Js,Us,Pr,Cr,hr)=>{for(const br of yr){const Kr=h.getTile(br);if(Wt&&!Kr.patternsLoaded())continue;const Pn=Kr.getBucket(y);if(!Pn||Pn.elevationType!=="none"&&!Cr||Pn.elevationType==="none"&&Cr)continue;T.prepareDrawTile();const wa=[...Js],si=T.shadowRenderer,Or=Pn.elevationType==="road"&&!!si&&si.enabled;let Ka=[0,0,0];if(Or){const Gn=T.style.directionalLight,Xi=T.style.ambientLight;Gn&&Xi&&(Ka=sg(T.style,Gn,Xi)),wa.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const Cn=Pn.programConfigurations.get(y.id);let di=!1;if(es&&Kr.imageAtlas){const Gn=i.e3.from(es),Xi=Gn.getPrimary().scaleSelf(ot).toString(),Ho=Kr.imageAtlas.patternPositions.get(Xi),_o=Gn.getSecondary(),Di=_o?Kr.imageAtlas.patternPositions.get(_o.scaleSelf(ot).toString()):null;di=!!Ho&&!!Di,Ho&&Cn.setConstantPatternPositions(Ho,Di)}Ht>0&&(di||Cn.getPatternTransitionVertexBuffer("line-pattern"))&&wa.push("LINE_PATTERN_TRANSITION");const Ci=T.isTileAffectedByFog(br),bi=T.getOrCreateProgram(Yt,{config:Cn,defines:wa,overrideFog:Ci});if(!Wt&&wt&&yt&&Kr.lineAtlas){const Gn=Kr.lineAtlas.getDash(wt,yt);Gn&&Cn.setConstantPatternPositions(Gn)}Or&&si.setupShadows(Kr.tileID.toUnwrapped(),bi,"vector-tile");let[Ga,Wn]=y.paint.get("line-trim-offset");(yt==="round"||yt==="square")&&Ga!==Wn&&(Ga===0&&(Ga-=1),Wn===1&&(Wn+=1));const ii=ut?br.projMatrix:null,So=le?1/Pn.tileToMeter/i.ay(Kr,1,T.transform.zoom):1,no=le?1/Pn.tileToMeter/i.ay(Kr,1,Math.floor(T.transform.zoom)):1,ui=Wt?i.e4(T,Kr,y,ii,ot,So,no,[Ga,Wn],Ka,Ht):i.e5(T,Kr,y,ii,Pn.lineClipsArray.length,ot,So,no,[Ga,Wn],Ka);if(qs){const Gn=Pn.gradients[y.id];let Xi=Gn.texture;if(y.gradientVersion!==Gn.version){let Ho=256;if(y.stepInterpolant){const _o=h.getSource().maxzoom,Di=br.canonical.z===_o?Math.ceil(1<{as!=null&&(as.value=ts*J),bi.draw(T,De.TRIANGLES,Us,Gn,nt,mn.disabled,ui,y.id,Pn.layoutVertexBuffer,Pn.indexBuffer,Pn.segments,y.paint,T.transform.zoom,Cn,[Pn.layoutVertexBuffer2,Pn.patternVertexBuffer,Pn.zOffsetVertexBuffer]),as!=null&&(as.value=ts)};if(xs&&!Cr){const Gn=T.stencilModeForClipping(br).ref;Gn===0&&ut&&Ne.clear({stencil:0});const Xi={func:De.EQUAL,mask:255};ui.u_alpha_discard_threshold=.8,za(new yn(Xi,Gn,255,De.KEEP,De.KEEP,De.INVERT)),ui.u_alpha_discard_threshold=0,za(new yn(Xi,Gn,255,De.KEEP,De.KEEP,De.KEEP))}else ui.u_alpha_discard_threshold=xs&&Cr&&hr?.8:0,za(Cr?Pr:T.stencilModeForClipping(br))}};let Is=T.depthModeForSublayer(0,Fr.ReadOnly);const rr=new Fr(T.depthOcclusion?De.GREATER:De.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D);if(y.hasNonElevatedBuckets){const yr=!ut&&T.terrain;J!==0&&yr?i.w(`Occlusion opacity for layer ${y.id} is supported on terrain only if the layer has line-z-offset enabled.`):yr?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${y.id}.`):Jt(A,Bt,Is,yn.disabled,!1,!0)}if(y.hasElevatedBuckets){ne==="hd-road-markup"?ve||(Is=rr,Bt.push("ELEVATED_ROADS")):(Bt.push("ELEVATED"),Is=rr,Ge&&Bt.push(Ve?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),je&&Bt.push("ELEVATION_REFERENCE_SEA"));const yr=xs?T.stencilModeFor3D():yn.disabled;T.forceTerrainMode=!0,Jt(A,Bt,Is,yr,!0,!0),xs&&Jt(A,Bt,Is,yr,!0,!1),T.forceTerrainMode=!1}xs&&(T.resetStencilClippingMasks(),ut&&Ne.clear({stencil:0})),J===0||T.depthOcclusion||ut||T.layersWithOcclusionOpacity.push(T.currentLayer)},fill:function(T,h,y,A){const D=y.paint.get("fill-color"),F=y.paint.get("fill-opacity");if(F.constantOr(1)===0)return;const z=y.paint.get("fill-emissive-strength"),W=T.colorModeForDrapableLayerRenderPass(z),J=y.paint.get("fill-pattern"),ne=T.opaquePassEnabledForLayer()&&!J.constantOr(1)&&D.constantOr(i.ao.transparent).a===1&&F.constantOr(0)===1?"opaque":"translucent";let le="none";y.layout.get("fill-elevation-reference")!=="none"?le="road":y.paint.get("fill-z-offset").constantOr(1)!==0&&(le="offset");const je=!(!T.terrain||!T.terrain.enabled),ve={painter:T,sourceCache:h,layer:y,coords:A,colorMode:W,elevationType:le,terrainEnabled:je,pass:ne};if(T.renderPass==="shadow")return void(T.shadowRenderer&&le==="road"&&!je&&function(De){const{painter:Pe,sourceCache:Ge,layer:Ve,coords:nt}=De,ut=Pe.context.gl,ot=De.painter.shadowRenderer;for(const Et of nt){const Nt=Ge.getTile(Et),Tt=Nt.getBucket(Ve);if(!Tt)continue;const wt=Tt.elevatedStructures;if(!wt||!wt.shadowCasterSegments||wt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Pe.prepareDrawTile();const yt=Tt.bufferData.programConfigurations.get(Ve.id),Ot=Pe.isTileAffectedByFog(Et),Wt=Pe.getOrCreateProgram("elevatedStructuresDepth",{config:yt,overrideFog:Ot}),Ht=ot.calculateShadowPassMatrixFromTile(Nt.tileID.toUnwrapped());Pe.uploadCommonUniforms(Pe.context,Wt,Et.toUnwrapped());const es={u_matrix:Ht,u_depth_bias:0};Wt.draw(Pe,ut.TRIANGLES,ot.getShadowPassDepthMode(),yn.disabled,ot.getShadowPassColorMode(),mn.disabled,es,Ve.id,wt.vertexBuffer,wt.indexBuffer,wt.shadowCasterSegments,Ve.paint,Pe.transform.zoom,yt)}}(ve));const Ne=T.emissiveMode==="mrt-fallback";if(le!=="offset"){if(m3(ve,!1,Ne),le==="road"){const De=!je&&T.renderPass==="translucent";De&&h3(T,h,y,A,"geometry"),m3(ve,!0,Ne,yn.disabled),De&&function(Pe){const{painter:Ge,sourceCache:Ve,layer:nt,coords:ut,colorMode:ot}=Pe,Et=Ge.context.gl,Nt=Pe.painter.shadowRenderer,Tt=!!Nt&&Nt.enabled,wt=new Fr(Ge.context.gl.LEQUAL,Fr.ReadOnly,Ge.depthRangeFor3D);let yt=[0,0,0];if(Tt){const Wt=Ge.style.directionalLight,Ht=Ge.style.ambientLight;Wt&&Ht&&(yt=sg(Ge.style,Wt,Ht))}const Ot=Wt=>{for(const Ht of ut){const es=Ve.getTile(Ht),ts=es.getBucket(nt);if(!ts)continue;const xs=ts.elevatedStructures;if(!xs)continue;let qs,Yt;if(Wt?(qs=xs.renderableBridgeSegments,Yt=xs.bridgeProgramConfigurations.get(nt.id)):(qs=xs.renderableTunnelSegments,Yt=xs.tunnelProgramConfigurations.get(nt.id)),!qs||qs.segments[0].primitiveLength===0)continue;Yt.updatePaintBuffers(),Ge.prepareDrawTile();const Bt=Ge.isTileAffectedByFog(Ht),as=[];Tt&&as.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const Jt=Ge.getOrCreateProgram("elevatedStructures",{config:Yt,overrideFog:Bt,defines:as}),Is=Ge.translatePosMatrix(Ht.projMatrix,es,nt.paint.get("fill-translate"),nt.paint.get("fill-translate-anchor"));Tt&&Nt.setupShadows(es.tileID.toUnwrapped(),Jt,"vector-tile");const rr=Ty(Is,yt);Ge.uploadCommonUniforms(Ge.context,Jt,Ht.toUnwrapped()),Jt.draw(Ge,Et.TRIANGLES,wt,yn.disabled,ot,mn.backCCW,rr,nt.id,xs.vertexBuffer,xs.indexBuffer,qs,nt.paint,Ge.transform.zoom,Yt,[xs.vertexBufferNormal])}};Ot(!0),Ot(!1)}(ve)}}else m3(ve,!1,Ne,T.stencilModeFor3D())},"fill-extrusion":function(T,h,y,A){const D=y.paint.get("fill-extrusion-opacity"),F=T.context,z=F.gl,W=T.terrain,J=W&&W.renderingToTexture;if(D===0)return;const ne=T.emissiveMode==="mrt-fallback",le=T.conflationActive&&T.style.isLayerClipped(y,h.getSource()),je=T.style.order.indexOf(y.fqid);if(le&&function(ve,Ne,De,Pe,Ge){for(const Ve of Pe){const nt=Ne.getTile(Ve).getBucket(De);nt&&(nt.updateReplacement(Ve,ve.replacementSource,Ge),nt.uploadCentroid(ve.context))}}(T,h,y,A,je),W||le)for(const ve of A){const Ne=h.getTile(ve).getBucket(y);Ne&&qme(T.context,h,ve,Ne,y,W,le)}if(T.renderPass==="shadow"&&T.shadowRenderer){const ve=T.shadowRenderer;if(W&&D<.65&&y._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const Ne=ve.getShadowPassDepthMode(),De=ve.getShadowPassColorMode();p3(T,h,y,A,Ne,yn.disabled,De,le)}else if(T.renderPass==="translucent"){const ve=!y.paint.get("fill-extrusion-pattern").constantOr(1),Ne=y.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!J&&Ne.a!==0){const De=new Fr(T.context.gl.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D);D===1&&ve?p3(T,h,y,A,De,yn.disabled,Hn.unblended,le):(p3(T,h,y,A,De,yn.disabled,Hn.disabled,le),p3(T,h,y,A,De,T.stencilModeFor3D(),T.colorModeForRenderPass(),le),T.resetStencilClippingMasks())}if(T.style.enable3dLights()&&ve&&(!W&&T.transform.projection.name!=="globe"||J)){const De=y.paint.get("fill-extrusion-opacity"),Pe=y.paint.get("fill-extrusion-ambient-occlusion-intensity"),Ge=y.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Ve=y.paint.get("fill-extrusion-flood-light-intensity"),nt=y.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ut=y.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(nt?null:y.lut).toArray01().slice(0,3),ot=Pe>0&&Ge>0,Et=Ve>0,Nt=(yt,Ot,Wt)=>(1-Wt)*yt+Wt*Ot,Tt=new v6;Tt.translate=y.paint.get("fill-extrusion-translate"),Tt.translateAnchor=y.paint.get("fill-extrusion-translate-anchor"),Tt.edgeRadius=y.layout.get("fill-extrusion-edge-radius"),Tt.cutoffFadeRange=y.paint.get("fill-extrusion-cutoff-fade-range");const wt=yt=>{const Ot=T.depthModeForSublayer(1,Fr.ReadOnly,z.LEQUAL,!0),Wt=y.paint.get(yt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ht=Nt(.1,3,Wt),es=T._showOverdrawInspector;if(!es){const ts=new yn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),xs=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);ag(Tt,T,h,y,A,Ot,ts,xs,mn.disabled,yt,"sdf",De,Pe,Ge,Ve,ut,Ht,le,!1)}{const ts=es?yn.disabled:new yn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),xs=es?T.colorModeForRenderPass():new Hn([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],i.ao.transparent,[!0,!0,!0,!0]);ag(Tt,T,h,y,A,Ot,ts,xs,mn.disabled,yt,"color",De,Pe,Ge,Ve,ut,Ht,le,!1)}};if(J){const yt=()=>{const Wt=W.drapeBufferSize[0],Ht=W.drapeBufferSize[1];let es=W.framebufferCopyTexture;return es&&(!es||es.size[0]===Wt&&es.size[1]===Ht)||(es&&es.destroy(),es=W.framebufferCopyTexture=new i.T(F,new i.q({width:Wt,height:Ht}),z.RGBA8)),es.bind(z.LINEAR,z.CLAMP_TO_EDGE),z.copyTexSubImage2D(z.TEXTURE_2D,0,0,0,0,0,Wt,Ht),es},Ot=(Wt,Ht,es)=>{const ts=T.depthModeForSublayer(1,Fr.ReadOnly,z.LEQUAL,!1),xs=y.paint.get(Wt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),qs=Nt(.1,3,xs);{const Yt=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0]);ag(Tt,T,h,y,A,ts,yn.disabled,Yt,mn.disabled,Wt,"clear",De,Pe,Ge,Ve,ut,qs,le,Ht)}{const Yt=new yn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),Bt=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);ag(Tt,T,h,y,A,ts,Yt,Bt,mn.disabled,Wt,"sdf",De,Pe,Ge,Ve,ut,qs,le,Ht)}ne&&!Wt&&(es=yt());{const Yt=Wt?z.ZERO:z.ONE_MINUS_DST_ALPHA,Bt=new yn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),as=new Hn([Yt,z.DST_ALPHA,z.ONE_MINUS_DST_ALPHA,z.ZERO],i.ao.transparent,[!0,!0,!0,!0]);ag(Tt,T,h,y,A,ts,Bt,as,mn.disabled,Wt,"color",De,Pe,Ge,Ve,ut,qs,le,Ht)}if(!ne||Wt){const Yt=new Hn([z.ONE,z.ONE,z.ONE,Wt?z.ZERO:z.ONE],i.ao.transparent,[!1,!1,!1,!0],Wt?z.FUNC_ADD:z.MAX);ag(Tt,T,h,y,A,ts,yn.disabled,Yt,mn.disabled,Wt,"clear",De,Pe,Ge,Ve,ut,qs,le,Ht,es)}else{z.drawBuffers([z.NONE,z.COLOR_ATTACHMENT1]);const Yt=new yn({func:z.EQUAL,mask:255},254,255,z.KEEP,z.DECR,z.DECR),Bt=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!0,!1,!1,!1],z.MAX);ag(Tt,T,h,y,A,ts,Yt,Bt,mn.disabled,Wt,"emissive",De,Pe,Ge,Ve,ut,qs,le,Ht,es),z.drawBuffers([z.COLOR_ATTACHMENT0])}};if(ot||Et){let Wt;T.prepareDrawTile(),ne&&!ot||(Wt=yt()),ot&&Ot(!0,!1,Wt),Et&&Ot(!1,!0,Wt)}}else ot&&wt(!0),Et&&wt(!1),(ot||Et)&&T.resetStencilClippingMasks()}}},building:function(T,h,y,A){T.currentLayer0&&F>0,ne=!0;const le=y.paint.get("building-vertical-scale");if(le<=0)return;T.shadowRenderer||(ne=!1);const je=T.conflationActive&&T.style.isLayerClipped(y,h.getSource()),ve=T.style.order.indexOf(y.fqid);if(function(Ne,De,Pe,Ge,Ve,nt){for(const ut of nt){const ot=De.getTile(ut).getBucket(Pe);ot&&(Ve&&ot.updateReplacement(ut,Ne.replacementSource,Ge),ot.uploadUpdatedIndexBuffer(Ne.context))}}(T,h,y,ve,je,A),function(Ne,De,Pe,Ge){for(const Ve of Ge){const nt=De.getTile(Ve).getBucket(Pe);nt&&nt.needsEvaluation()&&nt.uploadUpdatedColorBuffer(Ne.context)}}(T,h,y,A),y.resetLayerRenderingStats(T),T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0),T.renderPass==="shadow"&&T.shadowRenderer){const Ne=T.shadowRenderer,De=[],Pe=Ne.getShadowPassDepthMode();p2({painter:T,source:h,layer:y,coords:A,defines:De,blendMode:Ne.getShadowPassColorMode(),depthMode:Pe,opacity:W,verticalScale:le,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(T.renderPass==="translucent"){let Ne=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];ne&&(Ne=Ne.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),T.shadowRenderer&&T.shadowRenderer.useNormalOffset&&(Ne=Ne.concat("NORMAL_OFFSET"));const De=y.paint.get("building-facade-emissive-chance"),Pe=y.paint.get("building-ambient-occlusion-intensity"),Ge=y.paint.get("building-flood-light-intensity"),Ve=y.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",nt=y.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Ve?null:y.lut).toArray01().slice(0,3),ut=y.paint.get("building-flood-light-ground-attenuation"),ot=Ge>0,Et=new Fr(T.context.gl.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D);W<1&&p2({painter:T,source:h,layer:y,coords:A,defines:Ne,blendMode:Hn.disabled,depthMode:Et,opacity:W,verticalScale:le,facadeEmissiveChance:De,facadeAOIntensity:Pe,floodLightIntensity:Ge,floodLightColor:nt,depthOnly:!0});const Nt=T.colorModeForRenderPass();p2({painter:T,source:h,layer:y,coords:A,defines:Ne,blendMode:Nt,depthMode:Et,opacity:W,verticalScale:le,facadeEmissiveChance:De,facadeAOIntensity:Pe,floodLightIntensity:Ge,floodLightColor:nt}),J&&f3(T,h,y,A,!0,W,D,F,Ge,nt,z,je),ot&&f3(T,h,y,A,!1,W,D,F,Ge,nt,ut,je)}else if(T.renderPass==="light-beam"){const Ne=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],De=new Fr(T.context.gl.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D);p2({painter:T,source:h,layer:y,coords:A,defines:Ne,blendMode:Hn.alphaBlended,depthMode:De,opacity:W,verticalScale:le,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!1),T.resetStencilClippingMasks()},hillshade:function(T,h,y,A){if(T.renderPass!=="offscreen"&&T.renderPass!=="translucent"||T.style.disableElevatedTerrain)return;const D=T.context,F=T.terrain&&T.terrain.renderingToTexture,[z,W]=T.renderPass!=="translucent"||F?[{},A]:T.stencilConfigForOverlap(A);for(const J of W){const ne=h.getTile(J);if(ne.needsHillshadePrepare&&T.renderPass==="offscreen")Pme(T,ne,y);else if(T.renderPass==="translucent"){const le=T.depthModeForSublayer(0,Fr.ReadOnly),je=y.paint.get("hillshade-emissive-strength"),ve=T.colorModeForDrapableLayerRenderPass(je),Ne=F&&T.terrain?T.terrain.stencilModeForRTTOverlap(J):z[J.overscaledZ];Eme(T,J,ne,y,le,Ne,ve)}}D.viewport.set([0,0,T.width,T.height]),T.resetStencilClippingMasks()},raster:function(T,h,y,A,D,F){if(T.renderPass!=="translucent"||y.paint.get("raster-opacity")===0)return;const z=T.transform.projection.name==="globe",W=y.paint.get("raster-elevation")!==0,J=W&&z;if(T.renderElevatedRasterBackface&&!J)return;const ne=T.context,le=ne.gl,je=h.getSource(),ve=function(Nt,Tt,wt,yt,Ot){const Wt=Tt.paint.get("raster-color"),Ht=Nt.type==="raster-array",es=[],ts=Tt.paint.get("raster-resampling"),xs=Tt.paint.get("raster-color-mix");let qs=Tt.paint.get("raster-color-range");const Yt=[xs[0],xs[1],xs[2],0],Bt=xs[3];let as=ts==="nearest"?yt.NEAREST:yt.LINEAR;if(Ht&&(es.push("RASTER_ARRAY"),Wt||es.push("RASTER_COLOR"),ts==="linear"&&es.push("RASTER_ARRAY_LINEAR"),as=yt.NEAREST,!qs&&Nt.rasterLayers)){const Jt=Nt.rasterLayers.find(({id:Is})=>Is===Tt.sourceLayer);Jt&&Jt.fields&&Jt.fields.range&&(qs=Jt.fields.range)}if(qs=qs||[0,1],Wt){es.push("RASTER_COLOR"),wt.activeTexture.set(yt.TEXTURE2),Tt.updateColorRamp(qs);let Jt=Tt.colorRampTexture;Jt||(Jt=Tt.colorRampTexture=new i.T(wt,Tt.colorRamp,yt.RGBA8)),Jt.bind(yt.LINEAR,yt.CLAMP_TO_EDGE)}return Ot&&es.push("USE_MRT1"),{mix:Yt,range:qs,offset:Bt,defines:es,resampling:as}}(je,y,ne,le,T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback");if(je instanceof i.aU&&!A.length&&!z)return;const Ne=y.paint.get("raster-emissive-strength"),De=T.colorModeForDrapableLayerRenderPass(Ne),Pe=T.terrain&&T.terrain.renderingToTexture,Ge=!T.options.moving,Ve=y.paint.get("raster-resampling")==="nearest"?le.NEAREST:le.LINEAR;if(je instanceof i.aU&&!A.length&&(je.onNorthPole||je.onSouthPole)){const Nt=W?T.stencilModeFor3D():yn.disabled;return void f2(!!je.onNorthPole,null,T,h,y,Ne,ve,mn.disabled,Nt)}if(!A.length)return;const[nt,ut]=je instanceof i.aU||Pe?[{},A]:T.stencilConfigForOverlap(A),ot=ut[ut.length-1].overscaledZ;J&&ve.defines.push("PROJECTION_GLOBE_VIEW"),W&&ve.defines.push("RENDER_CUTOFF");const Et=(Nt,Tt,wt)=>{for(const yt of Nt){const Ot=yt.toUnwrapped(),Wt=h.getTile(yt);if(Pe&&(!Wt||!Wt.hasData()))continue;ne.activeTexture.set(le.TEXTURE0);const Ht=og(Wt,je,y,ve);if(!Ht||!Ht.texture)continue;const{texture:es,mix:ts,offset:xs,tileSize:qs,buffer:Yt}=Ht;let Bt,as;Pe?(Bt=Fr.disabled,as=yt.projMatrix):W?(Bt=new Fr(le.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D),as=z?Float32Array.from(T.transform.expandedFarZProjMatrix):T.transform.calculateProjMatrix(Ot,Ge)):(Bt=T.depthModeForSublayer(yt.overscaledZ-ot,y.paint.get("raster-opacity")===1?Fr.ReadWrite:Fr.ReadOnly,le.LESS),as=T.transform.calculateProjMatrix(Ot,Ge));const Jt=T.terrain&&Pe?T.terrain.stencilModeForRTTOverlap(yt):nt[yt.overscaledZ],Is=F?0:y.paint.get("raster-fade-duration");Wt.registerFadeDuration(Is);const rr=h.findLoadedParent(yt,0),yr=c2(Wt,rr,h,T.transform,Is);let Js,Us;!yr.isFading&&Wt.refreshedUponExpiration&&(Wt.refreshedUponExpiration=!1),T.terrain&&T.terrain.prepareDrawTile(),ne.activeTexture.set(le.TEXTURE0),es.bind(Ve,le.CLAMP_TO_EDGE),ne.activeTexture.set(le.TEXTURE1),rr?(rr.texture&&rr.texture.bind(Ve,le.CLAMP_TO_EDGE),Js=Math.pow(2,rr.tileID.overscaledZ-Wt.tileID.overscaledZ),Us=[Wt.tileID.canonical.x*Js%1,Wt.tileID.canonical.y*Js%1]):es.bind(Ve,le.CLAMP_TO_EDGE),"useMipmap"in es&&ne.extTextureFilterAnisotropic&&T.transform.pitch>20&&le.texParameterf(le.TEXTURE_2D,ne.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ne.extTextureFilterAnisotropicMax);const Pr=T.transform;let Cr;const hr=W?nF(Pr):[0,0,0,0];let br,Kr,Pn,wa,si,Or=0;if(J&&je instanceof i.aU&&je.coordinates.length>3)br=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Kr=Float32Array.from(Pr.globeMatrix),Pn=Float32Array.from(i.dF(Pr)),wa=[i.aF(Pr.center.lng),i.aJ(Pr.center.lat)],Cr=je.elevatedGlobePerspectiveTransform,si=je.elevatedGlobeGridMatrix||new Float32Array(9);else if(J){const Ci=i.dG(yt.canonical);Or=i.dH(Ci.getCenter().lat),br=Float32Array.from(i.bk(i.dJ(yt.canonical))),Kr=Float32Array.from(Pr.globeMatrix),Pn=Float32Array.from(i.dF(Pr)),wa=[i.aF(Pr.center.lng),i.aJ(Pr.center.lat)],Cr=[0,0],si=Float32Array.from(i.dI(yt.canonical,Ci,Or,Pr.worldSize/Pr._pixelsPerMercatorPixel))}else Cr=je instanceof i.aU?je.perspectiveTransform:[0,0],br=new Float32Array(16),Kr=new Float32Array(9),Pn=new Float32Array(16),wa=[0,0],si=new Float32Array(9);const Ka=XR(as,br,Kr,Pn,si,Us||[0,0],i.aj(T.transform.zoom),wa,hr,Js||1,yr,y,Cr,W?y.paint.get("raster-elevation"):0,2,ts,xs,ve.range,qs,Yt,Ne),Cn=T.isTileAffectedByFog(yt),di=T.getOrCreateProgram("raster",{defines:ve.defines,overrideFog:Cn});if(T.uploadCommonUniforms(ne,di,Ot),je instanceof i.aU){const Ci=je.elevatedGlobeVertexBuffer,bi=je.elevatedGlobeIndexBuffer;if(Pe||!z)je.boundsBuffer&&je.boundsSegments&&di.draw(T,le.TRIANGLES,Bt,yn.disabled,De,mn.disabled,Ka,y.id,je.boundsBuffer,T.quadTriangleIndexBuffer,je.boundsSegments);else if(Ci&&bi){const Ga=Pr.zoom<=i.c_?je.elevatedGlobeSegments:je.getSegmentsForLongitude(Pr.center.lng);Ga&&di.draw(T,le.TRIANGLES,Bt,yn.disabled,De,Tt,Ka,y.id,Ci,bi,Ga)}}else if(J){Bt=new Fr(le.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D);const Ci=T.globeSharedBuffers;if(Ci){const[bi,Ga,Wn]=Ci.getGridBuffers(Or,!1);di.draw(T,le.TRIANGLES,Bt,wt||Jt,T.colorModeForRenderPass(),Tt,Ka,y.id,bi,Ga,Wn)}}else{const{tileBoundsBuffer:Ci,tileBoundsIndexBuffer:bi,tileBoundsSegments:Ga}=T.getTileBoundsBuffers(Wt);di.draw(T,le.TRIANGLES,Bt,Jt,De,mn.disabled,Ka,y.id,Ci,bi,Ga)}}if(!(je instanceof i.aU)&&J)for(const yt of Nt){const Ot=yt.canonical.y===(1<>>16,2654435769),((yt=Math.imul(yt^yt>>>16,2654435769))>>>0)/4294967296},wt=1/1.1;for(let yt=0;yti.e9[Jt](es));Yt.push(es);const Bt=es.canonical.x,as=es.canonical.y;for(const Jt of Yt){const Is=ot.getTile(Ot?Jt.wrapped():Jt);if(!Is)continue;const rr=Is.rasterParticleState;if(!rr)continue;const yr=Jt.canonical.x+(1<Tt.tileID)),Ne&&(ne.activeTexture.set(le.TEXTURE0),T.imageManager.bind(T.context,y.scope));const Nt=[];if(T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&Nt.push("USE_MRT1"),J){const Tt=T.getOrCreateProgram(ut,{overrideFog:!1,overrideRtt:!0,defines:Nt}),wt=new Float32Array(i.bA([])),yt=new i.aQ(0,0,0,0,0),Ot=Ne?Ey(wt,W,z,T,0,y.scope,De,J,{tileID:yt,tileSize:ve}):u2(wt,W,z,D.toPremultipliedRenderColor(F?null:y.lut));Tt.draw(T,le.TRIANGLES,Ve,Ge,nt,mn.disabled,Ot,y.id,T.viewportBuffer,T.quadTriangleIndexBuffer,T.viewportSegments)}else for(const Tt of Et){const wt=T.isTileAffectedByFog(Tt),yt=T.getOrCreateProgram(ut,{overrideFog:wt,defines:Nt}),Ot=Tt.toUnwrapped(),Wt=A?Tt.projMatrix:T.transform.calculateProjMatrix(Ot);T.prepareDrawTile();const Ht=h?h.getTile(Tt):ot?ot[Tt.key]:new Ym(Tt,ve,je.zoom,T),es=Ne?Ey(Wt,W,z,T,0,y.scope,De,J,{tileID:Tt,tileSize:ve}):u2(Wt,W,z,D.toPremultipliedRenderColor(F?null:y.lut));T.uploadCommonUniforms(ne,yt,Ot);const{tileBoundsBuffer:ts,tileBoundsIndexBuffer:xs,tileBoundsSegments:qs}=T.getTileBoundsBuffers(Ht);yt.draw(T,le.TRIANGLES,Ve,Ge,nt,mn.disabled,es,y.id,ts,xs,qs)}},sky:function(T,h,y){const A=T._atmosphere?i.aj(T.transform.zoom):1,D=y.paint.get("sky-opacity")*A;if(D===0)return;const F=T.context,z=y.paint.get("sky-type"),W=new Fr(F.gl.LEQUAL,Fr.ReadOnly,[0,1]),J=T.frameCounter/1e3%1;z==="atmosphere"?T.renderPass==="offscreen"?y.needsSkyboxCapture(T)&&(function(ne,le,je,ve){const Ne=ne.context,De=Ne.gl;let Pe=le.skyboxFbo;if(!Pe){Pe=le.skyboxFbo=Ne.createFramebuffer(32,32,1,null),le.skyboxGeometry=new v3(Ne),le.skyboxTexture=Ne.gl.createTexture(),De.bindTexture(De.TEXTURE_CUBE_MAP,le.skyboxTexture),De.texParameteri(De.TEXTURE_CUBE_MAP,De.TEXTURE_WRAP_S,De.CLAMP_TO_EDGE),De.texParameteri(De.TEXTURE_CUBE_MAP,De.TEXTURE_WRAP_T,De.CLAMP_TO_EDGE),De.texParameteri(De.TEXTURE_CUBE_MAP,De.TEXTURE_MIN_FILTER,De.LINEAR),De.texParameteri(De.TEXTURE_CUBE_MAP,De.TEXTURE_MAG_FILTER,De.LINEAR);for(let ut=0;ut<6;++ut)De.texImage2D(De.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,De.RGBA,32,32,0,De.RGBA,De.UNSIGNED_BYTE,null)}Ne.bindFramebuffer.set(Pe.framebuffer),Ne.viewport.set([0,0,32,32]);const Ge=le.getCenter(ne,!0),Ve=ne.getOrCreateProgram("skyboxCapture"),nt=new Float64Array(16);i.bA(nt),i.en(nt,nt,.5*-Math.PI),hv(ne,le,Ve,nt,Ge,0),i.bA(nt),i.en(nt,nt,.5*Math.PI),hv(ne,le,Ve,nt,Ge,1),i.bA(nt),i.cU(nt,nt,.5*-Math.PI),hv(ne,le,Ve,nt,Ge,2),i.bA(nt),i.cU(nt,nt,.5*Math.PI),hv(ne,le,Ve,nt,Ge,3),i.bA(nt),hv(ne,le,Ve,nt,Ge,4),i.bA(nt),i.en(nt,nt,Math.PI),hv(ne,le,Ve,nt,Ge,5),Ne.viewport.set([0,0,ne.width,ne.height])}(T,y),y.markSkyboxValid(T)):T.renderPass==="sky"&&function(ne,le,je,ve,Ne){const De=ne.context,Pe=De.gl,Ge=ne.transform,Ve=ne.getOrCreateProgram("skybox");De.activeTexture.set(Pe.TEXTURE0),Pe.bindTexture(Pe.TEXTURE_CUBE_MAP,le.skyboxTexture);const nt=((ut,ot,Et,Nt,Tt)=>({u_matrix:ut,u_sun_direction:ot,u_cubemap:0,u_opacity:Nt,u_temporal_offset:Tt}))(Ge.skyboxMatrix,le.getCenter(ne,!1),0,ve,Ne);ne.uploadCommonUniforms(De,Ve),Ve.draw(ne,Pe.TRIANGLES,je,yn.disabled,ne.colorModeForRenderPass(),mn.backCW,nt,"skybox",le.skyboxGeometry.vertexBuffer,le.skyboxGeometry.indexBuffer,le.skyboxGeometry.segment)}(T,y,W,D,J):z==="gradient"&&T.renderPass==="sky"&&function(ne,le,je,ve,Ne){const De=ne.context,Pe=De.gl,Ge=ne.transform,Ve=ne.getOrCreateProgram("skyboxGradient");le.skyboxGeometry||(le.skyboxGeometry=new v3(De)),De.activeTexture.set(Pe.TEXTURE0);let nt=le.colorRampTexture;nt||(nt=le.colorRampTexture=new i.T(De,le.colorRamp,Pe.RGBA8)),nt.bind(Pe.LINEAR,Pe.CLAMP_TO_EDGE);const ut=((ot,Et,Nt,Tt,wt)=>({u_matrix:ot,u_color_ramp:0,u_center_direction:Et,u_radius:i.an(Nt),u_opacity:Tt,u_temporal_offset:wt}))(Ge.skyboxMatrix,le.getCenter(ne,!1),le.paint.get("sky-gradient-radius"),ve,Ne);ne.uploadCommonUniforms(De,Ve),Ve.draw(ne,Pe.TRIANGLES,je,yn.disabled,ne.colorModeForRenderPass(),mn.backCW,ut,"skyboxGradient",le.skyboxGeometry.vertexBuffer,le.skyboxGeometry.indexBuffer,le.skyboxGeometry.segment)}(T,y,W,D,J)},custom:function(T,h,y,A){const D=T.context,F=y.implementation;if(!T.transform.projection.unsupportedLayers||!T.transform.projection.unsupportedLayers.includes("custom")||T.terrain&&(T.terrain.renderingToTexture||T.renderPass==="offscreen")&&y.isDraped(h)){if(T.renderPass==="offscreen"){const z=F.prerender;if(z){if(T.setCustomLayerDefaults(),D.setColorMode(T.colorModeForRenderPass()),T.transform.projection.name==="globe"){const W=T.transform.pointMerc;z.call(F,D.gl,T.transform.customLayerMatrix(),T.transform.getProjection(),T.transform.globeToMercatorMatrix(),i.aj(T.transform.zoom),[W.x,W.y],T.transform.pixelsPerMeterRatio)}else z.call(F,D.gl,T.transform.customLayerMatrix());D.setDirty(),T.setBaseState()}}else if(T.renderPass==="translucent"){if(T.terrain&&T.terrain.renderingToTexture){const W=F.renderToTile;if(W){const J=A[0].canonical,ne={x:J.x+A[0].wrap*(F.wrapTileId?0:1<{ne&&(ne.useNormalOffset=!0,le||(ne.enabled=!0))},ve=h.getSource();if(T.renderPass==="light-beam"&&ve.type!=="batched-model")return;if(ve.type==="vector"||ve.type==="geojson")return function(ot,Et,Nt,Tt,wt){const yt=ot.transform,Ot=yt.projection.name==="globe",Wt=yt.getFreeCameraOptions().position;if(!ot.modelManager)return;const Ht=ot.modelManager;Nt.modelManager=Ht;const es=ot.shadowRenderer;if(!Nt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ts=Nt._unevaluatedLayout._values["model-id"],xs=Object.assign({},Nt.layout.get("model-id").parameters),qs=ot.style.order.indexOf(Nt.fqid),Yt=Nt.paint.get("model-opacity").constantOr(1);for(const Bt of Tt){const as=Et.getTile(Bt).getBucket(Nt);if(!as||as.projection.name!==yt.projection.name)continue;const Jt=as.getModelUris();if(Jt&&!as.modelsRequested&&(Ht.addModelsFromBucket(Jt,wt),as.modelsRequested=!0),Ot)xs.zoom=Bt.overscaledZ;else{const hr=zu(Bt,yt);xs.zoom=hr}const Is=ts.possiblyEvaluate(xs);if(fF(ot,as,Bt),Hf.shadowUniformsInitialized=!1,Hf.useSingleShadowCascade=!!es&&es.getMaxCascadeForTile(Bt.toUnwrapped())===0,ot.renderPass==="shadow"&&es){if(ot.currentShadowCascade===1&&as.isInsideFirstShadowMapFrustum)continue;const hr=yt.calculatePosMatrix(Bt.toUnwrapped(),yt.worldSize);if(Hf.tileMatrix.set(hr),Hf.shadowTileMatrix=Float32Array.from(es.calculateShadowPassMatrixFromMatrix(hr)),Hf.aabb.min=[0,0,0],Hf.aabb.max[0]=Hf.aabb.max[1]=i.al,Hf.aabb.max[2]=0,Hme(as,Hf,ot,Nt.scope))continue}const rr=1<0&&ot.style.isLayerClipped(Nt,Et.getSource())&&as.updateReplacement(Bt,ot.replacementSource,qs,Nt.scope)&&(as.uploaded=!1,as.upload(ot.context));let Js=0;const Us=new Array,Pr=new Array,Cr=new Array;for(let hr in as.instancesPerModel){const br=as.instancesPerModel[hr];br.features.length>0&&!Ot&&(hr=Is.evaluate(br.features[0].feature,{}));const Kr=Ht.getModel(hr,wt);if(Kr||Ht.hasURLBeenRequested(hr)||as.modelUris.includes(hr)||(as.modelUris.push(hr),as.modelsRequested=!1),Kr&&Kr.uploaded)if(Ot){const Pn=i.c5([],[Wt.x,Wt.y,Wt.z],ot.transform.worldSize);i.ew(Pn,Pn);for(let wa=0;wa0&&Ka.elevationUpdate(hr.terrain,wa,Or,Kr.source),Ka.needsReEvaluation(hr,si,Kr)&&Ka.evaluate(Kr))}})(ot,Et,Nt,Tt),function(){let hr,br,Kr;Us?(hr=Tt.length-1,br=-1,Kr=-1):(hr=0,br=Tt.length,Kr=1);const Pn=new Float64Array(16),wa=i.cA(),si=new i.P(0,0);for(let Or=hr;Or!==br;Or+=Kr){const Ka=Tt[Or],Cn=Et.getTile(Ka).getBucket(Nt);if(!Cn||!Cn.uploaded)continue;let di=!1;Wt&&(di=Wt.getMaxCascadeForTile(Ka.toUnwrapped())===0);const Ci=yt.calculatePosMatrix(Ka.toUnwrapped(),yt.worldSize),bi=Cn.modelTraits;!rr&&Us&&(i.bl(Pn,Ci),i.af(wa,es,Pn),si.x=wa[0],si.y=wa[1]);const Ga=[];Cn.setFilter(Nt.filter);for(const Wn of Cn.getNodesInfo()){if(Wn.hiddenByReplacement||!Wn.node.meshes)continue;const ii=Wn.node;let So=0;ot.terrain&&ii.elevation&&(So=ii.elevation*ot.terrain.exaggeration());const no=(()=>{const Vd=Wn.aabb;return Is.min=[...Vd.min],Is.max=[...Vd.max],Is.min[2]+=So,Is.max[2]+=So,i.af(Is.min,Is.min,Ci),i.af(Is.max,Is.max,Ci),Is})(),ui=Wn.evaluatedScale;if(ui[0]<=1&&ui[1]<=1&&ui[2]<=1&&no.intersects(yr)===0)continue;if(!rr&&Us){const Vd=.16666666666666666;Wn.cameraCollisionOpacity=es[0]>no.min[0]&&es[0]no.min[1]&&es[1]!Us||Wn.opacity===1&&ii.opacity===1?Wn.depthii.depth?-1:1);for(const Wn of Ga){const ii=Wn.nodeInfo,So=ii.node;let no=i.aB([],Yt,Wn.tileModelMatrix);i.aB(no,xs,no);const ui=i.bl([],no);i.eg(ui,ui),i.cS(ui,ui,g2),no=i.aB(no,no,So.globalMatrix);const za=ot.renderPass==="light-beam",Gn=Nt.paint.get("model-color-use-theme").constantOr("default")==="none",Xi=bi&i.eI.HasMapboxMeshFeatures,Ho=Xi?0:ii.evaluatedRMEA[0][2];for(let _o=0;_o=gs||wo>=gs}}const od=Di.material;let hm;od.occlusionTexture&&od.occlusionTexture.offsetScale&&(hm=od.occlusionTexture.offsetScale,Ul.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const ap=ot.getOrCreateProgram("model",Ul);!rr&&Wt&&Wt.setupShadowsFromMatrix(Wn.tileModelMatrix,ap,Wt.useNormalOffset),ot.uploadCommonUniforms(wt,ap,null,Hd);const mh=od.pbrMetallicRoughness;mh.metallicFactor=.9,mh.roughnessFactor=.5;const Lo=ov(new Float32Array(Td),new Float32Array(no),new Float32Array(ui),new Float32Array(So.globalMatrix),ot,Wn.opacity,mh.baseColorFactor,od.emissiveFactor,mh.metallicFactor,mh.roughnessFactor,od,Ho,Nt,[0,0,0],hm);!Bu&&(ii.hasTranslucentParts||Wn.opacity<1)&&ap.draw(ot,wt.gl.TRIANGLES,as,yn.disabled,Hn.disabled,mn.backCCW,Lo,Nt.id,Di.vertexBuffer,Di.indexBuffer,Di.segments,Nt.paint,ot.transform.zoom,void 0,Vd),ap.draw(ot,wt.gl.TRIANGLES,Bu?Jt:as,yn.disabled,Bu||Wn.opacity<1||ii.hasTranslucentParts?Hn.alphaBlended:Hn.unblended,mn.backCCW,Lo,Nt.id,Di.vertexBuffer,Di.indexBuffer,Di.segments,Nt.paint,ot.transform.zoom,void 0,Vd)}}}}()}(T,h,y,A),void je();if(ve.type!=="model")return;const Ne=ve.getModels(),De=[],Pe=T.transform.getFreeCameraOptions().position,Ge=i.c5([],[Pe.x,Pe.y,Pe.z],T.transform.worldSize);i.ew(Ge,Ge);const Ve=[],nt=[];let ut=0;for(const ot of Ne){const Et=h.getFeatureState("",ot.id),Nt={type:"Unknown",id:ot.id,properties:ot.featureProperties},Tt=y.paint.get("model-rotation").evaluate(Nt,Et),wt=y.paint.get("model-scale").evaluate(Nt,Et),yt=y.paint.get("model-translation").evaluate(Nt,Et),Ot=y.paint.get("model-opacity").evaluate(Nt,Et);hF(y,ot.id,Et,ot.featureProperties,ot.nodeOverrideNames,ot.nodeOverrides),mF(y,ot.id,Et,ot.featureProperties,ot.materialOverrideNames,ot.materialOverrides),ot.nodeOverrides.size>0&&ot.computeBoundsAndApplyParent(),ot.computeModelMatrix(T,Tt,wt,yt,W,z,!1);const Wt=i.bA([]),Ht=i.ef(ot.position.lat,T.transform.zoom),es=i.bq([],[1,1,1/Ht]);i.br(Wt,Wt,Ge),De.push({zScaleMatrix:es,negCameraPosMatrix:Wt});for(const ts of ot.nodes)mv(T,ts,ot.matrix,T.transform.expandedFarZProjMatrix,ut,Ve,nt,ot.materialOverrides,Ot);ut++}if(Ve.sort((ot,Et)=>Et.depth-ot.depth),T.renderPass!=="shadow")pF(T,y,Ve,nt,De),je();else{for(const ot of nt)$p(ot.mesh,ot.nodeModelMatrix,T,y);for(const ot of Ve)$p(ot.mesh,ot.nodeModelMatrix,T,y);je()}}},S3={line:function(T,h,y){if(T.hasElevatedBuckets=!1,T.hasNonElevatedBuckets=!1,T._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||T._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(h){const A=h.getVisibleCoordinates();for(const D of A){const F=h.getTile(D).getBucket(T);if(F&&(F.elevationType!=="none"?T.hasElevatedBuckets=!0:T.hasNonElevatedBuckets=!0,T.hasElevatedBuckets&&T.hasNonElevatedBuckets))break}}}else T.hasNonElevatedBuckets=!0},model:function(T,h,y){const A=h.getSource();if(!A.loaded())return;if(A.type==="vector"||A.type==="geojson")return void(y.modelManager&&y.modelManager.upload(y,x2(y,T)));if(A.type==="batched-model"||A.type!=="model")return;const D=A.getModels();for(const F of D)F.upload(y.context)},raster:function(T,h,y){const A=h.getSource();if(!(A instanceof Sd&&A.loaded()))return;const D=T.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=T.paint.get("raster-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(W=>h.getTileByID(W));for(const W of z)W.updateNeeded(T.id,F)&&A.prepareTile(W,D,T.id,F)},"raster-particle":function(T,h,y){const A=h.getSource();if(!(A instanceof Sd&&A.loaded()))return;const D=T.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=T.paint.get("raster-particle-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(W=>h.getTileByID(W));for(const W of z)W.updateNeeded(T.id,F)&&A.prepareTile(W,D,T.id,F)}},um={fill:h3},C3={fill:function(T,h,y,A){if(!y.layout||y.layout.get("fill-elevation-reference")==="none"||y.paint.get("fill-opacity").constantOr(1)===0)return;const D=T.context.gl,F=new Fr(D.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D),z=new yn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),W=T.transform.getFreeCameraOptions().position,J=T.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ne of A){const le=h.getTile(ne),je=le.getBucket(y);if(!je)continue;const ve=je.elevatedStructures;if(!ve||ve.depthSegments.segments[0].primitiveLength===0)continue;const Ne=rF(ne.toUnwrapped(),W),De=T.translatePosMatrix(ne.projMatrix,le,y.paint.get("fill-translate"),y.paint.get("fill-translate-anchor")),Pe=iv(De,Ne,0,1,0);J.draw(T,D.TRIANGLES,F,z,Hn.disabled,mn.disabled,Pe,y.id,ve.vertexBuffer,ve.indexBuffer,ve.depthSegments,y.paint,T.transform.zoom)}}};class M3{constructor(h,y,A,D,F){this.context=new ub(h,y),this.transform=A,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=i.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const z=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const J of z)this._debugParams.enabledLayers[J]=!0;for(const J of z);this.occlusionParams=new mb,this.setup(),this.numSublayers=El.maxUnderzooming+El.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 J1(this),this._wireframeDebugCache=new Iy,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const W=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,W,h.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.worldview=F,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(h,y){const A=!!h&&!!h.terrain&&this.transform.projection.supportsTerrain;if(!(A||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new d6(this,h));const D=this._terrain;this.transform.elevation=A?D:null,D.update(h,this.transform,y),this.transform.elevation&&!D.enabled&&(this.transform.elevation=null)}_updateFog(h){const y=h.fog;if(!y||this.transform.projection.name==="globe"||y.getOpacity(this.transform.pitch)<1||y.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[A,D]=y.getFovAdjustedRange(this.transform._fov);if(A>D)return void(this.transform.fogCullDistSq=null);const F=A+.78*(D-A);this.transform.fogCullDistSq=F*F}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(h){h&&!this._terrain&&(this._terrain=new d6(this,this.style)),this._forceTerrainMode=h}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(h,y){if(this.width=h*i.o.devicePixelRatio,this.height=y*i.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const A of this.style.order)this.style._mergedLayers[A].resize()}setup(){const h=this.context,y=new i.bd;y.emplaceBack(0,0),y.emplaceBack(i.al,0),y.emplaceBack(0,i.al),y.emplaceBack(i.al,i.al),this.tileExtentBuffer=h.createVertexBuffer(y,i.bf.members),this.tileExtentSegments=i.bg.simpleSegment(0,0,4,2);const A=new i.bd;A.emplaceBack(0,0),A.emplaceBack(i.al,0),A.emplaceBack(0,i.al),A.emplaceBack(i.al,i.al),this.debugBuffer=h.createVertexBuffer(A,i.bf.members),this.debugSegments=i.bg.simpleSegment(0,0,4,5);const D=new i.bd;D.emplaceBack(-1,-1),D.emplaceBack(1,-1),D.emplaceBack(-1,1),D.emplaceBack(1,1),this.viewportBuffer=h.createVertexBuffer(D,i.bf.members),this.viewportSegments=i.bg.simpleSegment(0,0,4,2);const F=new i.b1;F.emplaceBack(0,0,0,0),F.emplaceBack(i.al,0,i.al,0),F.emplaceBack(0,i.al,0,i.al),F.emplaceBack(i.al,i.al,i.al,i.al),this.mercatorBoundsBuffer=h.createVertexBuffer(F,i.bi.members),this.mercatorBoundsSegments=i.bg.simpleSegment(0,0,4,2);const z=new i.b0;z.emplaceBack(0,1,2),z.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=h.createIndexBuffer(z);const W=new i.be;for(const ne of[0,1,3,2,0])W.emplaceBack(ne);this.debugIndexBuffer=h.createIndexBuffer(W),this.emptyTexture=new i.T(h,new i.q({width:1,height:1},Uint8Array.of(0,0,0,0)),h.gl.RGBA8),this.identityMat=i.bC();const J=this.context.gl;this.stencilClearMode=new yn({func:J.ALWAYS,mask:0},0,255,J.ZERO,J.ZERO,J.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(h){return h._makeTileBoundsBuffers(this.context,this.transform.projection),h._tileBoundsBuffer?{tileBoundsBuffer:h._tileBoundsBuffer,tileBoundsIndexBuffer:h._tileBoundsIndexBuffer,tileBoundsSegments:h._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const h=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,h.TRIANGLES,Fr.disabled,this.stencilClearMode,Hn.disabled,mn.disabled,l2(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,y,A){if(!y||this.currentStencilSource===y.id||!h.isTileClipped()||!A||A.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let W=!1;for(const J of A)if(this._tileClippingMaskIDs[J.key]===void 0){W=!0;break}if(!W)return}this.currentStencilSource=y.id;const D=this.context,F=D.gl;this.nextStencilID+A.length>256&&this.clearStencil(),D.setColorMode(Hn.disabled),D.setDepthMode(Fr.disabled);const z=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const W of A){const J=y.getTile(W),ne=this._tileClippingMaskIDs[W.key]=this.nextStencilID++,{tileBoundsBuffer:le,tileBoundsIndexBuffer:je,tileBoundsSegments:ve}=this.getTileBoundsBuffers(J);z.draw(this,F.TRIANGLES,Fr.disabled,new yn({func:F.ALWAYS,mask:0},ne,255,F.KEEP,F.KEEP,F.REPLACE),Hn.disabled,mn.disabled,l2(W.projMatrix),"$clipping",le,je,ve)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,y=this.context.gl;return new yn({func:y.NOTEQUAL,mask:255},h,255,y.KEEP,y.KEEP,y.REPLACE)}stencilModeForClipping(h){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(h);const y=this.context.gl;return new yn({func:y.EQUAL,mask:255},this._tileClippingMaskIDs[h.key],0,y.KEEP,y.KEEP,y.REPLACE)}stencilConfigForOverlap(h){const y=this.context.gl,A=h.sort((z,W)=>W.overscaledZ-z.overscaledZ),D=A[A.length-1].overscaledZ,F=A[0].overscaledZ-D+1;if(F>1){this.currentStencilSource=void 0,this.nextStencilID+F>256&&this.clearStencil();const z={};for(let W=0;Wthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((h,y)=>h+y/this._fpsHistory.length,0))}render(h,y){const A=i.o.now();this._dt=A-this._timeStamp,this._timeStamp=A,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=h.map.repaint,this.style=h,this.options=y;const D=this.style._mergedLayers,F=!(!this.terrain||!this.terrain.enabled),z=()=>this.style._getOrder(F).filter(Yt=>{const Bt=D[Yt];return!(Bt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Bt.type]});let W=z(),J=!1,ne=!1,le=null,je=0,ve=!1;for(const Yt of W){const Bt=D[Yt];Bt.visibility!=="none"&&(Bt.type==="circle"?J=!0:Bt.type==="building"?(le=Bt,++je):Bt.type==="symbol"&&(Bt.hasOcclusionOpacityProperties?ne=!0:J=!0))}this.updateEmissiveMode();let Ne=W.map(Yt=>D[Yt]);const De=this.style._mergedSourceCaches;this.imageManager=h.imageManager,this.modelManager=h.modelManager,this.symbolFadeChange=h.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Yt in De){const Bt=De[Yt];Bt.used&&(Bt.prepare(this.context),Bt.getSource().usedInConflation&&++je)}let Pe=!1;for(const Yt of Ne)Yt.isHidden(this.transform.zoom)||(Yt.type==="clip"&&(Pe=!0),this.prepareLayer(Yt));const Ge={},Ve={},nt={},ut={},ot={};for(const Yt in De){const Bt=De[Yt];Ge[Yt]=Bt.getVisibleCoordinates(),Ve[Yt]=Ge[Yt].slice().reverse(),nt[Yt]=Bt.getVisibleCoordinates(!0).reverse(),ut[Yt]=Bt.getShadowCasterCoordinates(),ot[Yt]=Bt.sortCoordinatesByDistance(Ge[Yt])}const Et=Yt=>{const Bt=this.style.getLayerSourceCache(Yt);return Bt&&Bt.used?Bt.getSource():null};if(je||Pe||this._clippingActiveLastFrame){const Yt=[],Bt=[];let as=0;for(const Jt of Ne)this.isSourceForClippingOrConflation(Jt,Et(Jt))&&(Yt.push(Jt),Bt.push(as)),as++;if(Yt&&(Pe||Yt.length>1)||this._clippingActiveLastFrame){Pe=!1;const Jt=[];for(let Is=0;Is0){const Jt=Et(Bt);Jt&&(this.minCutoffZoom=Math.max(Jt.minzoom,this.minCutoffZoom)),Bt.minzoom&&(this.minCutoffZoom=Math.max(Bt.minzoom,this.minCutoffZoom))}Bt.is3D(F)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Yt),this._lastOcclusionLayer=Yt)}const Nt=this.style&&this.style.fog;Nt?(this._fogVisible=Nt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=Nt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(nt),this.opaquePassCutoff=0,W=z(),Ne=W.map(Yt=>D[Yt]));const Tt=this._shadowRenderer;if(Tt){Tt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Yt in De)for(const Bt of Ge[Yt]){let as={min:0,max:0};this.terrain&&(as=this.terrain.getMinMaxForTile(Bt)||as),Tt.addShadowReceiver(Bt.toUnwrapped(),as.min,as.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 uF(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const wt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),yt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(wt&&!this._snow&&(this._snow=new S6(this)),!wt&&this._snow&&(this._snow.destroy(),delete this._snow),yt&&!this._rain&&(this._rain=new k3(this)),!yt&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),le){this.buildingTileBorderManager||(this.buildingTileBorderManager=new b3);const Yt=this.style.getLayerSourceCache(le);this.buildingTileBorderManager.updateBorders(Yt,le)}if(!at.has(this.context.gl))return;this.renderPass="offscreen";for(const Yt of Ne){const Bt=h.getLayerSourceCache(Yt);if(!Yt.hasOffscreenPass()||Yt.isHidden(this.transform.zoom))continue;const as=Bt?Ve[Bt.id]:void 0;(Yt.type==="custom"||Yt.type==="raster"||Yt.type==="raster-particle"||Yt.isSky()||as&&as.length)&&this.renderLayer(this,Bt,Yt,as)}this.depthRangeFor3D=[0,1-(Ne.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,ut)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Ot=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Wt=(()=>{if(y.showOverdrawInspector)return i.ao.black;const Yt=this.style.fog;if(Yt&&this.transform.projection.supportsFog){const Bt=this.style.getLut(Yt.scope);if(!Ot){const as=Yt.properties.get("color-use-theme")==="none",Jt=Yt.properties.get("color").toNonPremultipliedRenderColor(as?null:Bt).toArray01();return new i.ao(...Jt)}if(Ot){const as=Yt.properties.get("space-color-use-theme")==="none",Jt=Yt.properties.get("space-color").toNonPremultipliedRenderColor(as?null:Bt).toArray01();return new i.ao(...Jt)}}return i.ao.transparent})();if(this.context.clear({color:Wt,depth:1}),this.clearStencil(),this._showOverdrawInspector=y.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Ot&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=W.length-1;this.currentLayer>=0;this.currentLayer--){const Yt=Ne[this.currentLayer],Bt=h.getLayerSourceCache(Yt);if(Yt.isSky())continue;const as=Bt?(Yt.is3D(F)?ot:Ve)[Bt.id]:void 0;this._renderTileClippingMasks(Yt,Bt,as),this.renderLayer(this,Bt,Yt,as)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Ot&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||i.aj(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&Yt.hasShadowPass()&&--es==0){{this.clearStencil(),this.resetStencilClippingMasks();const as=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const as=this.currentLayer;this.depthOcclusion=!0;for(const Jt of this.layersWithOcclusionOpacity){this.currentLayer=Jt;const Is=Ne[this.currentLayer],rr=h.getLayerSourceCache(Is),yr=rr?Ve[rr.id]:void 0;this.terrain||this._renderTileClippingMasks(Is,rr,rr?Ge[rr.id]:void 0),this.renderLayer(this,rr,Is,yr)}this.depthOcclusion=!1,this.currentLayer=as,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Yt=null;Ne.forEach(Bt=>{const as=h.getLayerSourceCache(Bt);as&&!Bt.isHidden(this.transform.zoom)&&as.getVisibleCoordinates().length&&(!Yt||Yt.getSource().maxzoom0?y.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(h,y,A){const D=A===void 0?this.terrain&&this.terrain.renderingToTexture:A,F=[];return this.style&&this.style.enable3dLights()&&(h==="globeRaster"||h==="terrainRaster"?(F.push("LIGHTING_3D_MODE"),F.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):D||F.push("LIGHTING_3D_MODE")),this.renderPass==="shadow"&&(this._shadowMapDebug||F.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(F.push("TERRAIN"),this.linearFloatFilteringSupported()&&F.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&F.push("GLOBE"),!this._fogVisible||D||y!==void 0&&!y||F.push("FOG","FOG_DITHERING"),D&&F.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&F.push("OVERDRAW_INSPECTOR"),F}getOrCreateProgram(h,y){this.cache=this.cache||{};const A=y&&y.defines||[],D=y&&y.config,F=this.currentGlobalDefines(h,y&&y.overrideFog,y&&y.overrideRtt).concat(A),z=VR.cacheKey(XE[h],h,F,D);return this.cache[z]||(this.cache[z]=new VR(this.context,h,XE[h],D,u3[h],F)),this.cache[z]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const h=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(h.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(h,y){if(this.style.enable3dLights()){const A=this.style.directionalLight,D=this.style.ambientLight;if(A&&D){const F=((z,W,J)=>{const ne=z.properties.get("direction"),le=z.properties.get("color-use-theme")==="none",je=z.properties.get("color").toNonPremultipliedRenderColor(le?null:J.getLut(z.scope)).toArray01(),ve=z.properties.get("intensity"),Ne=W.properties.get("color-use-theme")==="none",De=W.properties.get("color").toNonPremultipliedRenderColor(Ne?null:J.getLut(W.scope)).toArray01(),Pe=W.properties.get("intensity"),Ge=[ne.x,ne.y,ne.z],Ve=i.dN(De,Pe),nt=i.dN(je,ve);return{u_lighting_ambient_color:Ve,u_lighting_directional_dir:Ge,u_lighting_directional_color:nt,u_ground_radiance:lb(Ge,nt,Ve)}})(A,D,this.style);y.setLightsUniformValues(h,F)}}}uploadCommonUniforms(h,y,A,D,F){if(this.uploadCommonLightUniforms(h,y),this.terrain&&this.terrain.renderingToTexture)return;const z=this.style.fog;if(z){const W=z.getOpacity(this.transform.pitch),J=((ne,le,je,ve,Ne,De,Pe,Ge,Ve,nt,ut,ot)=>{const Et=ne.transform,Nt=le.properties.get("color-use-theme")==="none",Tt=le.properties.get("color").toNonPremultipliedRenderColor(Nt?null:ne.style.getLut(le.scope)).toArray01();Tt[3]=ve;const wt=ne.frameCounter/1e3%1,[yt,Ot]=le.properties.get("vertical-range");return{u_fog_matrix:je?Et.calculateFogTileMatrix(je):ot||ne.identityMat,u_fog_range:le.getFovAdjustedRange(Et._fov),u_fog_color:Tt,u_fog_horizon_blend:le.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(yt,Ot),Ot],u_fog_temporal_offset:wt,u_frustum_tl:Ne,u_frustum_tr:De,u_frustum_br:Pe,u_frustum_bl:Ge,u_globe_pos:Ve,u_globe_radius:nt,u_viewport:ut,u_globe_transition:i.aj(Et.zoom),u_is_globe:+(Et.projection.name==="globe")}})(this,z,A,W,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.o.devicePixelRatio,this.transform.height*i.o.devicePixelRatio],D);y.setFogUniformValues(h,J)}F&&y.setCutoffUniformValues(h,F.uniformValues)}setTileLoadedFlag(h){this.tileLoaded=h}saveCanvasCopy(){const h=this.canvasCopy();h&&(this.frameCopies.push(h),this.tileLoaded=!1)}canvasCopy(){const h=this.context.gl,y=h.createTexture();return h.bindTexture(h.TEXTURE_2D,y),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,0,0,h.drawingBufferWidth,h.drawingBufferHeight,0),y}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const h=this.style&&this.style.fog;return!!h&&h.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const h=this._backgroundTiles,y=this._backgroundTiles={},A=this.transform.coveringTiles({tileSize:512});for(const D of A)y[D.key]=h[D.key]||new Ym(D,512,this.transform.tileZoom,this,void 0,this.worldview);return y}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(h,y){return!(!h.is3D(!(!this.terrain||!this.terrain.enabled))||h.type!=="clip"&&h.type!=="building"&&(h.minzoom&&h.minzoom>this.transform.zoom||(this.style._clipLayerPresent||h.sourceLayer!=="building"&&h.sourceLayer!=="procedural_buildings")&&(!y||y.type!=="batched-model")))}isTileAffectedByFog(h){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let y=this._cachedTileFogOpacities[h.key];return y||(this._cachedTileFogOpacities[h.key]=y=this.style.fog.getOpacityForTile(h)),y[0]>=gs||y[1]>=gs}setupDepthForOcclusion(h,y,A){const D=this.context,F=D.gl,z=!!A;var W;A||(A={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),D.activeTexture.set(F.TEXTURE3),h&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),A.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],A.u_depth_range_unpack=[2/((W=this.depthRangeFor3D)[1]-W[0]),-1-2*W[0]/(W[1]-W[0])],A.u_occluder_half_size=.5*this.occlusionParams.occluderSize,A.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),D.activeTexture.set(F.TEXTURE0),z||y.setTerrainUniformValues(D,A)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const h=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=h?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function T3(T,h){let y=!1,A=null;const D=()=>{A=null,y&&(T(),A=setTimeout(D,h),y=!1)};return()=>(y=!0,A||D(),A)}class C6{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=T3(this._updateHashUnthrottled.bind(this),300)}addTo(h){return this._map=h,window.addEventListener("hashchange",this._onHashChange,!1),h.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const h=this._map;if(!h)return"";const y=$l(h);if(this._hashName){const A=this._hashName;let D=!1;const F=location.hash.slice(1).split("&").map(z=>{const W=z.split("=")[0];return W===A?(D=!0,`${W}=${y}`):z}).filter(z=>z);return D||F.push(`${A}=${y}`),`#${F.join("&")}`}return`#${y}`}_getCurrentHash(){const h=location.hash.replace("#","");if(this._hashName){let y;return h.split("&").map(A=>A.split("=")).forEach(A=>{A[0]===this._hashName&&(y=A)}),(y&&y[1]||"").split("/")}return h.split("/")}_onHashChange(){const h=this._map;if(!h)return!1;const y=this._getCurrentHash();if(y.length>=3&&!y.some(A=>isNaN(Number(A)))){const A=h.dragRotate.isEnabled()&&h.touchZoomRotate.isEnabled()?+(y[3]||0):h.getBearing();return h.jumpTo({center:[+y[2],+y[1]],zoom:+y[0],bearing:A,pitch:+(y[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function $l(T,h){const y=T.getCenter(),A=Math.round(100*T.getZoom())/100,D=Math.ceil((A*Math.LN2+Math.log(512/360/.5))/Math.LN10),F=Math.pow(10,D),z=Math.round(y.lng*F)/F,W=Math.round(y.lat*F)/F,J=T.getBearing(),ne=T.getPitch();let le=h?`/${z}/${W}/${A}`:`${A}/${W}/${z}`;return(J||ne)&&(le+="/"+Math.round(10*J)/10),ne&&(le+=`/${Math.round(ne)}`),le}const fb={linearity:.3,easing:i.eT(0,0,.3,1)},M6=Object.assign({deceleration:2500,maxSpeed:1400},fb),T6=Object.assign({deceleration:20,maxSpeed:1400},fb),fv=Object.assign({deceleration:1e3,maxSpeed:360},fb),A6=Object.assign({deceleration:1e3,maxSpeed:90},fb);class E6{constructor(h){this._map=h,this.clear()}clear(){this._inertiaBuffer=[]}record(h){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.o.now(),settings:h})}_drainInertiaBuffer(){const h=this._inertiaBuffer,y=i.o.now();for(;h.length>0&&y-h[0].time>160;)h.shift()}_onMoveEnd(h){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const y={zoom:0,bearing:0,pitch:0,pan:new i.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:F}of this._inertiaBuffer)y.zoom+=F.zoomDelta||0,y.bearing+=F.bearingDelta||0,y.pitch+=F.pitchDelta||0,F.panDelta&&y.pan._add(F.panDelta),F.around&&(y.around=F.around),F.pinchAround&&(y.pinchAround=F.pinchAround);const A=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(y.pan.mag()){const F=Wf(y.pan.mag(),A,Object.assign({},M6,h||{}));D.offset=y.pan.mult(F.amount/y.pan.mag()),D.center=this._map.transform.center,xb(D,F)}if(y.zoom){const F=Wf(y.zoom,A,T6);D.zoom=this._map.transform.zoom+F.amount,xb(D,F)}if(y.bearing){const F=Wf(y.bearing,A,fv);D.bearing=this._map.transform.bearing+i.aA(F.amount,-179,179),xb(D,F)}if(y.pitch){const F=Wf(y.pitch,A,A6);D.pitch=this._map.transform.pitch+F.amount,xb(D,F)}if(D.zoom||D.bearing){const F=y.pinchAround===void 0?y.around:y.pinchAround;D.around=F?this._map.unproject(F):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function xb(T,h){(!T.duration||T.durationy.unproject(J)),W=F.reduce((J,ne,le,je)=>J.add(ne.div(je.length)),new i.P(0,0));super(h,{points:F,point:W,lngLats:z,lngLat:y.unproject(W),originalEvent:A}),this._defaultPrevented=!1}}class P6 extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,y){super("wheel",{originalEvent:y}),this._defaultPrevented=!1}}class A3{constructor(h,y){this._map=h,this._clickTolerance=y.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new P6(this._map,h))}mousedown(h,y){return this._mousedownPos=y,this._firePreventable(new hh(h.type,this._map,h))}mouseup(h){this._map.fire(new hh(h.type,this._map,h))}preclick(h){const y=new MouseEvent("preclick",h);this._map.fire(new hh(y.type,this._map,y))}click(h,y){this._mousedownPos&&this._mousedownPos.dist(y)>=this._clickTolerance||(this.preclick(h),this._map.fire(new hh(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new hh(h.type,this._map,h))}mouseover(h){this._map.fire(new hh(h.type,this._map,h))}mouseout(h){this._map.fire(new hh(h.type,this._map,h))}touchstart(h){return this._firePreventable(new Dy(h.type,this._map,h))}touchmove(h){this._map.fire(new Dy(h.type,this._map,h))}touchend(h){this._map.fire(new Dy(h.type,this._map,h))}touchcancel(h){this._map.fire(new Dy(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class I6{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new hh(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new hh("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new hh(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class E3{constructor(h,y){this._map=h,this._el=h.getCanvasContainer(),this._container=h.getContainer(),this._clickTolerance=y.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(h,y){this.isEnabled()&&h.shiftKey&&h.button===0&&(L(),this._startPos=this._lastPos=y,this._active=!0)}mousemoveWindow(h,y){if(!this._active)return;const A=y,D=this._startPos,F=this._lastPos;if(!D||!F||F.equals(A)||!this._box&&A.dist(D){this._box&&(this._box.style.transform=`translate(${z}px,${J}px)`,this._box.style.width=W-z+"px",this._box.style.height=ne-J+"px")})}mouseupWindow(h,y){if(!this._active)return;const A=this._startPos,D=y;if(A&&h.button===0){if(this.reset(),q(),A.x!==D.x||A.y!==D.y)return this._map.fire(new i.z("boxzoomend",{originalEvent:h})),{cameraAnimation:F=>F.fitScreenCoordinates(A,D,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",h)}}keydown(h){this._active&&h.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",h))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),I(),delete this._startPos,delete this._lastPos}_fireEvent(h,y){return this._map.fire(new i.z(h,{originalEvent:y}))}}function P3(T,h){const y={};for(let A=0;Athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=h.timeStamp),A.length===this.numTouches&&(this.centroid=function(D){const F=new i.P(0,0);for(const z of D)F._add(z);return F.div(D.length)}(y),this.touches=P3(A,y)))}touchmove(h,y,A){if(this.aborted||!this.centroid)return;const D=P3(A,y);for(const F in this.touches){const z=D[F];(!z||z.dist(this.touches[F])>30)&&(this.aborted=!0)}}touchend(h,y,A){if((!this.centroid||h.timeStamp-this.startTime>500)&&(this.aborted=!0),A.length===0){const D=!this.aborted&&this.centroid;if(this.reset(),D)return D}}}class I3{constructor(h){this.singleTap=new yF(h),this.numTaps=h.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(h,y,A){this.singleTap.touchstart(h,y,A)}touchmove(h,y,A){this.singleTap.touchmove(h,y,A)}touchend(h,y,A){const D=this.singleTap.touchend(h,y,A);if(D){const F=h.timeStamp-this.lastTime<500,z=!this.lastTap||this.lastTap.dist(D)<30;if(F&&z||this.reset(),this.count++,this.lastTime=h.timeStamp,this.lastTap=D,this.count===this.numTaps)return this.reset(),D}}}class vF{constructor(){this._zoomIn=new I3({numTouches:1,numTaps:2}),this._zoomOut=new I3({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,y,A){this._zoomIn.touchstart(h,y,A),this._zoomOut.touchstart(h,y,A)}touchmove(h,y,A){this._zoomIn.touchmove(h,y,A),this._zoomOut.touchmove(h,y,A)}touchend(h,y,A){const D=this._zoomIn.touchend(h,y,A),F=this._zoomOut.touchend(h,y,A);return D?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()+1,around:z.unproject(D)},{originalEvent:h})}):F?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()-1,around:z.unproject(F)},{originalEvent:h})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const bF={0:1,2:2},L6={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class L3{constructor(h){this.reset(),this._clickTolerance=h.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(h,y){return!1}_move(h,y){return{}}mousedown(h,y){if(this._lastPoint)return;const A=V(h);this._correctButton(h,A)&&(this._lastPoint=y,this._eventButton=A)}mousemoveWindow(h,y){const A=this._lastPoint;if(A){if(h.preventDefault(),this._eventButton!=null&&function(D,F){const z=bF[F];return D.buttons===void 0||(D.buttons&z)!==z}(h,this._eventButton))this.reset();else if(this._moved||!(y.dist(A)0&&(this._active=!0);const D=P3(A,y),F=new i.P(0,0),z=new i.P(0,0);let W=0;for(const ne in D){const le=D[ne],je=this._touches[ne];je&&(F._add(le),z._add(le.sub(je)),W++,D[ne]=le)}if(this._touches=D,W{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class D3{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(h){}_move(h,y,A){return{}}touchstart(h,y,A){this._firstTwoTouches||A.length<2||(this._firstTwoTouches=[A[0].identifier,A[1].identifier],this._start([y[0],y[1]]))}touchmove(h,y,A){const D=this._firstTwoTouches;if(!D)return;h.preventDefault();const[F,z]=D,W=y2(A,y,F),J=y2(A,y,z);if(!W||!J)return;const ne=this._aroundCenter?null:W.add(J).div(2);return this._move([W,J],ne,h)}touchend(h,y,A){if(!this._firstTwoTouches)return;const[D,F]=this._firstTwoTouches,z=y2(A,y,D),W=y2(A,y,F);z&&W||(this._active&&q(),this.reset())}touchcancel(){this.reset()}enable(h){this._enabled=!0,this._aroundCenter=!!h&&h.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function y2(T,h,y){for(let A=0;AMath.abs(T.x)}class Gme extends D3{constructor(h){super(),this._map=h}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(h){this._lastPoints=h,O3(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,y,A){const D=this._lastPoints;if(!D)return;const F=h[0].sub(D[0]),z=h[1].sub(D[1]);return this._map._cooperativeGestures&&!i.eU()&&A.touches.length<3||(this._valid=this.gestureBeginsVertically(F,z,A.timeStamp),!this._valid)?void 0:(this._lastPoints=h,this._active=!0,{pitchDelta:(F.y+z.y)/2*-.5})}gestureBeginsVertically(h,y,A){if(this._valid!==void 0)return this._valid;const D=h.mag()>=2,F=y.mag()>=2;if(!D&&!F)return;if(!D||!F)return this._firstMove==null&&(this._firstMove=A),A-this._firstMove<100&&void 0;const z=h.y>0==y.y>0;return O3(h)&&O3(y)&&z}}const Kme={panStep:100,bearingStep:15,pitchStep:10};class Zme{constructor(){const h=Kme;this._panStep=h.panStep,this._bearingStep=h.bearingStep,this._pitchStep=h.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(h){if(h.altKey||h.ctrlKey||h.metaKey)return;let y=0,A=0,D=0,F=0,z=0;switch(h.keyCode){case 61:case 107:case 171:case 187:y=1;break;case 189:case 109:case 173:y=-1;break;case 37:h.shiftKey?A=-1:(h.preventDefault(),F=-1);break;case 39:h.shiftKey?A=1:(h.preventDefault(),F=1);break;case 38:h.shiftKey?D=1:(h.preventDefault(),z=-1);break;case 40:h.shiftKey?D=-1:(h.preventDefault(),z=1);break;default:return}return this._rotationDisabled&&(A=0,D=0),{cameraAnimation:W=>{const J=W.getZoom();W.easeTo({duration:300,easeId:"keyboardHandler",easing:v2,zoom:y?Math.round(J)+y*(h.shiftKey?2:1):J,bearing:W.getBearing()+A*this._bearingStep,pitch:W.getPitch()+D*this._pitchStep,offset:[-F*this._panStep,-z*this._panStep],center:W.getCenter()},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function v2(T){return T*(2-T)}const R6=4.000244140625,F6=1/450;class R3{constructor(h,y){this._map=h,this._el=h.getCanvasContainer(),this._handler=y,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=F6,i.aY(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(h){this._defaultZoomRate=h}setWheelZoomRate(h){this._wheelZoomRate=h}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(h){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!h&&h.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(h){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(h.ctrlKey||h.metaKey||this.isZooming()||i.eU()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let y=h.deltaMode===WheelEvent.DOM_DELTA_LINE?40*h.deltaY:h.deltaY;const A=i.o.now(),D=A-(this._lastWheelEventTime||0);this._lastWheelEventTime=A,y!==0&&y%R6==0?this._type="wheel":y!==0&&Math.abs(y)<4?this._type="trackpad":D>400?(this._type=null,this._lastValue=y,this._timeout=window.setTimeout(this._onTimeout,40,h)):this._type||(this._type=Math.abs(D*y)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,y+=this._lastValue)),h.shiftKey&&y&&(y/=4),this._type&&(this._lastWheelEvent=h,this._delta-=y,this._active||this._start(h)),h.preventDefault()}_onTimeout(h){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(h)}_start(h){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const y=U(this._el,h);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:y,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const h=this._map.transform;this._type==="wheel"&&h.projection.wrap&&(h._center.lng>=180||h._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const y=()=>h._terrainEnabled()&&this._aroundCoord?h.computeZoomRelativeTo(this._aroundCoord):h.zoom;if(this._delta!==0){const ne=this._type==="wheel"&&Math.abs(this._delta)>R6?this._wheelZoomRate:this._defaultZoomRate;let le=2/(1+Math.exp(-Math.abs(this._delta*ne)));this._delta<0&&le!==0&&(le=1/le);const je=y(),ve=Math.pow(2,je),Ne=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):ve;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(Ne*le))),this._type==="wheel"&&(this._startZoom=je,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const A=typeof this._targetZoom=="number"?this._targetZoom:y(),D=this._startZoom,F=this._easing;let z,W=!1;if(this._type==="wheel"&&D&&F){const ne=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),le=F(ne);z=i.ak(D,A,le),ne<1?this._frameId||(this._frameId=!0):W=!0}else z=A,W=!0;this._active=!0,W&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let J=z-y();return J*this._lastDelta<0&&(J=0),{noInertia:!0,needsRenderFrame:!W,zoomDelta:J,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let y=i.eV;if(this._prevEase){const A=this._prevEase,D=(i.o.now()-A.start)/A.duration,F=A.easing(D+.01)-A.easing(D),z=.27/Math.sqrt(F*F+1e-4)*.01,W=Math.sqrt(.0729-z*z);y=i.eT(z,W,.25,1)}return this._prevEase={start:i.o.now(),duration:h,easing:y},y}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=j("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class cg{constructor(h,y){this._clickZoom=h,this._tapZoom=y}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 F3{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(h,y){return h.preventDefault(),{cameraAnimation:A=>{A.easeTo({duration:300,zoom:A.getZoom()+(h.shiftKey?-1:1),around:A.unproject(y)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ql{constructor(){this._tap=new I3({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(h,y,A){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?A.length>0&&(this._swipePoint=y[0],this._swipeTouch=A[0].identifier):this._tap.touchstart(h,y,A))}touchmove(h,y,A){if(this._tapTime){if(this._swipePoint){if(A[0].identifier!==this._swipeTouch)return;const D=y[0],F=D.y-this._swipePoint.y;return this._swipePoint=D,h.preventDefault(),this._active=!0,{zoomDelta:F/128}}}else this._tap.touchmove(h,y,A)}touchend(h,y,A){this._tapTime?this._swipePoint&&A.length===0&&this.reset():this._tap.touchend(h,y,A)&&(this._tapTime=h.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Gf{constructor(h,y,A){this._el=h,this._mousePan=y,this._touchPan=A}enable(h){this._inertiaOptions=h||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class b2{constructor(h,y,A){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=y,this._mousePitch=A}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class z3{constructor(h,y,A,D){this._el=h,this._touchZoom=y,this._touchRotate=A,this._tapDragZoom=D,this._rotationDisabled=!1,this._enabled=!0}enable(h){this._touchZoom.enable(h),this._rotationDisabled||this._touchRotate.enable(h),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const _2=T=>T.zoom||T.drag||T.pitch||T.rotate;class Yme extends i.z{}class w2{constructor(){this.constants=[1,1,.01],this.radius=0}setup(h,y){const A=i.av([],y,h);this.radius=i.ag(A[2]<0?i.eX([],A,this.constants):[A[0],A[1],0])}projectRay(h){i.eX(h,h,this.constants),i.aw(h,h),i.eY(h,h,this.constants);const y=i.c5([],h,this.radius);if(y[2]>0){const A=i.c5([],[0,0,1],i.bJ(y,[0,0,1])),D=i.c5([],i.aw([],[y[0],y[1],0]),this.radius),F=i.d8([],y,i.c5([],i.av([],i.d8([],D,A),y),2));y[0]=F[0],y[1]=F[1]}return y}}function B3(T){return T.panDelta&&T.panDelta.mag()||T.zoomDelta||T.bearingDelta||T.pitchDelta}class Xme{constructor(h,y){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new E6(h),this._bearingSnap=y.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new w2,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(y),i.aY(["handleEvent","handleWindowEvent"],this);const A=this._el;this._listeners=[[A,"touchstart",{passive:!0}],[A,"touchmove",{passive:!1}],[A,"touchend",void 0],[A,"touchcancel",void 0],[A,"mousedown",void 0],[A,"mousemove",void 0],[A,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[A,"mouseover",void 0],[A,"mouseout",void 0],[A,"dblclick",void 0],[A,"click",void 0],[A,"keydown",{capture:!1}],[A,"keyup",void 0],[A,"wheel",{passive:!1}],[A,"contextmenu",void 0],[window,"blur",void 0]];for(const[D,F,z]of this._listeners){const W=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(F,W,z)}}destroy(){for(const[h,y,A]of this._listeners){const D=h===document?this.handleWindowEvent:this.handleEvent;h.removeEventListener(y,D,A)}}_addDefaultHandlers(h){const y=this._map,A=y.getCanvasContainer();this._add("mapEvent",new A3(y,h));const D=y.boxZoom=new E3(y,h);this._add("boxZoom",D);const F=new vF,z=new F3;y.doubleClickZoom=new cg(z,F),this._add("tapZoom",F),this._add("clickZoom",z);const W=new ql;this._add("tapDragZoom",W);const J=y.touchPitch=new Gme(y);this._add("touchPitch",J);const ne=new D6(h),le=new O6(h);y.dragRotate=new b2(h,ne,le),this._add("mouseRotate",ne,["mousePitch"]),this._add("mousePitch",le,["mouseRotate"]);const je=new _F(h),ve=new wF(y,h);y.dragPan=new Gf(A,je,ve),this._add("mousePan",je),this._add("touchPan",ve,["touchZoom","touchRotate"]);const Ne=new bo,De=new Wme;y.touchZoomRotate=new z3(A,De,Ne,W),this._add("touchRotate",Ne,["touchPan","touchZoom"]),this._add("touchZoom",De,["touchPan","touchRotate"]),this._add("blockableMapEvent",new I6(y));const Pe=y.scrollZoom=new R3(y,this);this._add("scrollZoom",Pe,["mousePan"]);const Ge=y.keyboard=new Zme;this._add("keyboard",Ge);for(const Ve of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Ve]&&y[Ve].enable(h[Ve])}_add(h,y,A){this._handlers.push({handlerName:h,handler:y,allowed:A}),this._handlersById[h]=y}stop(h){if(!this._updatingCamera){for(const{handler:y}of this._handlers)y.reset();this._inertia.clear(),this._fireEvents({},{},h),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:h}of this._handlers)if(h.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!_2(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(h,y,A){for(const D in h)if(D!==A&&(!y||y.indexOf(D)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const y=[];for(const A of h)this._el.contains(A.target)&&y.push(A);return y}handleEvent(h,y){this._updatingCamera=!0;const A=h.type==="renderFrame",D=A?void 0:h,F={needsRenderFrame:!1},z={},W={},J=h.touches?this._getMapTouches(h.touches):void 0,ne=J?B(this._el,J):A?void 0:U(this._el,h);for(const{handlerName:ve,handler:Ne,allowed:De}of this._handlers){if(!Ne.isEnabled())continue;let Pe;this._blockedByActive(W,De,ve)?Ne.reset():Ne[y||h.type]&&(Pe=Ne[y||h.type](h,ne,J),this.mergeHandlerResult(F,z,Pe,ve,D),Pe&&Pe.needsRenderFrame&&this._triggerRenderFrame()),(Pe||Ne.isActive())&&(W[ve]=Ne)}const le={};for(const ve in this._previousActiveHandlers)W[ve]||(le[ve]=D);this._previousActiveHandlers=W,(Object.keys(le).length||B3(F))&&(this._changes.push([F,z,le]),this._triggerRenderFrame()),(Object.keys(W).length||B3(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:je}=F;je&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],je(this._map))}mergeHandlerResult(h,y,A,D,F){if(!A)return;Object.assign(h,A);const z={handlerName:D,originalEvent:A.originalEvent||F};A.zoomDelta!==void 0&&(y.zoom=z),A.panDelta!==void 0&&(y.drag=z),A.pitchDelta!==void 0&&(y.pitch=z),A.bearingDelta!==void 0&&(y.rotate=z)}_applyChanges(){const h={},y={},A={};for(const[D,F,z]of this._changes)D.panDelta&&(h.panDelta=(h.panDelta||new i.P(0,0))._add(D.panDelta)),D.zoomDelta&&(h.zoomDelta=(h.zoomDelta||0)+D.zoomDelta),D.bearingDelta&&(h.bearingDelta=(h.bearingDelta||0)+D.bearingDelta),D.pitchDelta&&(h.pitchDelta=(h.pitchDelta||0)+D.pitchDelta),D.around!==void 0&&(h.around=D.around),D.aroundCoord!==void 0&&(h.aroundCoord=D.aroundCoord),D.pinchAround!==void 0&&(h.pinchAround=D.pinchAround),D.noInertia&&(h.noInertia=D.noInertia),Object.assign(y,F),Object.assign(A,z);this._updateMapTransform(h,y,A),this._changes=[]}_updateMapTransform(h,y,A){const D=this._map,F=D.transform,z=nt=>[nt.x,nt.y,nt.z];if((nt=>{const ut=this._eventsInProgress.drag;return ut&&!this._handlersById[ut.handlerName].isActive()})()&&!B3(h)){const nt=F.zoom;F.cameraElevationReference="sea",this._originalZoom!=null&&F._orthographicProjectionAtLowPitch&&F.projection.name!=="globe"&&F.pitch===0?(F.cameraElevationReference="ground",F.zoom=this._originalZoom):(F.recenterOnTerrain(),F.cameraElevationReference="ground"),nt!==F.zoom&&this._map._update(!0)}if(F._isCameraConstrained&&D._stop(!0),!B3(h))return void this._fireEvents(y,A,!0);let{panDelta:W,zoomDelta:J,bearingDelta:ne,pitchDelta:le,around:je,aroundCoord:ve,pinchAround:Ne}=h;F._isCameraConstrained&&(J>0&&(J=0),F._isCameraConstrained=!1),Ne!==void 0&&(je=Ne),(J||(nt=>y[nt]&&!this._eventsInProgress[nt])("drag"))&&je&&(this._dragOrigin=z(F.pointCoordinate3D(je)),this._originalZoom=F.zoom,this._trackingEllipsoid.setup(F._camera.position,this._dragOrigin)),F.cameraElevationReference="sea",D._stop(!0),je=je||D.transform.centerPoint,ne&&(F.bearing+=ne),le&&(F.pitch+=le),F._updateCameraState();const De=[0,0,0];if(W)if(F.projection.name==="mercator"){const nt=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(je).dir),ut=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(je.sub(W)).dir);De[0]=ut[0]-nt[0],De[1]=ut[1]-nt[1]}else{const nt=F.pointCoordinate(je);if(F.projection.name==="globe"){W=W.rotate(-F.angle);const ut=F._pixelsPerMercatorPixel/F.worldSize;De[0]=-W.x*i.eW(i.a$(nt.y))*ut,De[1]=-W.y*i.eW(F.center.lat)*ut}else{const ut=F.pointCoordinate(je.sub(W));nt&&ut&&(De[0]=ut.x-nt.x,De[1]=ut.y-nt.y)}}const Pe=F.zoom,Ge=[0,0,0];if(J){const nt=z(ve||F.pointCoordinate3D(je)),ut={dir:i.aw([],i.av([],nt,F._camera.position))};if(ut.dir[2]<0){const ot=F.zoomDeltaToMovement(nt,J);i.c5(Ge,ut.dir,ot)}}const Ve=i.d8(De,De,Ge);F._translateCameraConstrained(Ve),J&&Math.abs(F.zoom-Pe)>1e-4&&F.recenterOnTerrain(),F.cameraElevationReference="ground",this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(y,A,!0)}_fireEvents(h,y,A){const D=_2(this._eventsInProgress),F=_2(h),z={};for(const le in h){const{originalEvent:je}=h[le];this._eventsInProgress[le]||(z[`${le}start`]=je),this._eventsInProgress[le]=h[le]}!D&&F&&this._fireEvent("movestart",F.originalEvent);for(const le in z)this._fireEvent(le,z[le]);F&&this._fireEvent("move",F.originalEvent);for(const le in h){const{originalEvent:je}=h[le];this._fireEvent(le,je)}const W={};let J;for(const le in this._eventsInProgress){const{handlerName:je,originalEvent:ve}=this._eventsInProgress[le];this._handlersById[je].isActive()||(delete this._eventsInProgress[le],J=y[je]||ve,W[`${le}end`]=J)}for(const le in W)this._fireEvent(le,W[le]);const ne=_2(this._eventsInProgress);if(A&&(D||F)&&!ne){this._updatingCamera=!0;const le=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),je=ve=>ve!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Yme("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const $3="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class z6 extends i.E{constructor(h,y){super(),this._moving=!1,this._zooming=!1,this.transform=h,this._bearingSnap=y.bearingSnap,this._respectPrefersReducedMotion=y.respectPrefersReducedMotion!==!1,i.aY(["_renderFrameCallback"],this)}getCenter(){return new i.aT(this.transform.center.lng,this.transform.center.lat)}setCenter(h,y){return this.jumpTo({center:h},y)}panBy(h,y,A){return h=i.P.convert(h).mult(-1),this.panTo(this.transform.center,Object.assign({offset:h},y),A)}panTo(h,y,A){return this.easeTo(Object.assign({center:h},y),A)}getZoom(){return this.transform.zoom}setZoom(h,y){return this.jumpTo({zoom:h},y),this}zoomTo(h,y,A){return this.easeTo(Object.assign({zoom:h},y),A)}zoomIn(h,y){return this.zoomTo(this.getZoom()+1,h,y),this}zoomOut(h,y){return this.zoomTo(this.getZoom()-1,h,y),this}getBearing(){return this.transform.bearing}setBearing(h,y){return this.jumpTo({bearing:h},y),this}getPadding(){return this.transform.padding}setPadding(h,y){return this.jumpTo({padding:h},y),this}rotateTo(h,y,A){return this.easeTo(Object.assign({bearing:h},y),A)}resetNorth(h,y){return this.rotateTo(0,Object.assign({duration:1e3},h),y),this}resetNorthPitch(h,y){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},h),y),this}snapToNorth(h,y){return Math.abs(this.getBearing())h.aspect?A/(2*Math.tan(.5*h.fovX)*h.aspect):D/(2*Math.tan(.5*h.fovY)*h.aspect)}_cameraForBoundsOnGlobe(h,y,A,D,F,z){const W=h.clone(),J=this._extendCameraOptions(z);W.bearing=D,W.pitch=F;const ne=i.aT.convert(y),le=i.aT.convert(A),je=.5*(ne.lat+le.lat),ve=.5*(ne.lng+le.lng),Ne=i.eZ(je,ve),De=i.aw([],Ne),Pe=i.aw([],i.bI([],De,[0,1,0])),Ge=i.bI([],Pe,De),Ve=[Pe[0],Pe[1],Pe[2],0,Ge[0],Ge[1],Ge[2],0,De[0],De[1],De[2],0,0,0,0,1],nt=[Ne,i.eZ(ne.lat,ne.lng),i.eZ(le.lat,ne.lng),i.eZ(le.lat,le.lng),i.eZ(ne.lat,le.lng),i.eZ(je,ne.lng),i.eZ(je,le.lng),i.eZ(ne.lat,ve),i.eZ(le.lat,ve)];let ut=i.d9.fromPoints(nt.map(Jt=>[i.bJ(Pe,Jt),i.bJ(Ge,Jt),i.bJ(De,Jt)]));const ot=i.af([],ut.center,Ve);i.e_(ot)===0&&i.e$(ot,0,0,1),i.aw(ot,ot),i.c5(ot,ot,i.aD),W.center=i.f0(ot);const Et=W.getWorldToCameraMatrix(),Nt=i.bl(new Float64Array(16),Et);ut=i.d9.applyTransform(ut,i.aB([],Et,Ve));const Tt=this._extendAABB(ut,W,J,D);if(!Tt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ut=Tt,i.af(ot,ot,Et);const wt=.5*(ut.max[2]-ut.min[2]),yt=this._minimumAABBFrustumDistance(W,ut),Ot=i.c5([],[0,0,1],wt),Wt=i.d8(Ot,ot,Ot),Ht=yt+(W.pitch===0?0:i.bG(ot,Wt)),es=W.globeCenterInViewSpace,ts=i.av([],ot,[es[0],es[1],es[2]]);i.aw(ts,ts),i.c5(ts,ts,Ht);const xs=i.d8([],ot,ts);i.af(xs,xs,Nt);const qs=i.eM/i.aD,Yt=i.ag(xs),Bt=i.cf(Math.max(Yt*qs-i.eM,Number.EPSILON),0),as=Math.min(W.zoomFromMercatorZAdjusted(Bt),J.maxZoom);return as>.5*(i.c_+i.cL)?(W.setProjection({name:"mercator"}),W.zoom=as,this._cameraForBounds(W,y,A,D,F,z)):{center:W.center,zoom:as,bearing:D,pitch:F}}_extendAABB(h,y,A,D){const F=.5*((A.padding.left||0)+(A.padding.right||0)),z=.5*((A.padding.top||0)+(A.padding.bottom||0)),W=z,J=F,ne=F,le=z,je=y.width-(J+ne),ve=y.height-(W+le),Ne=i.av([],h.max,h.min),De=Math.min(je/Ne[0],ve/Ne[1]),Pe=Math.min(y.scaleZoom(y.scale*De),A.maxZoom);if(isNaN(Pe))return null;const Ge=y.scale/y.zoomScale(Pe),Ve=new i.d9([h.min[0]-J*Ge,h.min[1]-le*Ge,h.min[2]],[h.max[0]+ne*Ge,h.max[1]+W*Ge,h.max[2]]),nt=(typeof A.offset.x=="number"&&typeof A.offset.y=="number"?new i.P(A.offset.x,A.offset.y):i.P.convert(A.offset)).rotate(-i.an(D));return Ve.center[0]-=nt.x*Ge,Ve.center[1]+=nt.y*Ge,Ve}queryTerrainElevation(h,y){const A=this.transform.elevation;return A?(y=Object.assign({},{exaggerated:!0},y),A.getAtPoint(i.ae.fromLngLat(h),null,y.exaggerated)):null}_cameraForBounds(h,y,A,D,F,z){if(h.projection.name==="globe")return this._cameraForBoundsOnGlobe(h,y,A,D,F,z);const W=h.clone(),J=this._extendCameraOptions(z);W.bearing=D,W.pitch=F;const ne=i.aT.convert(y),le=i.aT.convert(A),je=new i.aT(ne.lng,le.lat),ve=new i.aT(le.lng,ne.lat),Ne=W.project(ne),De=W.project(le),Pe=this.queryTerrainElevation(ne),Ge=this.queryTerrainElevation(le),Ve=this.queryTerrainElevation(je),nt=this.queryTerrainElevation(ve),ut=[[Ne.x,Ne.y,Math.min(Pe||0,Ge||0,Ve||0,nt||0)],[De.x,De.y,Math.max(Pe||0,Ge||0,Ve||0,nt||0)]];let ot=i.d9.fromPoints(ut);const Et=W.getWorldToCameraMatrix(),Nt=i.bl(new Float64Array(16),Et);ot=i.d9.applyTransform(ot,Et);const Tt=this._extendAABB(ot,W,J,D);if(!Tt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ot=Tt;const wt=.5*i.av([],ot.max,ot.min)[2],yt=this._minimumAABBFrustumDistance(W,ot),Ot=[0,0,1,0];i.aC(Ot,Ot,Et),i.f1(Ot,Ot);const Wt=i.c5([],Ot,yt+wt),Ht=i.d8([],ot.center,Wt);i.af(ot.center,ot.center,Nt),i.af(Ht,Ht,Nt);const es=W.unproject(new i.P(ot.center[0],ot.center[1])),ts=i.f2(W.projection,es),xs=Math.pow(2,ts),qs=Math.min(W._zoomFromMercatorZ(Ht[2]*W.pixelsPerMeter*xs/W.worldSize),J.maxZoom);return W.mercatorFromTransition&&qs<.5*(i.c_+i.cL)?(W.setProjection({name:"globe"}),W.zoom=qs,this._cameraForBounds(W,y,A,D,F,z)):{center:es,zoom:qs,bearing:D,pitch:F}}fitBounds(h,y,A){const D=this.cameraForBounds(h,y);return this._fitInternal(D,y,A)}fitScreenCoordinates(h,y,A,D,F){const z=i.P.convert(h),W=i.P.convert(y),J=new i.P(Math.min(z.x,W.x),Math.min(z.y,W.y)),ne=new i.P(Math.max(z.x,W.x),Math.max(z.y,W.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(z,W))return this;const le=this.transform.pointLocation3D(J),je=this.transform.pointLocation3D(ne),ve=this.transform.pointLocation3D(new i.P(J.x,ne.y)),Ne=this.transform.pointLocation3D(new i.P(ne.x,J.y)),De=[Math.min(le.lng,je.lng,ve.lng,Ne.lng),Math.min(le.lat,je.lat,ve.lat,Ne.lat)],Pe=[Math.max(le.lng,je.lng,ve.lng,Ne.lng),Math.max(le.lat,je.lat,ve.lat,Ne.lat)],Ge=D&&D.pitch?D.pitch:this.getPitch(),Ve=this._cameraForBounds(this.transform,De,Pe,A,Ge,D);return this._fitInternal(Ve,D,F)}_fitInternal(h,y,A){return h?(y=Object.assign(h,y)).linear?this.easeTo(y,A):this.flyTo(y,A):this}jumpTo(h,y){this.stop();const A=h.preloadOnly?this.transform.clone():this.transform;let D=!1,F=!1,z=!1;"zoom"in h&&A.zoom!==+h.zoom&&(D=!0,A.zoom=+h.zoom),h.center!==void 0&&(A.center=i.aT.convert(h.center)),"bearing"in h&&A.bearing!==+h.bearing&&(F=!0,A.bearing=+h.bearing),"pitch"in h&&A.pitch!==+h.pitch&&(z=!0,A.pitch=+h.pitch);const W=typeof h.padding=="number"?this._extendPadding(h.padding):h.padding;if(h.padding!=null&&!A.isPaddingEqual(W))if(h.retainPadding===!1){const J=A.clone();J.padding=W,A.setLocationAtPoint(A.center,J.centerPoint)}else A.padding=W;return h.preloadOnly?(this._preloadTiles(A),this):(this.fire(new i.z("movestart",y)).fire(new i.z("move",y)),D&&this.fire(new i.z("zoomstart",y)).fire(new i.z("zoom",y)).fire(new i.z("zoomend",y)),F&&this.fire(new i.z("rotatestart",y)).fire(new i.z("rotate",y)).fire(new i.z("rotateend",y)),z&&this.fire(new i.z("pitchstart",y)).fire(new i.z("pitch",y)).fire(new i.z("pitchend",y)),this.fire(new i.z("moveend",y)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.w($3),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,y){const A=this.transform;if(!A.projection.supportsFreeCamera)return i.w($3),this;this.stop();const D=A.zoom,F=A.pitch,z=A.bearing;A.setFreeCameraOptions(h);const W=D!==A.zoom,J=F!==A.pitch,ne=z!==A.bearing;return this.fire(new i.z("movestart",y)).fire(new i.z("move",y)),W&&this.fire(new i.z("zoomstart",y)).fire(new i.z("zoom",y)).fire(new i.z("zoomend",y)),ne&&this.fire(new i.z("rotatestart",y)).fire(new i.z("rotate",y)).fire(new i.z("rotateend",y)),J&&this.fire(new i.z("pitchstart",y)).fire(new i.z("pitch",y)).fire(new i.z("pitchend",y)),this.fire(new i.z("moveend",y)),this}easeTo(h,y){this._stop(!1,h.easeId),((h=Object.assign({offset:[0,0],duration:500,easing:i.eV},h)).animate===!1||this._prefersReducedMotion(h))&&(h.duration=0);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),W=this.getPadding(),J="zoom"in h?+h.zoom:D,ne="bearing"in h?this._normalizeBearing(h.bearing,F):F,le="pitch"in h?+h.pitch:z,je=this._extendPadding(h.padding),ve=i.P.convert(h.offset);let Ne,De,Pe;if(A.projection.name==="globe"){const Ot=i.ae.fromLngLat(A.center),Wt=ve.rotate(-A.angle);Ot.x+=Wt.x/A.worldSize,Ot.y+=Wt.y/A.worldSize;const Ht=Ot.toLngLat(),es=i.aT.convert(h.center||Ht);this._normalizeCenter(es),Ne=A.centerPoint.add(Wt),De=new i.P(Ot.x,Ot.y).mult(A.worldSize),Pe=new i.P(i.aF(es.lng),i.aJ(es.lat)).mult(A.worldSize).sub(De)}else{Ne=A.centerPoint.add(ve);const Ot=A.pointLocation(Ne),Wt=i.aT.convert(h.center||Ot);this._normalizeCenter(Wt),De=A.project(Ot),Pe=A.project(Wt).sub(De)}const Ge=A.zoomScale(J-D);let Ve,nt;h.around&&(Ve=i.aT.convert(h.around),nt=A.locationPoint(Ve));const ut=this._zooming||J!==D,ot=this._rotating||F!==ne,Et=this._pitching||le!==z,Nt=!A.isPaddingEqual(je),Tt=h.retainPadding===!1?A.clone():A,wt=Ot=>Wt=>{if(ut&&(Ot.zoom=i.ak(D,J,Wt)),ot&&(Ot.bearing=i.ak(F,ne,Wt)),Et&&(Ot.pitch=i.ak(z,le,Wt)),Nt&&(Tt.interpolatePadding(W,je,Wt),Ne=Tt.centerPoint.add(ve)),Ve)Ot.setLocationAtPoint(Ve,nt);else{const Ht=Ot.zoomScale(Ot.zoom-D),es=J>D?Math.min(2,Ge):Math.max(.5,Ge),ts=Math.pow(es,1-Wt),xs=Ot.unproject(De.add(Pe.mult(Wt*ts)).mult(Ht));Ot.setLocationAtPoint(Ot.renderWorldCopies?xs.wrap():xs,Ne)}return h.preloadOnly||this._fireMoveEvents(y),Ot};if(h.preloadOnly){const Ot=this._emulate(wt,h.duration,A);return this._preloadTiles(Ot),this}const yt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ut,this._rotating=ot,this._pitching=Et,this._padding=Nt,this._easeId=h.easeId,this._prepareEase(y,h.noMoveStart,yt),this._ease(wt(A),Ot=>{A.cameraElevationReference==="sea"&&A.recenterOnTerrain(),this._afterEase(y,Ot)},h),this}_prepareEase(h,y,A={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),y||A.moving||this.fire(new i.z("movestart",h)),this._zooming&&!A.zooming&&this.fire(new i.z("zoomstart",h)),this._rotating&&!A.rotating&&this.fire(new i.z("rotatestart",h)),this._pitching&&!A.pitching&&this.fire(new i.z("pitchstart",h))}_fireMoveEvents(h){this.fire(new i.z("move",h)),this._zooming&&this.fire(new i.z("zoom",h)),this._rotating&&this.fire(new i.z("rotate",h)),this._pitching&&this.fire(new i.z("pitch",h))}_afterEase(h,y){if(this._easeId&&y&&this._easeId===y)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const A=this._zooming,D=this._rotating,F=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,A&&this.fire(new i.z("zoomend",h)),D&&this.fire(new i.z("rotateend",h)),F&&this.fire(new i.z("pitchend",h)),this.fire(new i.z("moveend",h))}flyTo(h,y){if(this._prefersReducedMotion(h)){const Jt=i.aH(h,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Jt,y)}this.stop(),h=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eV},h);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),W=this.getPadding(),J="zoom"in h?i.aA(+h.zoom,A.minZoom,A.maxZoom):D,ne="bearing"in h?this._normalizeBearing(h.bearing,F):F,le="pitch"in h?+h.pitch:z,je=this._extendPadding(h.padding),ve=A.zoomScale(J-D),Ne=i.P.convert(h.offset);let De=A.centerPoint.add(Ne);const Pe=A.pointLocation(De),Ge=i.aT.convert(h.center||Pe);this._normalizeCenter(Ge);const Ve=A.project(Pe),nt=A.project(Ge).sub(Ve);let ut=h.curve;const ot=Math.max(A.width,A.height),Et=ot/ve,Nt=nt.mag();if("minZoom"in h){const Jt=i.aA(Math.min(h.minZoom,D,J),A.minZoom,A.maxZoom),Is=ot/A.zoomScale(Jt-D);ut=Math.sqrt(Is/Nt*2)}const Tt=ut*ut;function wt(Jt){const Is=(Et*Et-ot*ot+(Jt?-1:1)*Tt*Tt*Nt*Nt)/(2*(Jt?Et:ot)*Tt*Nt);return Math.log(Math.sqrt(Is*Is+1)-Is)}function yt(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function Ot(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const Wt=wt(0);let Ht=function(Jt){return Ot(Wt)/Ot(Wt+ut*Jt)},es=function(Jt){return ot*((Ot(Wt)*(yt(Is=Wt+ut*Jt)/Ot(Is))-yt(Wt))/Tt)/Nt;var Is},ts=(wt(1)-Wt)/ut;if(Math.abs(Nt)<1e-6||!isFinite(ts)){if(Math.abs(ot-Et)<1e-6)return this.easeTo(h,y);const Jt=Eth.maxDuration&&(h.duration=0);const xs=F!==ne,qs=le!==z,Yt=!A.isPaddingEqual(je),Bt=h.retainPadding===!1?A.clone():A,as=Jt=>Is=>{const rr=Is*ts,yr=1/Ht(rr);Jt.zoom=Is===1?J:D+Jt.scaleZoom(yr),xs&&(Jt.bearing=i.ak(F,ne,Is)),qs&&(Jt.pitch=i.ak(z,le,Is)),Yt&&(Bt.interpolatePadding(W,je,Is),De=Bt.centerPoint.add(Ne));const Js=Is===1?Ge:Jt.unproject(Ve.add(nt.mult(es(rr))).mult(yr));return Jt.setLocationAtPoint(Jt.renderWorldCopies?Js.wrap():Js,De),Jt._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(y),Jt};if(h.preloadOnly){const Jt=this._emulate(as,h.duration,A);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=xs,this._pitching=qs,this._padding=Yt,this._prepareEase(y,!1),this._ease(as(A),()=>this._afterEase(y),h),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(h){}_cancelRenderFrame(h){}_stop(h,y){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const A=this._onEaseEnd;this._onEaseEnd=void 0,A.call(this,y)}if(!h){const A=this.handlers;A&&A.stop(!1)}return this}_ease(h,y,A){A.animate===!1||A.duration===0?(h(1),y()):(this._easeStart=i.o.now(),this._easeOptions=A,this._onEaseFrame=h,this._onEaseEnd=y,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const h=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),y=this._onEaseFrame;y&&y(this._easeOptions.easing(h)),h<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(h,y){h=i.bT(h,-180,180);const A=Math.abs(h-y);return Math.abs(h-360-y)180?-360:A<-180?360:0}_prefersReducedMotion(h){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(h&&h.essential)}_emulate(h,y,A){const D=Math.ceil(15*y/1e3),F=[],z=h(A.clone());for(let W=0;W<=D;W++){const J=z(W/D);F.push(J.clone())}return F}_preloadTiles(h,y){}}class j2{constructor(h={}){this.options=h,i.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(h){const y=this.options&&this.options.compact,A=h._getUIString("AttributionControl.ToggleAttribution");this._map=h,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=j("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",A);const D=j("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",A),this._innerContainer=j("div","mapboxgl-ctrl-attrib-inner",this._container),y&&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),y===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let h=this._editLink;h||(h=this._editLink=this._container.querySelector(".mapbox-improve-map"));const y=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.e.ACCESS_TOKEN}];if(h){const A=y.reduce((D,F,z)=>(F.value&&(D+=`${F.key}=${F.value}${zD.length-F.length),h=h.filter((D,F)=>{for(let z=F+1;z=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?h=[...this.options.customAttribution,...h]:h.unshift(this.options.customAttribution));const A=h.map(D=>function(F){const z=new DOMParser().parseFromString(F,"text/html");return Array.from(z.body.querySelectorAll("*")).forEach(W=>{const J=W.textContent||"";if(W.tagName!=="A")return void W.replaceWith(z.createTextNode(J));const ne=W.getAttribute("href");if(!ne||!/^(https?:|mailto:)/i.test(ne))return void W.replaceWith(z.createTextNode(J));const le=z.createElement("a");le.href=ne,le.textContent=J,le.rel="noopener nofollow";const je=W.getAttribute("class");je&&(le.className=je),W.replaceWith(le)}),z.body.innerHTML}(D)).join(" | ");A!==this._attribHTML&&(this._attribHTML=A,h.length?(this._innerContainer.innerHTML=A,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class N2{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=j("div","mapboxgl-ctrl");const y=j("a","mapboxgl-ctrl-logo");return y.target="_blank",y.rel="noopener nofollow",y.href="https://www.mapbox.com/",y.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),y.setAttribute("rel","noopener nofollow"),this._container.appendChild(y),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(h){h&&h.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const h=this._map.style._sourceCaches;if(Object.entries(h).length===0)return!0;for(const y in h){const A=h[y].getSource();if(A.hasOwnProperty("mapbox_logo")&&!A.mapbox_logo)return!1}return!0}_updateCompact(){const h=this._container.children;if(h.length){const y=h[0];this._map.getCanvasContainer().offsetWidth<250?y.classList.add("mapboxgl-compact"):y.classList.remove("mapboxgl-compact")}}}class gb{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",y=>this._onIndoorUpdate(y)),this._container}_createButton(h,y){const A=j("button",h,this._container);return A.type="button",A.addEventListener("click",y),A}_createSeparator(){return j("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(h,y){this._map&&(h.setAttribute("aria-label",y),h.textContent=y)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(h){if(!h||!h.floors)return this._model=h,void(this._container.style.display="none");const y=this._model;this._model=h,this._container.style.display="inline-block",this._container.style.borderRadius="8px",y&&Array.from(this._container.children).forEach(A=>A.remove()),h.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(h.floors,h.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const h=this._createButton("mapboxgl-ctrl-buildings-toggle",()=>{const y=this._map;this._model&&y&&y._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});j("span","mapboxgl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&h.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(h),this._createSeparator()}_updateBuildingsButtonState(){const h=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");h&&this._model&&(this._model.activeFloorsVisible?h.classList.remove("mapboxgl-ctrl-level-button-selected"):h.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(h,y){for(let A=0;A{this._map._selectIndoorFloor(D.id)});this._setButtonTitle(F,D.zIndex.toString()),this._model&&D.id===this._model.selectedFloorId&&y&&F.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(F),A=this._endTime)return this._end;const y=i.dD((h-this._startTime)/(this._endTime-this._startTime));return this._start*(1-y)+this._end*y}isEasing(h){return h>=this._startTime&&h<=this._endTime}jumpTo(h){this._startTime=-1/0,this._endTime=-1/0,this._start=h,this._end=h}easeTo(h,y,A){this._start=this.getValue(y),this._end=h,this._startTime=y,this._endTime=y+A}}const hg={"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 Oy extends i.z{constructor(h,y,A,D){const{point:F,lngLat:z,originalEvent:W,target:J}=h;super(h.type,{point:F,lngLat:z,originalEvent:W,target:J}),this.preventDefault=()=>{h.preventDefault()},this.id=y,this.interaction=A,this.feature=D}}class qp{constructor(h){this.map=h,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(h,y){if(this.typeById.has(h))throw new Error(`Interaction id "${h}" already exists.`);const A=y.filter;let D=y.type;A&&this.filters.set(h,i.b6(A)),D==="mouseover"&&(D="mouseenter"),D==="mouseout"&&(D="mouseleave");const F=this.interactionsByType.get(D)||new Map;D==="mouseenter"||D==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(h,y)):F.size===0&&this.map.on(D,this.handleType),F.size===0&&this.interactionsByType.set(D,F),F.set(h,y),this.typeById.set(h,D)}get(h){const y=this.typeById.get(h);if(!y)return;const A=this.interactionsByType.get(y);return A?A.get(h):void 0}remove(h){const y=this.typeById.get(h);if(!y)return;this.typeById.delete(h),this.filters.delete(h);const A=this.interactionsByType.get(y);A&&(A.delete(h),y==="mouseenter"||y==="mouseleave"?(this.delegatedInteractions.delete(h),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):A.size===0&&this.map.off(y,this.handleType))}queryTargets(h,y){const A=[];for(const[D,F]of y)F.target&&A.push({targetId:D,target:F.target,filter:this.filters.get(D)});return this.map.style.queryRenderedTargets(h,A,this.map.transform)}handleMove(h){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const y=this.queryTargets(h.point,Array.from(this.delegatedInteractions).reverse());y.length&&(h.type="mouseenter",this.handleType(h,y));const A=new Map;for(const[D,{feature:F}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||A.set(F.id,F);A.size&&(h.type="mouseleave",this.handleType(h,Array.from(A.values())))}handleOut(h){const y=Array.from(this.hoveredFeatures.values()).map(({feature:A})=>A);y.length&&(h.type="mouseleave",this.handleType(h,y)),this.hoveredFeatures.clear()}handleType(h,y){const A=h.type==="mouseenter";if(A&&!this.interactionsByType.has(h.type))return void i.w("mouseenter interaction required for mouseleave to work.");const D=Array.from(this.interactionsByType.get(h.type)).reverse(),F=!!y;y=y||this.queryTargets(h.point,D);let z=!1;const W=new Set;for(const J of y){for(const[ne,le]of D){if(!le.target)continue;const je=J.variants?J.variants[ne]:null;if(je){for(const ve of je){if(vy(ve,J,W,ne))continue;const Ne=new i.dx(J,ve),De=Yx(ve,J,ne);F&&Ne.id!==void 0&&(Ne.state=this.map.getFeatureState(Ne));const Pe=A?this.prevHoveredFeatures.get(De):null,Ge=new Oy(h,ne,le,Ne),Ve=Pe?Pe.stop:le.handler(Ge);if(A&&this.hoveredFeatures.set(De,{feature:J,stop:Ve}),Ve!==!1){z=!0;break}}if(z)break}}if(z)break}if(!z)for(const[J,ne]of D){const{handler:le,target:je}=ne;if(!je&&le(new Oy(h,J,ne,null))!==!1)break}}}function Qme(T,h){if(Array.isArray(T)&&Array.isArray(h)){const y=new Set(T),A=new Set(h);return y.size===A.size&&T.every(D=>A.has(D))}return i.by(T,h)}const Jme={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"},epe={showCompass:!0,showZoom:!0,visualizePitch:!1};class tpe{constructor(h,y,A=!1){this._clickTolerance=10,this.element=y,this.mouseRotate=new D6({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,A&&(this.mousePitch=new O6({clickTolerance:h.dragRotate._mousePitch._clickTolerance})),i.aY(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),y.addEventListener("mousedown",this.mousedown),y.addEventListener("touchstart",this.touchstart,{passive:!1}),y.addEventListener("touchmove",this.touchmove),y.addEventListener("touchend",this.touchend),y.addEventListener("touchcancel",this.reset)}down(h,y){this.mouseRotate.mousedown(h,y),this.mousePitch&&this.mousePitch.mousedown(h,y),L()}move(h,y){const A=this.map,D=this.mouseRotate.mousemoveWindow(h,y),F=D&&D.bearingDelta;if(F&&A.setBearing(A.getBearing()+F),this.mousePitch){const z=this.mousePitch.mousemoveWindow(h,y),W=z&&z.pitchDelta;W&&A.setPitch(A.getPitch()+W)}}off(){const h=this.element;h.removeEventListener("mousedown",this.mousedown),h.removeEventListener("touchstart",this.touchstart),h.removeEventListener("touchmove",this.touchmove),h.removeEventListener("touchend",this.touchend),h.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){I(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(h){this.down(Object.assign({},h,{ctrlKey:!0,preventDefault:()=>h.preventDefault()}),U(this.element,h)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(h){this.move(h,U(this.element,h))}mouseup(h){this.mouseRotate.mouseupWindow(h),this.mousePitch&&this.mousePitch.mouseupWindow(h),this.offTemp()}touchstart(h){h.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=B(this.element,h.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>h.preventDefault()},this._startPos))}touchmove(h){h.targetTouches.length!==1?this.reset():(this._lastPos=B(this.element,h.targetTouches)[0],this.move({preventDefault:()=>h.preventDefault()},this._lastPos))}touchend(h){h.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)y.width||h.y>y.height;y.locationPoint3D(A).distSqr(h)180;){const A=y.locationPoint3D(T);if(A.x>=0&&A.y>=0&&A.x<=y.width&&A.y<=y.height)break;T.lng>y.center.lng?T.lng-=360:T.lng+=360}return T}const Ud={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%)"},sp={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class q3 extends i.E{constructor(h,y){super(),(h instanceof HTMLElement||y)&&(h=Object.assign({element:h},y)),i.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:A="center",color:D="#3FB1CE",scale:F=1,draggable:z=!1,clickTolerance:W=0,rotation:J=sp.rotation,rotationAlignment:ne=sp.rotationAlignment,pitchAlignment:le=sp.pitchAlignment,occludedOpacity:je=sp.occludedOpacity,altitude:ve=sp.altitude}=h||{};this._anchor=A,this._color=D,this._scale=F,this._draggable=z,this._clickTolerance=W,this._rotation=J,this._rotationAlignment=ne,this._pitchAlignment=le,this._occludedOpacity=je,this._altitude=ve,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),h&&h.element?(this._element=h.element,this._offset=i.P.convert(h&&h.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=i.P.convert(h&&h.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",Pe=>{Pe.preventDefault()}),this._element.addEventListener("mousedown",Pe=>{Pe.preventDefault()});const Ne=this._element.classList;for(const Pe in Ud)Ne.remove(`mapboxgl-marker-anchor-${Pe}`);Ne.add(`mapboxgl-marker-anchor-${this._anchor}`);const De=h&&h.className?h.className.trim().split(/\s+/):[];Ne.add(...De),this._popup=null}_createDefaultMarker(){const h=j("div"),y=w("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},h);if(this._altitude===0){const A=w("radialGradient",{id:"shadowGradient"},w("defs",{},y));w("stop",{offset:"10%","stop-opacity":.4},A),w("stop",{offset:"100%","stop-opacity":.05},A),w("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},y)}return w("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},y),w("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},y),w("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},y),h}addTo(h){return h===this._map||(this.remove(),this._map=h,h.getCanvasContainer().appendChild(this._element),h.on("move",this._updateMoving),h.on("moveend",this._update),h.on("remove",this._clearFadeTimer),h._addMarker(this),this.setDraggable(this._draggable),this._update(),h.on("click",this._onMapClick)),this}remove(){const h=this._map;return h&&(h.off("click",this._onMapClick),h.off("move",this._updateMoving),h.off("moveend",this._update),h.off("mousedown",this._addDragHandler),h.off("touchstart",this._addDragHandler),h.off("mouseup",this._onUp),h.off("touchend",this._onUp),h.off("mousemove",this._onMove),h.off("touchmove",this._onMove),h.off("remove",this._clearFadeTimer),h._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=i.aT.convert(h),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(h){return h===this._altitude||(this._defaultMarker&&(this._altitude===0&&h!==0||this._altitude!==0&&h===0)&&(this._element=this._createDefaultMarker()),this._altitude=h||sp.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(h){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),h){if(!("offset"in h.options)){const D=Math.sqrt(Math.pow(13.5,2)/2);h.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[D,-1*(38.1-13.5+D)],"bottom-right":[-D,-1*(38.1-13.5+D)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=h,h._marker=this,h._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(h){const y=h.code,A=h.charCode||h.keyCode;y!=="Space"&&y!=="Enter"&&A!==32&&A!==13||this.togglePopup()}_onMapClick(h){const y=h.originalEvent.target,A=this._element;this._popup&&(y===A||A.contains(y))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const h=this._popup;return h?(h.isOpen()?(h.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(h.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const h=this._map,y=this._pos;if(!h||!y)return!1;const A=h.unproject(y,this._altitude),D=h.getFreeCameraOptions();if(!D.position)return!1;const F=D.position.toLngLat();return F.distanceTo(A)<.9*F.distanceTo(this._lngLat)}_evaluateOpacity(){const h=this._map;if(!h)return;const y=this._pos;if(!y||y.x<0||y.x>h.transform.width||y.y<0||y.y>h.transform.height)return void this._clearFadeTimer();const A=h.unproject(y,this._altitude);let D;h._showingGlobe()&&i.f5(h.transform,this._lngLat)?D=0:(D=1-h._queryFogOpacity(A),h.transform._terrainEnabled()&&h.getTerrain()&&this._behindTerrain()&&(D*=this._occludedOpacity)),this._element.style.opacity=`${D}`,this._element.style.pointerEvents=D>0?"auto":"none",this._popup&&this._popup._setOpacity(D),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const h=this._pos;if(!h||!this._map)return;const y=this._offset.mult(this._scale);this._element.style.transform=` translate(${h.x}px,${h.y}px) ${Ud[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${y.x}px,${y.y}px) `}_calculateXYTransform(){const h=this._pos,y=this._map,A=this.getPitchAlignment();if(!y||!h||A!=="map")return"";if(!y._showingGlobe()){const J=y.getPitch();return J?`rotateX(${J}deg)`:""}const D=i.cX(i.f6(y.transform,this._lngLat)),F=h.sub(i.f7(y.transform)),z=Math.abs(F.x)+Math.abs(F.y);if(z===0)return"";const W=D/z;return`rotateX(${-F.y*W}deg) rotateY(${F.x*W}deg)`}_calculateZTransform(){const h=this._pos,y=this._map;if(!y||!h)return"";let A=0;const D=this.getRotationAlignment();if(D==="map")if(y._showingGlobe()){const F=y.project(new i.aT(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),z=y.project(new i.aT(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(F);A=i.cX(Math.atan2(z.y,z.x))-90}else A=-y.getBearing();else if(D==="horizon"){const F=i.ah(4,6,y.getZoom()),z=i.f7(y.transform);z.y+=F*y.transform.height;const W=h.sub(z),J=i.cX(Math.atan2(W.y,W.x));A=(J>90?J-270:J+90)*(1-F)}return A+=this._rotation,A?`rotateZ(${A}deg)`:""}_update(h){cancelAnimationFrame(this._updateFrameId);const y=this._map;y&&(y.transform.renderWorldCopies&&(this._lngLat=B6(this._lngLat,this._pos,y.transform)),this._pos=y.project(this._lngLat,this._altitude),h===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),y._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(y._showingGlobe()||y.getTerrain()||y.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(h){return this._offset=i.P.convert(h),this._update(),this}addClassName(h){return this._element.classList.add(h),this}removeClassName(h){return this._element.classList.remove(h),this}toggleClassName(h){return this._element.classList.toggle(h)}_onMove(h){const y=this._map;if(!y)return;const A=this._pointerdownPos,D=this._positionDelta;if(A&&D){if(!this._isDragging){const F=this._clickTolerance||y._clickTolerance;if(h.point.dist(A)T.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(T.minPitch!=null&&T.maxPitch!=null&&T.minPitch>T.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(T.minPitch!=null&&T.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(T.maxPitch!=null&&T.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(T.antialias&&i.f3(window)&&(T.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 VE(T.minZoom,T.maxZoom,T.minPitch,T.maxPitch,T.renderWorldCopies,null,null),T),this._repaint=!!T.repaint,this._interactive=T.interactive,this._minTileCacheSize=T.minTileCacheSize,this._maxTileCacheSize=T.maxTileCacheSize,this._failIfMajorPerformanceCaveat=T.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=T.preserveDrawingBuffer,this._antialias=T.antialias,this._trackResize=T.trackResize,this._bearingSnap=T.bearingSnap,this._refreshExpiredTiles=T.refreshExpiredTiles,this._fadeDuration=T.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=T.crossSourceCollisions,this._collectResourceTiming=T.collectResourceTiming,this._language=this._parseLanguage(T.language),this._worldview=T.worldview,this._renderTaskQueue=new dg,this._domRenderTaskQueue=new dg,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},hg,T.locale),this._clickTolerance=T.clickTolerance,this._cooperativeGestures=T.cooperativeGestures,this._performanceMetricsCollection=T.performanceMetricsCollection,this._tessellationStep=T.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=T.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ug(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=T.scaleFactor,this._requestManager=new X(T.transformRequest,T.accessToken,T.testMode),this._silenceAuthErrors=!!T.testMode,this._contextCreateOptions=T.contextCreateOptions?Object.assign({},T.contextCreateOptions):{},typeof T.container=="string"){const y=document.getElementById(T.container);if(!y)throw new Error(`Container '${T.container.toString()}' not found.`);this._container=y}else{if(!(T.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=T.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."),T.maxBounds&&this.setMaxBounds(T.maxBounds),this._spriteFormat=T.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 Xme(this,T),this._localFontFamily=T.localFontFamily,this._localIdeographFontFamily=T.localIdeographFontFamily,(T.style||!T.testMode)&&this.setStyle(T.style||i.e.DEFAULT_STYLE,{config:T.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),T.projection&&this.setProjection(T.projection),T.hash&&(this._hash=new C6(typeof T.hash=="string"&&T.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){h.center==null&&h.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:T.center,zoom:T.zoom,bearing:T.bearing,pitch:T.pitch});const y=T.bounds;y&&(this.resize(),this.fitBounds(y,Object.assign({},T.fitBoundsOptions,{duration:0})))}this.resize(),T.attributionControl&&this.addControl(new j2({customAttribution:T.customAttribution})),this._logoControl=new N2,this.addControl(this._logoControl,T.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",y=>{this._update(y.dataType==="style"),this.fire(new i.z(`${y.dataType}data`,y))}),this.on("dataloading",y=>{this.fire(new i.z(`${y.dataType}dataloading`,y))}),this._interactions=new qp(this)}_getMapId(){return this._mapId}addControl(T,h){if(h===void 0&&(h=T.getDefaultPosition?T.getDefaultPosition():"top-right"),!T||!T.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 y=T.onAdd(this);this._controls.push(T);const A=this._controlPositions[h];return h.indexOf("bottom")!==-1?A.insertBefore(y,A.firstChild):A.appendChild(y),this}removeControl(T){if(!T||!T.onRemove)return this.fire(new i.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const h=this._controls.indexOf(T);return h>-1&&this._controls.splice(h,1),T.onRemove(this),this}hasControl(T){return this._controls.indexOf(T)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(T){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const h=!this._moving;return h&&this.fire(new i.z("movestart",T)).fire(new i.z("move",T)),this.fire(new i.z("resize",T)),h&&this.fire(new i.z("moveend",T)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(T){return this.transform.setMaxBounds(i.aI.convert(T)),this._update()}setMinZoom(T){if((T=T??-2)>=-2&&T<=this.transform.maxZoom)return this.transform.minZoom=T,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=T,this._update(),this.getZoom()>T?this.setZoom(T):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(T){if((T=T??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(T>=0&&T<=this.transform.maxPitch)return this.transform.minPitch=T,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(T>=this.transform.minPitch)return this.transform.maxPitch=T,this._update(),this.getPitch()>T?this.setPitch(T):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(T){return this._scaleFactor=T,this.painter.scaleFactor=T,this._scaleFactorChanged=!0,this.style._updateFilteredLayers(h=>h.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(T){return this.transform.renderWorldCopies=T,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(T){return T==="auto"?navigator.language:Array.isArray(T)?T.length===0?void 0:T.map(h=>h==="auto"?navigator.language:h):T}setLanguage(T){const h=this._parseLanguage(T);if(!this.style||h===this._language)return this;this._language=h,this.style.reloadSources();for(const y of this._controls)y._setLanguage&&y._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(T){return this.style&&T!==this._worldview?(this._worldview=T,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(T){return this._lazyInitEmptyStyle(),T?typeof T=="string"&&(T={name:T}):T=null,this._useExplicitProjection=!!T,this._prioritizeAndUpdateProjection(T,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const T=this.transform,h=T.projection.name;let y;h==="globe"&&T.zoom>=i.cL?(T.setMercatorFromTransition(),y=!0):h==="mercator"&&T.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(T),this.style.applyProjectionUpdate();const A=this.transform.getProjection().name==="mercator"&&y!==this.transform.mercatorFromTransition;return(h||A)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(T,h){return this.transform.locationPoint3D(i.aT.convert(T),h)}unproject(T,h){return this.transform.pointLocation3D(i.P.convert(T),h)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(T,h,y){const A=D=>{let F=[];if(Array.isArray(h)){const z=h.filter(W=>this.getLayer(W));F=z.length?this.queryRenderedFeatures(D,{layers:z}):[]}else F=this.queryRenderedFeatures(D,{target:h});return F};if(T==="mouseenter"||T==="mouseover"){let D=!1;return{listener:y,targets:h,delegates:{mousemove:z=>{const W=A(z.point);W.length?D||(D=!0,y.call(this,new hh(T,this,z.originalEvent,{features:W}))):D=!1},mouseout:()=>{D=!1}}}}if(T==="mouseleave"||T==="mouseout"){let D=!1;return{listener:y,targets:h,delegates:{mousemove:W=>{A(W.point).length?D=!0:D&&(D=!1,y.call(this,new hh(T,this,W.originalEvent)))},mouseout:W=>{D&&(D=!1,y.call(this,new hh(T,this,W.originalEvent)))}}}}{const D=F=>{const z=A(F.point);z.length&&(F.features=z,y.call(this,F),delete F.features)};return{listener:y,targets:h,delegates:{[T]:D}}}}on(T,h,y){if(typeof h=="function"||y===void 0)return super.on(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(T,h,y);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[T]=this._delegatedListeners[T]||[],this._delegatedListeners[T].push(A);for(const D in A.delegates)this.on(D,A.delegates[D]);return this}once(T,h,y){if(typeof h=="function"||y===void 0)return super.once(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(T,h,y);for(const D in A.delegates)this.once(D,A.delegates[D]);return this}off(T,h,y){if(typeof h=="function"||y===void 0)return super.off(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._delegatedListeners?this._delegatedListeners[T]:void 0;return A&&(D=>{for(let F=0;F{if(y){const D=typeof y=="string"?y:y instanceof Error?y.message:y.error;i.w(`Unable to perform style diff: ${D}. Rebuilding the style from scratch.`),this._updateStyle(T,h)}else A&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=h.localIdeographFontFamily,this._localFontFamily=h.localFontFamily,this._updateStyle(T,h))}_getUIString(T){const h=this._locale[T];if(h==null)throw new Error(`Missing UI string '${T}'`);return h}_updateStyle(T,h){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),T){const y=Object.assign({},h);h&&h.config&&(y.initialConfig=h.config,delete y.config),this.style=new tp(this,y).load(T),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new tp(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(T){return T==null?(this.fire(new i.y(new Error("IDs can't be empty."))),!1):!i.dr(T)||(this.fire(new i.y(new Error(`IDs can't contain special symbols: "${T}".`))),!1)}_isTargetValid(T){return"featuresetId"in T?this._isValidId("importId"in T?T.importId:T.featuresetId):"layerId"in T&&this._isValidId(T.layerId)}_areTargetsValid(T){if(Array.isArray(T)){for(const h of T)if(!this._isValidId(h))return!1;return!0}return this._isTargetValid(T)}addSource(T,h){return this._isValidId(T)?(this._lazyInitEmptyStyle(),this.style.addSource(T,h),this._update(!0)):this}isSourceLoaded(T){return!!this._isValidId(T)&&!!this.style&&this.style._isSourceCacheLoaded(T)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(T,h,y){this._lazyInitEmptyStyle(),this.style.addSourceType(T,h,y)}removeSource(T){return this._isValidId(T)?(this.style.removeSource(T),this._updateTerrain(),this._update(!0)):this}getSource(T){return this._isValidId(T)?this.style.getOwnSource(T):null}addImage(T,h,{pixelRatio:y=1,sdf:A=!1,stretchX:D,stretchY:F,content:z}={}){this._lazyInitEmptyStyle();const W=i.I.from(T);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:J,height:ne,data:le}=i.o.getImageData(h);this.style.addImage(W,{data:new i.q({width:J,height:ne},le),pixelRatio:y,stretchX:D,stretchY:F,content:z,sdf:A,version:0,usvg:!1})}else if(h.width===void 0||h.height===void 0)this.fire(new i.y(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:J,height:ne}=h,le=h;this.style.addImage(W,{data:new i.q({width:J,height:ne},new Uint8Array(le.data)),pixelRatio:y,stretchX:D,stretchY:F,content:z,sdf:A,usvg:!1,version:0,userImage:le}),le.onAdd&&le.onAdd(this,T)}}updateImage(T,h){this._lazyInitEmptyStyle();const y=i.I.from(T),A=this.style.getImage(y);if(!A)return void this.fire(new i.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const D=h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap?i.o.getImageData(h):h,{width:F,height:z,data:W}=D;if(F===void 0||z===void 0)return void this.fire(new i.y(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(F!==(A.usvg?A.icon.usvg_tree.width:A.data.width)||z!==(A.usvg?A.icon.usvg_tree.height:A.data.height))return void this.fire(new i.y(new Error(`The width and height of the updated image (${F}, ${z}) must be that same as the previous version of the image (${A.data.width}, ${A.data.height})`)));const J=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let ne=!1;A.usvg?(A.data=new i.q({width:F,height:z},new Uint8Array(W)),A.usvg=!1,A.icon=void 0,ne=!0):A.data.replace(W,J),this.style.updateImage(y,A,ne)}hasImage(T){return T?!!this.style&&!!this.style.getImage(i.I.from(T)):(this.fire(new i.y(new Error("Missing required image id"))),!1)}removeImage(T){this.style.removeImage(i.I.from(T))}loadImage(T,h){i.n(this._requestManager.transformRequest(T,i.R.Image),(y,A)=>{h(y,A instanceof HTMLImageElement?i.o.getImageData(A):A)})}listImages(){return this.style.listImages().map(T=>T.name)}addModel(T,h){this._lazyInitEmptyStyle(),this.style.addModel(T,h)}hasModel(T){return T?this.style.hasModel(T):(this.fire(new i.y(new Error("Missing required model id"))),!1)}removeModel(T){this.style.removeModel(T)}listModels(){return this.style.listModels()}addLayer(T,h){return this._isValidId(T.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(T,h),this._update(!0)):this}getSlot(T){const h=this.getLayer(T);return h&&h.slot||null}setSlot(T,h){return this.style.setSlot(T,h),this.style.mergeLayers(),this._update(!0)}addImport(T,h){return this.style.addImport(T,h).catch(y=>this.fire(new i.y(new Error("Failed to add import",y)))),this}updateImport(T,h){return typeof h!="string"&&h.id!==T?(this.removeImport(T),this.addImport(h)):(this.style.updateImport(T,h),this._update(!0))}removeImport(T){return this.style.removeImport(T),this}moveImport(T,h){return this.style.moveImport(T,h),this._update(!0)}moveLayer(T,h){return this._isValidId(T)?(this.style.moveLayer(T,h),this._update(!0)):this}removeLayer(T){return this._isValidId(T)?(this.style.removeLayer(T),this._update(!0)):this}getLayer(T){if(!this._isValidId(T))return null;const h=this.style.getOwnLayer(T);return h?h.type==="custom"?h.implementation:h.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(T,h,y){return this._isValidId(T)?(this.style.setLayerZoomRange(T,h,y),this._update(!0)):this}setFilter(T,h,y={}){return this._isValidId(T)?(this.style.setFilter(T,h,y),this._update(!0)):this}getFilter(T){return this._isValidId(T)?this.style.getFilter(T):null}setPaintProperty(T,h,y,A={}){return this._isValidId(T)?(this.style.setPaintProperty(T,h,y,A),this._update(!0)):this}getPaintProperty(T,h){return this._isValidId(T)?this.style.getPaintProperty(T,h):null}setLayoutProperty(T,h,y,A={}){return this._isValidId(T)?(this.style.setLayoutProperty(T,h,y,A),this._update(!0)):this}getLayoutProperty(T,h){return this._isValidId(T)?this.style.getLayoutProperty(T,h):null}setLayerProperty(T,h,y,A={}){return this._isValidId(T)?(h==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(T,h,y,A),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(T){return this.style.setGlyphsUrl(T),this._update(!0)}getSchema(T){return this.style.getSchema(T)}setSchema(T,h){return this.style.setSchema(T,h),this._update(!0)}getConfig(T){return this.style.getConfig(T)}setConfig(T,h){return this.style.setConfig(T,h),this._update(!0)}getConfigProperty(T,h){return this.style.getConfigProperty(T,h)}setConfigProperty(T,h,y){return this.style.setConfigProperty(T,h,y),this._update(!0)}getFeaturesetDescriptors(T){return this.style.getFeaturesetDescriptors(T)}setLights(T){if(this._lazyInitEmptyStyle(),T&&T.length===1&&T[0].type==="flat"){const h=T[0];h.properties?this.style.setFlatLight(h.properties,h.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(T),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const T=this.style.getLights()||[];return T.length===0&&T.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),T}setLight(T,h={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:T}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(T){return this._lazyInitEmptyStyle(),!T&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(T),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(T){return this._lazyInitEmptyStyle(),this.style.setFog(T),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(T){return this._lazyInitEmptyStyle(),this.style.setSnow(T),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(T){return this._lazyInitEmptyStyle(),this.style.setRain(T),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(T){return this._lazyInitEmptyStyle(),this.style.setColorTheme(T),this._update(!0)}setImportColorTheme(T,h){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(T,h),this._update(!0)}setCamera(T){return this.style.setCamera(T),this._triggerCameraUpdate(T)}_triggerCameraUpdate(T){return this._update(this.transform.setOrthographicProjectionAtLowPitch(T["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(T){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aT.convert(T),this.transform):0}setFeatureState(T,h){return T.source&&!this._isValidId(T.source)?this:(this.style.setFeatureState(T,h),this._update())}removeFeatureState(T,h){return T.source&&!this._isValidId(T.source)?this:(this.style.removeFeatureState(T,h),this._update())}getFeatureState(T){return T.source&&!this._isValidId(T.source)?null:this.style.getFeatureState(T)}_selectIndoorFloor(T){this.indoor.selectFloor(T)}_setIndoorActiveFloorsVisibility(T){this.indoor.setActiveFloorsVisibility(T)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new gb),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const T=this._container.getBoundingClientRect().width||400,h=this._container.getBoundingClientRect().height||300;let y,A,D,F=this._container;for(;F&&(!A||!D);){const z=window.getComputedStyle(F).transform;z&&z!=="none"&&(y=z.match(/matrix.*\((.+)\)/)[1].split(", "),y[0]&&y[0]!=="0"&&y[0]!=="1"&&(A=y[0]),y[3]&&y[3]!=="0"&&y[3]!=="1"&&(D=y[3])),F=F.parentElement}this._containerWidth=A?Math.abs(T/A):T,this._containerHeight=D?Math.abs(h/D):h}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&i.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new PR(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 T=this._container;T.classList.add("mapboxgl-map"),(this._missingCSSCanary=j("div","mapboxgl-canary",T)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=j("div","mapboxgl-canvas-container",T);this._canvas=j("canvas","mapboxgl-canvas",h),this._interactive&&(h.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const y=this._controlContainer=j("div","mapboxgl-control-container",T),A=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{A[D]=j("div",`mapboxgl-ctrl-${D}`,y)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(T,h){const y=i.o.devicePixelRatio||1;this._canvas.width=y*Math.ceil(T),this._canvas.height=y*Math.ceil(h),this._canvas.style.width=`${T}px`,this._canvas.style.height=`${h}px`}_addMarker(T){this._markers.push(T)}_removeMarker(T){const h=this._markers.indexOf(T);h!==-1&&this._markers.splice(h,1)}_addPopup(T){this._popups.push(T)}_removePopup(T){const h=this._popups.indexOf(T);h!==-1&&this._popups.splice(h,1)}_setupPainter(){const T=Object.assign({},_.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),h=this._canvas.getContext("webgl2",T);h?(et(h,!0),this.painter=new M3(h,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",y=>{y.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.k.testSupport(h)):this.fire(new i.y(new Error("Failed to initialize WebGL")))}_contextLost(T){T.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.z("webglcontextlost",{originalEvent:T}))}_contextRestored(T){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:T}))}_onMapScroll(T){if(T.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(T){return this.style?(this._styleDirty=this._styleDirty||T,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(T){return this._update(),this._renderTaskQueue.add(T)}_cancelRenderFrame(T){this._renderTaskQueue.remove(T)}_requestDomTask(T){!this.loaded()||this.loaded()&&!this.isMoving()?T():this._domRenderTaskQueue.add(T)}_render(T){let h;this.fire(new i.z("renderstart")),++this._frameId;const y=this.painter.context.extTimerQuery,A=i.o.now(),D=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(h=D.createQuery(),D.beginQuery(y.TIME_ELAPSED_EXT,h)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(T),this._domRenderTaskQueue.run(T),this._removed)return;this._updateProjectionTransition();const F=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const ne=this.transform.zoom,le=this.transform.pitch,je=i.o.now(),ve=new i.ac(ne,{now:je,fadeDuration:F,pitch:le,transition:this.style.transition,worldview:this._worldview});this.style.update(ve)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let z=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),z=this._updateAverageElevation(A),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):z=this._updateAverageElevation(A);const W=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,F,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),W&&(this._placementDirty=W.needsRerender),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:F,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.mark(u.load),this.fire(new i.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),h){const ne=i.o.now()-A;D.endQuery(y.TIME_ELAPSED_EXT),setTimeout(()=>{const le=D.getQueryParameter(h,D.QUERY_RESULT)/1e6;D.deleteQuery(h),this.fire(new i.z("gpu-timing-frame",{cpuTime:ne,gpuTime:le}))},50)}if(this.listens("gpu-timing-layer")){const ne=this.painter.collectGpuTimers();setTimeout(()=>{const le=this.painter.queryGpuTimers(ne);this.fire(new i.z("gpu-timing-layer",{layerTimes:le}))},50)}if(this.listens("gpu-timing-deferred-render")){const ne=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const le=this.painter.queryGpuTimeDeferredRender(ne);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:le}))},50)}const J=this._sourcesDirty||this._styleDirty||this._placementDirty||z;if(J||this._repaint)this.triggerRepaint();else{const ne=this.idle();if(ne&&(z=this._updateAverageElevation(A,!0)),z)this.triggerRepaint();else if(this._triggerFrame(!1),ne&&(this.fire(new i.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const le=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:le})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||J||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&pt(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(T){for(const h of this._markers)T&&!this.getRenderWorldCopies()&&(h._lngLat=h._lngLat.wrap()),h._update();for(const h of this._popups)!T||this.getRenderWorldCopies()||h._trackPointer||(h._lngLat=h._lngLat.wrap()),h._update()}_updateAverageElevation(T,h=!1){const y=D=>(this.transform.averageElevation=D,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&y(0);const A=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(A||(h||T-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(T)){const D=this.transform.averageElevation;let F=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(F)?F=0:this._averageElevationLastSampledAt=T;const z=Math.abs(D-F);if(z>1){if(this._isInitialLoad||A)return this._averageElevation.jumpTo(F),y(F);this._averageElevation.easeTo(F,T,300)}else if(z>1e-4)return this._averageElevation.jumpTo(F),y(F)}return!!this._averageElevation.isEasing(T)&&y(this._averageElevation.getValue(T))}_authenticate(){qe(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,T=>{if(T&&(T.message===ee||T.status===401)){const h=this.painter.context.gl;et(h,!1),this._logoControl instanceof N2&&this._logoControl._updateLogo(),h&&h.clear(h.DEPTH_BUFFER_BIT|h.COLOR_BUFFER_BIT|h.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.y(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),Ae(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Ce(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&we(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){tt(this._requestManager._customAccessToken)}_updateTerrain(){const T=this._isDragging();this.painter.updateTerrain(this.style,T)}_calculateSpeedIndex(){const T=this.painter.canvasCopy(),h=this.painter.getCanvasCopiesAndTimestamps();h.timeStamps.push(performance.now());const y=this.painter.context.gl,A=y.createFramebuffer();function D(F){y.framebufferTexture2D(y.FRAMEBUFFER,y.COLOR_ATTACHMENT0,y.TEXTURE_2D,F,0);const z=new Uint8Array(y.drawingBufferWidth*y.drawingBufferHeight*4);return y.readPixels(0,0,y.drawingBufferWidth,y.drawingBufferHeight,y.RGBA,y.UNSIGNED_BYTE,z),z}return y.bindFramebuffer(y.FRAMEBUFFER,A),this._canvasPixelComparison(D(T),h.canvasCopies.map(D),h.timeStamps)}_canvasPixelComparison(T,h,y){let A=y[1]-y[0];const D=T.length/4;for(let F=0;F{const y=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,y&&this._render(h)}))}_preloadTiles(T){const h=this.style?this.style.getSourceCaches():[];return i.bw(h,(y,A)=>y._preloadTiles(T,A),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(T){this._trackResize&&this.resize({originalEvent:T})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(T){this._showTileBoundaries!==T&&(this._showTileBoundaries=T,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(T){this._showParseStatus!==T&&(this._showParseStatus=T,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(T){this._showTerrainWireframe!==T&&(this._showTerrainWireframe=T,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(T){this._showLayers2DWireframe!==T&&(this._showLayers2DWireframe=T,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(T){this._showLayers3DWireframe!==T&&(this._showLayers3DWireframe=T,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(T){this._speedIndexTiming!==T&&(this._speedIndexTiming=T,this._update())}get showPadding(){return!!this._showPadding}set showPadding(T){this._showPadding!==T&&(this._showPadding=T,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(T){this._showCollisionBoxes!==T&&(this._showCollisionBoxes=T,this.style&&T?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(T){this._showOverdrawInspector!==T&&(this._showOverdrawInspector=T,this._update())}get repaint(){return!!this._repaint}set repaint(T){this._repaint!==T&&(this._repaint=T,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(T){this._vertices=T,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(T){this._showTileAABBs!==T&&(this._showTileAABBs=T,T&&this._update())}_setCacheLimits(T,h){i.f4(T,h)}get version(){return c}},NavigationControl:class{constructor(T={}){this.options=Object.assign({},epe,T),this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",h=>{this._map&&this._map.zoomIn({},{originalEvent:h})}),j("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",h=>{this._map&&this._map.zoomOut({},{originalEvent:h})}),j("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",h=>{const y=this._map;y&&(this.options.visualizePitch?y.resetNorthPitch({},{originalEvent:h}):y.resetNorth({},{originalEvent:h}))}),this._compassIcon=j("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const T=this._map;if(!T)return;const h=T.getZoom(),y=h===T.getMaxZoom(),A=h===T.getMinZoom();this._zoomInButton.disabled=y,this._zoomOutButton.disabled=A,this._zoomInButton.setAttribute("aria-disabled",y.toString()),this._zoomOutButton.setAttribute("aria-disabled",A.toString())}_rotateCompassArrow(){const T=this._map;if(!T)return;const h=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(T.transform.pitch*(Math.PI/180)),.5)}) rotateX(${T.transform.pitch}deg) rotateZ(${T.transform.angle*(180/Math.PI)}deg)`:`rotate(${T.transform.angle*(180/Math.PI)}deg)`;T._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=h)})}onAdd(T){return this._map=T,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),T.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&T.on("pitch",this._rotateCompassArrow),T.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new tpe(T,this._compass,this.options.visualizePitch)),this._container}onRemove(){const T=this._map;T&&(this._container.remove(),this.options.showZoom&&T.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&T.off("pitch",this._rotateCompassArrow),T.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(T,h){const y=j("button",T,this._container);return y.type="button",y.addEventListener("click",h),y}_setButtonTitle(T,h){if(!this._map)return;const y=this._map._getUIString(`NavigationControl.${h}`);T.setAttribute("aria-label",y),T.firstElementChild&&T.firstElementChild.setAttribute("title",y)}},GeolocateControl:class extends i.E{constructor(T={}){super();const h=navigator.geolocation;this.options=Object.assign({geolocation:h},spe,T),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=T3(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(T){return this._map=T,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(T){const h=(y=!!this.options.geolocation)=>{this._supportsGeolocation=y,T(y)};this._supportsGeolocation!==void 0?T(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(y=>h(y.state!=="denied")).catch(()=>h()):h()}_isOutOfMapMaxBounds(T){const h=this._map.getMaxBounds(),y=T.coords;return!!h&&(y.longitudeh.getEast()||y.latitudeh.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(T){if(this._map){if(this._isOutOfMapMaxBounds(T))return this._setErrorState(),this.fire(new i.z("outofmaxbounds",T)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=T,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(T),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(T),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("geolocate",Object.assign({coords:T.coords,timestamp:T.timestamp},T.toJSON?{toJSON:T.toJSON.bind(T)}:{}))),this._finish()}}_updateCamera(T){const h=new i.aT(T.coords.longitude,T.coords.latitude),y=T.coords.accuracy,A=this._map.getBearing(),D=Object.assign({bearing:A},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(y),D,{geolocateSource:!0})}_updateMarker(T){if(T){const h=new i.aT(T.coords.longitude,T.coords.latitude);this._accuracyCircleMarker.setLngLat(h).addTo(this._map),this._userLocationDotMarker.setLngLat(h).addTo(this._map),this._accuracy=T.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const T=this._map.transform,h=i.cf(1,T._center.lat)*T.worldSize,y=Math.ceil(2*this._accuracy*h);this._circleElement.style.width=`${y}px`,this._circleElement.style.height=`${y}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(T){if(this._map){if(this.options.trackUserLocation)if(T.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(T.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",T)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(T){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",h=>h.preventDefault()),this._geolocateButton=j("button","mapboxgl-ctrl-geolocate",this._container),j("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",T===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}else{const h=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=j("div","mapboxgl-user-location"),this._dotElement.appendChild(j("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(j("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new q3({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=j("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new q3({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",h=>{h.geolocateSource||this._watchState!=="ACTIVE_LOCK"||h.originalEvent&&h.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new i.z("trackuserlocationend")))})}}_onDeviceOrientation(T){this._userLocationDotMarker&&(T.webkitCompassHeading?this._heading=T.webkitCompassHeading:T.absolute===!0&&(this._heading=-1*T.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 T;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(T={maximumAge:6e5,timeout:0},this._noTimeout=!0):(T=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,T),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 T=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};typeof DeviceMotionEvent<"u"&&typeof DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(h=>{h==="granted"&&T()}).catch(console.error):T()}_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:j2,ScaleControl:class{constructor(T={}){this.options=Object.assign({},yb,T),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const T=this.options.maxWidth||100,h=this._map,y=h._containerHeight/2,A=h._containerWidth/2-T/2,D=h.unproject([A,y]),F=h.unproject([A+T,y]),z=D.distanceTo(F);if(this.options.unit==="imperial"){const W=3.2808*z;W>5280?this._setScale(T,W/5280,"mile"):this._setScale(T,W,"foot")}else this.options.unit==="nautical"?this._setScale(T,z/1852,"nautical-mile"):z>=1e3?this._setScale(T,z/1e3,"kilometer"):this._setScale(T,z,"meter")}_setScale(T,h,y){this._map._requestDomTask(()=>{const A=function(F){const z=Math.pow(10,`${Math.floor(F)}`.length-1);let W=F/z;return W=W>=10?10:W>=5?5:W>=3?3:W>=2?2:W>=1?1:function(J){const ne=Math.pow(10,Math.ceil(-Math.log(J)/Math.LN10));return Math.round(J*ne)/ne}(W),z*W}(h),D=A/h;this._container.innerHTML=y!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:y}).format(A):`${A} ${$6[y]}`,this._container.style.width=T*D+"px"})}onAdd(T){return this._map=T,this._language=T.getLanguage(),this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-scale",T.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(T){this._language=T,this._update()}setUnit(T){this.options.unit=T,this._update()}},FullscreenControl:class{constructor(T={}){this._fullscreen=!1,T&&T.container&&(T.container instanceof HTMLElement?this._container=T.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(T){return this._map=T,this._container||(this._container=this._map.getContainer()),this._controlContainer=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const T=this._fullscreenButton=j("button","mapboxgl-ctrl-fullscreen",this._controlContainer);j("span","mapboxgl-ctrl-icon",T).setAttribute("aria-hidden","true"),T.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const T=this._getTitle();this._fullscreenButton.setAttribute("aria-label",T),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",T)}_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:gb,Popup:class extends i.E{constructor(T){super(),this.options=Object.assign(Object.create(rp),T),this._altitude=this.options.altitude,i.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(T&&T.className?T.className.trim().split(/\s+/):[])}addTo(T){return this._map&&this.remove(),this._map=T,this.options.closeOnClick&&T.on("preclick",this._onClose),this.options.closeOnMove&&T.on("move",this._onClose),T.on("remove",this.remove),this._update(),T._addPopup(this),this._focusFirstElement(),this._trackPointer?(T.on("mousemove",this._onMouseEvent),T.on("mouseup",this._onMouseEvent),T._canvasContainer.classList.add("mapboxgl-track-pointer")):T.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 T=this._map;return T&&(T.off("move",this._update),T.off("move",this._onClose),T.off("preclick",this._onClose),T.off("click",this._onClose),T.off("remove",this.remove),T.off("mousemove",this._onMouseEvent),T.off("mouseup",this._onMouseEvent),T.off("drag",this._onMouseEvent),T._canvasContainer&&T._canvasContainer.classList.remove("mapboxgl-track-pointer"),T._removePopup(this),this._map=void 0),this.fire(new i.z("close")),this}getLngLat(){return this._lngLat}setLngLat(T){this._lngLat=i.aT.convert(T),this._pos=null,this._trackPointer=!1,this._update();const h=this._map;return h&&(h.on("move",this._update),h.off("mousemove",this._onMouseEvent),h._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(T){return this._altitude=T,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const T=this._map;return T&&(T.off("move",this._update),T.on("mousemove",this._onMouseEvent),T.on("drag",this._onMouseEvent),T._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(T){return this.setDOMContent(document.createTextNode(T))}setHTML(T){const h=document.createDocumentFragment(),y=document.createElement("body");let A;for(y.innerHTML=T;A=y.firstChild,A;)h.appendChild(A);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(T){return this.options.maxWidth=T,this._update(),this}setDOMContent(T){let h=this._content;if(h)for(;h.hasChildNodes();)h.firstChild&&h.removeChild(h.firstChild);else h=this._content=j("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(T),this.options.closeButton){const y=this._closeButton=j("button","mapboxgl-popup-close-button",h);y.type="button",y.setAttribute("aria-label","Close popup"),y.innerHTML='',y.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(T){return this._classList.add(T),this._updateClassList(),this}removeClassName(T){return this._classList.delete(T),this._updateClassList(),this}setOffset(T){return this.options.offset=T,this._update(),this}toggleClassName(T){let h;return this._classList.delete(T)?h=!1:(this._classList.add(T),h=!0),this._updateClassList(),h}_onMouseEvent(T){this._update(T.point)}_getAnchor(T){if(this.options.anchor)return this.options.anchor;const h=this._map,y=this._container,A=this._pos;if(!h||!y||!A)return"bottom";const D=y.offsetWidth,F=y.offsetHeight,z=A.xh.transform.width-D/2;if(A.y+Th.transform.height-F){if(z)return"bottom-left";if(W)return"bottom-right"}return z?"left":W?"right":"bottom"}_updateClassList(){const T=this._container;if(!T)return;const h=[...this._classList];h.push("mapboxgl-popup"),this._anchor&&h.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&h.push("mapboxgl-popup-track-pointer"),T.className=h.join(" ")}_update(T){const h=this._map,y=this._content;if(!h||!this._lngLat&&!this._trackPointer||!y)return;let A=this._container;if(A||(A=this._container=j("div","mapboxgl-popup",h.getContainer()),this._tip=j("div","mapboxgl-popup-tip",A),A.appendChild(y)),this.options.maxWidth&&A.style.maxWidth!==this.options.maxWidth&&(A.style.maxWidth=this.options.maxWidth),h.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=B6(this._lngLat,this._pos,h.transform)),!this._trackPointer||T){const D=this._pos=this._trackPointer&&T instanceof i.P?T:h.project(this._lngLat,this._altitude),F=xv(this.options.offset),z=this._anchor=this._getAnchor(F.y),W=xv(this.options.offset,z),J=D.add(W).round();h._requestDomTask(()=>{this._container&&z&&(this._container.style.transform=`${Ud[z]} translate(${J.x}px,${J.y}px)`)})}if(!this._marker&&h._showingGlobe()){const D=i.f5(h.transform,this._lngLat)?0:1;this._setOpacity(D)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const T=this._container.querySelector(np);T&&T.focus()}_onClose(){this.remove()}_setOpacity(T){this._container&&(this._container.style.opacity=`${T}`),this._content&&(this._content.style.pointerEvents=T?"auto":"none")}},Marker:q3,Style:tp,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:Ru,Evented:i.E,config:i.e,prewarm:i.f9,clearPrewarmedResources:i.f8,get accessToken(){return i.e.ACCESS_TOKEN},set accessToken(T){i.e.ACCESS_TOKEN=T},get baseApiUrl(){return i.e.API_URL},set baseApiUrl(T){i.e.API_URL=T},get workerCount(){return i.fi.workerCount},set workerCount(T){i.fi.workerCount=T},get maxParallelImageRequests(){return i.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(T){i.e.MAX_PARALLEL_IMAGE_REQUESTS=T},clearStorage(T){i.fh(T)},get workerUrl(){return i.fg.workerUrl},set workerUrl(T){i.fg.workerUrl=T},get workerClass(){return i.fg.workerClass},set workerClass(T){i.fg.workerClass=T},get workerParams(){return i.fg.workerParams},set workerParams(T){i.fg.workerParams=T},get dracoUrl(){return i.ff()},set dracoUrl(T){i.fe(T)},get meshoptUrl(){return i.fd()},set meshoptUrl(T){i.fc(T)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(fWe);var bNt=fWe.exports;const Ao=Po(bNt);function ys({className:t,...s}){return e.jsx("div",{className:It("animate-pulse rounded-md bg-muted",t),...s})}const s6e={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},r6e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function _Nt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function wNt({listings:t,isLoading:s}){const r=fr(),n=k.useRef(null),a=k.useRef(null),o=k.useRef([]),[l,i]=k.useState(""),[c,u]=k.useState(!0);return k.useEffect(()=>{(async()=>{u(!0);try{const{data:g}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();g!=null&&g.value&&i(g.value)}catch(g){console.error("Error fetching mapbox token:",g)}u(!1)})()},[]),k.useEffect(()=>{if(!n.current||!l||a.current)return;Ao.accessToken=l;const f=t.filter(_=>_.latitude!=null&&_.longitude!=null);let g=[-98.5795,39.8283],b=4;if(f.length>0){const _=f.reduce((w,N)=>w+N.longitude,0)/f.length,j=f.reduce((w,N)=>w+N.latitude,0)/f.length;g=[_,j],b=f.length===1?12:10}return a.current=new Ao.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:b,center:g}),a.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var _;(_=a.current)==null||_.remove(),a.current=null}},[l]),k.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(g=>g.remove()),o.current=[];const f=t.filter(g=>g.latitude!=null&&g.longitude!=null);if(f.forEach(g=>{var L,I,O;const b=s6e[g.status]||"#10B981",_=((L=g.photos)==null?void 0:L.find(q=>q.is_primary))||((I=g.photos)==null?void 0:I[0]),w=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${g.slug||g.id}`:`/public/listing/${g.slug||g.id}`,N=document.createElement("div");N.className="cursor-pointer",N.innerHTML=`
`;const S=new Ao.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${_!=null&&_.photo_url?``:""}
${_Nt(g.price)}
${g.property_address||""}
${g.city}, ${g.state}
${r6e[g.status]||g.status} ${g.bedrooms?`${g.bedrooms} bed`:""} ${g.bathrooms?`${g.bathrooms} bath`:""}
${(O=g.agent)!=null&&O.name?`
Listed by ${g.agent.name}
`:""}
Click to view details →
`),M=new Ao.Marker(N).setLngLat([g.longitude,g.latitude]).setPopup(S).addTo(a.current);o.current.push(M)}),f.length>1){const g=new Ao.LngLatBounds;f.forEach(b=>g.extend([b.longitude,b.latitude])),a.current.fitBounds(g,{padding:60,maxZoom:13})}else f.length===1&&a.current.flyTo({center:[f[0].longitude,f[0].latitude],zoom:12})},[t,l]),k.useEffect(()=>(window.__navigateToPublicListing__=f=>{r(f)},()=>{delete window.__navigateToPublicListing__}),[r]),c||s?e.jsx(ys,{className:"w-full h-[500px] rounded-lg"}):!l||t.filter(f=>f.latitude!=null&&f.longitude!=null).length===0?null:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:Object.entries(s6e).map(([f,g])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:g}}),e.jsx("span",{className:"text-xs text-gray-600",children:r6e[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function eD(t,[s,r]){return Math.min(r,Math.max(s,t))}function LO(t){const s=k.useRef({value:t,previous:t});return k.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var jNt=[" ","Enter","ArrowUp","ArrowDown"],NNt=[" ","Enter"],$S="Select",[Hde,Wde,kNt]=yO($S),[YA]=ad($S,[kNt,F0]),Gde=F0(),[SNt,Ew]=YA($S),[CNt,MNt]=YA($S),gWe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:c,dir:u,name:p,autoComplete:f,disabled:g,required:b,form:_}=t,j=Gde(s),[w,N]=k.useState(null),[S,M]=k.useState(null),[L,I]=k.useState(!1),O=Tw(u),[q,U]=ah({prop:n,defaultProp:a??!1,onChange:o,caller:$S}),[B,V]=ah({prop:l,defaultProp:i,onChange:c,caller:$S}),Y=k.useRef(null),Q=w?_||!!w.closest("form"):!0,[ee,X]=k.useState(new Set),ie=Array.from(ee).map(re=>re.props.value).join(";");return e.jsx(wO,{...j,children:e.jsxs(SNt,{required:b,scope:s,trigger:w,onTriggerChange:N,valueNode:S,onValueNodeChange:M,valueNodeHasChildren:L,onValueNodeHasChildrenChange:I,contentId:Tu(),value:B,onValueChange:V,open:q,onOpenChange:U,dir:O,triggerPointerDownPosRef:Y,disabled:g,children:[e.jsx(Hde.Provider,{scope:s,children:e.jsx(CNt,{scope:t.__scopeSelect,onNativeOptionAdd:k.useCallback(re=>{X(oe=>new Set(oe).add(re))},[]),onNativeOptionRemove:k.useCallback(re=>{X(oe=>{const ce=new Set(oe);return ce.delete(re),ce})},[]),children:r})}),Q?e.jsxs($We,{"aria-hidden":!0,required:b,tabIndex:-1,name:p,autoComplete:f,value:B,onChange:re=>V(re.target.value),disabled:g,form:_,children:[B===void 0?e.jsx("option",{value:""}):null,Array.from(ee)]},ie):null]})})};gWe.displayName=$S;var yWe="SelectTrigger",vWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=Gde(r),l=Ew(yWe,r),i=l.disabled||n,c=qa(s,l.onTriggerChange),u=Wde(r),p=k.useRef("touch"),[f,g,b]=UWe(j=>{const w=u().filter(M=>!M.disabled),N=w.find(M=>M.value===l.value),S=VWe(w,j,N);S!==void 0&&l.onValueChange(S.value)}),_=j=>{i||(l.onOpenChange(!0),b()),j&&(l.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return e.jsx(qA,{asChild:!0,...o,children:e.jsx(nn.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":qWe(l.value)?"":void 0,...a,ref:c,onClick:Ir(a.onClick,j=>{j.currentTarget.focus(),p.current!=="mouse"&&_(j)}),onPointerDown:Ir(a.onPointerDown,j=>{p.current=j.pointerType;const w=j.target;w.hasPointerCapture(j.pointerId)&&w.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(_(j),j.preventDefault())}),onKeyDown:Ir(a.onKeyDown,j=>{const w=f.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&g(j.key),!(w&&j.key===" ")&&jNt.includes(j.key)&&(_(),j.preventDefault())})})})});vWe.displayName=yWe;var bWe="SelectValue",_We=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,c=Ew(bWe,r),{onValueNodeHasChildrenChange:u}=c,p=o!==void 0,f=qa(s,c.onValueNodeChange);return jd(()=>{u(p)},[u,p]),e.jsx(nn.span,{...i,ref:f,style:{pointerEvents:"none"},children:qWe(c.value)?e.jsx(e.Fragment,{children:l}):o})});_We.displayName=bWe;var TNt="SelectIcon",wWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(nn.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});wWe.displayName=TNt;var ANt="SelectPortal",jWe=t=>e.jsx(FA,{asChild:!0,...t});jWe.displayName=ANt;var qS="SelectContent",NWe=k.forwardRef((t,s)=>{const r=Ew(qS,t.__scopeSelect),[n,a]=k.useState();if(jd(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?yp.createPortal(e.jsx(kWe,{scope:t.__scopeSelect,children:e.jsx(Hde.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(SWe,{...t,ref:s})});NWe.displayName=qS;var Ag=10,[kWe,Pw]=YA(qS),ENt="SelectContentImpl",PNt=lw("SelectContent.RemoveScroll"),SWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:g,collisionPadding:b,sticky:_,hideWhenDetached:j,avoidCollisions:w,...N}=t,S=Ew(qS,r),[M,L]=k.useState(null),[I,O]=k.useState(null),q=qa(s,Ce=>L(Ce)),[U,B]=k.useState(null),[V,Y]=k.useState(null),Q=Wde(r),[ee,X]=k.useState(!1),ie=k.useRef(!1);k.useEffect(()=>{if(M)return Rde(M)},[M]),Lde();const re=k.useCallback(Ce=>{const[xe,...we]=Q().map(Te=>Te.ref.current),[Le]=we.slice(-1),tt=document.activeElement;for(const Te of Ce)if(Te===tt||(Te==null||Te.scrollIntoView({block:"nearest"}),Te===xe&&I&&(I.scrollTop=0),Te===Le&&I&&(I.scrollTop=I.scrollHeight),Te==null||Te.focus(),document.activeElement!==tt))return},[Q,I]),oe=k.useCallback(()=>re([U,M]),[re,U,M]);k.useEffect(()=>{ee&&oe()},[ee,oe]);const{onOpenChange:ce,triggerPointerDownPosRef:ge}=S;k.useEffect(()=>{if(M){let Ce={x:0,y:0};const xe=Le=>{var tt,Te;Ce={x:Math.abs(Math.round(Le.pageX)-(((tt=ge.current)==null?void 0:tt.x)??0)),y:Math.abs(Math.round(Le.pageY)-(((Te=ge.current)==null?void 0:Te.y)??0))}},we=Le=>{Ce.x<=10&&Ce.y<=10?Le.preventDefault():M.contains(Le.target)||ce(!1),document.removeEventListener("pointermove",xe),ge.current=null};return ge.current!==null&&(document.addEventListener("pointermove",xe),document.addEventListener("pointerup",we,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",xe),document.removeEventListener("pointerup",we,{capture:!0})}}},[M,ce,ge]),k.useEffect(()=>{const Ce=()=>ce(!1);return window.addEventListener("blur",Ce),window.addEventListener("resize",Ce),()=>{window.removeEventListener("blur",Ce),window.removeEventListener("resize",Ce)}},[ce]);const[ye,ue]=UWe(Ce=>{const xe=Q().filter(tt=>!tt.disabled),we=xe.find(tt=>tt.ref.current===document.activeElement),Le=VWe(xe,Ce,we);Le&&setTimeout(()=>Le.ref.current.focus())}),pe=k.useCallback((Ce,xe,we)=>{const Le=!ie.current&&!we;(S.value!==void 0&&S.value===xe||Le)&&(B(Ce),Le&&(ie.current=!0))},[S.value]),_e=k.useCallback(()=>M==null?void 0:M.focus(),[M]),$e=k.useCallback((Ce,xe,we)=>{const Le=!ie.current&&!we;(S.value!==void 0&&S.value===xe||Le)&&Y(Ce)},[S.value]),Ae=n==="popper"?Cve:CWe,Ie=Ae===Cve?{side:i,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:g,collisionPadding:b,sticky:_,hideWhenDetached:j,avoidCollisions:w}:{};return e.jsx(kWe,{scope:r,content:M,viewport:I,onViewportChange:O,itemRefCallback:pe,selectedItem:U,onItemLeave:_e,itemTextRefCallback:$e,focusSelectedItem:oe,selectedItemText:V,position:n,isPositioned:ee,searchRef:ye,children:e.jsx(MO,{as:PNt,allowPinchZoom:!0,children:e.jsx(SO,{asChild:!0,trapped:S.open,onMountAutoFocus:Ce=>{Ce.preventDefault()},onUnmountAutoFocus:Ir(a,Ce=>{var xe;(xe=S.trigger)==null||xe.focus({preventScroll:!0}),Ce.preventDefault()}),children:e.jsx(kw,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Ce=>Ce.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(Ae,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:Ce=>Ce.preventDefault(),...N,...Ie,onPlaced:()=>X(!0),ref:q,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Ir(N.onKeyDown,Ce=>{const xe=Ce.ctrlKey||Ce.altKey||Ce.metaKey;if(Ce.key==="Tab"&&Ce.preventDefault(),!xe&&Ce.key.length===1&&ue(Ce.key),["ArrowUp","ArrowDown","Home","End"].includes(Ce.key)){let Le=Q().filter(tt=>!tt.disabled).map(tt=>tt.ref.current);if(["ArrowUp","End"].includes(Ce.key)&&(Le=Le.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ce.key)){const tt=Ce.target,Te=Le.indexOf(tt);Le=Le.slice(Te+1)}setTimeout(()=>re(Le)),Ce.preventDefault()}})})})})})})});SWe.displayName=ENt;var INt="SelectItemAlignedPosition",CWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=Ew(qS,r),l=Pw(qS,r),[i,c]=k.useState(null),[u,p]=k.useState(null),f=qa(s,q=>p(q)),g=Wde(r),b=k.useRef(!1),_=k.useRef(!0),{viewport:j,selectedItem:w,selectedItemText:N,focusSelectedItem:S}=l,M=k.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&j&&w&&N){const q=o.trigger.getBoundingClientRect(),U=u.getBoundingClientRect(),B=o.valueNode.getBoundingClientRect(),V=N.getBoundingClientRect();if(o.dir!=="rtl"){const tt=V.left-U.left,Te=B.left-tt,pt=q.left-Te,fe=q.width+pt,qe=Math.max(fe,U.width),at=window.innerWidth-Ag,et=eD(Te,[Ag,Math.max(Ag,at-qe)]);i.style.minWidth=fe+"px",i.style.left=et+"px"}else{const tt=U.right-V.right,Te=window.innerWidth-B.right-tt,pt=window.innerWidth-q.right-Te,fe=q.width+pt,qe=Math.max(fe,U.width),at=window.innerWidth-Ag,et=eD(Te,[Ag,Math.max(Ag,at-qe)]);i.style.minWidth=fe+"px",i.style.right=et+"px"}const Y=g(),Q=window.innerHeight-Ag*2,ee=j.scrollHeight,X=window.getComputedStyle(u),ie=parseInt(X.borderTopWidth,10),re=parseInt(X.paddingTop,10),oe=parseInt(X.borderBottomWidth,10),ce=parseInt(X.paddingBottom,10),ge=ie+re+ee+ce+oe,ye=Math.min(w.offsetHeight*5,ge),ue=window.getComputedStyle(j),pe=parseInt(ue.paddingTop,10),_e=parseInt(ue.paddingBottom,10),$e=q.top+q.height/2-Ag,Ae=Q-$e,Ie=w.offsetHeight/2,Ce=w.offsetTop+Ie,xe=ie+re+Ce,we=ge-xe;if(xe<=$e){const tt=Y.length>0&&w===Y[Y.length-1].ref.current;i.style.bottom="0px";const Te=u.clientHeight-j.offsetTop-j.offsetHeight,pt=Math.max(Ae,Ie+(tt?_e:0)+Te+oe),fe=xe+pt;i.style.height=fe+"px"}else{const tt=Y.length>0&&w===Y[0].ref.current;i.style.top="0px";const pt=Math.max($e,ie+j.offsetTop+(tt?pe:0)+Ie)+we;i.style.height=pt+"px",j.scrollTop=xe-$e+j.offsetTop}i.style.margin=`${Ag}px 0`,i.style.minHeight=ye+"px",i.style.maxHeight=Q+"px",n==null||n(),requestAnimationFrame(()=>b.current=!0)}},[g,o.trigger,o.valueNode,i,u,j,w,N,o.dir,n]);jd(()=>M(),[M]);const[L,I]=k.useState();jd(()=>{u&&I(window.getComputedStyle(u).zIndex)},[u]);const O=k.useCallback(q=>{q&&_.current===!0&&(M(),S==null||S(),_.current=!1)},[M,S]);return e.jsx(DNt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:b,onScrollButtonChange:O,children:e.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:e.jsx(nn.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});CWe.displayName=INt;var LNt="SelectPopperPosition",Cve=k.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=Ag,...o}=t,l=Gde(r);return e.jsx(jO,{...l,...o,ref:s,align:n,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Cve.displayName=LNt;var[DNt,dje]=YA(qS,{}),Mve="SelectViewport",MWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=Pw(Mve,r),l=dje(Mve,r),i=qa(s,o.onViewportChange),c=k.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),e.jsx(Hde.Slot,{scope:r,children:e.jsx(nn.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Ir(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&f){const b=Math.abs(c.current-p.scrollTop);if(b>0){const _=window.innerHeight-Ag*2,j=parseFloat(f.style.minHeight),w=parseFloat(f.style.height),N=Math.max(j,w);if(N<_){const S=N+b,M=Math.min(_,S),L=S-M;f.style.height=M+"px",f.style.bottom==="0px"&&(p.scrollTop=L>0?L:0,f.style.justifyContent="flex-end")}}}c.current=p.scrollTop})})})]})});MWe.displayName=Mve;var TWe="SelectGroup",[ONt,RNt]=YA(TWe),FNt=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Tu();return e.jsx(ONt,{scope:r,id:a,children:e.jsx(nn.div,{role:"group","aria-labelledby":a,...n,ref:s})})});FNt.displayName=TWe;var AWe="SelectLabel",EWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=RNt(AWe,r);return e.jsx(nn.div,{id:a.id,...n,ref:s})});EWe.displayName=AWe;var woe="SelectItem",[zNt,PWe]=YA(woe),IWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=Ew(woe,r),c=Pw(woe,r),u=i.value===n,[p,f]=k.useState(o??""),[g,b]=k.useState(!1),_=qa(s,S=>{var M;return(M=c.itemRefCallback)==null?void 0:M.call(c,S,n,a)}),j=Tu(),w=k.useRef("touch"),N=()=>{a||(i.onValueChange(n),i.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(zNt,{scope:r,value:n,disabled:a,textId:j,isSelected:u,onItemTextChange:k.useCallback(S=>{f(M=>M||((S==null?void 0:S.textContent)??"").trim())},[]),children:e.jsx(Hde.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(nn.div,{role:"option","aria-labelledby":j,"data-highlighted":g?"":void 0,"aria-selected":u&&g,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:_,onFocus:Ir(l.onFocus,()=>b(!0)),onBlur:Ir(l.onBlur,()=>b(!1)),onClick:Ir(l.onClick,()=>{w.current!=="mouse"&&N()}),onPointerUp:Ir(l.onPointerUp,()=>{w.current==="mouse"&&N()}),onPointerDown:Ir(l.onPointerDown,S=>{w.current=S.pointerType}),onPointerMove:Ir(l.onPointerMove,S=>{var M;w.current=S.pointerType,a?(M=c.onItemLeave)==null||M.call(c):w.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ir(l.onPointerLeave,S=>{var M;S.currentTarget===document.activeElement&&((M=c.onItemLeave)==null||M.call(c))}),onKeyDown:Ir(l.onKeyDown,S=>{var L;((L=c.searchRef)==null?void 0:L.current)!==""&&S.key===" "||(NNt.includes(S.key)&&N(),S.key===" "&&S.preventDefault())})})})})});IWe.displayName=woe;var wI="SelectItemText",LWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=Ew(wI,r),i=Pw(wI,r),c=PWe(wI,r),u=MNt(wI,r),[p,f]=k.useState(null),g=qa(s,N=>f(N),c.onItemTextChange,N=>{var S;return(S=i.itemTextRefCallback)==null?void 0:S.call(i,N,c.value,c.disabled)}),b=p==null?void 0:p.textContent,_=k.useMemo(()=>e.jsx("option",{value:c.value,disabled:c.disabled,children:b},c.value),[c.disabled,c.value,b]),{onNativeOptionAdd:j,onNativeOptionRemove:w}=u;return jd(()=>(j(_),()=>w(_)),[j,w,_]),e.jsxs(e.Fragment,{children:[e.jsx(nn.span,{id:c.textId,...o,ref:g}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren?yp.createPortal(o.children,l.valueNode):null]})});LWe.displayName=wI;var DWe="SelectItemIndicator",OWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return PWe(DWe,r).isSelected?e.jsx(nn.span,{"aria-hidden":!0,...n,ref:s}):null});OWe.displayName=DWe;var Tve="SelectScrollUpButton",RWe=k.forwardRef((t,s)=>{const r=Pw(Tve,t.__scopeSelect),n=dje(Tve,t.__scopeSelect),[a,o]=k.useState(!1),l=qa(s,n.onScrollButtonChange);return jd(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=c.scrollTop>0;o(u)};const c=r.viewport;return i(),c.addEventListener("scroll",i),()=>c.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(zWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop-c.offsetHeight)}}):null});RWe.displayName=Tve;var Ave="SelectScrollDownButton",FWe=k.forwardRef((t,s)=>{const r=Pw(Ave,t.__scopeSelect),n=dje(Ave,t.__scopeSelect),[a,o]=k.useState(!1),l=qa(s,n.onScrollButtonChange);return jd(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=c.scrollHeight-c.clientHeight,p=Math.ceil(c.scrollTop)c.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(zWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop+c.offsetHeight)}}):null});FWe.displayName=Ave;var zWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=Pw("SelectScrollButton",r),l=k.useRef(null),i=Wde(r),c=k.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return k.useEffect(()=>()=>c(),[c]),jd(()=>{var p;const u=i().find(f=>f.ref.current===document.activeElement);(p=u==null?void 0:u.ref.current)==null||p.scrollIntoView({block:"nearest"})},[i]),e.jsx(nn.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Ir(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Ir(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Ir(a.onPointerLeave,()=>{c()})})}),BNt="SelectSeparator",BWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(nn.div,{"aria-hidden":!0,...n,ref:s})});BWe.displayName=BNt;var Eve="SelectArrow",$Nt=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Gde(r),o=Ew(Eve,r),l=Pw(Eve,r);return o.open&&l.position==="popper"?e.jsx(NO,{...a,...n,ref:s}):null});$Nt.displayName=Eve;var qNt="SelectBubbleInput",$We=k.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=k.useRef(null),o=qa(n,a),l=LO(s);return k.useEffect(()=>{const i=a.current;if(!i)return;const c=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(l!==s&&p){const f=new Event("change",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(nn.select,{...r,style:{...F$e,...r.style},ref:o,defaultValue:s})});$We.displayName=qNt;function qWe(t){return t===""||t===void 0}function UWe(t){const s=vd(t),r=k.useRef(""),n=k.useRef(0),a=k.useCallback(l=>{const i=r.current+l;s(i),function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))}(i)},[s]),o=k.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return k.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function VWe(t,s,r){const a=s.length>1&&Array.from(s).every(u=>u===s[0])?s[0]:s,o=r?t.indexOf(r):-1;let l=UNt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const c=l.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function UNt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var VNt=gWe,HWe=vWe,HNt=_We,WNt=wWe,GNt=jWe,WWe=NWe,KNt=MWe,GWe=EWe,KWe=IWe,ZNt=LWe,YNt=OWe,ZWe=RWe,YWe=FWe,XWe=BWe;const Ks=VNt,Ys=HNt,Hs=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(HWe,{ref:n,className:It("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[s,e.jsx(WNt,{asChild:!0,children:e.jsx(Eo,{className:"h-4 w-4 opacity-50"})})]}));Hs.displayName=HWe.displayName;const QWe=k.forwardRef(({className:t,...s},r)=>e.jsx(ZWe,{ref:r,className:It("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(ff,{className:"h-4 w-4"})}));QWe.displayName=ZWe.displayName;const JWe=k.forwardRef(({className:t,...s},r)=>e.jsx(YWe,{ref:r,className:It("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Eo,{className:"h-4 w-4"})}));JWe.displayName=YWe.displayName;const Ws=k.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(GNt,{children:e.jsxs(WWe,{ref:a,className:It("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[e.jsx(QWe,{}),e.jsx(KNt,{className:It("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(JWe,{})]})}));Ws.displayName=WWe.displayName;const XNt=k.forwardRef(({className:t,...s},r)=>e.jsx(GWe,{ref:r,className:It("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));XNt.displayName=GWe.displayName;const Mt=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(KWe,{ref:n,className:It("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(YNt,{children:e.jsx(va,{className:"h-4 w-4"})})}),e.jsx(ZNt,{children:s})]}));Mt.displayName=KWe.displayName;const QNt=k.forwardRef(({className:t,...s},r)=>e.jsx(XWe,{ref:r,className:It("-mx-1 my-1 h-px bg-muted",t),...s}));QNt.displayName=XWe.displayName;const JNt=t=>mt({queryKey:["public-listings",t],queryFn:async()=>{let s=H.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0).order("created_at",{ascending:!1});t!=null&&t.status&&(s=s.eq("status",t.status)),t!=null&&t.propertyType&&(s=s.eq("property_type",t.propertyType)),t!=null&&t.city&&(s=s.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(s=s.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(s=s.lte("price",t.maxPrice));const{data:r,error:n}=await s;if(n)throw n;return r}}),eGe=t=>mt({queryKey:["public-listing",t],queryFn:async()=>{const s=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t);let r=H.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, agent_notes, agent_notes_public, mls_link, video_link, video_id, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary, sort_order), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds, bunny_video_id) `).eq("is_approved",!0).eq("is_public",!0);s?r=r.eq("id",t):r=r.eq("slug",t);const{data:n,error:a}=await r.single();if(a)throw a;return n},enabled:!!t}),tGe=()=>Lt({mutationFn:async({listingId:t,agentId:s,firstName:r,lastName:n,email:a,phone:o,shareToken:l})=>{let i=null,c=null;if(l){const{data:g}=await H.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();g&&(i=g.id,c=g.sharing_agent_id)}const{data:u,error:p}=await H.from("listing_leads").insert({listing_id:t,agent_id:c||s,first_name:r,last_name:n,email:a,phone:o,share_id:i,referred_by_agent_id:c}).select().single();if(p)throw p;const{error:f}=await H.functions.invoke("process-listing-lead",{body:{leadId:u.id}});return f&&console.error("Error processing lead:",f),u}}),ekt=()=>Lt({mutationFn:async t=>{const{error:s}=await H.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),tkt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},n6e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},skt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function sGe(){const[t,s]=k.useState(""),[r,n]=k.useState(!1),[a,o]=k.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=JNt({city:t||void 0,status:a.status||void 0,propertyType:a.propertyType||void 0,minPrice:a.minPrice?Number(a.minPrice):void 0,maxPrice:a.maxPrice?Number(a.maxPrice):void 0}),c=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f),u=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),s("")},p=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsx("title",{children:"LevelUp Listings - Find Your Dream Home | Real Estate for Sale"}),e.jsx("meta",{name:"description",content:"Browse exclusive property listings from LevelUp real estate agents. Find homes for sale, condos, townhouses, and luxury properties. View photos, prices, and connect with agents."}),e.jsx("link",{rel:"canonical",href:"https://listings.relevelup.com"}),e.jsx("meta",{property:"og:title",content:"LevelUp Listings - Find Your Dream Home"}),e.jsx("meta",{property:"og:description",content:"Browse exclusive property listings from LevelUp real estate agents. Find homes for sale, view photos, and connect with agents."}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:"https://listings.relevelup.com"}),e.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),e.jsx("meta",{property:"og:locale",content:"en_US"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:"LevelUp Listings - Find Your Dream Home"}),e.jsx("meta",{name:"twitter:description",content:"Browse exclusive property listings from LevelUp real estate agents."}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"keywords",content:"homes for sale, real estate, property listings, houses, condos, townhouses, luxury homes, LevelUp"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"WebSite",name:"LevelUp Listings",url:"https://listings.relevelup.com",description:"Browse exclusive property listings from LevelUp real estate agents",potentialAction:{"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:"https://listings.relevelup.com?q={search_term_string}"},"query-input":"required name=search_term_string"}})}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateAgent",name:"LevelUp",url:"https://relevelup.com",logo:"https://listings.relevelup.com/assets/levelup-logo-color.png"})})]}),e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("header",{className:"bg-white border-b border-gray-200 sticky top-0 z-50",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Pi,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:pWe,alt:"LevelUp",className:"h-8"})}),e.jsx("nav",{className:"hidden md:flex items-center gap-6",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors",children:"About LevelUp"})})]})})}),e.jsxs("section",{className:"relative bg-cover bg-center py-20 md:py-32",style:{backgroundImage:`url(${vNt})`},children:[e.jsx("div",{className:"absolute inset-0 bg-black/40"}),e.jsxs("div",{className:"relative max-w-7xl mx-auto px-4",children:[e.jsx("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-white mb-3 text-center drop-shadow-lg",children:"Find Your Perfect Home"}),e.jsx("p",{className:"text-white/90 text-center mb-10 text-lg md:text-xl drop-shadow",children:"Exclusive listings from LevelUp agents"}),e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex gap-0 shadow-2xl rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"relative flex-1 bg-white",children:[e.jsx(cn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(ze,{placeholder:"Enter an address, neighborhood, city, or ZIP code",value:t,onChange:f=>s(f.target.value),className:"pl-12 h-14 md:h-16 text-base md:text-lg border-0 focus-visible:ring-0 rounded-none bg-white"})]}),e.jsx(K,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(cn,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>n(!r),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[e.jsx(W_,{className:"h-4 w-4"}),r?"Hide Filters":"More Filters"]})}),r&&e.jsxs("div",{className:"mt-4 p-6 bg-white rounded-lg shadow-xl",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Status"}),e.jsxs(Ks,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(Hs,{className:"bg-white",children:e.jsx(Ys,{placeholder:"Any status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"Any status"}),Object.entries(n6e).map(([f,g])=>e.jsx(Mt,{value:f,children:g},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Property Type"}),e.jsxs(Ks,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(Hs,{className:"bg-white",children:e.jsx(Ys,{placeholder:"Any type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"Any type"}),Object.entries(skt).map(([f,g])=>e.jsx(Mt,{value:f,children:g},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Min Price"}),e.jsx(ze,{type:"number",placeholder:"No min",value:a.minPrice,onChange:f=>o({...a,minPrice:f.target.value}),className:"bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Max Price"}),e.jsx(ze,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:f=>o({...a,maxPrice:f.target.value}),className:"bg-white"})]})]}),p&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(Rr,{className:"h-4 w-4"}),"Clear all"]})})]})]})]})]}),l&&l.length>0&&e.jsx("section",{className:"py-8 bg-white border-b border-gray-200",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"Explore on Map"}),e.jsx(wNt,{listings:l,isLoading:i})]})}),e.jsx("section",{className:"py-8",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:i?e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:[...Array(8)].map((f,g)=>e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[e.jsx(ys,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(ys,{className:"h-7 w-28"}),e.jsx(ys,{className:"h-4 w-full"}),e.jsx(ys,{className:"h-4 w-3/4"})]})]},g))}):l&&l.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("h2",{className:"text-xl font-semibold text-gray-900",children:[l.length," ",l.length===1?"Home":"Homes"," Available"]})}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:l.map(f=>{var j,w,N;const g=((j=f.photos)==null?void 0:j.find(S=>S.is_primary))||((w=f.photos)==null?void 0:w[0]),_=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${f.slug||f.id}`:`/public/listing/${f.slug||f.id}`;return e.jsx(Pi,{to:_,children:e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm hover:shadow-lg transition-shadow cursor-pointer group border border-gray-100",children:[e.jsxs("div",{className:"aspect-[4/3] relative overflow-hidden bg-gray-100",children:[g?e.jsx("img",{src:g.photo_url,alt:f.property_address||f.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(bn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(st,{className:`absolute top-2 left-2 ${tkt[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:n6e[f.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:S=>S.preventDefault(),children:e.jsx(ni,{className:"h-5 w-5 text-gray-600"})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"text-xl font-bold text-gray-900 mb-1",children:c(f.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[f.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),f.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:f.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[f.city,", ",f.state]}),f.agent&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[e.jsx("p",{className:"text-xs text-gray-500 truncate",children:f.agent.name}),((N=f.agent.brokerage)==null?void 0:N.name)&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:f.agent.brokerage.name})]})]})]})},f.id)})})]}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-4 rounded-full bg-gray-100 flex items-center justify-center",children:e.jsx(bn,{className:"h-10 w-10 text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No listings found"}),e.jsx("p",{className:"text-gray-500 mb-6",children:p?"Try adjusting your search or filters":"Check back soon for new listings"}),p&&e.jsx(K,{variant:"outline",onClick:u,children:"Clear filters"})]})})}),e.jsx("footer",{className:"bg-gray-900 text-white py-10 mt-auto",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("img",{src:cje,alt:"LevelUp",className:"h-6"})}),e.jsxs("p",{className:"text-gray-400 text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-white text-sm transition-colors",children:"relevelup.com"})]})})})]})]})}const Ee=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Ee.displayName="Card";const Pt=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("flex flex-col space-y-1.5 p-6",t),...s}));Pt.displayName="CardHeader";const Rt=k.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:It("text-2xl font-semibold leading-none tracking-tight",t),...s}));Rt.displayName="CardTitle";const gr=k.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:It("text-sm text-muted-foreground",t),...s}));gr.displayName="CardDescription";const Oe=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("p-6 pt-0",t),...s}));Oe.displayName="CardContent";const VL=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("flex items-center p-6 pt-0",t),...s}));VL.displayName="CardFooter";var rkt="Label",rGe=k.forwardRef((t,s)=>e.jsx(nn.label,{...t,ref:s,onMouseDown:r=>{var a;r.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));rGe.displayName=rkt;var nGe=rGe;const nkt=pC("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),be=k.forwardRef(({className:t,...s},r)=>e.jsx(nGe,{ref:r,className:It(nkt(),t),...s}));be.displayName=nGe.displayName;const joe="/assets/levelup-logo-color-D3mY9gCJ.png";function akt(){const t=id(),s=window.location.hostname;if(!(s==="listings.relevelup.com"||s.startsWith("listings.")))return null;const n=t.pathname.slice(1);return!n||n===""?e.jsx(sGe,{}):n.startsWith("public/")?null:e.jsx(ikt,{slug:n})}function ikt({slug:t}){return e.jsx(ckt,{slug:t})}const okt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},lkt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},a6e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function ckt({slug:t}){var B,V;const{data:s,isLoading:r}=eGe(t),n=tGe(),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState(""),[p,f]=k.useState(""),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(null),S=Y=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Y),M=async Y=>{if(Y.preventDefault(),!(!a.trim()||!c.trim()||!s)){b(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:c.trim(),phone:p.trim()}),j(!0),me.success("Thanks! The agent will be in touch soon.")}catch(Q){console.error("Lead submission error:",Q),me.error(`Failed to submit: ${Q.message||"Please try again"}`)}finally{b(!1)}}},L=(s==null?void 0:s.photos)||[],I=L.find(Y=>Y.is_primary)||L[0],O=()=>{w!==null&&N(w===0?L.length-1:w-1)},q=()=>{w!==null&&N(w===L.length-1?0:w+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(ys,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ys,{className:"h-10 w-48 mb-6"}),e.jsx(ys,{className:"aspect-video mb-6"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-4",children:[e.jsx(ys,{className:"h-12 w-48"}),e.jsx(ys,{className:"h-6 w-full"}),e.jsx(ys,{className:"h-6 w-3/4"})]}),e.jsx(ys,{className:"h-64"})]})]})]});if(!s)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:joe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(bn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const U=s.property_address?`${s.property_address} - ${s.city}, ${s.state}`:`${s.city}, ${s.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsxs("title",{children:[U," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${a6e[s.property_type]} in ${s.city}, ${s.state}. ${((B=s.description)==null?void 0:B.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:U}),e.jsx("meta",{property:"og:description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),I&&e.jsx("meta",{property:"og:image",content:I.photo_url})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:joe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs("a",{href:"/",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),L.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>N(0),children:e.jsx("img",{src:I==null?void 0:I.photo_url,alt:"Primary",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:L.slice(1,5).map((Y,Q)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>N(Q+1),children:[e.jsx("img",{src:Y.photo_url,alt:`Photo ${Q+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),Q===3&&L.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",L.length-5," more"]})]},Y.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(st,{className:`${okt[s.status]} text-white border-0`,children:lkt[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:S(s.price)}),s.property_address&&e.jsx("p",{className:"text-xl font-medium",children:s.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ma,{className:"h-4 w-4"}),s.city,", ",s.state,s.neighborhood&&` • ${s.neighborhood}`]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[s.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Im,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.bedrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Beds"})]}),s.bathrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Ju,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.bathrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Baths"})]}),s.square_footage&&e.jsxs("div",{className:"text-center",children:[e.jsx(b0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),s.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(st,{variant:"secondary",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),a6e[s.property_type]]}),s.lot_size&&e.jsxs(st,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(st,{variant:"secondary",children:"HOA"})]}),s.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})]}),s.agent_notes&&s.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.agent_notes})]}),s.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(to,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((V=s.agent.brokerage)==null?void 0:V.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:_?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(cr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:M,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"firstName",children:"First Name *"}),e.jsx(ze,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:Y=>o(Y.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ze,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:Y=>i(Y.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:c,onChange:Y=>u(Y.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:Y=>f(Y.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:g,children:g?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(fs,{open:w!==null,onOpenChange:()=>N(null),children:e.jsxs(ps,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(_s,{className:"sr-only",children:e.jsx(vs,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>N(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Rr,{className:"h-5 w-5"})}),w!==null&&L[w]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:L[w].photo_url,alt:`Photo ${w+1}`,className:"w-full max-h-[80vh] object-contain"}),L.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:O,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:q,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(da,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[w+1," / ",L.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function Kde({card:t,variant:s}){const r=t.brokerage_display_name||t.brokerage_logo_url,n=t.team_name||t.team_logo_url;if(!r&&!n)return null;const a={standard:{container:"bg-slate-50 border border-slate-100",text:"text-slate-600",subtext:"text-slate-400"},luxury:{container:"bg-[#1e2636] border border-[#c9a84c]/10",text:"text-[#e2e8f0]",subtext:"text-[#4a5568]"},bold:{container:"bg-gray-50 border border-gray-100",text:"text-[#1a1a2e]",subtext:"text-gray-400"},classic:{container:"bg-white border border-[#d4cfc5] shadow-sm",text:"text-[#1b3a4b]",subtext:"text-[#a0aec0]"}}[s];return e.jsx("div",{className:`rounded-2xl p-4 mb-6 ${a.container}`,children:e.jsxs("div",{className:`flex flex-col items-center gap-3 ${r&&n?"divide-y divide-current/10":""}`,children:[r&&e.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-full",children:[t.brokerage_logo_url&&e.jsx("img",{src:t.brokerage_logo_url,alt:t.brokerage_display_name||"Brokerage",style:{height:`${t.brokerage_logo_size||56}px`},className:"max-w-[280px] object-contain"}),t.brokerage_display_name&&!t.brokerage_logo_url&&e.jsx("p",{className:`text-sm font-medium ${a.text}`,children:t.brokerage_display_name})]}),n&&e.jsxs("div",{className:`flex flex-col items-center gap-1.5 w-full ${r?"pt-3":""}`,children:[t.team_logo_url&&e.jsx("img",{src:t.team_logo_url,alt:t.team_name||"Team",style:{height:`${t.team_logo_size||56}px`},className:"max-w-[280px] object-contain"}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:`text-sm font-medium ${a.text}`,children:t.team_name})]})]})})}const aGe=t=>mt({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await H.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await H.from("profiles").select("name, email, phone, brokerage_id").eq("id",s.user_id).single();let a=null;if(n!=null&&n.brokerage_id){const{data:i}=await H.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 H.from("profiles").select("avatar_url").eq("id",s.user_id).single();if(i!=null&&i.avatar_url)o=i.avatar_url;else{const{data:c}=await H.storage.from("avatars").list(`${s.user_id}`);if(c&&c.length>0){const{data:u}=H.storage.from("avatars").getPublicUrl(`${s.user_id}/${c[0].name}`);o=`${u.publicUrl}?t=${Date.now()}`}}}catch{}const l={...n||{name:null,email:null,phone:null,brokerage_id:null},email:s.display_email||(n==null?void 0:n.email)||null};return{...s,social_links:s.social_links||[],profile:l,brokerage_name:s.brokerage_display_name||a,avatar_url:o}},enabled:!!t}),dkt=()=>mt({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:s}=await H.from("agent_cards").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),ukt=t=>mt({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),iGe=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("agent_cards").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),me.success("Agent card created")},onError:s=>me.error(s.message)})},oGe=()=>{const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("agent_cards").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),me.success("Agent card updated")},onError:s=>me.error(s.message)})},fo=async(t,s,r,n)=>{const a=new URLSearchParams(window.location.search);await H.from("agent_card_interactions").insert({card_id:t,interaction_type:s,interaction_detail:r||null,referrer:document.referrer||null,user_agent:navigator.userAgent||null,utm_source:a.get("utm_source")||null,utm_medium:a.get("utm_medium")||null,utm_campaign:a.get("utm_campaign")||null,metadata:{}})},hkt=async(t,s)=>{const{error:r}=await H.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},lGe=t=>mt({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("agent_card_interactions").select("interaction_type, interaction_detail, created_at").eq("card_id",t).order("created_at",{ascending:!1}).limit(500);if(r)throw r;const{data:n,error:a}=await H.from("agent_card_leads").select("*").eq("card_id",t).order("created_at",{ascending:!1});if(a)throw a;const o=(s==null?void 0:s.filter(c=>c.interaction_type==="card_view").length)||0,l=(s==null?void 0:s.filter(c=>c.interaction_type==="button_click").length)||0,i=(s==null?void 0:s.filter(c=>c.interaction_type==="contact_saved").length)||0;return{views:o,clicks:l,saves:i,leads:n||[],interactions:s||[]}},enabled:!!t});function Zde({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=k.useState(""),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(""),[j,w]=k.useState(!1),N=async S=>{if(S.preventDefault(),!o.trim()){me.error("Please enter your name");return}w(!0);try{await hkt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:b.trim()||void 0,intent:f||void 0}),fo(r,"lead_submitted",n),H.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:b.trim()||void 0,intent:f||void 0}}).catch(M=>console.error("Card lead notify failed:",M)),me.success(n==="booking"?"Request sent! They'll be in touch soon.":n==="connect"?"Info shared! They'll be in touch soon.":"Referral submitted! Thank you."),s(!1),l(""),c(""),p(""),g(""),_("")}catch{me.error("Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),e.jsx(Gr,{children:n==="booking"?`Let ${a} know you'd like to connect.`:n==="connect"?`Share your info and ${a} will reach out.`:`Know someone who could use ${a}'s help?`})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-name",children:"Name *"}),e.jsx(ze,{id:"lead-name",value:o,onChange:S=>l(S.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(ze,{id:"lead-phone",type:"tel",value:u,onChange:S=>p(S.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-email",children:"Email"}),e.jsx(ze,{id:"lead-email",type:"email",value:i,onChange:S=>c(S.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select one"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buy",children:"Buy a home"}),e.jsx(Mt,{value:"sell",children:"Sell my home"}),e.jsx(Mt,{value:"both",children:"Buy & Sell"}),e.jsx(Mt,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(ze,{id:"lead-message",value:b,onChange:S=>_(S.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full rounded-2xl",disabled:j,children:j?"Sending...":"Submit"})]})]})})}const mkt=t=>mt({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("card_blocks").select("*").eq("card_id",t).eq("is_visible",!0).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),pkt=t=>mt({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),fkt=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("card_blocks").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["card-blocks",r.card_id]}),t.invalidateQueries({queryKey:["card-blocks-all",r.card_id]}),me.success("Block added")},onError:s=>me.error(s.message)})},xkt=()=>{const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("card_blocks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),me.success("Block updated")},onError:s=>me.error(s.message)})},gkt=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("card_blocks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),me.success("Block removed")},onError:s=>me.error(s.message)})};function ykt(t){const s=t.match(/(?:iframe\.mediadelivery\.net\/embed\/|video\.bunnycdn\.com\/play\/)(\d+)\/([a-f0-9-]+)/i);return s?`https://iframe.mediadelivery.net/embed/${s[1]}/${s[2]}?autoplay=false&responsive=true`:(t.includes("iframe.mediadelivery.net"),t)}function vkt(t){const s=t.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/);return s?`https://www.youtube.com/embed/${s[1]}`:null}const bkt={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 _kt({block:t,variant:s}){const r=t.config;if(!r.video_url)return null;const n=r.video_url.includes("mediadelivery.net")||r.video_url.includes("bunnycdn.com"),a=vkt(r.video_url),o=n||!!a,l=n?ykt(r.video_url):a||r.video_url;return e.jsx("div",{className:bkt[s],children:o?e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:l,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsx("video",{src:r.video_url,controls:!0,className:"w-full",preload:"metadata"})})}const wkt={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 jkt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=k.useState(0);if(n.length===0)return null;const l=wkt[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(H_,{className:"h-4 w-4 mb-2 opacity-30"}),e.jsxs("p",{className:`${l.quote} mb-3`,children:['"',i.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:l.name,children:i.name}),i.role&&e.jsx("p",{className:l.role,children:i.role})]})]}),n.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[e.jsx("button",{onClick:()=>o(c=>(c-1+n.length)%n.length),className:l.nav,children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:n.map((c,u)=>e.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${u===a?l.dot:l.dotInactive}`,onClick:()=>o(u)},u))}),e.jsx("button",{onClick:()=>o(c=>(c+1)%n.length),className:l.nav,children:e.jsx(da,{className:"h-4 w-4"})})]})]})}const Nkt={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 kkt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=Nkt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const Skt={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 Ckt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=Skt[r];return e.jsx("div",{className:o.container,children:a.map((l,i)=>e.jsxs("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(tn,{className:`h-4 w-4 ${o.icon}`})]},i))})}const Pve={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 Mkt({path:t,color:s,size:r=20}){return e.jsx("svg",{viewBox:"0 0 24 24",width:r,height:r,fill:s,children:e.jsx("path",{d:t})})}const Tkt={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 Akt({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=Tkt[r];return a.length===0?null:e.jsxs("div",{className:o.container,children:[e.jsx("h3",{className:o.title,children:"Follow Me"}),e.jsx("div",{className:"flex flex-wrap gap-3 justify-center",children:a.map((l,i)=>{const c=Pve[l.platform.toLowerCase()];return!c||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:c.label,children:e.jsx(Mkt,{path:c.icon,color:c.color})},i)})})]})}function Yde({cardId:t,variant:s}){const{data:r}=mkt(t);if(!r||r.length===0)return null;const n=r.filter(l=>l.block_type==="social_media"&&l.is_visible),a=r.filter(l=>l.block_type!=="social_media"),o=n.length>0?{...n[0],config:{platforms:n.flatMap(l=>l.config.platforms||[])}}:null;return r.findIndex(l=>l.block_type==="social_media"),e.jsxs(e.Fragment,{children:[a.map(l=>{switch(l.block_type){case"video_intro":return e.jsx(_kt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(jkt,{block:l,variant:s},l.id);case"specialties":return e.jsx(kkt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(Ckt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(Akt,{block:o,cardId:t,variant:s})]})}async function Ekt(t){try{const s=await fetch(t);if(!s.ok)return null;const r=await s.blob(),n=r.type||"image/jpeg";return new Promise(a=>{const o=new FileReader;o.onloadend=()=>{const i=o.result.split(",")[1];a({base64:i,mimeType:n})},o.onerror=()=>a(null),o.readAsDataURL(r)})}catch{return null}}function Pkt(t){const s=t.trim().split(/\s+/);if(s.length<=1)return{first:s[0]||"",last:""};const r=s.pop();return{first:s.join(" "),last:r}}async function Xde(t){const{first:s,last:r}=Pkt(t.name),n=["BEGIN:VCARD","VERSION:3.0",`FN:${t.name}`,`N:${r};${s};;;`];if(t.phone&&n.push(`TEL;TYPE=CELL:${t.phone}`),t.email&&n.push(`EMAIL;TYPE=INTERNET:${t.email}`),t.brokerage&&n.push(`ORG:${t.brokerage}`),n.push(`URL:${t.cardUrl}`),t.avatarUrl){const i=await Ekt(t.avatarUrl);if(i){const u={"image/jpeg":"JPEG","image/jpg":"JPEG","image/png":"PNG","image/gif":"GIF","image/webp":"JPEG"}[i.mimeType]||"JPEG";n.push(`PHOTO;ENCODING=b;TYPE=${u}:${i.base64}`)}}n.push("END:VCARD");const a=new Blob([n.join(`\r `)],{type:"text/vcard"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=`${t.name.replace(/\s+/g,"_")}.vcf`,l.click(),URL.revokeObjectURL(o),me.success("Contact saved!")}function Ikt({card:t}){var N;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,M)=>{fo(t.id,"button_click",S),M()},c=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},g=()=>{var S,M;fo(t.id,"contact_saved"),Xde({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},b=async()=>{if(fo(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:t.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},_=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Nn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx($a,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:l})]}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',t.positioning_statement,'"']})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs(K,{onClick:c,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(Un,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),e.jsxs(K,{onClick:u,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(so,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(K,{onClick:p,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(cr,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(K,{onClick:f,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(hn,{className:"h-5 w-5 mr-2"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-4 w-4 text-amber-500 fill-amber-500"}),e.jsx("span",{className:"font-bold text-slate-900",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-slate-50 rounded-2xl p-4 mb-6 border border-slate-100",children:e.jsxs("p",{className:"text-sm text-slate-600 italic text-center",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-2",children:"About Me"}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:t.bio})]}),e.jsx(Kde,{card:t,variant:"standard"}),e.jsx(Yde,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(K,{variant:"ghost",onClick:g,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(yi,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs(K,{variant:"ghost",onClick:()=>{fo(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Jn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(K,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(pr,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(K,{variant:"ghost",onClick:j,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Tl,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(K,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(wd,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,M)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:w[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(Zde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Lkt({card:t}){var N;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,M)=>{fo(t.id,"button_click",S),M()},c=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},g=()=>{var S,M;fo(t.id,"contact_saved"),Xde({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},b=async()=>{if(fo(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:t.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},_=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Nn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx($a,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-serif bg-[#c9a84c]/20 text-[#e8d48b]",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-white tracking-wide mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#e8d48b] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#c9a84c] tracking-widest uppercase mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#a0aec0] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Un,label:"Call",handler:c},{icon:so,label:"Text",handler:u},{icon:cr,label:"Email",handler:p}].map(({icon:S,label:M,handler:L})=>e.jsxs("button",{onClick:L,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(S,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:M})]},M))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-xl mb-6 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] text-[#0f1419] hover:opacity-90 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#c9a84c] fill-[#c9a84c]"}),e.jsx("span",{className:"font-bold text-white",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-[#1e2636] rounded-xl p-4 mb-6 border border-[#c9a84c]/10",children:e.jsxs("p",{className:"text-sm text-[#a0aec0] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#c9a84c] mb-2 tracking-wide uppercase",children:"About"}),e.jsx("p",{className:"text-sm text-[#a0aec0] leading-relaxed",children:t.bio})]}),e.jsx(Kde,{card:t,variant:"luxury"}),e.jsx(Yde,{cardId:t.id,variant:"luxury"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:g,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(yi,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{fo(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(pr,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Tl,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(wd,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,M)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:w[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(Zde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Dkt({card:t}){var M,L,I,O;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",l=o.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2),i={accent:((L=t.bold_theme_colors)==null?void 0:L.accent)||"#ff5722",dark:((I=t.bold_theme_colors)==null?void 0:I.dark)||"#1a1a2e",button:((O=t.bold_theme_colors)==null?void 0:O.button)||"#ff5722"},c=(q,U)=>{const B=parseInt(q.replace("#",""),16),V=Math.max(0,(B>>16)-U),Y=Math.max(0,(B>>8&255)-U),Q=Math.max(0,(B&255)-U);return`#${(V<<16|Y<<8|Q).toString(16).padStart(6,"0")}`};c(i.accent,25),c(i.dark,-20),c(i.button,25);const u=(q,U)=>{fo(t.id,"button_click",q),U()},p=()=>u("call",()=>{var q;(q=t.profile)!=null&&q.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),f=()=>u("text",()=>{var q;(q=t.profile)!=null&&q.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),g=()=>u("email",()=>{var q;(q=t.profile)!=null&&q.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),b=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},_=()=>{var q,U;fo(t.id,"contact_saved"),Xde({name:o,phone:(q=t.profile)==null?void 0:q.phone,email:(U=t.profile)==null?void 0:U.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},j=async()=>{if(fo(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},w=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},S={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[e.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[t.show_photo&&e.jsxs(Nn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx($a,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-black text-white",style:{backgroundColor:i.accent},children:l})]}),e.jsx("h1",{className:"text-3xl font-black text-white tracking-tight mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-bold mb-1",style:{color:`${i.accent}cc`},children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-bold uppercase tracking-wider mb-1",style:{color:i.accent},children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-bold text-white/60 uppercase tracking-wider",children:t.team_name})]}),e.jsxs("div",{className:"max-w-md mx-auto px-5 -mt-6",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl px-5 py-8",children:[t.positioning_statement&&e.jsx("p",{className:"text-center font-bold text-lg leading-snug mb-6 max-w-xs mx-auto",style:{color:i.dark},children:t.positioning_statement}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Un,label:"Call",handler:p},{icon:so,label:"Text",handler:f},{icon:cr,label:"Email",handler:g}].map(({icon:q,label:U,handler:B})=>e.jsxs("button",{onClick:B,className:"flex flex-col items-center gap-1.5 py-4 text-white rounded-2xl transition-opacity font-bold hover:opacity-85",style:{backgroundColor:i.dark},children:[e.jsx(q,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:U})]},U))}),e.jsxs("button",{onClick:b,className:"w-full h-14 text-base font-black rounded-2xl mb-6 text-white transition-opacity hover:opacity-90 flex items-center justify-center gap-2 uppercase tracking-wide",style:{backgroundColor:i.button},children:[e.jsx(hn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:t.review_snippet&&e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-5 w-5",style:{color:i.accent,fill:i.accent}}),e.jsx("span",{className:"font-black text-2xl",style:{color:i.dark},children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"rounded-2xl p-4 mb-6",style:{backgroundColor:`${i.accent}15`},children:e.jsxs("p",{className:"text-sm font-medium text-center",style:{color:i.dark},children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xs font-black mb-2 uppercase tracking-wider",style:{color:i.accent},children:"About Me"}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:t.bio})]}),e.jsx(Kde,{card:t,variant:"bold"}),e.jsx(Yde,{cardId:t.id,variant:"bold"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(yi,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{fo(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Jn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(pr,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:N,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Tl,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(wd,{className:"h-4 w-4",style:{color:i.accent}})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-6",children:t.social_links.slice(0,3).map((q,U)=>e.jsx("a",{href:q.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${q.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:S[q.platform.toLowerCase()]||"🔗"},U))})]}),e.jsx("div",{className:"text-center py-6",children:e.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),e.jsx(Zde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Okt({card:t}){var N;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,M)=>{fo(t.id,"button_click",S),M()},c=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},g=()=>{var S,M;fo(t.id,"contact_saved"),Xde({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},b=async()=>{if(fo(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},_=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Nn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx($a,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-serif bg-[#1b3a4b] text-white",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-[#1b3a4b] mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#4a5568] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Un,label:"Call",handler:c},{icon:so,label:"Text",handler:u},{icon:cr,label:"Email",handler:p}].map(({icon:S,label:M,handler:L})=>e.jsxs("button",{onClick:L,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(S,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:M})]},M))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-lg mb-6 bg-[#1b3a4b] hover:bg-[#264d61] text-white transition-colors flex items-center justify-center gap-2 shadow-sm",children:[e.jsx(hn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsx("div",{className:"flex items-center justify-center gap-6",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#d4a843] fill-[#d4a843]"}),e.jsx("span",{className:"font-bold text-[#1b3a4b] font-serif",children:"5.0"})]})})}),t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsxs("p",{className:"text-sm text-[#4a5568] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#1b3a4b] mb-2 font-serif",children:"About"}),e.jsx("p",{className:"text-sm text-[#4a5568] leading-relaxed",children:t.bio})]}),e.jsx(Kde,{card:t,variant:"classic"}),e.jsx(Yde,{cardId:t.id,variant:"classic"}),e.jsxs("div",{className:"bg-white rounded-lg border border-[#d4cfc5] shadow-sm divide-y divide-[#e8e3db] mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:g,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(yi,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{fo(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(pr,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Tl,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(wd,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,M)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:w[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(Zde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function uje({card:t}){switch(t.theme){case"luxury":return e.jsx(Lkt,{card:t});case"bold":return e.jsx(Dkt,{card:t});case"classic":return e.jsx(Okt,{card:t});case"standard":default:return e.jsx(Ikt,{card:t})}}function Rkt(){const t=id();k.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Agent Cards"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific agent's card URL to view their digital business card."})]})}):e.jsx(Fkt,{slug:s})}function Fkt({slug:t}){return e.jsx(zkt,{slug:t})}function zkt({slug:t}){var o;const{data:s,isLoading:r,error:n}=aGe(t);if(k.useEffect(()=>{s!=null&&s.id&&fo(s.id,"card_view")},[s==null?void 0:s.id]),r)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(ys,{className:"h-28 w-28 rounded-full"}),e.jsx(ys,{className:"h-6 w-48"}),e.jsx(ys,{className:"h-4 w-36"})]}),e.jsx(ys,{className:"h-12 w-full"}),e.jsx(ys,{className:"h-12 w-full"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Card Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This agent card doesn't exist or isn't published yet."})]})});const a=((o=s.profile)==null?void 0:o.name)||"Agent";return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsxs("title",{children:[a," | Real Estate Agent"]}),e.jsx("meta",{name:"description",content:s.positioning_statement||`Connect with ${a}, your trusted real estate professional.`}),e.jsx("meta",{property:"og:title",content:`${a} | Real Estate Agent`}),e.jsx("meta",{property:"og:description",content:s.positioning_statement||`Connect with ${a}`}),s.avatar_url&&e.jsx("meta",{property:"og:image",content:s.avatar_url})]}),e.jsx(uje,{card:s})]})}function cGe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=k.useState(n||""),[c,u]=k.useState(a||""),[p,f]=k.useState(o||""),[g,b]=k.useState(""),[_,j]=k.useState(""),[w,N]=k.useState(!1),[S,M]=k.useState(!1),L=async I=>{if(I.preventDefault(),!l.trim()){me.error("Please enter your name");return}N(!0);try{const{error:O}=await H.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:c.trim()||null,phone:p.trim()||null,intent:g||null,message:_.trim()||null});if(O)throw O;try{await H.rpc("log_presentation_view",{p_presentation_id:t,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}H.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:c.trim()||void 0,phone:p.trim()||void 0,intent:g||void 0,message:_.trim()||void 0}}).catch(q=>console.error("Presentation lead notify failed:",q)),M(!0)}catch{me.error("Something went wrong. Please try again.")}finally{N(!1)}};return S?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(va,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you!"}),e.jsx("p",{className:"text-gray-500",children:r?`${r} will be in touch soon.`:"We'll be in touch soon."})]}):e.jsxs("form",{onSubmit:L,className:"space-y-4 max-w-md mx-auto",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(ze,{id:"pres-lead-name",value:l,onChange:I=>i(I.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(ze,{id:"pres-lead-phone",type:"tel",value:p,onChange:I=>f(I.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(ze,{id:"pres-lead-email",type:"email",value:c,onChange:I=>u(I.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(Ks,{value:g,onValueChange:b,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select one"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buy",children:"Buy a home"}),e.jsx(Mt,{value:"sell",children:"Sell my home"}),e.jsx(Mt,{value:"both",children:"Buy & Sell"}),e.jsx(Mt,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(ze,{id:"pres-lead-message",value:_,onChange:I=>j(I.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:w,children:w?"Sending...":s})]})}function Bkt(){const t=id();k.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Smart Presentations"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific presentation URL to view it."})]})}):e.jsx($kt,{shareToken:s})}function $kt({shareToken:t}){var _;const[s,r]=k.useState(null),[n,a]=k.useState(!0),[o,l]=k.useState(0),[i,c]=k.useState(!1);k.useEffect(()=>{u()},[t]);const u=async()=>{const{data:j,error:w}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(w||!j){c(!0),a(!1);return}const{data:N}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let S;if(N!=null&&N.brokerage_id){const{data:L}=await H.from("brokerages").select("name").eq("id",N.brokerage_id).single();S=(L==null?void 0:L.name)||void 0}let M=null;if(j.contact_id){const{data:L}=await H.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();M=L}r({...j,owner_name:N==null?void 0:N.name,owner_email:N==null?void 0:N.email,owner_phone:N==null?void 0:N.phone,owner_avatar:N==null?void 0:N.avatar_url,owner_title:(N==null?void 0:N.title)||void 0,brokerage_name:S,contact_name:M?[M.first_name,M.last_name].filter(Boolean).join(" "):void 0,contact_email:(M==null?void 0:M.email)||void 0,contact_phone:(M==null?void 0:M.phone)||void 0}),a(!1);try{await H.rpc("log_presentation_view",{p_presentation_id:j.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await H.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}},f=j=>{const w=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(w)return`https://www.youtube.com/embed/${w[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const M=j.replace("/play/","/embed/"),L=M.includes("?")?"&":"?";return`${M}${L}responsive=true`}if(j.includes("iframe.mediadelivery.net")){const M=j.includes("?")?"&":"?";return`${j}${M}responsive=true`}const N=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(N)return`https://www.loom.com/embed/${N[1]}`;const S=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return S?`https://iframe.mediadelivery.net/embed/${S[1]}/${S[2]}?responsive=true`:j};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(ys,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const g=s.sections.filter(j=>j.is_visible!==!1),b=g[o];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsx("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-end",children:e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[b!=null&&b.video_url?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:f(b.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"})}):b!=null&&b.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:b.image_url,alt:b.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:b==null?void 0:b.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:b==null?void 0:b.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:b==null?void 0:b.description})]}),(b==null?void 0:b.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:b.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:g.map((j,w)=>e.jsx("button",{onClick:()=>l(w),className:It("w-full text-left p-4 rounded-xl border transition-all",o===w?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(w+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:j.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:j.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:j.description})]})]})},w))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(_=s.cta_url)!=null&&_.trim()?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(tn,{className:"h-5 w-5 ml-2"})]}):e.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:e.jsx(cGe,{presentationId:s.id,ctaLabel:s.cta_label,agentName:s.owner_name||void 0,prefillName:s.contact_name,prefillEmail:s.contact_email,prefillPhone:s.contact_phone})})]})]}),e.jsx("footer",{className:"border-t border-gray-100 bg-white mt-12 py-6 text-center text-xs text-gray-400",children:"Powered by LevelUp"})]})}const $x=()=>{const t=ci();return mt({queryKey:["user-team",t],queryFn:async()=>{const{data:s,error:r}=await H.from("team_members").select("id, team_id, role").eq("user_id",t).maybeSingle();if(console.log("[useUserTeam] membership query:",{userId:t,membership:s,error:r}),r)throw r;if(!s)return null;const{data:n,error:a}=await H.from("teams").select("*").eq("id",s.team_id).single();if(a)throw a;return{membershipId:s.id,teamId:s.team_id,role:s.role,team:n}},enabled:!!t,staleTime:5*60*1e3})};function qkt(){const{user:t}=Ds(),s=ci(),{data:r}=$x();return mt({queryKey:["open-houses",s,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:a}=await H.from("open_houses").select("*").eq("agent_id",s).order("event_date",{ascending:!1});if(a)throw a;let o=n||[];if((r==null?void 0:r.role)==="team_leader"&&r.teamId){const{data:l,error:i}=await H.rpc("get_team_open_houses",{_user_id:s});if(!i&&l){const c=[...new Set(l.map(f=>f.agent_id))],u={};if(c.length>0){const{data:f}=await H.from("profiles").select("id, name").in("id",c);f==null||f.forEach(g=>{g.name&&(u[g.id]=g.name)})}const p=l.map(f=>({...f,agent_name:u[f.agent_id]||void 0}));o=[...o,...p]}}return o.sort((l,i)=>i.event_date.localeCompare(l.event_date)),o},enabled:!!t&&!!s})}function VMs(t){const{user:s}=Ds();return mt({queryKey:["open-house",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_houses").select("*").eq("id",t).single();if(n)throw n;return r},enabled:!!s&&!!t})}function dGe(t){const{user:s}=Ds(),r=Qt();return k.useEffect(()=>{if(!t)return;const n=H.channel(`visitors-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${t}`},()=>{r.invalidateQueries({queryKey:["open-house-visitors",t]}),r.invalidateQueries({queryKey:["open-houses"]})}).subscribe();return()=>{H.removeChannel(n)}},[t,r]),mt({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:a}=await H.from("open_house_visitors").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(a)throw a;return n},enabled:!!s&&!!t})}function Ukt(){const t=Qt(),s=ci();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("open_houses").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),wn({title:"Open house created!"})},onError:r=>{wn({title:"Error",description:r.message,variant:"destructive"})}})}function uGe(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{error:n}=await H.from("open_houses").update(r).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["open-houses"]}),t.invalidateQueries({queryKey:["open-house",r.id]})}})}function Vkt(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("open_houses").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),wn({title:"Open house deleted"})}})}function Hkt(t){return mt({queryKey:["public-open-house",t],queryFn:async()=>{const{data:s,error:r}=await H.from("open_houses").select("*, profiles:agent_id(name, avatar_url, title)").eq("slug",t).eq("is_active",!0).single();if(r)throw r;let n=null;if(s.agent_id){const{data:a}=await H.from("agent_cards").select("slug").eq("user_id",s.agent_id).eq("is_published",!0).maybeSingle();a&&(n=a.slug)}return{...s,agent_card_slug:n}},enabled:!!t})}function Wkt(t){const{user:s}=Ds();return mt({queryKey:["survey-questions",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;return r},enabled:!!s&&!!t})}function Gkt(t){return mt({queryKey:["public-survey-questions",t],queryFn:async()=>{const{data:s,error:r}=await H.from("open_house_survey_questions").select("*").eq("open_house_id",t).eq("is_active",!0).order("sort_order");if(r)throw r;return s},enabled:!!t})}function Kkt(){return Lt({mutationFn:async t=>{const{error:s}=await H.from("open_house_survey_responses").insert(t);if(s)throw s}})}function Zkt(t){const{user:s}=Ds();return mt({queryKey:["survey-responses",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;const a=(r||[]).map(i=>i.id);if(a.length===0)return{questions:[],responses:[]};const{data:o,error:l}=await H.from("open_house_survey_responses").select("*").in("question_id",a).order("created_at",{ascending:!1});if(l)throw l;return{questions:r,responses:o||[]}},enabled:!!s&&!!t})}function Ykt(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("open_house_survey_questions").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function Xkt(){const t=Qt();return Lt({mutationFn:async({id:s,open_house_id:r,...n})=>{const{error:a}=await H.from("open_house_survey_questions").update(n).eq("id",s);if(a)throw a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function Qkt(){const t=Qt();return Lt({mutationFn:async({id:s,open_house_id:r})=>{const{error:n}=await H.from("open_house_survey_questions").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function Jkt(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.rpc("seed_default_survey_questions",{_open_house_id:s});if(r)throw r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r]})}})}function e4t(){return Lt({mutationFn:async t=>{const{data:s,error:r}=await H.from("open_house_visitors").insert(t).select("id").single();if(r)throw r;return s}})}var Qde="Switch",[t4t]=ad(Qde),[s4t,r4t]=t4t(Qde),hGe=k.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:c="on",onCheckedChange:u,form:p,...f}=t,[g,b]=k.useState(null),_=qa(s,M=>b(M)),j=k.useRef(!1),w=g?p||!!g.closest("form"):!0,[N,S]=ah({prop:a,defaultProp:o??!1,onChange:u,caller:Qde});return e.jsxs(s4t,{scope:r,checked:N,disabled:i,children:[e.jsx(nn.button,{type:"button",role:"switch","aria-checked":N,"aria-required":l,"data-state":xGe(N),"data-disabled":i?"":void 0,disabled:i,value:c,...f,ref:_,onClick:Ir(t.onClick,M=>{S(L=>!L),w&&(j.current=M.isPropagationStopped(),j.current||M.stopPropagation())})}),w&&e.jsx(fGe,{control:g,bubbles:!j.current,name:n,value:c,checked:N,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});hGe.displayName=Qde;var mGe="SwitchThumb",pGe=k.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=r4t(mGe,r);return e.jsx(nn.span,{"data-state":xGe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});pGe.displayName=mGe;var n4t="SwitchBubbleInput",fGe=k.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=qa(l,o),c=LO(r),u=_O(s);return k.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&b){const _=new Event("click",{bubbles:n});b.call(p,r),p.dispatchEvent(_)}},[c,r,n]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});fGe.displayName=n4t;function xGe(t){return t?"checked":"unchecked"}var gGe=hGe,a4t=pGe;const qr=k.forwardRef(({className:t,...s},r)=>e.jsx(gGe,{className:It("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...s,ref:r,children:e.jsx(a4t,{className:It("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")})}));qr.displayName=gGe.displayName;function ra(t){const s=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&s==="[object Date]"?new t.constructor(+t):typeof t=="number"||s==="[object Number]"||typeof t=="string"||s==="[object String]"?new Date(t):new Date(NaN)}function xl(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function Pl(t,s){const r=ra(t);return isNaN(s)?xl(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Bm(t,s){const r=ra(t);if(isNaN(s))return xl(t,NaN);if(!s)return r;const n=r.getDate(),a=xl(t,r.getTime());a.setMonth(r.getMonth()+s+1,0);const o=a.getDate();return n>=o?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}function yGe(t,s){const r=+ra(t);return xl(t,r+s)}const hje=6048e5,i4t=864e5,Jde=6e4,DO=36e5,o4t=1e3,sz=43200,i6e=1440;function o6e(t,s){return yGe(t,s*DO)}let l4t={};function Iw(){return l4t}function Xh(t,s){var i,c,u,p;const r=Iw(),n=(s==null?void 0:s.weekStartsOn)??((c=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=ra(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function $m(t){const s=ra(t);return s.setHours(0,0,0,0),s}function hw(t){const s=ra(t),r=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return r.setUTCFullYear(s.getFullYear()),+t-+r}function mf(t,s){const r=$m(t),n=$m(s),a=+r-hw(r),o=+n-hw(n);return Math.round((a-o)/i4t)}function c4t(t){const s=vGe(t),r=xl(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),A1(r)}function iM(t,s){return yGe(t,s*Jde)}function y4(t,s){const r=s*7;return Pl(t,r)}function d4t(t,s){return Bm(t,s*12)}function u4t(t){let s;return t.forEach(function(r){const n=ra(r);(s===void 0||s{const n=ra(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function hie(t,s){const r=ra(t),n=ra(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function mje(t){return xl(t,Date.now())}function Cl(t,s){const r=$m(t),n=$m(s);return+r==+n}function pje(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Ive(t){if(!pje(t)&&typeof t!="number")return!1;const s=ra(t);return!isNaN(Number(s))}function OT(t,s){const r=ra(t),n=ra(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function m4t(t,s,r){const n=Xh(t,r),a=Xh(s,r),o=+n-hw(n),l=+a-hw(a);return Math.round((o-l)/hje)}function ly(t,s){const r=ra(t),n=ra(s),a=l6e(r,n),o=Math.abs(mf(r,n));r.setDate(r.getDate()-a*o);const l=+(l6e(r,n)===-a),i=a*(o-l);return i===0?0:i}function l6e(t,s){const r=t.getFullYear()-s.getFullYear()||t.getMonth()-s.getMonth()||t.getDate()-s.getDate()||t.getHours()-s.getHours()||t.getMinutes()-s.getMinutes()||t.getSeconds()-s.getSeconds()||t.getMilliseconds()-s.getMilliseconds();return r<0?-1:r>0?1:r}function bGe(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function _Ge(t,s){return+ra(t)-+ra(s)}function p4t(t,s,r){const n=_Ge(t,s)/DO;return bGe(r==null?void 0:r.roundingMethod)(n)}function f4t(t){const s=ra(t);return s.setHours(23,59,59,999),s}function cx(t){const s=ra(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function x4t(t){const s=ra(t);return+f4t(s)==+cx(s)}function g4t(t,s){const r=ra(t),n=ra(s),a=hie(r,n),o=Math.abs(OT(r,n));let l;if(o<1)l=0;else{r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-a*o);let i=hie(r,n)===-a;x4t(ra(t))&&o===1&&hie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function y4t(t,s,r){const n=_Ge(t,s)/1e3;return bGe(r==null?void 0:r.roundingMethod)(n)}function v4t(t,s){const r=ra(t.start),n=ra(t.end);let a=+r>+n;const o=a?+r:+n,l=a?n:r;l.setHours(0,0,0,0);let i=1;const c=[];for(;+l<=o;)c.push(ra(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?c.reverse():c}function Fc(t){const s=ra(t);return s.setDate(1),s.setHours(0,0,0,0),s}function wGe(t){const s=ra(t),r=xl(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function eue(t,s){var i,c,u,p;const r=Iw(),n=(s==null?void 0:s.weekStartsOn)??((c=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=ra(t),o=a.getDay(),l=(o{let n;const a=b4t[t];return typeof a=="string"?n=a:s===1?n=a.one:n=a.other.replace("{{count}}",s.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function Sxe(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const w4t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},j4t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},N4t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},k4t={date:Sxe({formats:w4t,defaultWidth:"full"}),time:Sxe({formats:j4t,defaultWidth:"full"}),dateTime:Sxe({formats:N4t,defaultWidth:"full"})},S4t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},C4t=(t,s,r,n)=>S4t[t];function qP(t){return(s,r)=>{const n=r!=null&&r.context?String(r.context):"standalone";let a;if(n==="formatting"&&t.formattingValues){const l=t.defaultFormattingWidth||t.defaultWidth,i=r!=null&&r.width?String(r.width):l;a=t.formattingValues[i]||t.formattingValues[l]}else{const l=t.defaultWidth,i=r!=null&&r.width?String(r.width):t.defaultWidth;a=t.values[i]||t.values[l]}const o=t.argumentCallback?t.argumentCallback(s):s;return a[o]}}const M4t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},T4t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},A4t={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"]},E4t={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"]},P4t={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"}},I4t={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"}},L4t=(t,s)=>{const r=Number(t),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},D4t={ordinalNumber:L4t,era:qP({values:M4t,defaultWidth:"wide"}),quarter:qP({values:T4t,defaultWidth:"wide",argumentCallback:t=>t-1}),month:qP({values:A4t,defaultWidth:"wide"}),day:qP({values:E4t,defaultWidth:"wide"}),dayPeriod:qP({values:P4t,defaultWidth:"wide",formattingValues:I4t,defaultFormattingWidth:"wide"})};function UP(t){return(s,r={})=>{const n=r.width,a=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=s.match(a);if(!o)return null;const l=o[0],i=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(i)?R4t(i,f=>f.test(l)):O4t(i,f=>f.test(l));let u;u=t.valueCallback?t.valueCallback(c):c,u=r.valueCallback?r.valueCallback(u):u;const p=s.slice(l.length);return{value:u,rest:p}}}function O4t(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function R4t(t,s){for(let r=0;r{const n=s.match(t.matchPattern);if(!n)return null;const a=n[0],o=s.match(t.parsePattern);if(!o)return null;let l=t.valueCallback?t.valueCallback(o[0]):o[0];l=r.valueCallback?r.valueCallback(l):l;const i=s.slice(a.length);return{value:l,rest:i}}}const z4t=/^(\d+)(th|st|nd|rd)?/i,B4t=/\d+/i,$4t={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},q4t={any:[/^b/i,/^(a|c)/i]},U4t={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},V4t={any:[/1/i,/2/i,/3/i,/4/i]},H4t={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},W4t={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]},G4t={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},K4t={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]},Z4t={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},Y4t={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}},X4t={ordinalNumber:F4t({matchPattern:z4t,parsePattern:B4t,valueCallback:t=>parseInt(t,10)}),era:UP({matchPatterns:$4t,defaultMatchWidth:"wide",parsePatterns:q4t,defaultParseWidth:"any"}),quarter:UP({matchPatterns:U4t,defaultMatchWidth:"wide",parsePatterns:V4t,defaultParseWidth:"any",valueCallback:t=>t+1}),month:UP({matchPatterns:H4t,defaultMatchWidth:"wide",parsePatterns:W4t,defaultParseWidth:"any"}),day:UP({matchPatterns:G4t,defaultMatchWidth:"wide",parsePatterns:K4t,defaultParseWidth:"any"}),dayPeriod:UP({matchPatterns:Z4t,defaultMatchWidth:"any",parsePatterns:Y4t,defaultParseWidth:"any"})},tue={code:"en-US",formatDistance:_4t,formatLong:k4t,formatRelative:C4t,localize:D4t,match:X4t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Q4t(t){const s=ra(t);return mf(s,wGe(s))+1}function fje(t){const s=ra(t),r=+A1(s)-+c4t(s);return Math.round(r/hje)+1}function xje(t,s){var p,f,g,b;const r=ra(t),n=r.getFullYear(),a=Iw(),o=(s==null?void 0:s.firstWeekContainsDate)??((f=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((b=(g=a.locale)==null?void 0:g.options)==null?void 0:b.firstWeekContainsDate)??1,l=xl(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=Xh(l,s),c=xl(t,0);c.setFullYear(n,0,o),c.setHours(0,0,0,0);const u=Xh(c,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function J4t(t,s){var i,c,u,p;const r=Iw(),n=(s==null?void 0:s.firstWeekContainsDate)??((c=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.firstWeekContainsDate)??1,a=xje(t,s),o=xl(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),Xh(o,s)}function gje(t,s){const r=ra(t),n=+Xh(r,s)-+J4t(r,s);return Math.round(n/hje)+1}function fl(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const Lb={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return fl(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):fl(r+1,2)},d(t,s){return fl(t.getDate(),s.length)},a(t,s){const r=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(t,s){return fl(t.getHours()%12||12,s.length)},H(t,s){return fl(t.getHours(),s.length)},m(t,s){return fl(t.getMinutes(),s.length)},s(t,s){return fl(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return fl(a,s.length)}},_5={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},c6e={G:function(t,s,r){const n=t.getFullYear()>0?1:0;switch(s){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(t,s,r){if(s==="yo"){const n=t.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return Lb.y(t,s)},Y:function(t,s,r,n){const a=xje(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return fl(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):fl(o,s.length)},R:function(t,s){const r=vGe(t);return fl(r,s.length)},u:function(t,s){const r=t.getFullYear();return fl(r,s.length)},Q:function(t,s,r){const n=Math.ceil((t.getMonth()+1)/3);switch(s){case"Q":return String(n);case"QQ":return fl(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(t,s,r){const n=Math.ceil((t.getMonth()+1)/3);switch(s){case"q":return String(n);case"qq":return fl(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(t,s,r){const n=t.getMonth();switch(s){case"M":case"MM":return Lb.M(t,s);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(t,s,r){const n=t.getMonth();switch(s){case"L":return String(n+1);case"LL":return fl(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(t,s,r,n){const a=gje(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):fl(a,s.length)},I:function(t,s,r){const n=fje(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):fl(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Lb.d(t,s)},D:function(t,s,r){const n=Q4t(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):fl(n,s.length)},E:function(t,s,r){const n=t.getDay();switch(s){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(t,s,r,n){const a=t.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"e":return String(o);case"ee":return fl(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(t,s,r,n){const a=t.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"c":return String(o);case"cc":return fl(o,s.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(t,s,r){const n=t.getDay(),a=n===0?7:n;switch(s){case"i":return String(a);case"ii":return fl(a,s.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(t,s,r){const a=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,s,r){const n=t.getHours();let a;switch(n===12?a=_5.noon:n===0?a=_5.midnight:a=n/12>=1?"pm":"am",s){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,s,r){const n=t.getHours();let a;switch(n>=17?a=_5.evening:n>=12?a=_5.afternoon:n>=4?a=_5.morning:a=_5.night,s){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,s,r){if(s==="ho"){let n=t.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return Lb.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Lb.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):fl(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):fl(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Lb.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Lb.s(t,s)},S:function(t,s){return Lb.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return u6e(n);case"XXXX":case"XX":return n4(n);case"XXXXX":case"XXX":default:return n4(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return u6e(n);case"xxxx":case"xx":return n4(n);case"xxxxx":case"xxx":default:return n4(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+d6e(n,":");case"OOOO":default:return"GMT"+n4(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+d6e(n,":");case"zzzz":default:return"GMT"+n4(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return fl(n,s.length)},T:function(t,s,r){const n=t.getTime();return fl(n,s.length)}};function d6e(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Math.trunc(n/60),o=n%60;return o===0?r+String(a):r+String(a)+s+fl(o,2)}function u6e(t,s){return t%60===0?(t>0?"-":"+")+fl(Math.abs(t)/60,2):n4(t,s)}function n4(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=fl(Math.trunc(n/60),2),o=fl(n%60,2);return r+a+s+o}const h6e=(t,s)=>{switch(t){case"P":return s.date({width:"short"});case"PP":return s.date({width:"medium"});case"PPP":return s.date({width:"long"});case"PPPP":default:return s.date({width:"full"})}},NGe=(t,s)=>{switch(t){case"p":return s.time({width:"short"});case"pp":return s.time({width:"medium"});case"ppp":return s.time({width:"long"});case"pppp":default:return s.time({width:"full"})}},eSt=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return h6e(t,s);let o;switch(n){case"P":o=s.dateTime({width:"short"});break;case"PP":o=s.dateTime({width:"medium"});break;case"PPP":o=s.dateTime({width:"long"});break;case"PPPP":default:o=s.dateTime({width:"full"});break}return o.replace("{{date}}",h6e(n,s)).replace("{{time}}",NGe(a,s))},Lve={p:NGe,P:eSt},tSt=/^D+$/,sSt=/^Y+$/,rSt=["D","DD","YY","YYYY"];function kGe(t){return tSt.test(t)}function SGe(t){return sSt.test(t)}function Dve(t,s,r){const n=nSt(t,s,r);if(console.warn(n),rSt.includes(t))throw new RangeError(n)}function nSt(t,s,r){const n=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${s}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const aSt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,iSt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,oSt=/^'([^]*?)'?$/,lSt=/''/g,cSt=/[a-zA-Z]/;function ms(t,s,r){var p,f,g,b,_,j,w,N;const n=Iw(),a=(r==null?void 0:r.locale)??n.locale??tue,o=(r==null?void 0:r.firstWeekContainsDate)??((f=(p=r==null?void 0:r.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??n.firstWeekContainsDate??((b=(g=n.locale)==null?void 0:g.options)==null?void 0:b.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((j=(_=r==null?void 0:r.locale)==null?void 0:_.options)==null?void 0:j.weekStartsOn)??n.weekStartsOn??((N=(w=n.locale)==null?void 0:w.options)==null?void 0:N.weekStartsOn)??0,i=ra(t);if(!Ive(i))throw new RangeError("Invalid time value");let c=s.match(iSt).map(S=>{const M=S[0];if(M==="p"||M==="P"){const L=Lve[M];return L(S,a.formatLong)}return S}).join("").match(aSt).map(S=>{if(S==="''")return{isToken:!1,value:"'"};const M=S[0];if(M==="'")return{isToken:!1,value:dSt(S)};if(c6e[M])return{isToken:!0,value:S};if(M.match(cSt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+M+"`");return{isToken:!1,value:S}});a.localize.preprocessor&&(c=a.localize.preprocessor(i,c));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return c.map(S=>{if(!S.isToken)return S.value;const M=S.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&SGe(M)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&kGe(M))&&Dve(M,s,String(t));const L=c6e[M[0]];return L(i,M,a.localize,u)}).join("")}function dSt(t){const s=t.match(oSt);return s?s[1].replace(lSt,"'"):t}function uSt(t,s,r){const n=Iw(),a=(r==null?void 0:r.locale)??n.locale??tue,o=2520,l=hie(t,s);if(isNaN(l))throw new RangeError("Invalid time value");const i=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:l});let c,u;l>0?(c=ra(s),u=ra(t)):(c=ra(t),u=ra(s));const p=y4t(u,c),f=(hw(u)-hw(c))/1e3,g=Math.round((p-f)/60);let b;if(g<2)return r!=null&&r.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,i):p<10?a.formatDistance("lessThanXSeconds",10,i):p<20?a.formatDistance("lessThanXSeconds",20,i):p<40?a.formatDistance("halfAMinute",0,i):p<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):g===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",g,i);if(g<45)return a.formatDistance("xMinutes",g,i);if(g<90)return a.formatDistance("aboutXHours",1,i);if(gn.getTime()}function VS(t,s){const r=ra(t),n=ra(s);return+r<+n}function ySt(t){return+ra(t)>Date.now()}function vSt(t,s){const r=s instanceof Date?xl(s,0):new s(0);return r.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),r.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),r}const bSt=10;class CGe{constructor(){Mn(this,"subPriority",0)}validate(s,r){return!0}}class _St extends CGe{constructor(s,r,n,a,o){super(),this.value=s,this.validateValue=r,this.setValue=n,this.priority=a,o&&(this.subPriority=o)}validate(s,r){return this.validateValue(s,this.value,r)}set(s,r,n){return this.setValue(s,r,this.value,n)}}class wSt extends CGe{constructor(){super(...arguments);Mn(this,"priority",bSt);Mn(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:xl(r,vSt(r,Date))}}class al{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new _St(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class jSt extends al{constructor(){super(...arguments);Mn(this,"priority",140);Mn(this,"incompatibleTokens",["R","u","t","T"])}parse(r,n,a){switch(n){case"G":case"GG":case"GGG":return a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"});case"GGGGG":return a.era(r,{width:"narrow"});case"GGGG":default:return a.era(r,{width:"wide"})||a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"})}}set(r,n,a){return n.era=a,r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}const Ld={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}/},r0={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 Dd(t,s){return t&&{value:s(t.value),rest:t.rest}}function Jc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function n0(t,s){const r=s.match(t);if(!r)return null;if(r[0]==="Z")return{value:0,rest:s.slice(1)};const n=r[1]==="+"?1:-1,a=r[2]?parseInt(r[2],10):0,o=r[3]?parseInt(r[3],10):0,l=r[5]?parseInt(r[5],10):0;return{value:n*(a*DO+o*Jde+l*o4t),rest:s.slice(r[0].length)}}function MGe(t){return Jc(Ld.anyDigitsSigned,t)}function Nd(t,s){switch(t){case 1:return Jc(Ld.singleDigit,s);case 2:return Jc(Ld.twoDigits,s);case 3:return Jc(Ld.threeDigits,s);case 4:return Jc(Ld.fourDigits,s);default:return Jc(new RegExp("^\\d{1,"+t+"}"),s)}}function Noe(t,s){switch(t){case 1:return Jc(Ld.singleDigitSigned,s);case 2:return Jc(Ld.twoDigitsSigned,s);case 3:return Jc(Ld.threeDigitsSigned,s);case 4:return Jc(Ld.fourDigitsSigned,s);default:return Jc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function yje(t){switch(t){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function TGe(t,s){const r=s>0,n=r?s:1-s;let a;if(n<=50)a=t||100;else{const o=n+50,l=Math.trunc(o/100)*100,i=t>=o%100;a=t+l-(i?100:0)}return r?a:1-a}function AGe(t){return t%400===0||t%4===0&&t%100!==0}class NSt extends al{constructor(){super(...arguments);Mn(this,"priority",130);Mn(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(r,n,a){const o=l=>({year:l,isTwoDigitYear:n==="yy"});switch(n){case"y":return Dd(Nd(4,r),o);case"yo":return Dd(a.ordinalNumber(r,{unit:"year"}),o);default:return Dd(Nd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a){const o=r.getFullYear();if(a.isTwoDigitYear){const i=TGe(a.year,o);return r.setFullYear(i,0,1),r.setHours(0,0,0,0),r}const l=!("era"in n)||n.era===1?a.year:1-a.year;return r.setFullYear(l,0,1),r.setHours(0,0,0,0),r}}class kSt extends al{constructor(){super(...arguments);Mn(this,"priority",130);Mn(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(r,n,a){const o=l=>({year:l,isTwoDigitYear:n==="YY"});switch(n){case"Y":return Dd(Nd(4,r),o);case"Yo":return Dd(a.ordinalNumber(r,{unit:"year"}),o);default:return Dd(Nd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=xje(r,o);if(a.isTwoDigitYear){const c=TGe(a.year,l);return r.setFullYear(c,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Xh(r,o)}const i=!("era"in n)||n.era===1?a.year:1-a.year;return r.setFullYear(i,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Xh(r,o)}}class SSt extends al{constructor(){super(...arguments);Mn(this,"priority",130);Mn(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return Noe(n==="R"?4:n.length,r)}set(r,n,a){const o=xl(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),A1(o)}}class CSt extends al{constructor(){super(...arguments);Mn(this,"priority",130);Mn(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return Noe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class MSt extends al{constructor(){super(...arguments);Mn(this,"priority",120);Mn(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"Q":case"QQ":return Nd(n.length,r);case"Qo":return a.ordinalNumber(r,{unit:"quarter"});case"QQQ":return a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQQ":return a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return a.quarter(r,{width:"wide",context:"formatting"})||a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class TSt extends al{constructor(){super(...arguments);Mn(this,"priority",120);Mn(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"q":case"qq":return Nd(n.length,r);case"qo":return a.ordinalNumber(r,{unit:"quarter"});case"qqq":return a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"});case"qqqqq":return a.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return a.quarter(r,{width:"wide",context:"standalone"})||a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class ASt extends al{constructor(){super(...arguments);Mn(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Mn(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return Dd(Jc(Ld.month,r),o);case"MM":return Dd(Nd(2,r),o);case"Mo":return Dd(a.ordinalNumber(r,{unit:"month"}),o);case"MMM":return a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"});case"MMMMM":return a.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return a.month(r,{width:"wide",context:"formatting"})||a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}class ESt extends al{constructor(){super(...arguments);Mn(this,"priority",110);Mn(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(r,n,a){const o=l=>l-1;switch(n){case"L":return Dd(Jc(Ld.month,r),o);case"LL":return Dd(Nd(2,r),o);case"Lo":return Dd(a.ordinalNumber(r,{unit:"month"}),o);case"LLL":return a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"});case"LLLLL":return a.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return a.month(r,{width:"wide",context:"standalone"})||a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}function PSt(t,s,r){const n=ra(t),a=gje(n,r)-s;return n.setDate(n.getDate()-a*7),n}class ISt extends al{constructor(){super(...arguments);Mn(this,"priority",100);Mn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return Jc(Ld.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return Nd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return Xh(PSt(r,a,o),o)}}function LSt(t,s){const r=ra(t),n=fje(r)-s;return r.setDate(r.getDate()-n*7),r}class DSt extends al{constructor(){super(...arguments);Mn(this,"priority",100);Mn(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(r,n,a){switch(n){case"I":return Jc(Ld.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return Nd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return A1(LSt(r,a))}}const OSt=[31,28,31,30,31,30,31,31,30,31,30,31],RSt=[31,29,31,30,31,30,31,31,30,31,30,31];class FSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"subPriority",1);Mn(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return Jc(Ld.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return Nd(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=AGe(a),l=r.getMonth();return o?n>=1&&n<=RSt[l]:n>=1&&n<=OSt[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class zSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"subpriority",1);Mn(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(r,n,a){switch(n){case"D":case"DD":return Jc(Ld.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return Nd(n.length,r)}}validate(r,n){const a=r.getFullYear();return AGe(a)?n>=1&&n<=366:n>=1&&n<=365}set(r,n,a){return r.setMonth(0,a),r.setHours(0,0,0,0),r}}function vje(t,s,r){var f,g,b,_;const n=Iw(),a=(r==null?void 0:r.weekStartsOn)??((g=(f=r==null?void 0:r.locale)==null?void 0:f.options)==null?void 0:g.weekStartsOn)??n.weekStartsOn??((_=(b=n.locale)==null?void 0:b.options)==null?void 0:_.weekStartsOn)??0,o=ra(t),l=o.getDay(),c=(s%7+7)%7,u=7-a,p=s<0||s>6?s-(l+u)%7:(c+u)%7-(l+u)%7;return Pl(o,p)}class BSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"E":case"EE":case"EEE":return a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"EEEEE":return a.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"EEEE":default:return a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=vje(r,a,o),r.setHours(0,0,0,0),r}}class $St extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(r,n,a,o){const l=i=>{const c=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+c};switch(n){case"e":case"ee":return Dd(Nd(n.length,r),l);case"eo":return Dd(a.ordinalNumber(r,{unit:"day"}),l);case"eee":return a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeee":default:return a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=vje(r,a,o),r.setHours(0,0,0,0),r}}class qSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(r,n,a,o){const l=i=>{const c=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+c};switch(n){case"c":case"cc":return Dd(Nd(n.length,r),l);case"co":return Dd(a.ordinalNumber(r,{unit:"day"}),l);case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"cccc":default:return a.day(r,{width:"wide",context:"standalone"})||a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=vje(r,a,o),r.setHours(0,0,0,0),r}}function USt(t,s){const r=ra(t),n=pSt(r),a=s-n;return Pl(r,a)}class VSt extends al{constructor(){super(...arguments);Mn(this,"priority",90);Mn(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(r,n,a){const o=l=>l===0?7:l;switch(n){case"i":case"ii":return Nd(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return Dd(a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiii":return Dd(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Dd(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Dd(a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o)}}validate(r,n){return n>=1&&n<=7}set(r,n,a){return r=USt(r,a),r.setHours(0,0,0,0),r}}class HSt extends al{constructor(){super(...arguments);Mn(this,"priority",80);Mn(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(r,n,a){switch(n){case"a":case"aa":case"aaa":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaaa":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaa":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(yje(a),0,0,0),r}}class WSt extends al{constructor(){super(...arguments);Mn(this,"priority",80);Mn(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(r,n,a){switch(n){case"b":case"bb":case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbb":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(yje(a),0,0,0),r}}class GSt extends al{constructor(){super(...arguments);Mn(this,"priority",80);Mn(this,"incompatibleTokens",["a","b","t","T"])}parse(r,n,a){switch(n){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBB":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(yje(a),0,0,0),r}}class KSt extends al{constructor(){super(...arguments);Mn(this,"priority",70);Mn(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return Jc(Ld.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return Nd(n.length,r)}}validate(r,n){return n>=1&&n<=12}set(r,n,a){const o=r.getHours()>=12;return o&&a<12?r.setHours(a+12,0,0,0):!o&&a===12?r.setHours(0,0,0,0):r.setHours(a,0,0,0),r}}class ZSt extends al{constructor(){super(...arguments);Mn(this,"priority",70);Mn(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return Jc(Ld.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return Nd(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class YSt extends al{constructor(){super(...arguments);Mn(this,"priority",70);Mn(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return Jc(Ld.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return Nd(n.length,r)}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.getHours()>=12&&a<12?r.setHours(a+12,0,0,0):r.setHours(a,0,0,0),r}}class XSt extends al{constructor(){super(...arguments);Mn(this,"priority",70);Mn(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return Jc(Ld.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return Nd(n.length,r)}}validate(r,n){return n>=1&&n<=24}set(r,n,a){const o=a<=24?a%24:a;return r.setHours(o,0,0,0),r}}class QSt extends al{constructor(){super(...arguments);Mn(this,"priority",60);Mn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Jc(Ld.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return Nd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class JSt extends al{constructor(){super(...arguments);Mn(this,"priority",50);Mn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Jc(Ld.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return Nd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class eCt extends al{constructor(){super(...arguments);Mn(this,"priority",30);Mn(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Dd(Nd(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class tCt extends al{constructor(){super(...arguments);Mn(this,"priority",10);Mn(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return n0(r0.basicOptionalMinutes,r);case"XX":return n0(r0.basic,r);case"XXXX":return n0(r0.basicOptionalSeconds,r);case"XXXXX":return n0(r0.extendedOptionalSeconds,r);case"XXX":default:return n0(r0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:xl(r,r.getTime()-hw(r)-a)}}class sCt extends al{constructor(){super(...arguments);Mn(this,"priority",10);Mn(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return n0(r0.basicOptionalMinutes,r);case"xx":return n0(r0.basic,r);case"xxxx":return n0(r0.basicOptionalSeconds,r);case"xxxxx":return n0(r0.extendedOptionalSeconds,r);case"xxx":default:return n0(r0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:xl(r,r.getTime()-hw(r)-a)}}class rCt extends al{constructor(){super(...arguments);Mn(this,"priority",40);Mn(this,"incompatibleTokens","*")}parse(r){return MGe(r)}set(r,n,a){return[xl(r,a*1e3),{timestampIsSet:!0}]}}class nCt extends al{constructor(){super(...arguments);Mn(this,"priority",20);Mn(this,"incompatibleTokens","*")}parse(r){return MGe(r)}set(r,n,a){return[xl(r,a),{timestampIsSet:!0}]}}const aCt={G:new jSt,y:new NSt,Y:new kSt,R:new SSt,u:new CSt,Q:new MSt,q:new TSt,M:new ASt,L:new ESt,w:new ISt,I:new DSt,d:new FSt,D:new zSt,E:new BSt,e:new $St,c:new qSt,i:new VSt,a:new HSt,b:new WSt,B:new GSt,h:new KSt,H:new ZSt,K:new YSt,k:new XSt,m:new QSt,s:new JSt,S:new eCt,X:new tCt,x:new sCt,t:new rCt,T:new nCt},iCt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,oCt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,lCt=/^'([^]*?)'?$/,cCt=/''/g,dCt=/\S/,uCt=/[a-zA-Z]/;function bje(t,s,r,n){var j,w,N,S;const a=mSt(),o=a.locale??tue,l=a.firstWeekContainsDate??((w=(j=a.locale)==null?void 0:j.options)==null?void 0:w.firstWeekContainsDate)??1,i=a.weekStartsOn??((S=(N=a.locale)==null?void 0:N.options)==null?void 0:S.weekStartsOn)??0;if(s==="")return t===""?ra(r):xl(r,NaN);const c={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new wSt],p=s.match(oCt).map(M=>{const L=M[0];if(L in Lve){const I=Lve[L];return I(M,o.formatLong)}return M}).join("").match(iCt),f=[];for(let M of p){SGe(M)&&Dve(M,s,t),kGe(M)&&Dve(M,s,t);const L=M[0],I=aCt[L];if(I){const{incompatibleTokens:O}=I;if(Array.isArray(O)){const U=f.find(B=>O.includes(B.token)||B.token===L);if(U)throw new RangeError(`The format string mustn't contain \`${U.fullToken}\` and \`${M}\` at the same time`)}else if(I.incompatibleTokens==="*"&&f.length>0)throw new RangeError(`The format string mustn't contain \`${M}\` and any other token at the same time`);f.push({token:L,fullToken:M});const q=I.run(t,M,o.match,c);if(!q)return xl(r,NaN);u.push(q.setter),t=q.rest}else{if(L.match(uCt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+L+"`");if(M==="''"?M="'":L==="'"&&(M=hCt(M)),t.indexOf(M)===0)t=t.slice(M.length);else return xl(r,NaN)}}if(t.length>0&&dCt.test(t))return xl(r,NaN);const g=u.map(M=>M.priority).sort((M,L)=>L-M).filter((M,L,I)=>I.indexOf(M)===L).map(M=>u.filter(L=>L.priority===M).sort((L,I)=>I.subPriority-L.subPriority)).map(M=>M[0]);let b=ra(r);if(isNaN(b.getTime()))return xl(r,NaN);const _={};for(const M of g){if(!M.validate(b,c))return xl(r,NaN);const L=M.set(b,_,c);Array.isArray(L)?(b=L[0],Object.assign(_,L[1])):b=L}return xl(r,b)}function hCt(t){return t.match(lCt)[1].replace(cCt,"'")}function w0(t){return+ra(t)o-l);return r>=n&&r<=a}function mie(t,s){return Pl(t,-s)}function jm(t,s){const n=vCt(t);let a;if(n.date){const c=bCt(n.date,2);a=_Ct(c.restDateString,c.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const o=a.getTime();let l=0,i;if(n.time&&(l=wCt(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=jCt(n.timezone),isNaN(i))return new Date(NaN)}else{const c=new Date(o+l),u=new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u}return new Date(o+l+i)}const rz={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},xCt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,gCt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,yCt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function vCt(t){const s={},r=t.split(rz.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],rz.timeZoneDelimiter.test(s.date)&&(s.date=t.split(rz.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=rz.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function bCt(t,s){const r=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+s)+"})|(\\d{2}|[+-]\\d{"+(2+s)+"})$)"),n=t.match(r);if(!n)return{year:NaN,restDateString:""};const a=n[1]?parseInt(n[1]):null,o=n[2]?parseInt(n[2]):null;return{year:o===null?a:o*100,restDateString:t.slice((n[1]||n[2]).length)}}function _Ct(t,s){if(s===null)return new Date(NaN);const r=t.match(xCt);if(!r)return new Date(NaN);const n=!!r[4],a=VP(r[1]),o=VP(r[2])-1,l=VP(r[3]),i=VP(r[4]),c=VP(r[5])-1;if(n)return MCt(s,i,c)?NCt(s,i,c):new Date(NaN);{const u=new Date(0);return!SCt(s,o,l)||!CCt(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function VP(t){return t?parseInt(t):1}function wCt(t){const s=t.match(gCt);if(!s)return NaN;const r=Cxe(s[1]),n=Cxe(s[2]),a=Cxe(s[3]);return TCt(r,n,a)?r*DO+n*Jde+a*1e3:NaN}function Cxe(t){return t&&parseFloat(t.replace(",","."))||0}function jCt(t){if(t==="Z")return 0;const s=t.match(yCt);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return ACt(n,a)?r*(n*DO+a*Jde):NaN}function NCt(t,s,r){const n=new Date(0);n.setUTCFullYear(t,0,4);const a=n.getUTCDay()||7,o=(s-1)*7+r+1-a;return n.setUTCDate(n.getUTCDate()+o),n}const kCt=[31,null,31,30,31,30,31,31,30,31,30,31];function EGe(t){return t%400===0||t%4===0&&t%100!==0}function SCt(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(kCt[s]||(EGe(t)?29:28))}function CCt(t,s){return s>=1&&s<=(EGe(t)?366:365)}function MCt(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function TCt(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function ACt(t,s){return s>=0&&s<=59}function Mxe(t,s){const r=ra(t),n=r.getFullYear(),a=r.getDate(),o=xl(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=hSt(o);return r.setMonth(s,Math.min(a,l)),r}function HL(t,s){const r=ra(t);return r.setHours(s),r}function WL(t,s){const r=ra(t);return r.setMinutes(s),r}function p6e(t,s){const r=ra(t);return isNaN(+r)?xl(t,NaN):(r.setFullYear(s),r)}function v4(t,s){return Bm(t,-s)}var Ko;(function(t){t.assertEqual=a=>{};function s(a){}t.assertIs=s;function r(a){throw new Error}t.assertNever=r,t.arrayToEnum=a=>{const o={};for(const l of a)o[l]=l;return o},t.getValidEnumValues=a=>{const o=t.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),l={};for(const i of o)l[i]=a[i];return t.objectValues(l)},t.objectValues=a=>t.objectKeys(a).map(function(o){return a[o]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const o=[];for(const l in a)Object.prototype.hasOwnProperty.call(a,l)&&o.push(l);return o},t.find=(a,o)=>{for(const l of a)if(o(l))return l},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,o=" | "){return a.map(l=>typeof l=="string"?`'${l}'`:l).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(Ko||(Ko={}));var f6e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(f6e||(f6e={}));const ha=Ko.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Gb=t=>{switch(typeof t){case"undefined":return ha.undefined;case"string":return ha.string;case"number":return Number.isNaN(t)?ha.nan:ha.number;case"boolean":return ha.boolean;case"function":return ha.function;case"bigint":return ha.bigint;case"symbol":return ha.symbol;case"object":return Array.isArray(t)?ha.array:t===null?ha.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ha.promise:typeof Map<"u"&&t instanceof Map?ha.map:typeof Set<"u"&&t instanceof Set?ha.set:typeof Date<"u"&&t instanceof Date?ha.date:ha.object;default:return ha.unknown}},on=Ko.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 T0 extends Error{get errors(){return this.issues}constructor(s){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=s}format(s){const r=s||function(o){return o.message},n={_errors:[]},a=o=>{for(const l of o.issues)if(l.code==="invalid_union")l.unionErrors.map(a);else if(l.code==="invalid_return_type")a(l.returnTypeError);else if(l.code==="invalid_arguments")a(l.argumentsError);else if(l.path.length===0)n._errors.push(r(l));else{let i=n,c=0;for(;cr.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const o=a.path[0];r[o]=r[o]||[],r[o].push(s(a))}else n.push(s(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}T0.create=t=>new T0(t);const Ove=(t,s)=>{let r;switch(t.code){case on.invalid_type:t.received===ha.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case on.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Ko.jsonStringifyReplacer)}`;break;case on.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ko.joinValues(t.keys,", ")}`;break;case on.invalid_union:r="Invalid input";break;case on.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ko.joinValues(t.options)}`;break;case on.invalid_enum_value:r=`Invalid enum value. Expected ${Ko.joinValues(t.options)}, received '${t.received}'`;break;case on.invalid_arguments:r="Invalid function arguments";break;case on.invalid_return_type:r="Invalid function return type";break;case on.invalid_date:r="Invalid date";break;case on.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Ko.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case on.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case on.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case on.custom:r="Invalid input";break;case on.invalid_intersection_types:r="Intersection results could not be merged";break;case on.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case on.not_finite:r="Number must be finite";break;default:r=s.defaultError,Ko.assertNever(t)}return{message:r}};let ECt=Ove;function PCt(){return ECt}const ICt=t=>{const{data:s,path:r,errorMaps:n,issueData:a}=t,o=[...r,...a.path||[]],l={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let i="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)i=u(l,{data:s,defaultError:i}).message;return{...a,path:o,message:i}};function Xn(t,s){const r=PCt(),n=ICt({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ove?void 0:Ove].filter(a=>!!a)});t.common.issues.push(n)}class Mf{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(s,r){const n=[];for(const a of r){if(a.status==="aborted")return Fi;a.status==="dirty"&&s.dirty(),n.push(a.value)}return{status:s.value,value:n}}static async mergeObjectAsync(s,r){const n=[];for(const a of r){const o=await a.key,l=await a.value;n.push({key:o,value:l})}return Mf.mergeObjectSync(s,n)}static mergeObjectSync(s,r){const n={};for(const a of r){const{key:o,value:l}=a;if(o.status==="aborted"||l.status==="aborted")return Fi;o.status==="dirty"&&s.dirty(),l.status==="dirty"&&s.dirty(),o.value!=="__proto__"&&(typeof l.value<"u"||a.alwaysSet)&&(n[o.value]=l.value)}return{status:s.value,value:n}}}const Fi=Object.freeze({status:"aborted"}),jI=t=>({status:"dirty",value:t}),qx=t=>({status:"valid",value:t}),x6e=t=>t.status==="aborted",g6e=t=>t.status==="dirty",RT=t=>t.status==="valid",koe=t=>typeof Promise<"u"&&t instanceof Promise;var Na;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(Na||(Na={}));class mw{constructor(s,r,n,a){this._cachedPath=[],this.parent=s,this.data=r,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const y6e=(t,s)=>{if(RT(s))return{success:!0,data:s.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new T0(t.common.issues);return this._error=r,this._error}}};function io(t){if(!t)return{};const{errorMap:s,invalid_type_error:r,required_error:n,description:a}=t;if(s&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return s?{errorMap:s,description:a}:{errorMap:(l,i)=>{const{message:c}=t;return l.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??n??i.defaultError}:l.code!=="invalid_type"?{message:i.defaultError}:{message:c??r??i.defaultError}},description:a}}class Vo{get description(){return this._def.description}_getType(s){return Gb(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:Gb(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new Mf,ctx:{common:s.parent.common,data:s.data,parsedType:Gb(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(koe(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(s){const r=this._parse(s);return Promise.resolve(r)}parse(s,r){const n=this.safeParse(s,r);if(n.success)return n.data;throw n.error}safeParse(s,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Gb(s)},a=this._parseSync({data:s,path:n.path,parent:n});return y6e(n,a)}"~validate"(s){var n,a;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Gb(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return RT(o)?{value:o.value}:{issues:r.common.issues}}catch(o){(a=(n=o==null?void 0:o.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:s,path:[],parent:r}).then(o=>RT(o)?{value:o.value}:{issues:r.common.issues})}async parseAsync(s,r){const n=await this.safeParseAsync(s,r);if(n.success)return n.data;throw n.error}async safeParseAsync(s,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Gb(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(koe(a)?a:Promise.resolve(a));return y6e(n,o)}refine(s,r){const n=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,o)=>{const l=s(a),i=()=>o.addIssue({code:on.custom,...n(a)});return typeof Promise<"u"&&l instanceof Promise?l.then(c=>c?!0:(i(),!1)):l?!0:(i(),!1)})}refinement(s,r){return this._refinement((n,a)=>s(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(s){return new BT({schema:this,typeName:zi.ZodEffects,effect:{type:"refinement",refinement:s}})}superRefine(s){return this._refinement(s)}constructor(s){this.spa=this.safeParseAsync,this._def=s,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return X_.create(this,this._def)}nullable(){return $T.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return j0.create(this)}promise(){return Toe.create(this,this._def)}or(s){return Coe.create([this,s],this._def)}and(s){return Moe.create(this,s,this._def)}transform(s){return new BT({...io(this._def),schema:this,typeName:zi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Bve({...io(this._def),innerType:this,defaultValue:r,typeName:zi.ZodDefault})}brand(){return new s3t({typeName:zi.ZodBranded,type:this,...io(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new $ve({...io(this._def),innerType:this,catchValue:r,typeName:zi.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return _je.create(this,s)}readonly(){return qve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const LCt=/^c[^\s-]{8,}$/i,DCt=/^[0-9a-z]+$/,OCt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,RCt=/^[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,FCt=/^[a-z0-9_-]{21}$/i,zCt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,BCt=/^[-+]?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)?)??$/,$Ct=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,qCt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Txe;const UCt=/^(?:(?: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])$/,VCt=/^(?:(?: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])$/,HCt=/^(([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]))$/,WCt=/^(([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])$/,GCt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,KCt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,PGe="((\\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])))",ZCt=new RegExp(`^${PGe}$`);function IGe(t){let s="[0-5]\\d";t.precision?s=`${s}\\.\\d{${t.precision}}`:t.precision==null&&(s=`${s}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${s})${r}`}function YCt(t){return new RegExp(`^${IGe(t)}$`)}function XCt(t){let s=`${PGe}T${IGe(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),s=`${s}(${r.join("|")})`,new RegExp(`^${s}$`)}function QCt(t,s){return!!((s==="v4"||!s)&&UCt.test(t)||(s==="v6"||!s)&&HCt.test(t))}function JCt(t,s){if(!zCt.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||s&&a.alg!==s)}catch{return!1}}function e3t(t,s){return!!((s==="v4"||!s)&&VCt.test(t)||(s==="v6"||!s)&&WCt.test(t))}class j_ extends Vo{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==ha.string){const o=this._getOrReturnCtx(s);return Xn(o,{code:on.invalid_type,expected:ha.string,received:o.parsedType}),Fi}const n=new Mf;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),Xn(a,{code:on.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const l=s.data.length>o.value,i=s.data.lengths.test(a),{validation:r,code:on.invalid_string,...Na.errToObj(n)})}_addCheck(s){return new j_({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...Na.errToObj(s)})}url(s){return this._addCheck({kind:"url",...Na.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...Na.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...Na.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...Na.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...Na.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...Na.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...Na.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...Na.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...Na.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...Na.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...Na.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...Na.errToObj(s)})}datetime(s){return typeof s=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:s}):this._addCheck({kind:"datetime",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,offset:(s==null?void 0:s.offset)??!1,local:(s==null?void 0:s.local)??!1,...Na.errToObj(s==null?void 0:s.message)})}date(s){return this._addCheck({kind:"date",message:s})}time(s){return typeof s=="string"?this._addCheck({kind:"time",precision:null,message:s}):this._addCheck({kind:"time",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,...Na.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...Na.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...Na.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...Na.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...Na.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...Na.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...Na.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...Na.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...Na.errToObj(r)})}nonempty(s){return this.min(1,Na.errToObj(s))}trim(){return new j_({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new j_({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new j_({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(s=>s.kind==="datetime")}get isDate(){return!!this._def.checks.find(s=>s.kind==="date")}get isTime(){return!!this._def.checks.find(s=>s.kind==="time")}get isDuration(){return!!this._def.checks.find(s=>s.kind==="duration")}get isEmail(){return!!this._def.checks.find(s=>s.kind==="email")}get isURL(){return!!this._def.checks.find(s=>s.kind==="url")}get isEmoji(){return!!this._def.checks.find(s=>s.kind==="emoji")}get isUUID(){return!!this._def.checks.find(s=>s.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(s=>s.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(s=>s.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(s=>s.kind==="cuid2")}get isULID(){return!!this._def.checks.find(s=>s.kind==="ulid")}get isIP(){return!!this._def.checks.find(s=>s.kind==="ip")}get isCIDR(){return!!this._def.checks.find(s=>s.kind==="cidr")}get isBase64(){return!!this._def.checks.find(s=>s.kind==="base64")}get isBase64url(){return!!this._def.checks.find(s=>s.kind==="base64url")}get minLength(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxLength(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew j_({checks:[],typeName:zi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...io(t)});function t3t(t,s){const r=(t.toString().split(".")[1]||"").length,n=(s.toString().split(".")[1]||"").length,a=r>n?r:n,o=Number.parseInt(t.toFixed(a).replace(".","")),l=Number.parseInt(s.toFixed(a).replace(".",""));return o%l/10**a}class FT extends Vo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(s){if(this._def.coerce&&(s.data=Number(s.data)),this._getType(s)!==ha.number){const o=this._getOrReturnCtx(s);return Xn(o,{code:on.invalid_type,expected:ha.number,received:o.parsedType}),Fi}let n;const a=new Mf;for(const o of this._def.checks)o.kind==="int"?Ko.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?t3t(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.not_finite,message:o.message}),a.dirty()):Ko.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,Na.toString(r))}gt(s,r){return this.setLimit("min",s,!1,Na.toString(r))}lte(s,r){return this.setLimit("max",s,!0,Na.toString(r))}lt(s,r){return this.setLimit("max",s,!1,Na.toString(r))}setLimit(s,r,n,a){return new FT({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:Na.toString(a)}]})}_addCheck(s){return new FT({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:Na.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Na.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Na.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Na.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Na.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:Na.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:Na.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Na.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Na.toString(s)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.values.kind==="int"||s.kind==="multipleOf"&&Ko.isInteger(s.value))}get isFinite(){let s=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(s===null||n.valuenew FT({checks:[],typeName:zi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...io(t)});class tD extends Vo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(s){if(this._def.coerce)try{s.data=BigInt(s.data)}catch{return this._getInvalidInput(s)}if(this._getType(s)!==ha.bigint)return this._getInvalidInput(s);let n;const a=new Mf;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?s.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(s,n),Xn(n,{code:on.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):Ko.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Xn(r,{code:on.invalid_type,expected:ha.bigint,received:r.parsedType}),Fi}gte(s,r){return this.setLimit("min",s,!0,Na.toString(r))}gt(s,r){return this.setLimit("min",s,!1,Na.toString(r))}lte(s,r){return this.setLimit("max",s,!0,Na.toString(r))}lt(s,r){return this.setLimit("max",s,!1,Na.toString(r))}setLimit(s,r,n,a){return new tD({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:Na.toString(a)}]})}_addCheck(s){return new tD({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Na.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Na.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Na.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Na.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:Na.toString(r)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew tD({checks:[],typeName:zi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...io(t)});class Rve extends Vo{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==ha.boolean){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.boolean,received:n.parsedType}),Fi}return qx(s.data)}}Rve.create=t=>new Rve({typeName:zi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...io(t)});class Soe extends Vo{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==ha.date){const o=this._getOrReturnCtx(s);return Xn(o,{code:on.invalid_type,expected:ha.date,received:o.parsedType}),Fi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Xn(o,{code:on.invalid_date}),Fi}const n=new Mf;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),Xn(a,{code:on.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Ko.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new Soe({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:Na.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:Na.toString(r)})}get minDate(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s!=null?new Date(s):null}get maxDate(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew Soe({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:zi.ZodDate,...io(t)});class v6e extends Vo{_parse(s){if(this._getType(s)!==ha.symbol){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.symbol,received:n.parsedType}),Fi}return qx(s.data)}}v6e.create=t=>new v6e({typeName:zi.ZodSymbol,...io(t)});class b6e extends Vo{_parse(s){if(this._getType(s)!==ha.undefined){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.undefined,received:n.parsedType}),Fi}return qx(s.data)}}b6e.create=t=>new b6e({typeName:zi.ZodUndefined,...io(t)});class _6e extends Vo{_parse(s){if(this._getType(s)!==ha.null){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.null,received:n.parsedType}),Fi}return qx(s.data)}}_6e.create=t=>new _6e({typeName:zi.ZodNull,...io(t)});class w6e extends Vo{constructor(){super(...arguments),this._any=!0}_parse(s){return qx(s.data)}}w6e.create=t=>new w6e({typeName:zi.ZodAny,...io(t)});class j6e extends Vo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return qx(s.data)}}j6e.create=t=>new j6e({typeName:zi.ZodUnknown,...io(t)});class pw extends Vo{_parse(s){const r=this._getOrReturnCtx(s);return Xn(r,{code:on.invalid_type,expected:ha.never,received:r.parsedType}),Fi}}pw.create=t=>new pw({typeName:zi.ZodNever,...io(t)});class N6e extends Vo{_parse(s){if(this._getType(s)!==ha.undefined){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.void,received:n.parsedType}),Fi}return qx(s.data)}}N6e.create=t=>new N6e({typeName:zi.ZodVoid,...io(t)});class j0 extends Vo{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==ha.array)return Xn(r,{code:on.invalid_type,expected:ha.array,received:r.parsedType}),Fi;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(Xn(r,{code:on.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((l,i)=>a.type._parseAsync(new mw(r,l,r.path,i)))).then(l=>Mf.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new mw(r,l,r.path,i)));return Mf.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new j0({...this._def,minLength:{value:s,message:Na.toString(r)}})}max(s,r){return new j0({...this._def,maxLength:{value:s,message:Na.toString(r)}})}length(s,r){return new j0({...this._def,exactLength:{value:s,message:Na.toString(r)}})}nonempty(s){return this.min(1,s)}}j0.create=(t,s)=>new j0({type:t,minLength:null,maxLength:null,exactLength:null,typeName:zi.ZodArray,...io(s)});function z5(t){if(t instanceof Yd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=X_.create(z5(n))}return new Yd({...t._def,shape:()=>s})}else return t instanceof j0?new j0({...t._def,type:z5(t.element)}):t instanceof X_?X_.create(z5(t.unwrap())):t instanceof $T?$T.create(z5(t.unwrap())):t instanceof HS?HS.create(t.items.map(s=>z5(s))):t}class Yd extends Vo{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const s=this._def.shape(),r=Ko.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==ha.object){const u=this._getOrReturnCtx(s);return Xn(u,{code:on.invalid_type,expected:ha.object,received:u.parsedType}),Fi}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof pw&&this._def.unknownKeys==="strip"))for(const u in a.data)l.includes(u)||i.push(u);const c=[];for(const u of l){const p=o[u],f=a.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new mw(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof pw){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of i)c.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")i.length>0&&(Xn(a,{code:on.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of i){const f=a.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new mw(a,f,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of c){const f=await p.key,g=await p.value;u.push({key:f,value:g,alwaysSet:p.alwaysSet})}return u}).then(u=>Mf.mergeObjectSync(n,u)):Mf.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(s){return Na.errToObj,new Yd({...this._def,unknownKeys:"strict",...s!==void 0?{errorMap:(r,n)=>{var o,l;const a=((l=(o=this._def).errorMap)==null?void 0:l.call(o,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:Na.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new Yd({...this._def,unknownKeys:"strip"})}passthrough(){return new Yd({...this._def,unknownKeys:"passthrough"})}extend(s){return new Yd({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Yd({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:zi.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new Yd({...this._def,catchall:s})}pick(s){const r={};for(const n of Ko.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Yd({...this._def,shape:()=>r})}omit(s){const r={};for(const n of Ko.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new Yd({...this._def,shape:()=>r})}deepPartial(){return z5(this)}partial(s){const r={};for(const n of Ko.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new Yd({...this._def,shape:()=>r})}required(s){const r={};for(const n of Ko.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof X_;)o=o._def.innerType;r[n]=o}return new Yd({...this._def,shape:()=>r})}keyof(){return LGe(Ko.objectKeys(this.shape))}}Yd.create=(t,s)=>new Yd({shape:()=>t,unknownKeys:"strip",catchall:pw.create(),typeName:zi.ZodObject,...io(s)});Yd.strictCreate=(t,s)=>new Yd({shape:()=>t,unknownKeys:"strict",catchall:pw.create(),typeName:zi.ZodObject,...io(s)});Yd.lazycreate=(t,s)=>new Yd({shape:t,unknownKeys:"strip",catchall:pw.create(),typeName:zi.ZodObject,...io(s)});class Coe extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s),n=this._def.options;function a(o){for(const i of o)if(i.result.status==="valid")return i.result;for(const i of o)if(i.result.status==="dirty")return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(i=>new T0(i.ctx.common.issues));return Xn(r,{code:on.invalid_union,unionErrors:l}),Fi}if(r.common.async)return Promise.all(n.map(async o=>{const l={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:l}),ctx:l}})).then(a);{let o;const l=[];for(const c of n){const u={...r,common:{...r.common,issues:[]},parent:null},p=c._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:u}),u.common.issues.length&&l.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const i=l.map(c=>new T0(c));return Xn(r,{code:on.invalid_union,unionErrors:i}),Fi}}get options(){return this._def.options}}Coe.create=(t,s)=>new Coe({options:t,typeName:zi.ZodUnion,...io(s)});function Fve(t,s){const r=Gb(t),n=Gb(s);if(t===s)return{valid:!0,data:t};if(r===ha.object&&n===ha.object){const a=Ko.objectKeys(s),o=Ko.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const c=Fve(t[i],s[i]);if(!c.valid)return{valid:!1};l[i]=c.data}return{valid:!0,data:l}}else if(r===ha.array&&n===ha.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(x6e(o)||x6e(l))return Fi;const i=Fve(o.value,l.value);return i.valid?((g6e(o)||g6e(l))&&r.dirty(),{status:r.value,value:i.data}):(Xn(n,{code:on.invalid_intersection_types}),Fi)};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}))}}Moe.create=(t,s,r)=>new Moe({left:t,right:s,typeName:zi.ZodIntersection,...io(r)});class HS extends Vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ha.array)return Xn(n,{code:on.invalid_type,expected:ha.array,received:n.parsedType}),Fi;if(n.data.lengththis._def.items.length&&(Xn(n,{code:on.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((l,i)=>{const c=this._def.items[i]||this._def.rest;return c?c._parse(new mw(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>Mf.mergeArray(r,l)):Mf.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new HS({...this._def,rest:s})}}HS.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new HS({items:t,typeName:zi.ZodTuple,rest:null,...io(s)})};class k6e extends Vo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ha.map)return Xn(n,{code:on.invalid_type,expected:ha.map,received:n.parsedType}),Fi;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,c],u)=>({key:a._parse(new mw(n,i,n.path,[u,"key"])),value:o._parse(new mw(n,c,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const c of l){const u=await c.key,p=await c.value;if(u.status==="aborted"||p.status==="aborted")return Fi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const c of l){const u=c.key,p=c.value;if(u.status==="aborted"||p.status==="aborted")return Fi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}k6e.create=(t,s,r)=>new k6e({valueType:s,keyType:t,typeName:zi.ZodMap,...io(r)});class sD extends Vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ha.set)return Xn(n,{code:on.invalid_type,expected:ha.set,received:n.parsedType}),Fi;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Xn(n,{code:on.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const o=this._def.valueType;function l(c){const u=new Set;for(const p of c){if(p.status==="aborted")return Fi;p.status==="dirty"&&r.dirty(),u.add(p.value)}return{status:r.value,value:u}}const i=[...n.data.values()].map((c,u)=>o._parse(new mw(n,c,n.path,u)));return n.common.async?Promise.all(i).then(c=>l(c)):l(i)}min(s,r){return new sD({...this._def,minSize:{value:s,message:Na.toString(r)}})}max(s,r){return new sD({...this._def,maxSize:{value:s,message:Na.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}sD.create=(t,s)=>new sD({valueType:t,minSize:null,maxSize:null,typeName:zi.ZodSet,...io(s)});class S6e extends Vo{get schema(){return this._def.getter()}_parse(s){const{ctx:r}=this._processInputParams(s);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}S6e.create=(t,s)=>new S6e({getter:t,typeName:zi.ZodLazy,...io(s)});class zve extends Vo{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Xn(r,{received:r.data,code:on.invalid_literal,expected:this._def.value}),Fi}return{status:"valid",value:s.data}}get value(){return this._def.value}}zve.create=(t,s)=>new zve({value:t,typeName:zi.ZodLiteral,...io(s)});function LGe(t,s){return new zT({values:t,typeName:zi.ZodEnum,...io(s)})}class zT extends Vo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Xn(r,{expected:Ko.joinValues(n),received:r.parsedType,code:on.invalid_type}),Fi}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return Xn(r,{received:r.data,code:on.invalid_enum_value,options:n}),Fi}return qx(s.data)}get options(){return this._def.values}get enum(){const s={};for(const r of this._def.values)s[r]=r;return s}get Values(){const s={};for(const r of this._def.values)s[r]=r;return s}get Enum(){const s={};for(const r of this._def.values)s[r]=r;return s}extract(s,r=this._def){return zT.create(s,{...this._def,...r})}exclude(s,r=this._def){return zT.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}zT.create=LGe;class C6e extends Vo{_parse(s){const r=Ko.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==ha.string&&n.parsedType!==ha.number){const a=Ko.objectValues(r);return Xn(n,{expected:Ko.joinValues(a),received:n.parsedType,code:on.invalid_type}),Fi}if(this._cache||(this._cache=new Set(Ko.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=Ko.objectValues(r);return Xn(n,{received:n.data,code:on.invalid_enum_value,options:a}),Fi}return qx(s.data)}get enum(){return this._def.values}}C6e.create=(t,s)=>new C6e({values:t,typeName:zi.ZodNativeEnum,...io(s)});class Toe extends Vo{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==ha.promise&&r.common.async===!1)return Xn(r,{code:on.invalid_type,expected:ha.promise,received:r.parsedType}),Fi;const n=r.parsedType===ha.promise?r.data:Promise.resolve(r.data);return qx(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Toe.create=(t,s)=>new Toe({type:t,typeName:zi.ZodPromise,...io(s)});class BT extends Vo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===zi.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=this._def.effect||null,o={addIssue:l=>{Xn(n,l),l.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){const l=a.transform(n.data,o);if(n.common.async)return Promise.resolve(l).then(async i=>{if(r.value==="aborted")return Fi;const c=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return c.status==="aborted"?Fi:c.status==="dirty"||r.value==="dirty"?jI(c.value):c});{if(r.value==="aborted")return Fi;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?Fi:i.status==="dirty"||r.value==="dirty"?jI(i.value):i}}if(a.type==="refinement"){const l=i=>{const c=a.refinement(i,o);if(n.common.async)return Promise.resolve(c);if(c 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"?Fi:(i.status==="dirty"&&r.dirty(),l(i.value),{status:r.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?Fi:(i.status==="dirty"&&r.dirty(),l(i.value).then(()=>({status:r.value,value:i.value}))))}if(a.type==="transform")if(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!RT(l))return Fi;const i=a.transform(l.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>RT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):Fi);Ko.assertNever(a)}}BT.create=(t,s,r)=>new BT({schema:t,typeName:zi.ZodEffects,effect:s,...io(r)});BT.createWithPreprocess=(t,s,r)=>new BT({schema:s,effect:{type:"preprocess",transform:t},typeName:zi.ZodEffects,...io(r)});class X_ extends Vo{_parse(s){return this._getType(s)===ha.undefined?qx(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}X_.create=(t,s)=>new X_({innerType:t,typeName:zi.ZodOptional,...io(s)});class $T extends Vo{_parse(s){return this._getType(s)===ha.null?qx(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}$T.create=(t,s)=>new $T({innerType:t,typeName:zi.ZodNullable,...io(s)});class Bve extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===ha.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Bve.create=(t,s)=>new Bve({innerType:t,typeName:zi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...io(s)});class $ve extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return koe(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new T0(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new T0(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}$ve.create=(t,s)=>new $ve({innerType:t,typeName:zi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...io(s)});class M6e extends Vo{_parse(s){if(this._getType(s)!==ha.nan){const n=this._getOrReturnCtx(s);return Xn(n,{code:on.invalid_type,expected:ha.nan,received:n.parsedType}),Fi}return{status:"valid",value:s.data}}}M6e.create=t=>new M6e({typeName:zi.ZodNaN,...io(t)});class s3t extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class _je extends Vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Fi:o.status==="dirty"?(r.dirty(),jI(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"?Fi:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(s,r){return new _je({in:s,out:r,typeName:zi.ZodPipeline})}}class qve extends Vo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(RT(a)&&(a.value=Object.freeze(a.value)),a);return koe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}qve.create=(t,s)=>new qve({innerType:t,typeName:zi.ZodReadonly,...io(s)});var zi;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(zi||(zi={}));const gc=j_.create,GL=FT.create,r3t=Rve.create;pw.create;j0.create;const yC=Yd.create;Coe.create;Moe.create;HS.create;const Aoe=zve.create,DGe=zT.create;Toe.create;X_.create;$T.create;const Er=k.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:It("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...s}));Er.displayName="Textarea";const n3t=["Excellent","Good","Neutral","Bad","Very Bad"],a3t=[5,4,3,2,1];function i3t({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=Kkt(),[o,l]=k.useState({}),i=t.filter(g=>g.question_type==="rating"),c=t.filter(g=>g.question_type!=="rating"),u=(g,b)=>{l(_=>({..._,[g]:{rating_value:b}}))},p=(g,b)=>{l(_=>({..._,[g]:{text_value:b}}))},f=async()=>{const g=Object.entries(o).filter(([,b])=>b.rating_value!=null||b.text_value&&b.text_value.trim()).map(([b,_])=>{var j;return{visitor_id:s,question_id:b,rating_value:_.rating_value??null,text_value:((j=_.text_value)==null?void 0:j.trim())||null}});if(g.length>0)try{await a.mutateAsync(g)}catch{}r()};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Quick Feedback"}),e.jsx("button",{onClick:n,className:"text-sm text-slate-400 hover:text-slate-600 underline",children:"Skip"})]}),e.jsx("p",{className:"text-sm text-slate-500 -mt-2",children:"Your feedback helps the agent — totally optional!"}),i.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"flex-1"}),n3t.map(g=>e.jsx("div",{className:"w-12 text-center",children:e.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:g})},g))]}),i.map(g=>e.jsxs("div",{className:"flex items-center gap-1 py-1.5 border-b border-slate-100 last:border-0",children:[e.jsx("span",{className:"flex-1 text-sm text-slate-700 pr-2",children:g.question_text}),a3t.map(b=>{var _;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(g.id,b),className:`w-6 h-6 rounded-full border-2 transition-all ${((_=o[g.id])==null?void 0:_.rating_value)===b?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},b)})]},g.id))]}),c.map(g=>{var b;return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:g.question_text}),e.jsx(Er,{value:((b=o[g.id])==null?void 0:b.text_value)||"",onChange:_=>p(g.id,_.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},g.id)}),e.jsx(K,{onClick:f,disabled:a.isPending,className:"w-full h-12 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:a.isPending?e.jsx(ws,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const o3t=yC({first_name:gc().trim().min(1,"First name is required").max(50),last_name:gc().trim().max(50).optional(),email:gc().trim().email("Please enter a valid email").max(255).optional().or(Aoe("")),phone:gc().trim().max(20).optional().or(Aoe(""))}),l3t=[{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 OGe({slug:t}={}){var re;const s=yo(),r=t||s.slug,{data:n,isLoading:a,error:o}=Hkt(r),l=e4t(),[i,c]=k.useState("welcome"),[u,p]=k.useState(null),[f,g]=k.useState({first_name:"",last_name:"",email:"",phone:""}),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,S]=k.useState(!1),[M,L]=k.useState(""),[I,O]=k.useState(""),{data:q,isLoading:U}=Gkt(n==null?void 0:n.id),B=!!(n!=null&&n.enable_survey);k.useEffect(()=>{i==="pending_survey"&&(U||c(B&&((q==null?void 0:q.length)??0)>0?"survey":"done"))},[i,U,B,q]);const V=oe=>{if(!oe)return"";const[ce,ge]=oe.split(":"),ye=parseInt(ce),ue=ye>=12?"PM":"AM";return`${ye>12?ye-12:ye||12}:${ge} ${ue}`},Y=()=>{O("");const oe=o3t.safeParse(f);if(!oe.success){O(oe.error.issues[0].message);return}if(!f.email&&!f.phone){O("Please provide either an email or phone number");return}c("intent")},Q=async oe=>{_(oe);try{const ce=await l.mutateAsync({open_house_id:n.id,first_name:f.first_name.trim(),last_name:f.last_name.trim()||void 0,email:f.email.trim()||void 0,phone:f.phone.trim()||void 0,visitor_intent:oe,wants_market_updates:j,has_agent:N,working_with_agent_name:N&&M.trim()?M.trim():void 0});p(ce.id),B?!U&&q&&q.length>0?c("survey"):c("pending_survey"):c("done")}catch{O("Something went wrong. Please try again.")}};if(a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(bn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Open House Not Found"}),e.jsx("p",{className:"text-white/60",children:"This sign-in page doesn't exist or is no longer active."})]})});const ee=n.profiles,X=((re=ee==null?void 0:ee.name)==null?void 0:re.split(" ").map(oe=>oe[0]).join("").slice(0,2))||"?",ie=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsxs("title",{children:[ie?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${ie?"community event":"open house"} at ${n.property_address}`}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsxs(Nn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx($a,{src:(ee==null?void 0:ee.avatar_url)||"",alt:(ee==null?void 0:ee.name)||""}),e.jsx(kn,{className:"bg-white/10 text-white text-lg",children:X})]}),e.jsx("p",{className:"text-white/60 text-sm",children:ee==null?void 0:ee.name}),(ee==null?void 0:ee.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:ee.title})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[n.photo_url&&e.jsxs("div",{className:"relative h-44 sm:h-52 overflow-hidden",children:[e.jsx("img",{src:n.photo_url,alt:n.property_address,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/80 via-slate-900/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-6 pb-4",children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight drop-shadow-md",children:n.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-white/70 text-xs",children:[n.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]}),!n.photo_url&&e.jsx("div",{className:"bg-gradient-to-r from-slate-800 to-slate-700 px-6 py-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0 mt-0.5",children:ie?e.jsx(ka,{className:"h-5 w-5 text-white"}):e.jsx(bn,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:n.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[n.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[i==="welcome"&&e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Welcome!"}),e.jsx("p",{className:"text-slate-500 text-sm",children:n.agent_greeting||"Please sign in below."})]}),e.jsxs(K,{onClick:()=>c("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(Qa,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),i==="info"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>c("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ja,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Your Info"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(ze,{value:f.first_name,onChange:oe=>g(ce=>({...ce,first_name:oe.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(ze,{value:f.last_name,onChange:oe=>g(ce=>({...ce,last_name:oe.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(ze,{type:"email",value:f.email,onChange:oe=>g(ce=>({...ce,email:oe.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(ze,{type:"tel",value:f.phone,onChange:oe=>g(ce=>({...ce,phone:oe.target.value})),placeholder:"(555) 123-4567",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pt-1",children:[e.jsx("input",{type:"checkbox",checked:j,onChange:oe=>w(oe.target.checked),className:"rounded border-slate-300 text-slate-900 focus:ring-slate-500"}),e.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600",children:"Already working with an agent?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-400",children:N?"Yes":"No"}),e.jsx(qr,{checked:N,onCheckedChange:S})]})]}),N&&e.jsx(ze,{value:M,onChange:oe=>L(oe.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),I&&e.jsx("p",{className:"text-destructive text-sm",children:I}),e.jsxs(K,{onClick:Y,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Qa,{className:"h-5 w-5 ml-2"})]})]}),i==="intent"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>c("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ja,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"What brings you here?"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:l3t.map(oe=>e.jsxs("button",{onClick:()=>Q(oe.value),disabled:l.isPending,className:"flex flex-col items-center gap-2 p-5 rounded-xl border-2 border-slate-200 hover:border-slate-900 hover:bg-slate-50 transition-all text-center group",children:[e.jsx("span",{className:"text-2xl",children:oe.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:oe.label})]},oe.value))}),I&&e.jsx("p",{className:"text-destructive text-sm text-center",children:I})]}),i==="pending_survey"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-[3px] border-slate-200 border-t-slate-900 rounded-full animate-spin"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading survey..."})]}),i==="survey"&&u&&q&&e.jsx(i3t,{questions:q,visitorId:u,onComplete:()=>c("done"),onSkip:()=>c("done")}),i==="done"&&e.jsxs("div",{className:"text-center space-y-4 py-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto",children:e.jsx(sa,{className:"h-8 w-8 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"You're all set!"}),e.jsxs("p",{className:"text-slate-500 text-sm mt-1",children:["Thanks for signing in, ",f.first_name,". ",ie?"Enjoy the event!":"Enjoy the open house!"]})]}),(ee==null?void 0:ee.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:ee.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function HMs(t){const{user:s}=Ds();return mt({queryKey:["cohost-tokens",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_house_cohost_tokens").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(n)throw n;return r},enabled:!!s&&!!t})}function WMs(){const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async({openHouseId:r,label:n})=>{const{data:a,error:o}=await H.from("open_house_cohost_tokens").insert({open_house_id:r,label:n||null,created_by:s.id,expires_at:new Date(Date.now()+864e5).toISOString()}).select().single();if(o)throw o;return a},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["cohost-tokens",n.openHouseId]})}})}function GMs(){const t=Qt();return Lt({mutationFn:async({id:s,openHouseId:r})=>{const{error:n}=await H.from("open_house_cohost_tokens").update({is_active:!1}).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["cohost-tokens",r.openHouseId]})}})}function c3t(t){return mt({queryKey:["cohost-validate",t],queryFn:async()=>{const{data:s,error:r}=await H.from("open_house_cohost_tokens").select("*, open_houses(*)").eq("token",t).eq("is_active",!0).single();if(r)throw r;if(s.expires_at&&new Date(s.expires_at)s[r][n]??r,t)}var wje="ScrollArea",[RGe]=ad(wje),[u3t,Ux]=RGe(wje),FGe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,c]=k.useState(null),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(null),[N,S]=k.useState(0),[M,L]=k.useState(0),[I,O]=k.useState(!1),[q,U]=k.useState(!1),B=qa(s,Y=>c(Y)),V=Tw(a);return e.jsx(u3t,{scope:r,type:n,dir:V,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:f,onContentChange:g,scrollbarX:b,onScrollbarXChange:_,scrollbarXEnabled:I,onScrollbarXEnabledChange:O,scrollbarY:j,onScrollbarYChange:w,scrollbarYEnabled:q,onScrollbarYEnabledChange:U,onCornerWidthChange:S,onCornerHeightChange:L,children:e.jsx(nn.div,{dir:V,...l,ref:B,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":M+"px",...t.style}})})});FGe.displayName=wje;var zGe="ScrollAreaViewport",BGe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Ux(zGe,r),i=k.useRef(null),c=qa(s,i,l.onViewportChange);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),e.jsx(nn.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});BGe.displayName=zGe;var B0="ScrollAreaScrollbar",jje=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Ux(B0,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return k.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(h3t,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(m3t,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx($Ge,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(Nje,{...n,ref:s}):null});jje.displayName=B0;var h3t=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Ux(B0,t.__scopeScrollArea),[o,l]=k.useState(!1);return k.useEffect(()=>{const i=a.scrollArea;let c=0;if(i){const u=()=>{window.clearTimeout(c),l(!0)},p=()=>{c=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",p),()=>{window.clearTimeout(c),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(zd,{present:r||o,children:e.jsx($Ge,{"data-state":o?"visible":"hidden",...n,ref:s})})}),m3t=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Ux(B0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=nue(()=>c("SCROLL_END"),100),[i,c]=d3t("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 k.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,c]),k.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let f=u[p];const g=()=>{const b=u[p];f!==b&&(c("SCROLL"),l()),f=b};return u.addEventListener("scroll",g),()=>u.removeEventListener("scroll",g)}},[a.viewport,o,c,l]),e.jsx(zd,{present:r||i!=="hidden",children:e.jsx(Nje,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Ir(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Ir(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),$Ge=k.forwardRef((t,s)=>{const r=Ux(B0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=k.useState(!1),i=t.orientation==="horizontal",c=nue(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Ux(B0,t.__scopeScrollArea),o=k.useRef(null),l=k.useRef(0),[i,c]=k.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=WGe(i.viewport,i.content),p={...n,sizes:i,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:g=>o.current=g,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:g=>l.current=g};function f(g,b){return v3t(g,l.current,i,b)}return r==="horizontal"?e.jsx(p3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollLeft,b=T6e(g,i,a.dir);o.current.style.transform=`translate3d(${b}px, 0, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollLeft=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollLeft=f(g,a.dir))}}):r==="vertical"?e.jsx(f3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollTop,b=T6e(g,i);o.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollTop=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollTop=f(g))}}):null}),p3t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Ux(B0,t.__scopeScrollArea),[l,i]=k.useState(),c=k.useRef(null),u=qa(s,c,o.onScrollbarXChange);return k.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(UGe,{"data-orientation":"horizontal",...a,ref:u,sizes:r,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":rue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,f)=>{if(o.viewport){const g=o.viewport.scrollLeft+p.deltaX;t.onWheelScroll(g),KGe(g,f)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Poe(l.paddingLeft),paddingEnd:Poe(l.paddingRight)}})}})}),f3t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Ux(B0,t.__scopeScrollArea),[l,i]=k.useState(),c=k.useRef(null),u=qa(s,c,o.onScrollbarYChange);return k.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(UGe,{"data-orientation":"vertical",...a,ref:u,sizes:r,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":rue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,f)=>{if(o.viewport){const g=o.viewport.scrollTop+p.deltaY;t.onWheelScroll(g),KGe(g,f)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Poe(l.paddingTop),paddingEnd:Poe(l.paddingBottom)}})}})}),[x3t,qGe]=RGe(B0),UGe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:p,onResize:f,...g}=t,b=Ux(B0,r),[_,j]=k.useState(null),w=qa(s,B=>j(B)),N=k.useRef(null),S=k.useRef(""),M=b.viewport,L=n.content-n.viewport,I=vd(p),O=vd(c),q=nue(f,10);function U(B){if(N.current){const V=B.clientX-N.current.left,Y=B.clientY-N.current.top;u({x:V,y:Y})}}return k.useEffect(()=>{const B=V=>{const Y=V.target;(_==null?void 0:_.contains(Y))&&I(V,L)};return document.addEventListener("wheel",B,{passive:!1}),()=>document.removeEventListener("wheel",B,{passive:!1})},[M,_,L,I]),k.useEffect(O,[n,O]),qT(_,q),qT(b.content,q),e.jsx(x3t,{scope:r,scrollbar:_,hasThumb:a,onThumbChange:vd(o),onThumbPointerUp:vd(l),onThumbPositionChange:O,onThumbPointerDown:vd(i),children:e.jsx(nn.div,{...g,ref:w,style:{position:"absolute",...g.style},onPointerDown:Ir(t.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),N.current=_.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),U(B))}),onPointerMove:Ir(t.onPointerMove,U),onPointerUp:Ir(t.onPointerUp,B=>{const V=B.target;V.hasPointerCapture(B.pointerId)&&V.releasePointerCapture(B.pointerId),document.body.style.webkitUserSelect=S.current,b.viewport&&(b.viewport.style.scrollBehavior=""),N.current=null})})})}),Eoe="ScrollAreaThumb",VGe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=qGe(Eoe,t.__scopeScrollArea);return e.jsx(zd,{present:r||a.hasThumb,children:e.jsx(g3t,{ref:s,...n})})}),g3t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Ux(Eoe,r),l=qGe(Eoe,r),{onThumbPositionChange:i}=l,c=qa(s,f=>l.onThumbChange(f)),u=k.useRef(void 0),p=nue(()=>{u.current&&(u.current(),u.current=void 0)},100);return k.useEffect(()=>{const f=o.viewport;if(f){const g=()=>{if(p(),!u.current){const b=b3t(f,i);u.current=b,i()}};return i(),f.addEventListener("scroll",g),()=>f.removeEventListener("scroll",g)}},[o.viewport,p,i]),e.jsx(nn.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Ir(t.onPointerDownCapture,f=>{const b=f.target.getBoundingClientRect(),_=f.clientX-b.left,j=f.clientY-b.top;l.onThumbPointerDown({x:_,y:j})}),onPointerUp:Ir(t.onPointerUp,l.onThumbPointerUp)})});VGe.displayName=Eoe;var kje="ScrollAreaCorner",HGe=k.forwardRef((t,s)=>{const r=Ux(kje,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(y3t,{...t,ref:s}):null});HGe.displayName=kje;var y3t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Ux(kje,r),[o,l]=k.useState(0),[i,c]=k.useState(0),u=!!(o&&i);return qT(a.scrollbarX,()=>{var f;const p=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(p),c(p)}),qT(a.scrollbarY,()=>{var f;const p=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),u?e.jsx(nn.div,{...n,ref:s,style:{width:o,height:i,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function Poe(t){return t?parseInt(t,10):0}function WGe(t,s){const r=t/s;return isNaN(r)?0:r}function rue(t){const s=WGe(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function v3t(t,s,r,n="ltr"){const a=rue(r),o=a/2,l=s||o,i=a-l,c=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,p=r.content-r.viewport,f=n==="ltr"?[0,p]:[p*-1,0];return GGe([c,u],f)(t)}function T6e(t,s,r="ltr"){const n=rue(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,o=s.scrollbar.size-a,l=s.content-s.viewport,i=o-n,c=r==="ltr"?[0,l]:[l*-1,0],u=eD(t,c);return GGe([0,l],[0,i])(u)}function GGe(t,s){return r=>{if(t[0]===t[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(t[1]-t[0]);return s[0]+n*(r-t[0])}}function KGe(t,s){return t>0&&t{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return function a(){const o={left:t.scrollLeft,top:t.scrollTop},l=r.left!==o.left,i=r.top!==o.top;(l||i)&&s(),r=o,n=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(n)};function nue(t,s){const r=vd(t),n=k.useRef(0);return k.useEffect(()=>()=>window.clearTimeout(n.current),[]),k.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function qT(t,s){const r=vd(s);jd(()=>{let n=0;if(t){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(t),()=>{window.cancelAnimationFrame(n),a.unobserve(t)}}},[t,r])}var ZGe=FGe,_3t=BGe,w3t=HGe;const Gi=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(ZGe,{ref:n,className:It("relative overflow-hidden",t),...r,children:[e.jsx(_3t,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(aue,{}),e.jsx(w3t,{})]}));Gi.displayName=ZGe.displayName;const aue=k.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(jje,{ref:n,orientation:s,className:It("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:e.jsx(VGe,{className:"relative flex-1 rounded-full bg-border"})}));aue.displayName=jje.displayName;const Sje=k.createContext({});function Cje(t){const s=k.useRef(null);return s.current===null&&(s.current=t()),s.current}const j3t=typeof window<"u",YGe=j3t?k.useLayoutEffect:k.useEffect,iue=k.createContext(null);function Mje(t,s){t.indexOf(s)===-1&&t.push(s)}function Ioe(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const A0=(t,s,r)=>r>s?s:r{};const fw={},XGe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function QGe(t){return typeof t=="object"&&t!==null}const JGe=t=>/^0[^.\s]+$/u.test(t);function eKe(t){let s;return()=>(s===void 0&&(s=t()),s)}const Ax=t=>t,N3t=(t,s)=>r=>s(t(r)),OO=(...t)=>t.reduce(N3t),rD=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class Aje{constructor(){this.subscriptions=[]}add(s){return Mje(this.subscriptions,s),()=>Ioe(this.subscriptions,s)}notify(s,r,n){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](s,r,n);else for(let o=0;ot*1e3,_x=t=>t/1e3;function tKe(t,s){return s?t*(1e3/s):0}const sKe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,k3t=1e-7,S3t=12;function C3t(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=sKe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>k3t&&++iC3t(o,0,1,t,r);return o=>o===0||o===1?o:sKe(a(o),s,n)}const rKe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,nKe=t=>s=>1-t(1-s),aKe=RO(.33,1.53,.69,.99),Eje=nKe(aKe),iKe=rKe(Eje),oKe=t=>t>=1?1:(t*=2)<1?.5*Eje(t):.5*(2-Math.pow(2,-10*(t-1))),Pje=t=>1-Math.sin(Math.acos(t)),lKe=nKe(Pje),cKe=rKe(Pje),M3t=RO(.42,0,1,1),T3t=RO(0,0,.58,1),dKe=RO(.42,0,.58,1),A3t=t=>Array.isArray(t)&&typeof t[0]!="number",uKe=t=>Array.isArray(t)&&typeof t[0]=="number",E3t={linear:Ax,easeIn:M3t,easeInOut:dKe,easeOut:T3t,circIn:Pje,circInOut:cKe,circOut:lKe,backIn:Eje,backInOut:iKe,backOut:aKe,anticipate:oKe},P3t=t=>typeof t=="string",A6e=t=>{if(uKe(t)){Tje(t.length===4);const[s,r,n,a]=t;return RO(s,r,n,a)}else if(P3t(t))return E3t[t];return t},nz=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function I3t(t,s){let r=new Set,n=new Set,a=!1,o=!1;const l=new WeakSet;let i={delta:0,timestamp:0,isProcessing:!1};function c(p){l.has(p)&&(u.schedule(p),t()),p(i)}const u={schedule:(p,f=!1,g=!1)=>{const _=g&&a?r:n;return f&&l.add(p),_.add(p),p},cancel:p=>{n.delete(p),l.delete(p)},process:p=>{if(i=p,a){o=!0;return}a=!0;const f=r;r=n,n=f,r.forEach(c),r.clear(),a=!1,o&&(o=!1,u.process(p))}};return u}const L3t=40;function hKe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=nz.reduce((M,L)=>(M[L]=I3t(o),M),{}),{setup:i,read:c,resolveKeyframes:u,preUpdate:p,update:f,preRender:g,render:b,postRender:_}=l,j=()=>{const M=fw.useManualTiming,L=M?a.timestamp:performance.now();r=!1,M||(a.delta=n?1e3/60:Math.max(Math.min(L-a.timestamp,L3t),1)),a.timestamp=L,a.isProcessing=!0,i.process(a),c.process(a),u.process(a),p.process(a),f.process(a),g.process(a),b.process(a),_.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(j))},w=()=>{r=!0,n=!0,a.isProcessing||t(j)};return{schedule:nz.reduce((M,L)=>{const I=l[L];return M[L]=(O,q=!1,U=!1)=>(r||w(),I.schedule(O,q,U)),M},{}),cancel:M=>{for(let L=0;L(pie===void 0&&Nm.set(vh.isProcessing||fw.useManualTiming?vh.timestamp:performance.now()),pie),set:t=>{pie=t,queueMicrotask(D3t)}},mKe=t=>s=>typeof s=="string"&&s.startsWith(t),pKe=mKe("--"),O3t=mKe("var(--"),Ije=t=>O3t(t)?R3t.test(t.split("/*")[0].trim()):!1,R3t=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function E6e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const XA={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},nD={...XA,transform:t=>A0(0,1,t)},az={...XA,default:1},KL=t=>Math.round(t*1e5)/1e5,Lje=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function F3t(t){return t==null}const z3t=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Dje=(t,s)=>r=>!!(typeof r=="string"&&z3t.test(r)&&r.startsWith(t)||s&&!F3t(r)&&Object.prototype.hasOwnProperty.call(r,s)),fKe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(Lje);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},B3t=t=>A0(0,255,t),Exe={...XA,transform:t=>Math.round(B3t(t))},b4={test:Dje("rgb","red"),parse:fKe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Exe.transform(t)+", "+Exe.transform(s)+", "+Exe.transform(r)+", "+KL(nD.transform(n))+")"};function $3t(t){let s="",r="",n="",a="";return t.length>5?(s=t.substring(1,3),r=t.substring(3,5),n=t.substring(5,7),a=t.substring(7,9)):(s=t.substring(1,2),r=t.substring(2,3),n=t.substring(3,4),a=t.substring(4,5),s+=s,r+=r,n+=n,a+=a),{red:parseInt(s,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:a?parseInt(a,16)/255:1}}const Uve={test:Dje("#"),parse:$3t,transform:b4.transform},FO=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),$b=FO("deg"),N0=FO("%"),ia=FO("px"),q3t=FO("vh"),U3t=FO("vw"),P6e={...N0,parse:t=>N0.parse(t)/100,transform:t=>N0.transform(t*100)},oM={test:Dje("hsl","hue"),parse:fKe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+N0.transform(KL(s))+", "+N0.transform(KL(r))+", "+KL(nD.transform(n))+")"},Xd={test:t=>b4.test(t)||Uve.test(t)||oM.test(t),parse:t=>b4.test(t)?b4.parse(t):oM.test(t)?oM.parse(t):Uve.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?b4.transform(t):oM.transform(t),getAnimatableNone:t=>{const s=Xd.parse(t);return s.alpha=0,Xd.transform(s)}},V3t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function H3t(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(Lje))==null?void 0:s.length)||0)+(((r=t.match(V3t))==null?void 0:r.length)||0)>0}const xKe="number",gKe="color",W3t="var",G3t="var(",I6e="${}",K3t=/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 UT(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(K3t,c=>(Xd.test(c)?(n.color.push(o),a.push(gKe),r.push(Xd.parse(c))):c.startsWith(G3t)?(n.var.push(o),a.push(W3t),r.push(c)):(n.number.push(o),a.push(xKe),r.push(parseFloat(c))),++o,I6e)).split(I6e);return{values:r,split:i,indexes:n,types:a}}function Z3t(t){return UT(t).values}function yKe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:Xd.test(t)?Xd.getAnimatableNone(t):t,Q3t=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:X3t(t);function J3t(t){const s=UT(t);return yKe(s)(s.values.map((n,a)=>Q3t(n,s.split[a])))}const sy={test:H3t,parse:Z3t,createTransformer:Y3t,getAnimatableNone:J3t};function Pxe(t,s,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(s-t)*6*r:r<1/2?s:r<2/3?t+(s-t)*(2/3-r)*6:t}function e5t({hue:t,saturation:s,lightness:r,alpha:n}){t/=360,s/=100,r/=100;let a=0,o=0,l=0;if(!s)a=o=l=r;else{const i=r<.5?r*(1+s):r+s-r*s,c=2*r-i;a=Pxe(c,i,t+1/3),o=Pxe(c,i,t),l=Pxe(c,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function Loe(t,s){return r=>r>0?s:t}const wc=(t,s,r)=>t+(s-t)*r,Ixe=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},t5t=[Uve,b4,oM],s5t=t=>t5t.find(s=>s.test(t));function L6e(t){const s=s5t(t);if(!s)return!1;let r=s.parse(t);return s===oM&&(r=e5t(r)),r}const D6e=(t,s)=>{const r=L6e(t),n=L6e(s);if(!r||!n)return Loe(t,s);const a={...r};return o=>(a.red=Ixe(r.red,n.red,o),a.green=Ixe(r.green,n.green,o),a.blue=Ixe(r.blue,n.blue,o),a.alpha=wc(r.alpha,n.alpha,o),b4.transform(a))},Vve=new Set(["none","hidden"]);function r5t(t,s){return Vve.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function n5t(t,s){return r=>wc(t,s,r)}function Oje(t){return typeof t=="number"?n5t:typeof t=="string"?Ije(t)?Loe:Xd.test(t)?D6e:o5t:Array.isArray(t)?vKe:typeof t=="object"?Xd.test(t)?D6e:a5t:Loe}function vKe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>Oje(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function i5t(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=sy.createTransformer(s),n=UT(t),a=UT(s);return n.indexes.var.length===a.indexes.var.length&&n.indexes.color.length===a.indexes.color.length&&n.indexes.number.length>=a.indexes.number.length?Vve.has(t)&&!a.values.length||Vve.has(s)&&!n.values.length?r5t(t,s):OO(vKe(i5t(n,a),a.values),r):Loe(t,s)};function bKe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?wc(t,s,r):Oje(t)(t,s)}const l5t=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>Dl.update(s,r),stop:()=>xw(s),now:()=>vh.isProcessing?vh.timestamp:Nm.now()}},_Ke=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Doe?1/0:s}function c5t(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(Rje(n),Doe);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:_x(a)}}const md={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Hve(t,s){return t*Math.sqrt(1-s*s)}const d5t=12;function u5t(t,s,r){let n=r;for(let a=1;a{const p=u*l,f=p*t,g=p-r,b=Hve(u,l),_=Math.exp(-f);return Lxe-g/b*_},o=u=>{const f=u*l*t,g=f*r+r,b=Math.pow(l,2)*Math.pow(u,2)*t,_=Math.exp(-f),j=Hve(Math.pow(u,2),l);return(-a(u)+Lxe>0?-1:1)*((g-b)*_)/j}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-Lxe+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,c=u5t(a,o,i);if(t=gf(t),isNaN(c))return{stiffness:md.stiffness,damping:md.damping,duration:t};{const u=Math.pow(c,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const m5t=["duration","bounce"],p5t=["stiffness","damping","mass"];function O6e(t,s){return s.some(r=>t[r]!==void 0)}function f5t(t){let s={velocity:md.velocity,stiffness:md.stiffness,damping:md.damping,mass:md.mass,isResolvedFromDuration:!1,...t};if(!O6e(t,p5t)&&O6e(t,m5t))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*A0(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:md.mass,stiffness:a,damping:o}}else{const r=h5t({...t,velocity:0});s={...s,...r,mass:md.mass},s.isResolvedFromDuration=!0}return s}function Ooe(t=md.visualDuration,s=md.bounce){const r=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:s}:t;let{restSpeed:n,restDelta:a}=r;const o=r.keyframes[0],l=r.keyframes[r.keyframes.length-1],i={done:!1,value:o},{stiffness:c,damping:u,mass:p,duration:f,velocity:g,isResolvedFromDuration:b}=f5t({...r,velocity:-_x(r.velocity||0)}),_=g||0,j=u/(2*Math.sqrt(c*p)),w=l-o,N=_x(Math.sqrt(c/p)),S=Math.abs(w)<5;n||(n=S?md.restSpeed.granular:md.restSpeed.default),a||(a=S?md.restDelta.granular:md.restDelta.default);let M,L,I,O,q,U;if(j<1)I=Hve(N,j),O=(_+j*N*w)/I,M=V=>{const Y=Math.exp(-j*N*V);return l-Y*(O*Math.sin(I*V)+w*Math.cos(I*V))},q=j*N*O+w*I,U=j*N*w-O*I,L=V=>Math.exp(-j*N*V)*(q*Math.sin(I*V)+U*Math.cos(I*V));else if(j===1){M=Y=>l-Math.exp(-N*Y)*(w+(_+N*w)*Y);const V=_+N*w;L=Y=>Math.exp(-N*Y)*(N*V*Y-_)}else{const V=N*Math.sqrt(j*j-1);M=X=>{const ie=Math.exp(-j*N*X),re=Math.min(V*X,300);return l-ie*((_+j*N*w)*Math.sinh(re)+V*w*Math.cosh(re))/V};const Y=(_+j*N*w)/V,Q=j*N*Y-w*V,ee=j*N*w-Y*V;L=X=>{const ie=Math.exp(-j*N*X),re=Math.min(V*X,300);return ie*(Q*Math.sinh(re)+ee*Math.cosh(re))}}const B={calculatedDuration:b&&f||null,velocity:V=>gf(L(V)),next:V=>{if(!b&&j<1){const Q=Math.exp(-j*N*V),ee=Math.sin(I*V),X=Math.cos(I*V),ie=l-Q*(O*ee+w*X),re=gf(Q*(q*ee+U*X));return i.done=Math.abs(re)<=n&&Math.abs(l-ie)<=a,i.value=i.done?l:ie,i}const Y=M(V);if(b)i.done=V>=f;else{const Q=gf(L(V));i.done=Math.abs(Q)<=n&&Math.abs(l-Y)<=a}return i.value=i.done?l:Y,i},toString:()=>{const V=Math.min(Rje(B),Doe),Y=_Ke(Q=>B.next(V*Q).value,V,30);return V+"ms "+Y},toTransition:()=>{}};return B}Ooe.applyToOptions=t=>{const s=c5t(t,100,Ooe);return t.ease=s.ease,t.duration=gf(s.duration),t.type="keyframes",t};const x5t=5;function wKe(t,s,r){const n=Math.max(s-x5t,0);return tKe(r-t(n),s-n)}function Wve({keyframes:t,velocity:s=0,power:r=.8,timeConstant:n=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:i,max:c,restDelta:u=.5,restSpeed:p}){const f=t[0],g={done:!1,value:f},b=U=>i!==void 0&&Uc,_=U=>i===void 0?c:c===void 0||Math.abs(i-U)-j*Math.exp(-U/n),M=U=>N+S(U),L=U=>{const B=S(U),V=M(U);g.done=Math.abs(B)<=u,g.value=g.done?N:V};let I,O;const q=U=>{b(g.value)&&(I=U,O=Ooe({keyframes:[g.value,_(g.value)],velocity:wKe(M,U,g.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return q(0),{calculatedDuration:null,next:U=>{let B=!1;return!O&&I===void 0&&(B=!0,L(U),q(U)),I!==void 0&&U>=I?O.next(U-I):(!B&&L(U),g)}}}function g5t(t,s,r){const n=[],a=r||fw.mix||bKe,o=t.length-1;for(let l=0;ls[0];if(o===2&&s[0]===s[1])return()=>s[1];const l=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),s=[...s].reverse());const i=g5t(s,n,a),c=i.length,u=p=>{if(l&&p1)for(;fu(A0(t[0],t[o-1],p)):u}function v5t(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=rD(0,s,n);t.push(wc(r,1,a))}}function b5t(t){const s=[0];return v5t(s,t.length-1),s}function _5t(t,s){return t.map(r=>r*s)}function w5t(t,s){return t.map(()=>s||dKe).splice(0,t.length-1)}function ZL({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=A3t(n)?n.map(A6e):A6e(n),o={done:!1,value:s[0]},l=_5t(r&&r.length===s.length?r:b5t(s),t),i=y5t(l,s,{ease:Array.isArray(a)?a:w5t(s,a)});return{calculatedDuration:t,next:c=>(o.value=i(c),o.done=c>=t,o)}}const j5t=t=>t!==null;function oue(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(j5t),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const N5t={decay:Wve,inertia:Wve,tween:ZL,keyframes:ZL,spring:Ooe};function jKe(t){typeof t.type=="string"&&(t.type=N5t[t.type])}class Fje{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(s=>{this.resolve=s})}notifyFinished(){this.resolve()}then(s,r){return this.finished.then(s,r)}}const k5t=t=>t/100;class Roe extends Fje{constructor(s){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var n,a;const{motionValue:r}=this.options;r&&r.updatedAt!==Nm.now()&&this.tick(Nm.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(a=(n=this.options).onStop)==null||a.call(n))},this.options=s,this.initAnimation(),this.play(),s.autoplay===!1&&this.pause()}initAnimation(){const{options:s}=this;jKe(s);const{type:r=ZL,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const c=r||ZL;c!==ZL&&typeof i[0]!="number"&&(this.mixKeyframes=OO(k5t,bKe(i[0],i[1])),i=[0,100]);const u=c({...s,keyframes:i});o==="mirror"&&(this.mirroredGenerator=c({...s,keyframes:[...i].reverse(),velocity:-l})),u.calculatedDuration===null&&(u.calculatedDuration=Rje(u));const{calculatedDuration:p}=u;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=u}updateTime(s){const r=Math.round(s-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(s,r=!1){const{generator:n,totalDuration:a,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:i,calculatedDuration:c}=this;if(this.startTime===null)return n.next(0);const{delay:u=0,keyframes:p,repeat:f,repeatType:g,repeatDelay:b,type:_,onUpdate:j,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const N=this.currentTime-u*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?N<0:N>a;this.currentTime=Math.max(N,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let M=this.currentTime,L=n;if(f){const U=Math.min(this.currentTime,a)/i;let B=Math.floor(U),V=U%1;!V&&U>=1&&(V=1),V===1&&B--,B=Math.min(B,f+1),!!(B%2)&&(g==="reverse"?(V=1-V,b&&(V-=b/i)):g==="mirror"&&(L=l)),M=A0(0,1,V)*i}let I;S?(this.delayState.value=p[0],I=this.delayState):I=L.next(M),o&&!S&&(I.value=o(I.value));let{done:O}=I;!S&&c!==null&&(O=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const q=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return q&&_!==Wve&&(I.value=oue(p,this.options,w,this.speed)),j&&j(I.value),q&&this.finish(),I}then(s,r){return this.finished.then(s,r)}get duration(){return _x(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+_x(s)}get time(){return _x(this.currentTime)}set time(s){s=gf(s),this.currentTime=s,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=s,this.tick(s))}getGeneratorVelocity(){const s=this.currentTime;if(s<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(s);const r=this.generator.next(s).value;return wKe(n=>this.generator.next(n).value,s,r)}get speed(){return this.playbackSpeed}set speed(s){const r=this.playbackSpeed!==s;r&&this.driver&&this.updateTime(Nm.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=_x(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=l5t,startTime:r}=this.options;this.driver||(this.driver=s(l=>this.tick(l))),(o=(a=this.options).onPlay)==null||o.call(a);const n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=r??n),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Nm.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var s,r;this.notifyFinished(),this.teardown(),this.state="finished",(r=(s=this.options).onComplete)==null||r.call(s)}cancel(){var s,r;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(r=(s=this.options).onCancel)==null||r.call(s)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(s){return this.startTime=0,this.tick(s,!0)}attachTimeline(s){var r;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(r=this.driver)==null||r.stop(),s.observe(this)}}function S5t(t){for(let s=1;st*180/Math.PI,Gve=t=>{const s=_4(Math.atan2(t[1],t[0]));return Kve(s)},C5t={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Gve,rotateZ:Gve,skewX:t=>_4(Math.atan(t[1])),skewY:t=>_4(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Kve=t=>(t=t%360,t<0&&(t+=360),t),R6e=Gve,F6e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),z6e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),M5t={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:F6e,scaleY:z6e,scale:t=>(F6e(t)+z6e(t))/2,rotateX:t=>Kve(_4(Math.atan2(t[6],t[5]))),rotateY:t=>Kve(_4(Math.atan2(-t[2],t[0]))),rotateZ:R6e,rotate:R6e,skewX:t=>_4(Math.atan(t[4])),skewY:t=>_4(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Zve(t){return t.includes("scale")?1:0}function Yve(t,s){if(!t||t==="none")return Zve(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=M5t,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=C5t,a=i}if(!a)return Zve(s);const o=n[s],l=a[1].split(",").map(A5t);return typeof o=="function"?o(l):l[o]}const T5t=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return Yve(r,s)};function A5t(t){return parseFloat(t.trim())}const QA=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],JA=new Set(QA),B6e=t=>t===XA||t===ia,E5t=new Set(["x","y","z"]),P5t=QA.filter(t=>!E5t.has(t));function I5t(t){const s=[];return P5t.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const N_={width:({x:t},{paddingLeft:s="0",paddingRight:r="0",boxSizing:n})=>{const a=t.max-t.min;return n==="border-box"?a:a-parseFloat(s)-parseFloat(r)},height:({y:t},{paddingTop:s="0",paddingBottom:r="0",boxSizing:n})=>{const a=t.max-t.min;return n==="border-box"?a:a-parseFloat(s)-parseFloat(r)},top:(t,{top:s})=>parseFloat(s),left:(t,{left:s})=>parseFloat(s),bottom:({y:t},{top:s})=>parseFloat(s)+(t.max-t.min),right:({x:t},{left:s})=>parseFloat(s)+(t.max-t.min),x:(t,{transform:s})=>Yve(s,"x"),y:(t,{transform:s})=>Yve(s,"y")};N_.translateX=N_.x;N_.translateY=N_.y;const yS=new Set;let Xve=!1,Qve=!1,Jve=!1;function NKe(){if(Qve){const t=Array.from(yS).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=I5t(n);a.length&&(r.set(n,a),n.render())}),t.forEach(n=>n.measureInitialState()),s.forEach(n=>{n.render();const a=r.get(n);a&&a.forEach(([o,l])=>{var i;(i=n.getValue(o))==null||i.set(l)})}),t.forEach(n=>n.measureEndState()),t.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}Qve=!1,Xve=!1,yS.forEach(t=>t.complete(Jve)),yS.clear()}function kKe(){yS.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Qve=!0)})}function L5t(){Jve=!0,kKe(),NKe(),Jve=!1}class zje{constructor(s,r,n,a,o,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...s],this.onComplete=r,this.name=n,this.motionValue=a,this.element=o,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?(yS.add(this),Xve||(Xve=!0,Dl.read(kKe),Dl.resolveKeyframes(NKe))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:s,name:r,element:n,motionValue:a}=this;if(s[0]===null){const o=a==null?void 0:a.get(),l=s[s.length-1];if(o!==void 0)s[0]=o;else if(n&&r){const i=n.readValue(r,l);i!=null&&(s[0]=i)}s[0]===void 0&&(s[0]=l),a&&o===void 0&&a.set(s[0])}S5t(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),yS.delete(this)}cancel(){this.state==="scheduled"&&(yS.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const D5t=t=>t.startsWith("--");function SKe(t,s,r){D5t(s)?t.style.setProperty(s,r):t.style[s]=r}const O5t={};function CKe(t,s){const r=eKe(t);return()=>O5t[s]??r()}const R5t=CKe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),MKe=CKe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),NI=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,$6e={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:NI([0,.65,.55,1]),circOut:NI([.55,0,1,.45]),backIn:NI([.31,.01,.66,-.59]),backOut:NI([.33,1.53,.69,.99])};function TKe(t,s){if(t)return typeof t=="function"?MKe()?_Ke(t,s):"ease-out":uKe(t)?NI(t):Array.isArray(t)?t.map(r=>TKe(r,s)||$6e.easeOut):$6e[t]}function F5t(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:c}={},u=void 0){const p={[s]:r};c&&(p.offset=c);const f=TKe(i,a);Array.isArray(f)&&(p.easing=f);const g={delay:n,duration:a,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(g.pseudoElement=u),t.animate(p,g)}function AKe(t){return typeof t=="function"&&"applyToOptions"in t}function z5t({type:t,...s}){return AKe(t)&&MKe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class EKe extends Fje{constructor(s){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!s)return;const{element:r,name:n,keyframes:a,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:i,onComplete:c}=s;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=s,Tje(typeof s.type!="string");const u=z5t(s);this.animation=F5t(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=oue(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),SKe(r,n,p),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var s,r;(r=(s=this.animation).finish)==null||r.call(s)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:s}=this;s==="idle"||s==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var r,n,a;const s=(r=this.options)==null?void 0:r.element;!this.isPseudoElement&&(s!=null&&s.isConnected)&&((a=(n=this.animation).commitStyles)==null||a.call(n))}get duration(){var r,n;const s=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return _x(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+_x(s)}get time(){return _x(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=gf(s),r&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(s){s<0&&(this.finishedTime=null),this.animation.playbackRate=s}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(s){this.manualStartTime=this.animation.startTime=s}attachTimeline({timeline:s,rangeStart:r,rangeEnd:n,observe:a}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,s&&R5t()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),Ax):a(this)}}const PKe={anticipate:oKe,backInOut:iKe,circInOut:cKe};function B5t(t){return t in PKe}function $5t(t){typeof t.ease=="string"&&B5t(t.ease)&&(t.ease=PKe[t.ease])}const Dxe=10;class q5t extends EKe{constructor(s){$5t(s),jKe(s),super(s),s.startTime!==void 0&&s.autoplay!==!1&&(this.startTime=s.startTime),this.options=s}updateMotionValue(s){const{motionValue:r,onUpdate:n,onComplete:a,element:o,...l}=this.options;if(!r)return;if(s!==void 0){r.set(s);return}const i=new Roe({...l,autoplay:!1}),c=Math.max(Dxe,Nm.now()-this.startTime),u=A0(0,Dxe,c-Dxe),p=i.sample(c).value,{name:f}=this.options;o&&f&&SKe(o,f,p),r.setWithVelocity(i.sample(Math.max(0,c-u)).value,p,u),i.stop()}}const q6e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(sy.test(t)||t==="0")&&!t.startsWith("url("));function U5t(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function Z5t(t){var f;const{motionValue:s,name:r,repeatDelay:n,repeatType:a,damping:o,type:l,keyframes:i}=t;if(!(((f=s==null?void 0:s.owner)==null?void 0:f.current)instanceof HTMLElement))return!1;const{onUpdate:u,transformTemplate:p}=s.owner.getProps();return K5t()&&r&&(IKe.has(r)||G5t.has(r)&&W5t(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const Y5t=40;class X5t extends Fje{constructor({autoplay:s=!0,delay:r=0,type:n="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:i,name:c,motionValue:u,element:p,...f}){var _;super(),this.stop=()=>{var j,w;this._animation&&(this._animation.stop(),(j=this.stopTimeline)==null||j.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=Nm.now();const g={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:c,motionValue:u,element:p,...f},b=(p==null?void 0:p.KeyframeResolver)||zje;this.keyframeResolver=new b(i,(j,w,N)=>this.onKeyframesResolved(j,w,g,!N),c,u,p),(_=this.keyframeResolver)==null||_.scheduleResolve()}onKeyframesResolved(s,r,n,a){var N,S;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:c,isHandoff:u,onUpdate:p}=n;this.resolvedAt=Nm.now();let f=!0;V5t(s,o,l,i)||(f=!1,(fw.instantAnimations||!c)&&(p==null||p(oue(s,n,r))),s[0]=s[s.length-1],e1e(n),n.repeat=0);const b={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>Y5t?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},_=f&&!u&&Z5t(b),j=(S=(N=b.motionValue)==null?void 0:N.owner)==null?void 0:S.current;let w;if(_)try{w=new q5t({...b,element:j})}catch{w=new Roe(b)}else w=new Roe(b);w.finished.then(()=>{this.notifyFinished()}).catch(Ax),this.pendingTimeline&&(this.stopTimeline=w.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=w}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),L5t()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(s){this.animation.time=s}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(s){this.animation.speed=s}get startTime(){return this.animation.startTime}attachTimeline(s){return this._animation?this.stopTimeline=this.animation.attachTimeline(s):this.pendingTimeline=s,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var s;this._animation&&this.animation.cancel(),(s=this.keyframeResolver)==null||s.cancel()}}function LKe(t,s,r,n=0,a=1){const o=Array.from(t).sort((u,p)=>u.sortNodePosition(p)).indexOf(s),l=t.size,i=(l-1)*n;return typeof r=="function"?r(o,l):a===1?o*n:i-o*n}const Q5t=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function J5t(t){const s=Q5t.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function DKe(t,s,r=1){const[n,a]=J5t(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return XGe(l)?parseFloat(l):l}return Ije(a)?DKe(a,s,r+1):a}const eMt={type:"spring",stiffness:500,damping:25,restSpeed:10},tMt=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),sMt={type:"keyframes",duration:.8},rMt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},nMt=(t,{keyframes:s})=>s.length>2?sMt:JA.has(t)?t.startsWith("scale")?tMt(s[1]):eMt:rMt;function OKe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function Bje(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?OKe(r,t):r}const aMt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function iMt(t){for(const s in t)if(!aMt.has(s))return!0;return!1}const $je=(t,s,r,n={},a,o)=>l=>{const i=Bje(n,t)||{},c=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-gf(c);const p={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-u,onUpdate:g=>{s.set(g),i.onUpdate&&i.onUpdate(g)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:t,motionValue:s,element:o?void 0:a};iMt(i)||Object.assign(p,nMt(t,p)),p.duration&&(p.duration=gf(p.duration)),p.repeatDelay&&(p.repeatDelay=gf(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let f=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(e1e(p),p.delay===0&&(f=!0)),(fw.instantAnimations||fw.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,e1e(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const g=oue(p.keyframes,i);if(g!==void 0){Dl.update(()=>{p.onUpdate(g),p.onComplete()});return}}return i.isSync?new Roe(p):new X5t(p)};function U6e(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function qje(t,s,r,n){if(typeof s=="function"){const[a,o]=U6e(n);s=s(r!==void 0?r:t.custom,a,o)}if(typeof s=="string"&&(s=t.variants&&t.variants[s]),typeof s=="function"){const[a,o]=U6e(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function vS(t,s,r){const n=t.getProps();return qje(n,s,r!==void 0?r:n.custom,t)}const RKe=new Set(["width","height","top","left","right","bottom",...QA]),V6e=30,oMt=t=>!isNaN(parseFloat(t));class lMt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=Nm.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&((o=this.events.change)==null||o.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty()},this.hasAnimated=!1,this.setCurrent(s),this.owner=r.owner}setCurrent(s){this.current=s,this.updatedAt=Nm.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=oMt(this.current))}setPrevFrameValue(s=this.current){this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt}onChange(s){return this.on("change",s)}on(s,r){this.events[s]||(this.events[s]=new Aje);const n=this.events[s].add(r);return s==="change"?()=>{n(),Dl.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const s in this.events)this.events[s].clear()}attach(s,r){this.passiveEffect=s,this.stopPassiveEffect=r}set(s){this.passiveEffect?this.passiveEffect(s,this.updateAndNotify):this.updateAndNotify(s)}setWithVelocity(s,r,n){this.set(r),this.prev=void 0,this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt-n}jump(s,r=!0){this.updateAndNotify(s),this.prev=s,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var s;(s=this.events.change)==null||s.notify(this.current)}addDependent(s){this.dependents||(this.dependents=new Set),this.dependents.add(s)}removeDependent(s){this.dependents&&this.dependents.delete(s)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const s=Nm.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>V6e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,V6e);return tKe(parseFloat(this.current)-parseFloat(this.prevFrameValue),r)}start(s){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=s(r),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var s,r;(s=this.dependents)==null||s.clear(),(r=this.events.destroy)==null||r.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function VT(t,s){return new lMt(t,s)}const t1e=t=>Array.isArray(t);function cMt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,VT(r))}function dMt(t){return t1e(t)?t[t.length-1]||0:t}function uMt(t,s){const r=vS(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=dMt(o[l]);cMt(t,l,i)}}const jh=t=>!!(t&&t.getVelocity);function hMt(t){return!!(jh(t)&&t.add)}function s1e(t,s){const r=t.getValue("willChange");if(hMt(r))return r.add(s);if(!r&&fw.WillChange){const n=new fw.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function Uje(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const mMt="framerAppearId",FKe="data-"+Uje(mMt);function zKe(t){return t.props[FKe]}function pMt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function BKe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const c=t.getDefaultTransition();o=o?OKe(o,c):c;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],f=a&&t.animationState&&t.animationState.getState()[a];for(const g in i){const b=t.getValue(g,t.latestValues[g]??null),_=i[g];if(_===void 0||f&&pMt(f,g))continue;const j={delay:r,...Bje(o||{},g)},w=b.get();if(w!==void 0&&!b.isAnimating()&&!Array.isArray(_)&&_===w&&!j.velocity){Dl.update(()=>b.set(_));continue}let N=!1;if(window.MotionHandoffAnimation){const L=zKe(t);if(L){const I=window.MotionHandoffAnimation(L,g,Dl);I!==null&&(j.startTime=I,N=!0)}}s1e(t,g);const S=u??t.shouldReduceMotion;b.start($je(g,b,_,S&&RKe.has(g)?{type:!1}:j,t,N));const M=b.animation;M&&p.push(M)}if(l){const g=()=>Dl.update(()=>{l&&uMt(t,l)});p.length?Promise.all(p).then(g):g()}return p}function r1e(t,s,r={}){var c;const n=vS(t,s,r.type==="exit"?(c=t.presenceContext)==null?void 0:c.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(a=r.transitionOverride);const o=n?()=>Promise.all(BKe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:f,staggerDirection:g}=a;return fMt(t,s,u,p,f,g,r)}:()=>Promise.resolve(),{when:i}=a;if(i){const[u,p]=i==="beforeChildren"?[o,l]:[l,o];return u().then(()=>p())}else return Promise.all([o(),l(r.delay)])}function fMt(t,s,r=0,n=0,a=0,o=1,l){const i=[];for(const c of t.variantChildren)c.notify("AnimationStart",s),i.push(r1e(c,s,{...l,delay:r+(typeof n=="function"?0:n)+LKe(t.variantChildren,c,n,a,o)}).then(()=>c.notify("AnimationComplete",s)));return Promise.all(i)}function xMt(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>r1e(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=r1e(t,s,r);else{const a=typeof s=="function"?vS(t,s,r.custom):s;n=Promise.all(BKe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const gMt={test:t=>t==="auto",parse:t=>t},$Ke=t=>s=>s.test(t),qKe=[XA,ia,N0,$b,U3t,q3t,gMt],H6e=t=>qKe.find($Ke(t));function yMt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||JGe(t):!0}const vMt=new Set(["brightness","contrast","saturate","opacity"]);function bMt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(Lje)||[];if(!n)return t;const a=r.replace(n,"");let o=vMt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const _Mt=/\b([a-z-]*)\(.*?\)/gu,n1e={...sy,getAnimatableNone:t=>{const s=t.match(_Mt);return s?s.map(bMt).join(" "):t}},a1e={...sy,getAnimatableNone:t=>{const s=sy.parse(t);return sy.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},W6e={...XA,transform:Math.round},wMt={rotate:$b,rotateX:$b,rotateY:$b,rotateZ:$b,scale:az,scaleX:az,scaleY:az,scaleZ:az,skew:$b,skewX:$b,skewY:$b,distance:ia,translateX:ia,translateY:ia,translateZ:ia,x:ia,y:ia,z:ia,perspective:ia,transformPerspective:ia,opacity:nD,originX:P6e,originY:P6e,originZ:ia},Vje={borderWidth:ia,borderTopWidth:ia,borderRightWidth:ia,borderBottomWidth:ia,borderLeftWidth:ia,borderRadius:ia,borderTopLeftRadius:ia,borderTopRightRadius:ia,borderBottomRightRadius:ia,borderBottomLeftRadius:ia,width:ia,maxWidth:ia,height:ia,maxHeight:ia,top:ia,right:ia,bottom:ia,left:ia,inset:ia,insetBlock:ia,insetBlockStart:ia,insetBlockEnd:ia,insetInline:ia,insetInlineStart:ia,insetInlineEnd:ia,padding:ia,paddingTop:ia,paddingRight:ia,paddingBottom:ia,paddingLeft:ia,paddingBlock:ia,paddingBlockStart:ia,paddingBlockEnd:ia,paddingInline:ia,paddingInlineStart:ia,paddingInlineEnd:ia,margin:ia,marginTop:ia,marginRight:ia,marginBottom:ia,marginLeft:ia,marginBlock:ia,marginBlockStart:ia,marginBlockEnd:ia,marginInline:ia,marginInlineStart:ia,marginInlineEnd:ia,fontSize:ia,backgroundPositionX:ia,backgroundPositionY:ia,...wMt,zIndex:W6e,fillOpacity:nD,strokeOpacity:nD,numOctaves:W6e},jMt={...Vje,color:Xd,backgroundColor:Xd,outlineColor:Xd,fill:Xd,stroke:Xd,borderColor:Xd,borderTopColor:Xd,borderRightColor:Xd,borderBottomColor:Xd,borderLeftColor:Xd,filter:n1e,WebkitFilter:n1e,mask:a1e,WebkitMask:a1e},UKe=t=>jMt[t],NMt=new Set([n1e,a1e]);function VKe(t,s){let r=UKe(t);return NMt.has(r)||(r=sy),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const kMt=new Set(["auto","none","0"]);function SMt(t,s,r){let n=0,a;for(;n{s.getValue(c).set(u)}),this.resolveNoneKeyframes()}}function Hje(t,s,r){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){const a=document.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t).filter(n=>n!=null)}const HKe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function fie(t){return QGe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:Wje}=hKe(queueMicrotask,!1),Eg={x:!1,y:!1};function WKe(){return Eg.x||Eg.y}function MMt(t){return t==="x"||t==="y"?Eg[t]?null:(Eg[t]=!0,()=>{Eg[t]=!1}):Eg.x||Eg.y?null:(Eg.x=Eg.y=!0,()=>{Eg.x=Eg.y=!1})}function GKe(t,s){const r=Hje(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function TMt(t){return!(t.pointerType==="touch"||WKe())}function AMt(t,s,r={}){const[n,a,o]=GKe(t,r);return n.forEach(l=>{let i=!1,c=!1,u;const p=()=>{l.removeEventListener("pointerleave",_)},f=w=>{u&&(u(w),u=void 0),p()},g=w=>{i=!1,window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g),c&&(c=!1,f(w))},b=()=>{i=!0,window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",g,a)},_=w=>{if(w.pointerType!=="touch"){if(i){c=!0;return}f(w)}},j=w=>{if(!TMt(w))return;c=!1;const N=s(l,w);typeof N=="function"&&(u=N,l.addEventListener("pointerleave",_,a))};l.addEventListener("pointerenter",j,a),l.addEventListener("pointerdown",b,a)}),o}const KKe=(t,s)=>s?t===s?!0:KKe(t,s.parentElement):!1,Gje=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,EMt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function PMt(t){return EMt.has(t.tagName)||t.isContentEditable===!0}const IMt=new Set(["INPUT","SELECT","TEXTAREA"]);function LMt(t){return IMt.has(t.tagName)||t.isContentEditable===!0}const xie=new WeakSet;function G6e(t){return s=>{s.key==="Enter"&&t(s)}}function Oxe(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const DMt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=G6e(()=>{if(xie.has(r))return;Oxe(r,"down");const a=G6e(()=>{Oxe(r,"up")}),o=()=>Oxe(r,"cancel");r.addEventListener("keyup",a,s),r.addEventListener("blur",o,s)});r.addEventListener("keydown",n,s),r.addEventListener("blur",()=>r.removeEventListener("keydown",n),s)};function K6e(t){return Gje(t)&&!WKe()}const Z6e=new WeakSet;function OMt(t,s,r={}){const[n,a,o]=GKe(t,r),l=i=>{const c=i.currentTarget;if(!K6e(i)||Z6e.has(i))return;xie.add(c),r.stopPropagation&&Z6e.add(i);const u=s(c,i),p=(b,_)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",g),xie.has(c)&&xie.delete(c),K6e(b)&&typeof u=="function"&&u(b,{success:_})},f=b=>{p(b,c===window||c===document||r.useGlobalTarget||KKe(c,b.target))},g=b=>{p(b,!1)};window.addEventListener("pointerup",f,a),window.addEventListener("pointercancel",g,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),fie(i)&&(i.addEventListener("focus",u=>DMt(u,a)),!PMt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function Kje(t){return QGe(t)&&"ownerSVGElement"in t}const gie=new WeakMap;let qb;const ZKe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:Kje(n)&&"getBBox"in n?n.getBBox()[s]:n[r],RMt=ZKe("inline","width","offsetWidth"),FMt=ZKe("block","height","offsetHeight");function zMt({target:t,borderBoxSize:s}){var r;(r=gie.get(t))==null||r.forEach(n=>{n(t,{get width(){return RMt(t,s)},get height(){return FMt(t,s)}})})}function BMt(t){t.forEach(zMt)}function $Mt(){typeof ResizeObserver>"u"||(qb=new ResizeObserver(BMt))}function qMt(t,s){qb||$Mt();const r=Hje(t);return r.forEach(n=>{let a=gie.get(n);a||(a=new Set,gie.set(n,a)),a.add(s),qb==null||qb.observe(n)}),()=>{r.forEach(n=>{const a=gie.get(n);a==null||a.delete(s),a!=null&&a.size||qb==null||qb.unobserve(n)})}}const yie=new Set;let lM;function UMt(){lM=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};yie.forEach(s=>s(t))},window.addEventListener("resize",lM)}function VMt(t){return yie.add(t),lM||UMt(),()=>{yie.delete(t),!yie.size&&typeof lM=="function"&&(window.removeEventListener("resize",lM),lM=void 0)}}function Y6e(t,s){return typeof t=="function"?VMt(t):qMt(t,s)}function HMt(t){return Kje(t)&&t.tagName==="svg"}const WMt=[...qKe,Xd,sy],GMt=t=>WMt.find($Ke(t)),X6e=()=>({translate:0,scale:1,origin:0,originPoint:0}),cM=()=>({x:X6e(),y:X6e()}),Q6e=()=>({min:0,max:0}),fu=()=>({x:Q6e(),y:Q6e()}),KMt=new WeakMap;function lue(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function aD(t){return typeof t=="string"||Array.isArray(t)}const Zje=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Yje=["initial",...Zje];function cue(t){return lue(t.animate)||Yje.some(s=>aD(t[s]))}function YKe(t){return!!(cue(t)||t.variants)}function ZMt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(jh(a))t.addValue(n,a);else if(jh(o))t.addValue(n,VT(a,{owner:t}));else if(o!==a)if(t.hasValue(n)){const l=t.getValue(n);l.liveStyle===!0?l.jump(a):l.hasAnimated||l.set(a)}else{const l=t.getStaticValue(n);t.addValue(n,VT(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const i1e={current:null},XKe={current:!1},YMt=typeof window<"u";function XMt(){if(XKe.current=!0,!!YMt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>i1e.current=t.matches;t.addEventListener("change",s),s()}else i1e.current=!1}const J6e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Foe={};function QKe(t){Foe=t}function QMt(){return Foe}class JMt{scrapeMotionValuesFromProps(s,r,n){return{}}constructor({parent:s,props:r,presenceContext:n,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:l,visualState:i},c={}){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=zje,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 b=Nm.now();this.renderScheduledAtthis.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(XKe.current||XMt(),this.shouldReduceMotion=i1e.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var s;this.projection&&this.projection.unmount(),xw(this.notifyUpdate),xw(this.render),this.valueSubscriptions.forEach(r=>r()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(s=this.parent)==null||s.removeChild(this);for(const r in this.events)this.events[r].clear();for(const r in this.features){const n=this.features[r];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(s){this.children.add(s),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(s)}removeChild(s){this.children.delete(s),this.enteringChildren&&this.enteringChildren.delete(s)}bindToMotionValue(s,r){if(this.valueSubscriptions.has(s)&&this.valueSubscriptions.get(s)(),r.accelerate&&IKe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:c,ease:u,duration:p}=r.accelerate,f=new EKe({element:this.current,name:s,keyframes:i,times:c,ease:u,duration:gf(p)}),g=l(f);this.valueSubscriptions.set(s,()=>{g(),f.cancel()});return}const n=JA.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&Dl.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,s,r)),this.valueSubscriptions.set(s,()=>{a(),o&&o(),r.owner&&r.stop()})}sortNodePosition(s){return!this.current||!this.sortInstanceNodePosition||this.type!==s.type?0:this.sortInstanceNodePosition(this.current,s.current)}updateFeatures(){let s="animation";for(s in Foe){const r=Foe[s];if(!r)continue;const{isEnabled:n,Feature:a}=r;if(!this.features[s]&&a&&n(this.props)&&(this.features[s]=new a(this)),this.features[s]){const o=this.features[s];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):fu()}getStaticValue(s){return this.latestValues[s]}setStaticValue(s,r){this.latestValues[s]=r}update(s,r){(s.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=s,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let n=0;nr.variantChildren.delete(s)}addValue(s,r){const n=this.values.get(s);r!==n&&(n&&this.removeValue(s),this.bindToMotionValue(s,r),this.values.set(s,r),this.latestValues[s]=r.get())}removeValue(s){this.values.delete(s);const r=this.valueSubscriptions.get(s);r&&(r(),this.valueSubscriptions.delete(s)),delete this.latestValues[s],this.removeValueFromRenderState(s,this.renderState)}hasValue(s){return this.values.has(s)}getValue(s,r){if(this.props.values&&this.props.values[s])return this.props.values[s];let n=this.values.get(s);return n===void 0&&r!==void 0&&(n=VT(r===null?void 0:r,{owner:this}),this.addValue(s,n)),n}readValue(s,r){let n=this.latestValues[s]!==void 0||!this.current?this.latestValues[s]:this.getBaseTargetFromProps(this.props,s)??this.readValueFromInstance(this.current,s,this.options);return n!=null&&(typeof n=="string"&&(XGe(n)||JGe(n))?n=parseFloat(n):!GMt(n)&&sy.test(r)&&(n=VKe(s,r)),this.setBaseTarget(s,jh(n)?n.get():n)),jh(n)?n.get():n}setBaseTarget(s,r){this.baseTarget[s]=r}getBaseTarget(s){var o;const{initial:r}=this.props;let n;if(typeof r=="string"||typeof r=="object"){const l=qje(this.props,r,(o=this.presenceContext)==null?void 0:o.custom);l&&(n=l[s])}if(r&&n!==void 0)return n;const a=this.getBaseTargetFromProps(this.props,s);return a!==void 0&&!jh(a)?a:this.initialValues[s]!==void 0&&n===void 0?void 0:this.baseTarget[s]}on(s,r){return this.events[s]||(this.events[s]=new Aje),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){Wje.render(this.render)}}class JKe extends JMt{constructor(){super(...arguments),this.KeyframeResolver=CMt}sortInstanceNodePosition(s,r){return s.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(s,r){const n=s.style;return n?n[r]:void 0}removeValueFromRenderState(s,{vars:r,style:n}){delete r[s],delete n[s]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:s}=this.props;jh(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class Lw{constructor(s){this.isMounted=!1,this.node=s}update(){}}function eZe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function eTt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function tTt(t,s){if(!s)return t;const r=s({x:t.left,y:t.top}),n=s({x:t.right,y:t.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}function Rxe(t){return t===void 0||t===1}function o1e({scale:t,scaleX:s,scaleY:r}){return!Rxe(t)||!Rxe(s)||!Rxe(r)}function a4(t){return o1e(t)||tZe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function tZe(t){return ePe(t.x)||ePe(t.y)}function ePe(t){return t&&t!=="0%"}function zoe(t,s,r){const n=t-r,a=s*n;return r+a}function tPe(t,s,r,n,a){return a!==void 0&&(t=zoe(t,a,n)),zoe(t,r,n)+s}function l1e(t,s=0,r=1,n,a){t.min=tPe(t.min,s,r,n,a),t.max=tPe(t.max,s,r,n,a)}function sZe(t,{x:s,y:r}){l1e(t.x,s.translate,s.scale,s.originPoint),l1e(t.y,r.translate,r.scale,r.originPoint)}const sPe=.999999999999,rPe=1.0000000000001;function sTt(t,s,r,n=!1){var i;const a=r.length;if(!a)return;s.x=s.y=1;let o,l;for(let c=0;csPe&&(s.x=1),s.ysPe&&(s.y=1)}function t0(t,s){t.min+=s,t.max+=s}function nPe(t,s,r,n,a=.5){const o=wc(t.min,t.max,a);l1e(t,s,r,o,n)}function aPe(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function vie(t,s,r){const n=r??t;nPe(t.x,aPe(s.x,n.x),s.scaleX,s.scale,s.originX),nPe(t.y,aPe(s.y,n.y),s.scaleY,s.scale,s.originY)}function rZe(t,s){return eZe(tTt(t.getBoundingClientRect(),s))}function rTt(t,s,r){const n=rZe(t,r),{scroll:a}=s;return a&&(t0(n.x,a.offset.x),t0(n.y,a.offset.y)),n}const nTt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},aTt=QA.length;function iTt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(ia.test(t))t=parseFloat(t);else return t;const r=iPe(t,s.target.x),n=iPe(t,s.target.y);return`${r}% ${n}%`}},oTt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=sy.parse(t);if(a.length>5)return n;const o=sy.createTransformer(t),l=typeof a[0]!="number"?1:0,i=r.x.scale*s.x,c=r.y.scale*s.y;a[0+l]/=i,a[1+l]/=c;const u=wc(i,c,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},c1e={borderRadius:{...HP,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:HP,borderTopRightRadius:HP,borderBottomLeftRadius:HP,borderBottomRightRadius:HP,boxShadow:oTt};function aZe(t,{layout:s,layoutId:r}){return JA.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!c1e[t]||t==="opacity")}function Qje(t,s,r){var l;const n=t.style,a=s==null?void 0:s.style,o={};if(!n)return o;for(const i in n)(jh(n[i])||a&&jh(a[i])||aZe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function lTt(t){return window.getComputedStyle(t)}class cTt extends JKe{constructor(){super(...arguments),this.type="html",this.renderInstance=nZe}readValueFromInstance(s,r){var n;if(JA.has(r))return(n=this.projection)!=null&&n.isProjecting?Zve(r):T5t(s,r);{const a=lTt(s),o=(pKe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return rZe(s,r)}build(s,r,n){Xje(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return Qje(s,r,n)}}const dTt={offset:"stroke-dashoffset",array:"stroke-dasharray"},uTt={offset:"strokeDashoffset",array:"strokeDasharray"};function hTt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?dTt:uTt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const mTt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function iZe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},c,u,p){if(Xje(t,i,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:f,style:g}=t;f.transform&&(g.transform=f.transform,delete f.transform),(g.transform||f.transformOrigin)&&(g.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),g.transform&&(g.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete f.transformBox);for(const b of mTt)f[b]!==void 0&&(g[b]=f[b],delete f[b]);s!==void 0&&(f.x=s),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),a!==void 0&&hTt(f,a,o,l,!1)}const oZe=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"]),lZe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function pTt(t,s,r,n){nZe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(oZe.has(a)?a:Uje(a),s.attrs[a])}function cZe(t,s,r){const n=Qje(t,s,r);for(const a in t)if(jh(t[a])||jh(s[a])){const o=QA.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class fTt extends JKe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=fu}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(JA.has(r)){const n=UKe(r);return n&&n.default||0}return r=oZe.has(r)?r:Uje(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return cZe(s,r,n)}build(s,r,n){iZe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){pTt(s,r,n,a)}mount(s){this.isSVGTag=lZe(s.tagName),super.mount(s)}}const xTt=Yje.length;function dZe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?dZe(t.parent)||{}:{};return t.props.initial!==void 0&&(r.initial=t.props.initial),r}const s={};for(let r=0;rPromise.all(s.map(({animation:r,options:n})=>xMt(t,r,n)))}function bTt(t){let s=vTt(t),r=oPe(),n=!0,a=!1;const o=u=>(p,f)=>{var b;const g=vS(t,f,u==="exit"?(b=t.presenceContext)==null?void 0:b.custom:void 0);if(g){const{transition:_,transitionEnd:j,...w}=g;p={...p,...w,...j}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,f=dZe(t.parent)||{},g=[],b=new Set;let _={},j=1/0;for(let N=0;Nj&&I,V=!1;const Y=Array.isArray(L)?L:[L];let Q=Y.reduce(o(S),{});O===!1&&(Q={});const{prevResolvedValues:ee={}}=M,X={...ee,...Q},ie=ce=>{B=!0,b.has(ce)&&(V=!0,b.delete(ce)),M.needsAnimating[ce]=!0;const ge=t.getValue(ce);ge&&(ge.liveStyle=!1)};for(const ce in X){const ge=Q[ce],ye=ee[ce];if(_.hasOwnProperty(ce))continue;let ue=!1;t1e(ge)&&t1e(ye)?ue=!uZe(ge,ye):ue=ge!==ye,ue?ge!=null?ie(ce):b.add(ce):ge!==void 0&&b.has(ce)?ie(ce):M.protectedKeys[ce]=!0}M.prevProp=L,M.prevResolvedValues=Q,M.isActive&&(_={..._,...Q}),(n||a)&&t.blockInitialAnimation&&(B=!1);const re=q&&U;B&&(!re||V)&&g.push(...Y.map(ce=>{const ge={type:S};if(typeof ce=="string"&&(n||a)&&!re&&t.manuallyAnimateOnMount&&t.parent){const{parent:ye}=t,ue=vS(ye,ce);if(ye.enteringChildren&&ue){const{delayChildren:pe}=ue.transition||{};ge.delay=LKe(ye.enteringChildren,t,pe)}}return{animation:ce,options:ge}}))}if(b.size){const N={};if(typeof p.initial!="boolean"){const S=vS(t,Array.isArray(p.initial)?p.initial[0]:p.initial);S&&S.transition&&(N.transition=S.transition)}b.forEach(S=>{const M=t.getBaseTarget(S),L=t.getValue(S);L&&(L.liveStyle=!0),N[S]=M??null}),g.push({animation:N})}let w=!!g.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(w=!1),n=!1,a=!1,w?s(g):Promise.resolve()}function c(u,p){var g;if(r[u].isActive===p)return Promise.resolve();(g=t.variantChildren)==null||g.forEach(b=>{var _;return(_=b.animationState)==null?void 0:_.setActive(u,p)}),r[u].isActive=p;const f=i(u);for(const b in r)r[b].protectedKeys={};return f}return{animateChanges:i,setActive:c,setAnimateFunction:l,getState:()=>r,reset:()=>{r=oPe(),a=!0}}}function _Tt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!uZe(s,t):!1}function z2(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function oPe(){return{animate:z2(!0),whileInView:z2(),whileHover:z2(),whileTap:z2(),whileDrag:z2(),whileFocus:z2(),exit:z2()}}function d1e(t,s){t.min=s.min,t.max=s.max}function kg(t,s){d1e(t.x,s.x),d1e(t.y,s.y)}function lPe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const hZe=1e-4,wTt=1-hZe,jTt=1+hZe,mZe=.01,NTt=0-mZe,kTt=0+mZe;function km(t){return t.max-t.min}function STt(t,s,r){return Math.abs(t-s)<=r}function cPe(t,s,r,n=.5){t.origin=n,t.originPoint=wc(s.min,s.max,t.origin),t.scale=km(r)/km(s),t.translate=wc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=wTt&&t.scale<=jTt||isNaN(t.scale))&&(t.scale=1),(t.translate>=NTt&&t.translate<=kTt||isNaN(t.translate))&&(t.translate=0)}function YL(t,s,r,n){cPe(t.x,s.x,r.x,n?n.originX:void 0),cPe(t.y,s.y,r.y,n?n.originY:void 0)}function dPe(t,s,r,n=0){const a=n?wc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+km(s)}function CTt(t,s,r,n){dPe(t.x,s.x,r.x,n==null?void 0:n.x),dPe(t.y,s.y,r.y,n==null?void 0:n.y)}function uPe(t,s,r,n=0){const a=n?wc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+km(s)}function Boe(t,s,r,n){uPe(t.x,s.x,r.x,n==null?void 0:n.x),uPe(t.y,s.y,r.y,n==null?void 0:n.y)}function hPe(t,s,r,n,a){return t-=s,t=zoe(t,1/r,n),a!==void 0&&(t=zoe(t,1/a,n)),t}function MTt(t,s=0,r=1,n=.5,a,o=t,l=t){if(N0.test(s)&&(s=parseFloat(s),s=wc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=wc(o.min,o.max,n);t===o&&(i-=s),t.min=hPe(t.min,s,r,i,a),t.max=hPe(t.max,s,r,i,a)}function mPe(t,s,[r,n,a],o,l){MTt(t,s[r],s[n],s[a],s.scale,o,l)}const TTt=["x","scaleX","originX"],ATt=["y","scaleY","originY"];function pPe(t,s,r,n){mPe(t.x,s,TTt,r?r.x:void 0,n?n.x:void 0),mPe(t.y,s,ATt,r?r.y:void 0,n?n.y:void 0)}function fPe(t){return t.translate===0&&t.scale===1}function pZe(t){return fPe(t.x)&&fPe(t.y)}function xPe(t,s){return t.min===s.min&&t.max===s.max}function ETt(t,s){return xPe(t.x,s.x)&&xPe(t.y,s.y)}function gPe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function fZe(t,s){return gPe(t.x,s.x)&&gPe(t.y,s.y)}function yPe(t){return km(t.x)/km(t.y)}function vPe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Wy(t){return[t("x"),t("y")]}function PTt(t,s,r){let n="";const a=t.x.translate/s.x,o=t.y.translate/s.y,l=(r==null?void 0:r.z)||0;if((a||o||l)&&(n=`translate3d(${a}px, ${o}px, ${l}px) `),(s.x!==1||s.y!==1)&&(n+=`scale(${1/s.x}, ${1/s.y}) `),r){const{transformPerspective:u,rotate:p,rotateX:f,rotateY:g,skewX:b,skewY:_}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),f&&(n+=`rotateX(${f}deg) `),g&&(n+=`rotateY(${g}deg) `),b&&(n+=`skewX(${b}deg) `),_&&(n+=`skewY(${_}deg) `)}const i=t.x.scale*s.x,c=t.y.scale*s.y;return(i!==1||c!==1)&&(n+=`scale(${i}, ${c})`),n||"none"}const xZe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],ITt=xZe.length,bPe=t=>typeof t=="string"?parseFloat(t):t,_Pe=t=>typeof t=="number"||ia.test(t);function LTt(t,s,r,n,a,o){a?(t.opacity=wc(0,r.opacity??1,DTt(n)),t.opacityExit=wc(s.opacity??1,0,OTt(n))):o&&(t.opacity=wc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(rD(t,s,n))}function RTt(t,s,r){const n=jh(t)?t:VT(t);return n.start($je("",n,s,r)),n.animation}function iD(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const FTt=(t,s)=>t.depth-s.depth;class zTt{constructor(){this.children=[],this.isDirty=!1}add(s){Mje(this.children,s),this.isDirty=!0}remove(s){Ioe(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(FTt),this.isDirty=!1,this.children.forEach(s)}}function BTt(t,s){const r=Nm.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(xw(n),t(o-s))};return Dl.setup(n,!0),()=>xw(n)}function bie(t){return jh(t)?t.get():t}class $Tt{constructor(){this.members=[]}add(s){Mje(this.members,s);for(let r=this.members.length-1;r>=0;r--){const n=this.members[r];if(n===s||n===this.lead||n===this.prevLead)continue;const a=n.instance;(!a||a.isConnected===!1)&&!n.snapshot&&(Ioe(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Ioe(this.members,s),s===this.prevLead&&(this.prevLead=void 0),s===this.lead){const r=this.members[this.members.length-1];r&&this.promote(r)}}relegate(s){var r;for(let n=this.members.indexOf(s)-1;n>=0;n--){const a=this.members[n];if(a.isPresent!==!1&&((r=a.instance)==null?void 0:r.isConnected)!==!1)return this.promote(a),!0}return!1}promote(s,r){var a;const n=this.lead;if(s!==n&&(this.prevLead=n,this.lead=s,s.show(),n)){n.updateSnapshot(),s.scheduleRender();const{layoutDependency:o}=n.options,{layoutDependency:l}=s.options;(o===void 0||o!==l)&&(s.resumeFrom=n,r&&(n.preserveOpacity=!0),n.snapshot&&(s.snapshot=n.snapshot,s.snapshot.latestValues=n.animationValues||n.latestValues),(a=s.root)!=null&&a.isUpdating&&(s.isLayoutDirty=!0)),s.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(s=>{var r,n,a,o,l;(n=(r=s.options).onExitComplete)==null||n.call(r),(l=(a=s.resumingFrom)==null?void 0:(o=a.options).onExitComplete)==null||l.call(o)})}scheduleRender(){this.members.forEach(s=>s.instance&&s.scheduleRender(!1))}removeLeadSnapshot(){var s;(s=this.lead)!=null&&s.snapshot&&(this.lead.snapshot=void 0)}}const _ie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Fxe=["","X","Y","Z"],qTt=1e3;let UTt=0;function zxe(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function yZe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=zKe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Dl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&yZe(n)}function vZe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=UTt++,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(WTt),this.nodes.forEach(QTt),this.nodes.forEach(JTt),this.nodes.forEach(GTt)},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 c=0;cthis.root.updateBlockedByResize=!1;Dl.read(()=>{f=window.innerWidth}),t(l,()=>{const b=window.innerWidth;b!==f&&(f=b,this.root.updateBlockedByResize=!0,p&&p(),p=BTt(g,250),_ie.hasAnimatedSinceResize&&(_ie.hasAnimatedSinceResize=!1,this.nodes.forEach(kPe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||c)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeLayoutChanged:g,layout:b})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const _=this.options.transition||u.getDefaultTransition()||nAt,{onLayoutAnimationStart:j,onLayoutAnimationComplete:w}=u.getProps(),N=!this.targetLayout||!fZe(this.targetLayout,b),S=!f&&g;if(this.options.layoutRoot||this.resumeFrom||S||f&&(N||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const M={...Bje(_,"layout"),onPlay:j,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M),this.setAnimationOrigin(p,S)}else f||kPe(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=b})}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(),xw(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(eAt),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&&yZe(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&&!km(this.snapshot.measuredBox.x)&&!km(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 c=0;c{const I=L/1e3;SPe(f.x,l.x,I),SPe(f.y,l.y,I),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Boe(g,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),sAt(this.relativeTarget,this.relativeTargetOrigin,g,I),M&&ETt(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=fu()),kg(M,this.relativeTarget)),j&&(this.animationValues=p,LTt(p,u,this.latestValues,I,S,N)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=I},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,c,u;this.notifyListeners("animationStart"),(i=this.currentAnimation)==null||i.stop(),(u=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||u.stop(),this.pendingAnimation&&(xw(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Dl.update(()=>{_ie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=VT(0)),this.motionValue.jump(0,!1),this.currentAnimation=RTt(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(qTt),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:c,layout:u,latestValues:p}=l;if(!(!i||!c||!u)){if(this!==l&&this.layout&&u&&bZe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||fu();const f=km(this.layout.layoutBox.x);c.x.min=l.target.x.min,c.x.max=c.x.min+f;const g=km(this.layout.layoutBox.y);c.y.min=l.target.y.min,c.y.max=c.y.min+g}kg(i,c),vie(i,p),YL(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new $Tt),this.sharedNodes.get(l).add(i);const u=i.options.initialPromotionConfig;i.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(i):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var i;const{layoutId:l}=this.options;return l?((i=this.getStack())==null?void 0:i.lead)||this:this}getPrevLead(){var i;const{layoutId:l}=this.options;return l?(i=this.getStack())==null?void 0:i.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:i,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),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:c}=l;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(i=!0),!i)return;const u={};c.z&&zxe("z",l,u,this.animationValues);for(let p=0;p{var i;return(i=l.currentAnimation)==null?void 0:i.stop()}),this.root.nodes.forEach(jPe),this.root.sharedNodes.clear()}}}function VTt(t){t.updateLayout()}function HTt(t){var r;const s=((r=t.resumeFrom)==null?void 0:r.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&s&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:a}=t.layout,{animationType:o}=t.options,l=s.source!==t.layout.source;if(o==="size")Wy(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],b=km(g);g.min=n[f].min,g.max=g.min+b});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";d1e(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else bZe(o,s.layoutBox,n)&&Wy(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],b=km(n[f]);g.max=g.min+b,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+b)});const i=cM();YL(i,n,s.layoutBox);const c=cM();l?YL(c,t.applyTransform(a,!0),s.measuredBox):YL(c,n,s.layoutBox);const u=!pZe(i);let p=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:g,layout:b}=f;if(g&&b){const _=t.options.layoutAnchor||void 0,j=fu();Boe(j,s.layoutBox,g.layoutBox,_);const w=fu();Boe(w,n,b.layoutBox,_),fZe(j,w)||(p=!0),f.options.layoutRoot&&(t.relativeTarget=w,t.relativeTargetOrigin=j,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:c,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function WTt(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function GTt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function KTt(t){t.clearSnapshot()}function jPe(t){t.clearMeasurements()}function ZTt(t){t.isLayoutDirty=!0,t.updateLayout()}function NPe(t){t.isLayoutDirty=!1}function YTt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function XTt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function kPe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function QTt(t){t.resolveTargetDelta()}function JTt(t){t.calcProjection()}function eAt(t){t.resetSkewAndRotation()}function tAt(t){t.removeLeadSnapshot()}function SPe(t,s,r){t.translate=wc(s.translate,0,r),t.scale=wc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function CPe(t,s,r,n){t.min=wc(s.min,r.min,n),t.max=wc(s.max,r.max,n)}function sAt(t,s,r,n){CPe(t.x,s.x,r.x,n),CPe(t.y,s.y,r.y,n)}function rAt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const nAt={duration:.45,ease:[.4,0,.1,1]},MPe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),TPe=MPe("applewebkit/")&&!MPe("chrome/")?Math.round:Ax;function APe(t){t.min=TPe(t.min),t.max=TPe(t.max)}function aAt(t){APe(t.x),APe(t.y)}function bZe(t,s,r){return t==="position"||t==="preserve-aspect"&&!STt(yPe(s),yPe(r),.2)}function iAt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const oAt=vZe({attachResizeListener:(t,s)=>iD(t,"resize",s),measureScroll:()=>{var t,s;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((s=document.body)==null?void 0:s.scrollTop)||0}},checkIsScrollRoot:()=>!0}),Bxe={current:void 0},_Ze=vZe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Bxe.current){const t=new oAt({});t.mount(window),t.setOptions({layoutScroll:!0}),Bxe.current=t}return Bxe.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Jje=k.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function EPe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function lAt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=EPe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:b,height:_,top:j,left:w,right:N,bottom:S}=c.current;if(s||o===!1||!i.current||!b||!_)return;const M=r==="left"?`left: ${w}`:`right: ${N}`,L=n==="bottom"?`bottom: ${S}`:`top: ${j}`;i.current.dataset.motionPopId=l;const I=document.createElement("style");u&&(I.nonce=u);const O=a??document.head;return O.appendChild(I),I.sheet&&I.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${b}px !important; height: ${_}px !important; ${M}px !important; ${L}px !important; } `),()=>{var q;(q=i.current)==null||q.removeAttribute("data-motion-pop-id"),O.contains(I)&&O.removeChild(I)}},[s]),e.jsx(dAt,{isPresent:s,childRef:i,sizeRef:c,pop:o,children:o===!1?t:k.cloneElement(t,{ref:f})})}const hAt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:c,root:u})=>{const p=Cje(mAt),f=k.useId();let g=!0,b=k.useMemo(()=>(g=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:_=>{p.set(_,!0);for(const j of p.values())if(!j)return;n&&n()},register:_=>(p.set(_,!1),()=>p.delete(_))}),[r,p,n]);return o&&g&&(b={...b}),k.useMemo(()=>{p.forEach((_,j)=>p.set(j,!1))},[r]),k.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(uAt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:c,root:u,children:t}),e.jsx(iue.Provider,{value:b,children:t})};function mAt(){return new Map}function wZe(t=!0){const s=k.useContext(iue);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=k.useId();k.useEffect(()=>{if(t)return a(o)},[t]);const l=k.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const iz=t=>t.key||"";function PPe(t){const s=[];return k.Children.forEach(t,r=>{k.isValidElement(r)&&s.push(r)}),s}const jZe=({children:t,custom:s,initial:r=!0,onExitComplete:n,presenceAffectsLayout:a=!0,mode:o="sync",propagate:l=!1,anchorX:i="left",anchorY:c="top",root:u})=>{const[p,f]=wZe(l),g=k.useMemo(()=>PPe(t),[t]),b=l&&!p?[]:g.map(iz),_=k.useRef(!0),j=k.useRef(g),w=Cje(()=>new Map),N=k.useRef(new Set),[S,M]=k.useState(g),[L,I]=k.useState(g);YGe(()=>{_.current=!1,j.current=g;for(let U=0;U{const B=iz(U),V=l&&!p?!1:g===L||b.includes(B),Y=()=>{if(N.current.has(B))return;if(w.has(B))N.current.add(B),w.set(B,!0);else return;let Q=!0;w.forEach(ee=>{ee||(Q=!1)}),Q&&(q==null||q(),I(j.current),l&&(f==null||f()),n&&n())};return e.jsx(hAt,{isPresent:V,initial:!_.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:V?void 0:Y,anchorX:i,anchorY:c,children:U},B)})})},NZe=k.createContext({strict:!1}),IPe={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 LPe=!1;function pAt(){if(LPe)return;const t={};for(const s in IPe)t[s]={isEnabled:r=>IPe[s].some(n=>!!r[n])};QKe(t),LPe=!0}function kZe(){return pAt(),QMt()}function fAt(t){const s=kZe();for(const r in t)s[r]={...s[r],...t[r]};QKe(s)}const xAt=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 $oe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||xAt.has(t)}let SZe=t=>!$oe(t);function gAt(t){typeof t=="function"&&(SZe=s=>s.startsWith("on")?!$oe(s):t(s))}try{gAt(require("@emotion/is-prop-valid").default)}catch{}function yAt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||jh(t[a])||(SZe(a)||r===!0&&$oe(a)||!s&&!$oe(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const due=k.createContext({});function vAt(t,s){if(cue(t)){const{initial:r,animate:n}=t;return{initial:r===!1||aD(r)?r:void 0,animate:aD(n)?n:void 0}}return t.inherit!==!1?s:{}}function bAt(t){const{initial:s,animate:r}=vAt(t,k.useContext(due));return k.useMemo(()=>({initial:s,animate:r}),[DPe(s),DPe(r)])}function DPe(t){return Array.isArray(t)?t.join(" "):t}const eNe=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function CZe(t,s,r){for(const n in s)!jh(s[n])&&!aZe(n,r)&&(t[n]=s[n])}function _At({transformTemplate:t},s){return k.useMemo(()=>{const r=eNe();return Xje(r,s,t),Object.assign({},r.vars,r.style)},[s])}function wAt(t,s){const r=t.style||{},n={};return CZe(n,r,t),Object.assign(n,_At(t,s)),n}function jAt(t,s){const r={},n=wAt(t,s);return t.drag&&t.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(r.tabIndex=0),r.style=n,r}const MZe=()=>({...eNe(),attrs:{}});function NAt(t,s,r,n){const a=k.useMemo(()=>{const o=MZe();return iZe(o,s,lZe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};CZe(o,t.style,t),a.style={...o,...a.style}}return a}const kAt=["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 tNe(t){return typeof t!="string"||t.includes("-")?!1:!!(kAt.indexOf(t)>-1||/[A-Z]/u.test(t))}function SAt(t,s,r,{latestValues:n},a,o=!1,l){const c=(l??tNe(t)?NAt:jAt)(s,n,a,t),u=yAt(s,typeof t=="string",o),p=t!==k.Fragment?{...u,...c,ref:r}:{},{children:f}=s,g=k.useMemo(()=>jh(f)?f.get():f,[f]);return k.createElement(t,{...p,children:g})}function CAt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:MAt(r,n,a,t),renderState:s()}}function MAt(t,s,r,n){const a={},o=n(t,{});for(const g in o)a[g]=bie(o[g]);let{initial:l,animate:i}=t;const c=cue(t),u=YKe(t);s&&u&&!c&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let p=r?r.initial===!1:!1;p=p||l===!1;const f=p?i:l;if(f&&typeof f!="boolean"&&!lue(f)){const g=Array.isArray(f)?f:[f];for(let b=0;b(s,r)=>{const n=k.useContext(due),a=k.useContext(iue),o=()=>CAt(t,s,n,a);return r?o():Cje(o)},TAt=TZe({scrapeMotionValuesFromProps:Qje,createRenderState:eNe}),AAt=TZe({scrapeMotionValuesFromProps:cZe,createRenderState:MZe}),EAt=Symbol.for("motionComponentSymbol");function PAt(t,s,r){const n=k.useRef(r);k.useInsertionEffect(()=>{n.current=r});const a=k.useRef(null);return k.useCallback(o=>{var i;o&&((i=t.onMount)==null||i.call(t,o));const l=n.current;if(typeof l=="function")if(o){const c=l(o);typeof c=="function"&&(a.current=c)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);s&&(o?s.mount(o):s.unmount())},[s])}const AZe=k.createContext({});function B5(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function IAt(t,s,r,n,a,o){var M,L;const{visualElement:l}=k.useContext(due),i=k.useContext(NZe),c=k.useContext(iue),u=k.useContext(Jje),p=u.reducedMotion,f=u.skipAnimations,g=k.useRef(null),b=k.useRef(!1);n=n||i.renderer,!g.current&&n&&(g.current=n(t,{visualState:s,parent:l,props:r,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:p,skipAnimations:f,isSVG:o}),b.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const _=g.current,j=k.useContext(AZe);_&&!_.projection&&a&&(_.type==="html"||_.type==="svg")&&LAt(g.current,r,a,j);const w=k.useRef(!1);k.useInsertionEffect(()=>{_&&w.current&&_.update(r,c)});const N=r[FKe],S=k.useRef(!!N&&typeof window<"u"&&!((M=window.MotionHandoffIsComplete)!=null&&M.call(window,N))&&((L=window.MotionHasOptimisedAnimation)==null?void 0:L.call(window,N)));return YGe(()=>{b.current=!0,_&&(w.current=!0,window.MotionIsMounted=!0,_.updateFeatures(),_.scheduleRenderMicrotask(),S.current&&_.animationState&&_.animationState.animateChanges())}),k.useEffect(()=>{_&&(!S.current&&_.animationState&&_.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{var I;(I=window.MotionHandoffMarkAsComplete)==null||I.call(window,N)}),S.current=!1),_.enteringChildren=void 0)}),_}function LAt(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:c,layoutRoot:u,layoutAnchor:p,layoutCrossfade:f}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:EZe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&B5(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:c,layoutRoot:u,layoutAnchor:p})}function EZe(t){if(t)return t.options.allowProjection!==!1?t.projection:EZe(t.parent)}function $xe(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&fAt(n);const o=r?r==="svg":tNe(t),l=o?AAt:TAt;function i(u,p){let f;const g={...k.useContext(Jje),...u,layoutId:DAt(u)},{isStatic:b}=g,_=bAt(u),j=l(u,b);if(!b&&typeof window<"u"){OAt();const w=RAt(g);f=w.MeasureLayout,_.visualElement=IAt(t,j,g,a,w.ProjectionNode,o)}return e.jsxs(due.Provider,{value:_,children:[f&&_.visualElement?e.jsx(f,{visualElement:_.visualElement,...g}):null,SAt(t,u,PAt(j,_.visualElement,p),j,b,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=k.forwardRef(i);return c[EAt]=t,c}function DAt({layoutId:t}){const s=k.useContext(Sje).id;return s&&t!==void 0?s+"-"+t:t}function OAt(t,s){k.useContext(NZe).strict}function RAt(t){const s=kZe(),{drag:r,layout:n}=s;if(!r&&!n)return{};const a={...r,...n};return{MeasureLayout:r!=null&&r.isEnabled(t)||n!=null&&n.isEnabled(t)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}function FAt(t,s){if(typeof Proxy>"u")return $xe;const r=new Map,n=(o,l)=>$xe(o,l,t,s),a=(o,l)=>n(o,l);return new Proxy(a,{get:(o,l)=>l==="create"?n:(r.has(l)||r.set(l,$xe(l,void 0,t,s)),r.get(l))})}const zAt=(t,s)=>s.isSVG??tNe(t)?new fTt(s):new cTt(s,{allowProjection:t!==k.Fragment});class BAt extends Lw{constructor(s){super(s),s.animationState||(s.animationState=bTt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();lue(s)&&(this.unmountControls=s.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:s}=this.node.getProps(),{animate:r}=this.node.prevProps||{};s!==r&&this.updateAnimationControlsSubscription()}unmount(){var s;this.node.animationState.reset(),(s=this.unmountControls)==null||s.call(this)}}let $At=0;class qAt extends Lw{constructor(){super(...arguments),this.id=$At++,this.isExitComplete=!1}update(){var o;if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===n)return;if(s&&n===!1){if(this.isExitComplete){const{initial:l,custom:i}=this.node.getProps();if(typeof l=="string"){const c=vS(this.node,l,i);if(c){const{transition:u,transitionEnd:p,...f}=c;for(const g in f)(o=this.node.getValue(g))==null||o.jump(f[g])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const a=this.node.animationState.setActive("exit",!s);r&&!s&&a.then(()=>{this.isExitComplete=!0,r(this.id)})}mount(){const{register:s,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),s&&(this.unmount=s(this.id))}unmount(){}}const UAt={animation:{Feature:BAt},exit:{Feature:qAt}};function zO(t){return{point:{x:t.pageX,y:t.pageY}}}const VAt=t=>s=>Gje(s)&&t(s,zO(s));function XL(t,s,r,n){return iD(t,s,VAt(r),n)}const PZe=({current:t})=>t?t.ownerDocument.defaultView:null,OPe=(t,s)=>Math.abs(t-s);function HAt(t,s){const r=OPe(t.x,s.x),n=OPe(t.y,s.y);return Math.sqrt(r**2+n**2)}const RPe=new Set(["auto","scroll"]);class IZe{constructor(s,r,{transformPagePoint:n,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:l=3,element:i}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=b=>{this.handleScroll(b.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=oz(this.lastRawMoveEventInfo,this.transformPagePoint));const b=qxe(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,j=HAt(b.offset,{x:0,y:0})>=this.distanceThreshold;if(!_&&!j)return;const{point:w}=b,{timestamp:N}=vh;this.history.push({...w,timestamp:N});const{onStart:S,onMove:M}=this.handlers;_||(S&&S(this.lastMoveEvent,b),this.startEvent=this.lastMoveEvent),M&&M(this.lastMoveEvent,b)},this.handlePointerMove=(b,_)=>{this.lastMoveEvent=b,this.lastRawMoveEventInfo=_,this.lastMoveEventInfo=oz(_,this.transformPagePoint),Dl.update(this.updatePoint,!0)},this.handlePointerUp=(b,_)=>{this.end();const{onEnd:j,onSessionEnd:w,resumeAnimation:N}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=qxe(b.type==="pointercancel"?this.lastMoveEventInfo:oz(_,this.transformPagePoint),this.history);this.startEvent&&j&&j(b,S),w&&w(b,S)},!Gje(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const c=zO(s),u=oz(c,this.transformPagePoint),{point:p}=u,{timestamp:f}=vh;this.history=[{...p,timestamp:f}];const{onSessionStart:g}=r;g&&g(s,qxe(u,this.history)),this.removeListeners=OO(XL(this.contextWindow,"pointermove",this.handlePointerMove),XL(this.contextWindow,"pointerup",this.handlePointerUp),XL(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(RPe.has(n.overflowX)||RPe.has(n.overflowY))&&this.scrollPositions.set(r,{x:r.scrollLeft,y:r.scrollTop}),r=r.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(s){const r=this.scrollPositions.get(s);if(!r)return;const n=s===window,a=n?{x:window.scrollX,y:window.scrollY}:{x:s.scrollLeft,y:s.scrollTop},o={x:a.x-r.x,y:a.y-r.y};o.x===0&&o.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(s,a),Dl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),xw(this.updatePoint)}}function oz(t,s){return s?{point:s(t.point)}:t}function FPe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function qxe({point:t},s){return{point:t,delta:FPe(t,LZe(s)),offset:FPe(t,WAt(s)),velocity:GAt(s,.1)}}function WAt(t){return t[0]}function LZe(t){return t[t.length-1]}function GAt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=LZe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>gf(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>gf(s)*2&&(n=t[1]);const o=_x(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 KAt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?wc(r,t,n.max):Math.min(t,r)),t}function zPe(t,s,r){return{min:s!==void 0?t.min+s:void 0,max:r!==void 0?t.max+r-(t.max-t.min):void 0}}function ZAt(t,{top:s,left:r,bottom:n,right:a}){return{x:zPe(t.x,r,a),y:zPe(t.y,s,n)}}function BPe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=rD(s.min,s.max-n,t.min):n>a&&(r=rD(t.min,t.max-a,s.min)),A0(0,1,r)}function QAt(t,s){const r={};return s.min!==void 0&&(r.min=s.min-t.min),s.max!==void 0&&(r.max=s.max-t.min),r}const u1e=.35;function JAt(t=u1e){return t===!1?t=0:t===!0&&(t=u1e),{x:$Pe(t,"left","right"),y:$Pe(t,"top","bottom")}}function $Pe(t,s,r){return{min:qPe(t,s),max:qPe(t,r)}}function qPe(t,s){return typeof t=="number"?t:t[s]||0}const eEt=new WeakMap;class tEt{constructor(s){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=fu(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=s}start(s,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=f=>{r&&this.snapToCursor(zO(f).point),this.stopAnimation()},l=(f,g)=>{const{drag:b,dragPropagation:_,onDragStart:j}=this.getProps();if(b&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=MMt(b),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=g,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Wy(N=>{let S=this.getAxisMotionValue(N).get()||0;if(N0.test(S)){const{projection:M}=this.visualElement;if(M&&M.layout){const L=M.layout.layoutBox[N];L&&(S=km(L)*(parseFloat(S)/100))}}this.originPoint[N]=S}),j&&Dl.update(()=>j(f,g),!1,!0),s1e(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},i=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g;const{dragPropagation:b,dragDirectionLock:_,onDirectionLock:j,onDrag:w}=this.getProps();if(!b&&!this.openDragLock)return;const{offset:N}=g;if(_&&this.currentDirection===null){this.currentDirection=rEt(N),this.currentDirection!==null&&j&&j(this.currentDirection);return}this.updateAxis("x",g.point,N),this.updateAxis("y",g.point,N),this.visualElement.render(),w&&Dl.update(()=>w(f,g),!1,!0)},c=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g,this.stop(f,g),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new IZe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:PZe(this.visualElement),element:this.visualElement.current})}stop(s,r){const n=s||this.latestPointerEvent,a=r||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!a||!n)return;const{velocity:l}=a;this.startAnimation(l);const{onDragEnd:i}=this.getProps();i&&Dl.postRender(()=>i(n,a))}cancel(){this.isDragging=!1;const{projection:s,animationState:r}=this.visualElement;s&&(s.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),r&&r.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(s,r,n){const{drag:a}=this.getProps();if(!n||!lz(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=KAt(l,this.constraints[s],this.elastic[s])),o.set(l)}resolveConstraints(){var o;const{dragConstraints:s,dragElastic:r}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,a=this.constraints;s&&B5(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=ZAt(n.layoutBox,s):this.constraints=!1,this.elastic=JAt(r),a!==this.constraints&&!B5(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&Wy(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=QAt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!B5(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=rTt(n,a.root,this.visualElement.getTransformPagePoint());let l=YAt(a.layout.layoutBox,o);if(r){const i=r(eTt(l));this.hasMutatedConstraints=!!i,i&&(l=eZe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),c=this.constraints||{},u=Wy(p=>{if(!lz(p,r,this.currentDirection))return;let f=c&&c[p]||{};(l===!0||l===p)&&(f={min:0,max:0});const g=a?200:1e6,b=a?40:1e7,_={type:"inertia",velocity:n?s[p]:0,bounceStiffness:g,bounceDamping:b,timeConstant:750,restDelta:1,restSpeed:10,...o,...f};return this.startAxisValueAnimation(p,_)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return s1e(this.visualElement,s),n.start($je(s,n,0,r,this.visualElement,!1))}stopAnimation(){Wy(s=>this.getAxisMotionValue(s).stop())}getAxisMotionValue(s){const r=`_drag${s.toUpperCase()}`,n=this.visualElement.getProps(),a=n[r];return a||this.visualElement.getValue(s,(n.initial?n.initial[s]:void 0)||0)}snapToCursor(s){Wy(r=>{const{drag:n}=this.getProps();if(!lz(r,n,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(r);if(a&&a.layout){const{min:l,max:i}=a.layout.layoutBox[r],c=o.get()||0;o.set(s[r]-wc(l,i,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!B5(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Wy(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const c=i.get();a[l]=XAt({min:c,max:c},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(),Wy(l=>{if(!lz(l,s,null))return;const i=this.getAxisMotionValue(l),{min:c,max:u}=this.constraints[l];i.set(wc(c,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;eEt.set(this.visualElement,this);const s=this.visualElement.current,r=XL(s,"pointerdown",u=>{const{drag:p,dragListener:f=!0}=this.getProps(),g=u.target,b=g!==s&&LMt(g);p&&f&&!b&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();B5(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=sEt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),Dl.read(a);const i=iD(window,"resize",()=>this.scalePositionWithinConstraints()),c=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(Wy(f=>{const g=this.getAxisMotionValue(f);g&&(this.originPoint[f]+=u[f].translate,g.set(g.get()+u[f].translate))}),this.visualElement.render())});return()=>{i(),r(),l(),c&&c(),n&&n()}}getProps(){const s=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=u1e,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function UPe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function sEt(t,s,r){const n=Y6e(t,UPe(r)),a=Y6e(s,UPe(r));return()=>{n(),a()}}function lz(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function rEt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class nEt extends Lw{constructor(s){super(s),this.removeGroupControls=Ax,this.removeListeners=Ax,this.controls=new tEt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ax}update(){const{dragControls:s}=this.node.getProps(),{dragControls:r}=this.node.prevProps||{};s!==r&&(this.removeGroupControls(),s&&(this.removeGroupControls=s.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Uxe=t=>(s,r)=>{t&&Dl.update(()=>t(s,r),!1,!0)};class aEt extends Lw{constructor(){super(...arguments),this.removePointerDownListener=Ax}onPointerDown(s){this.session=new IZe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:PZe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:Uxe(s),onStart:Uxe(r),onMove:Uxe(n),onEnd:(o,l)=>{delete this.session,a&&Dl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=XL(this.node.current,"pointerdown",s=>this.onPointerDown(s))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Vxe=!1;class iEt extends k.Component{componentDidMount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n,layoutId:a}=this.props,{projection:o}=s;o&&(r.group&&r.group.add(o),n&&n.register&&a&&n.register(o),Vxe&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),_ie.hasEverUpdated=!0}getSnapshotBeforeUpdate(s){const{layoutDependency:r,visualElement:n,drag:a,isPresent:o}=this.props,{projection:l}=n;return l&&(l.isPresent=o,s.layoutDependency!==r&&l.setOptions({...l.options,layoutDependency:r}),Vxe=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||Dl.postRender(()=>{const i=l.getStack();(!i||!i.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:s,layoutAnchor:r}=this.props,{projection:n}=s;n&&(n.options.layoutAnchor=r,n.root.didUpdate(),Wje.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;Vxe=!0,a&&(a.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(a),n&&n.deregister&&n.deregister(a))}safeToRemove(){const{safeToRemove:s}=this.props;s&&s()}render(){return null}}function DZe(t){const[s,r]=wZe(),n=k.useContext(Sje);return e.jsx(iEt,{...t,layoutGroup:n,switchLayoutGroup:k.useContext(AZe),isPresent:s,safeToRemove:r})}const oEt={pan:{Feature:aEt},drag:{Feature:nEt,ProjectionNode:_Ze,MeasureLayout:DZe}};function VPe(t,s,r){const{props:n}=t;t.animationState&&n.whileHover&&t.animationState.setActive("whileHover",r==="Start");const a="onHover"+r,o=n[a];o&&Dl.postRender(()=>o(s,zO(s)))}class lEt extends Lw{mount(){const{current:s}=this.node;s&&(this.unmount=AMt(s,(r,n)=>(VPe(this.node,n,"Start"),a=>VPe(this.node,a,"End"))))}unmount(){}}class cEt extends Lw{constructor(){super(...arguments),this.isActive=!1}onFocus(){let s=!1;try{s=this.node.current.matches(":focus-visible")}catch{s=!0}!s||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=OO(iD(this.node.current,"focus",()=>this.onFocus()),iD(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function HPe(t,s,r){const{props:n}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&n.whileTap&&t.animationState.setActive("whileTap",r==="Start");const a="onTap"+(r==="End"?"":r),o=n[a];o&&Dl.postRender(()=>o(s,zO(s)))}class dEt extends Lw{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=OMt(s,(a,o)=>(HPe(this.node,o,"Start"),(l,{success:i})=>HPe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const h1e=new WeakMap,Hxe=new WeakMap,uEt=t=>{const s=h1e.get(t.target);s&&s(t)},hEt=t=>{t.forEach(uEt)};function mEt({root:t,...s}){const r=t||document;Hxe.has(r)||Hxe.set(r,{});const n=Hxe.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(hEt,{root:t,...s})),n[a]}function pEt(t,s,r){const n=mEt(s);return h1e.set(t,r),n.observe(t),()=>{h1e.delete(t),n.unobserve(t)}}const fEt={some:0,all:1};class xEt extends Lw{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var c;(c=this.stopObserver)==null||c.call(this);const{viewport:s={}}=this.node.getProps(),{root:r,margin:n,amount:a="some",once:o}=s,l={root:r?r.current:void 0,rootMargin:n,threshold:typeof a=="number"?a:fEt[a]},i=u=>{const{isIntersecting:p}=u;if(this.isInView===p||(this.isInView=p,o&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:f,onViewportLeave:g}=this.node.getProps(),b=p?f:g;b&&b(u)};this.stopObserver=pEt(this.node.current,l,i)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:s,prevProps:r}=this.node;["amount","margin","root"].some(gEt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function gEt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const yEt={inView:{Feature:xEt},tap:{Feature:dEt},focus:{Feature:cEt},hover:{Feature:lEt}},vEt={layout:{ProjectionNode:_Ze,MeasureLayout:DZe}},bEt={...UAt,...yEt,...oEt,...vEt},Gs=FAt(bEt,zAt),_Et={some:0,all:1};function wEt(t,s,{root:r,margin:n,amount:a="some"}={}){const o=Hje(t),l=new WeakMap,i=u=>{u.forEach(p=>{const f=l.get(p.target);if(p.isIntersecting!==!!f)if(p.isIntersecting){const g=s(p.target,p);typeof g=="function"?l.set(p.target,g):c.unobserve(p.target)}else typeof f=="function"&&(f(p),l.delete(p.target))})},c=new IntersectionObserver(i,{root:r,rootMargin:n,threshold:typeof a=="number"?a:_Et[a]});return o.forEach(u=>c.observe(u)),()=>c.disconnect()}function jEt(t,{root:s,margin:r,amount:n,once:a=!1,initial:o=!1}={}){const[l,i]=k.useState(o);return k.useEffect(()=>{if(!t.current||a&&l)return;const c=()=>(i(!0),a?void 0:()=>i(!1)),u={root:s&&s.current||void 0,margin:r,amount:n};return wEt(t.current,c,u)},[s,t,r,a,n]),l}function NEt(t){switch(t){case"buying":return{label:"Buying",emoji:"🏠",color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30"};case"selling":return{label:"Selling",emoji:"📋",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"};case"neighbor":return{label:"Neighbor",emoji:"👋",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"};case"browsing":return{label:"Browsing",emoji:"👀",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"};default:return{label:"Visitor",emoji:"🙂",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"}}}function WPe(t){return t.visitor_intent==="buying"&&!t.has_agent}function kEt({token:t}={}){var _;const s=yo(),r=t||s.token,{data:n,isLoading:a,isError:o}=c3t(r),l=Qt(),i=(_=n==null?void 0:n.open_houses)==null?void 0:_.id,{data:c}=mt({queryKey:["cohost-visitors",i],queryFn:async()=>{const{data:j,error:w}=await H.from("open_house_visitors").select("*").eq("open_house_id",i).order("created_at",{ascending:!1});if(w)throw w;return j},enabled:!!i});if(k.useEffect(()=>{if(!i)return;const j=H.channel(`cohost-visitors-${i}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${i}`},()=>{l.invalidateQueries({queryKey:["cohost-visitors",i]})}).subscribe();return()=>{H.removeChannel(j)}},[i,l]),a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-white/40",children:"Validating access..."})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-xl font-bold mb-2",children:"Link Expired or Invalid"}),e.jsx("p",{className:"text-white/40 text-sm",children:"This co-host link is no longer active. Ask the host for a new one."})]})});const u=n.open_houses,p=(c==null?void 0:c.length)||0,f=(c==null?void 0:c.filter(j=>j.visitor_intent==="buying").length)||0,g=(c==null?void 0:c.filter(WPe).length)||0,b=j=>{if(!j)return"";const[w,N]=j.split(":"),S=parseInt(w);return`${S>12?S-12:S||12}:${N} ${S>=12?"PM":"AM"}`};return e.jsxs("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex flex-col",children:[e.jsxs("div",{className:"border-b border-white/10 px-4 sm:px-6 py-3 flex items-center justify-between bg-black/30 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-xs font-medium text-emerald-400 uppercase tracking-wider",children:"Live · Co-Host View"})]}),e.jsx("h1",{className:"text-white font-bold text-sm sm:text-base truncate",children:u.property_address})]}),e.jsxs("div",{className:"flex items-center gap-4 sm:gap-6 text-white/70",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:p})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[e.jsx(eh,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:g})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(bn,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:f})]})]})]}),e.jsxs("div",{className:"px-4 sm:px-6 py-2 flex items-center gap-4 text-xs text-white/40 border-b border-white/5",children:[e.jsx("span",{children:ms(new Date(u.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),u.start_time&&e.jsxs("span",{children:[b(u.start_time),u.end_time?` – ${b(u.end_time)}`:""]})]}),e.jsx(Gi,{className:"flex-1 p-4 sm:p-6",children:c!=null&&c.length?e.jsx("div",{className:"space-y-2 max-w-3xl mx-auto",children:e.jsx(jZe,{children:c.map((j,w)=>{var M;const N=NEt(j.visitor_intent),S=WPe(j);return e.jsxs(Gs.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:w*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${S?"bg-orange-500/10 border-orange-500/30":"bg-white/5 border-white/10"}`,children:[e.jsx("div",{className:`w-11 h-11 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${S?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(M=j.first_name[0])==null?void 0:M.toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"font-semibold text-white truncate",children:[j.first_name," ",j.last_name||""]}),S&&e.jsx(st,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),j.has_agent&&e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-yellow-500/40 text-yellow-400",children:"⚠️ Has Agent"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsxs(st,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${N.color}`,children:[N.emoji," ",N.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:ms(new Date(j.created_at),"h:mm a")})]})]})]},j.id)})})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-20",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-white/5 flex items-center justify-center mb-4",children:e.jsx(h1,{className:"h-10 w-10 text-white/20"})}),e.jsx("h2",{className:"text-xl font-bold text-white/60 mb-1",children:"Waiting for visitors..."}),e.jsx("p",{className:"text-white/30 text-sm",children:"New sign-ins will appear here in real-time"})]})})]})}function SEt(){const s=id().pathname.slice(1);if(k.useEffect(()=>(document.body.classList.add("guestbook-page"),()=>{document.body.classList.remove("guestbook-page")}),[]),s.startsWith("live/")){const r=s.slice(5);if(r)return e.jsx(kEt,{token:r})}return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Guest Book"}),e.jsx("p",{className:"text-white/60",children:"The modern open house sign-in experience."}),e.jsx("p",{className:"text-white/40 text-sm mt-2",children:"Visit a specific open house link to sign in."})]})}):e.jsx(OGe,{slug:s})}function CEt({dealData:t,agentProfile:s,welcomeMessage:r,isWon:n}){var o;const a=t!=null&&t.property_address?`${t.property_address}, ${t.city||""}, ${t.state||""}`.replace(/,\s*,/g,",").replace(/,\s*$/,""):null;return e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-br from-[#2a4c64] via-[#345e7a] to-[#406E71] text-white px-4 pt-10 pb-16",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.04]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px)",backgroundSize:"24px 24px"}}),e.jsxs("div",{className:"relative text-center max-w-lg mx-auto",children:[s&&e.jsxs("div",{className:"mb-6",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:s.name,className:"w-20 h-20 rounded-full border-[3px] border-white/30 shadow-xl mx-auto mb-3 object-cover"}):e.jsx("div",{className:"w-20 h-20 rounded-full border-[3px] border-white/30 shadow-xl mx-auto mb-3 bg-white/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl font-bold text-white/70",children:((o=s.name)==null?void 0:o.charAt(0))||"?"})}),e.jsx("p",{className:"text-sm font-medium text-white/90",children:s.name}),e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"Your Real Estate Agent"})]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 bg-white/10 backdrop-blur-sm rounded-full px-3 py-1 text-xs font-medium text-white/80 mb-3",children:[e.jsx(bn,{className:"w-3 h-3"}),(t==null?void 0:t.deal_type)==="listing"?"Listing":(t==null?void 0:t.deal_type)==="buy-side"?"Purchase":"Transaction"]}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight mb-1.5 font-serif",children:(t==null?void 0:t.deal_name)||"Your Transaction Portal"}),a&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-white/60 text-sm",children:[e.jsx(ma,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:a})]}),r&&e.jsx("p",{className:"mt-4 text-sm text-white/70 leading-relaxed max-w-sm mx-auto",children:r})]})]}),s&&e.jsx("div",{className:"max-w-lg mx-auto px-4 -mt-8 relative z-10",children:e.jsx("div",{className:"bg-white rounded-2xl shadow-lg border border-slate-100 p-4",children:e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[s.phone&&e.jsxs("a",{href:`tel:${s.phone}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(Un,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Call"})]}),s.email&&e.jsxs("a",{href:`mailto:${s.email}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(cr,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Email"})]}),s.phone&&e.jsxs("a",{href:`sms:${s.phone}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx($c,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function MEt({journeyStages:t,currentIndex:s}){return t.length===0?null:e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800 mb-1",children:"Your Home Journey"}),e.jsx("p",{className:"text-xs text-slate-400 mb-5",children:"Follow along as your transaction progresses"}),e.jsx("div",{className:"relative",children:t.map((r,n)=>{const a=ns;return e.jsxs("div",{className:"flex items-start gap-3.5 relative",children:[n{var l,i;if(o.includes("youtube.com/watch")){const c=new URL(o).searchParams.get("v");return c?`https://www.youtube.com/embed/${c}`:null}if(o.includes("youtu.be/")){const c=(l=o.split("youtu.be/")[1])==null?void 0:l.split("?")[0];return c?`https://www.youtube.com/embed/${c}`:null}if(o.includes("loom.com/share/")){const c=(i=o.split("loom.com/share/")[1])==null?void 0:i.split("?")[0];return c?`https://www.loom.com/embed/${c}`:null}return o};return e.jsxs("div",{className:"bg-gradient-to-br from-[#406E71]/5 via-white to-[#406E71]/5 rounded-2xl border border-[#406E71]/15 overflow-hidden",children:[e.jsx("div",{className:"bg-[#406E71] px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qa,{className:"w-4 h-4 text-white/80"}),e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Current Stage"})]})}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-lg font-bold text-slate-800",children:t.label}),e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:t.description})]}),s&&e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-100",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Update from your agent"}),e.jsx("p",{className:"text-sm text-slate-700 leading-relaxed",children:s})]}),r&&e.jsxs("div",{className:"bg-blue-50/60 rounded-xl p-4 border border-blue-100",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-600 uppercase tracking-wider mb-1.5",children:"What's Next"}),e.jsx("p",{className:"text-sm text-blue-800 leading-relaxed",children:r})]}),n&&e.jsx("div",{className:"rounded-xl overflow-hidden bg-slate-900 aspect-video shadow-md",children:e.jsx("iframe",{src:a(n)||n,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Next step video"})})]})]})}function Ol(t){const s=t.split(/[-/T]/);if(s.length>=3){const r=Number(s[0]);return r>99?new Date(r,Number(s[1])-1,Number(s[2])):new Date(Number(s[2]),Number(s[0])-1,Number(s[1]))}return new Date(`${t}T12:00:00`)}function EEt(t,s){const r=ms(s,"yyyyMMdd");return`https://calendar.google.com/calendar/render?${new URLSearchParams({action:"TEMPLATE",text:t,dates:`${r}/${r}`,details:"Added from your Client Portal"}).toString()}`}function PEt(t,s){const r=ms(s,"yyyyMMdd");return`data:text/calendar;charset=utf-8,${encodeURIComponent(`BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT DTSTART;VALUE=DATE:${r} DTEND;VALUE=DATE:${r} SUMMARY:${t} DESCRIPTION:Added from your Client Portal END:VEVENT END:VCALENDAR`)}`}function IEt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:MM,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:cn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:bn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:hn,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,c,u)=>{const p=Ol(c);if(u==="google")window.open(EEt(i,p),"_blank");else{const f=PEt(i,p),g=document.createElement("a");g.href=f,g.download=`${i.replace(/\s+/g,"-").toLowerCase()}.ics`,g.click()}};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Key Dates"}),e.jsx("div",{className:"space-y-3",children:o.map(({label:i,date:c,icon:u,color:p})=>{const f=Ol(c),g=w0(f)&&!bu(f),b=bu(f),_=!g&&!b;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${p}`,children:e.jsx(u,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-slate-500",children:i}),e.jsxs("p",{className:`text-sm font-medium ${b?"text-emerald-600":g?"text-slate-400":"text-slate-800"}`,children:[ms(f,"MMM d, yyyy"),b&&e.jsx("span",{className:"ml-1.5 text-xs bg-emerald-100 text-emerald-700 px-1.5 py-0.5 rounded-full",children:"Today"})]})]}),g&&e.jsx("span",{className:"text-xs text-slate-400",children:"✓"}),_&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>l(i,c,"google"),className:"text-xs text-slate-400 hover:text-blue-500 transition-colors px-1.5 py-1 rounded hover:bg-blue-50",title:"Add to Google Calendar",children:e.jsx(R_,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>l(i,c,"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 LEt({documents:t}){const s=n=>n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(0)} KB`:`${(n/1048576).toFixed(1)} MB`,r=async n=>{const{data:a}=await H.storage.from("deal-files").createSignedUrl(n.storage_path,300);a!=null&&a.signedUrl&&window.open(a.signedUrl,"_blank")};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Documents"}),e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("button",{onClick:()=>r(n),className:"w-full flex items-center gap-3 p-3 rounded-xl hover:bg-slate-50 transition-colors text-left group",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0 group-hover:bg-blue-50 transition-colors",children:e.jsx(Sn,{className:"w-4 h-4 text-slate-500 group-hover:text-blue-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700 truncate",children:n.file_name}),e.jsx("p",{className:"text-xs text-slate-400",children:s(n.file_size)})]}),e.jsx(yi,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function DEt({updates:t}){const s=r=>{var n,a;if(r.includes("youtube.com/watch")){const o=new URL(r).searchParams.get("v");return o?`https://www.youtube.com/embed/${o}`:null}if(r.includes("youtu.be/")){const o=(n=r.split("youtu.be/")[1])==null?void 0:n.split("?")[0];return o?`https://www.youtube.com/embed/${o}`:null}if(r.includes("loom.com/share/")){const o=(a=r.split("loom.com/share/")[1])==null?void 0:a.split("?")[0];return o?`https://www.loom.com/embed/${o}`:null}return r};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-4",children:"Updates from Your Agent"}),e.jsx("div",{className:"space-y-4",children:t.map((r,n)=>e.jsx("div",{className:`${n>0?"pt-4 border-t border-slate-100":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 ${r.is_stage_change?"bg-emerald-100":"bg-blue-100"}`,children:r.is_stage_change?e.jsx(bd,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(Lm,{className:"w-3.5 h-3.5 text-blue-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h3",{className:"text-sm font-medium text-slate-800",children:r.title}),e.jsx("span",{className:"text-xs text-slate-400 flex-shrink-0",children:ms(new Date(r.created_at),"MMM d")})]}),r.content&&e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:r.content}),r.video_url&&e.jsx("div",{className:"mt-3 rounded-xl overflow-hidden bg-slate-900 aspect-video",children:e.jsx("iframe",{src:s(r.video_url)||r.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:r.title})})]})]})},r.id))})]})}function OEt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var _,j;const[l,i]=k.useState({first_name:((_=t.client_name)==null?void 0:_.split(" ")[0])||"",last_name:((j=t.client_name)==null?void 0:j.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[c,u]=k.useState({}),[p,f]=k.useState(!1),g=Lt({mutationFn:async()=>{const{error:w}=await H.from("portal_onboarding_submissions").insert({portal_id:t.id,first_name:l.first_name,last_name:l.last_name||null,email:l.email||null,phone:l.phone||null,preferred_contact_method:l.preferred_contact_method,client_role:l.client_role,notes:l.notes||null,device_fingerprint:a,custom_answers:Object.keys(c).length>0?c:null,spouse_first_name:p&&l.spouse_first_name||null,spouse_last_name:p&&l.spouse_last_name||null,spouse_email:p&&l.spouse_email||null,spouse_phone:p&&l.spouse_phone||null});if(w)throw w},onSuccess:o,onError:w=>{console.error("[PortalOnboarding] Submit failed:",w),me.error("Something went wrong. Please try again.")}}),b=s!=null&&s.property_address?`${s.property_address}, ${s.city||""}, ${s.state||""}`:null;return e.jsxs("div",{className:"max-w-md mx-auto px-4 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[(r==null?void 0:r.avatar_url)&&e.jsx("img",{src:r.avatar_url,alt:r.name,className:"w-14 h-14 rounded-full border-2 border-slate-200 mx-auto mb-3 object-cover"}),e.jsx("h1",{className:"text-xl font-bold text-slate-800",children:"Welcome to Your Portal"}),b&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[e.jsx(ma,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:b.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),e.jsxs("form",{onSubmit:w=>{w.preventDefault(),g.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(ze,{required:!0,value:l.first_name,onChange:w=>i(N=>({...N,first_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(ze,{value:l.last_name,onChange:w=>i(N=>({...N,last_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(ze,{type:"email",value:l.email,onChange:w=>i(N=>({...N,email:w.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(ze,{type:"tel",value:l.phone,onChange:w=>i(N=>({...N,phone:w.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(w=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,preferred_contact_method:w.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===w.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.label},w.value))})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(w=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,client_role:w})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===w?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.charAt(0).toUpperCase()+w.slice(1)},w))})]}),n.map(w=>e.jsxs("div",{children:[e.jsxs(be,{className:"text-xs text-slate-600",children:[w.question_text," ",w.is_required&&"*"]}),w.field_type==="text"&&e.jsx(ze,{required:w.is_required,value:c[w.id]||"",onChange:N=>u(S=>({...S,[w.id]:N.target.value})),className:"mt-1 rounded-xl"}),w.field_type==="textarea"&&e.jsx("textarea",{required:w.is_required,value:c[w.id]||"",onChange:N=>u(S=>({...S,[w.id]:N.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),w.field_type==="dropdown"&&e.jsxs("select",{required:w.is_required,value:c[w.id]||"",onChange:N=>u(S=>({...S,[w.id]:N.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[e.jsx("option",{value:"",children:"Select..."}),(w.options||[]).map(N=>e.jsx("option",{value:N,children:N},N))]}),w.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(N=>e.jsx("button",{type:"button",onClick:()=>u(S=>({...S,[w.id]:N})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${c[w.id]===N?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:N},N))})]},w.id)),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:w=>i(N=>({...N,notes:w.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>f(!p),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:p?"− Remove spouse/partner":"+ Add spouse/partner"}),p&&e.jsxs("div",{className:"mt-3 p-4 bg-slate-50 rounded-xl space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(ze,{value:l.spouse_first_name,onChange:w=>i(N=>({...N,spouse_first_name:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(ze,{value:l.spouse_last_name,onChange:w=>i(N=>({...N,spouse_last_name:w.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(ze,{type:"email",value:l.spouse_email,onChange:w=>i(N=>({...N,spouse_email:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(ze,{type:"tel",value:l.spouse_phone,onChange:w=>i(N=>({...N,spouse_phone:w.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(K,{type:"submit",disabled:g.isPending||!l.first_name,className:"w-full h-12 rounded-full text-sm font-semibold bg-slate-900 hover:bg-slate-800",children:g.isPending?"Submitting...":"Access My Portal"})]})]})}function REt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function FEt(t){return t==="buy-side"?"We're actively searching for homes that match your criteria.":t==="listing"?"Your property is now being marketed to potential buyers.":"Your transaction is actively moving forward."}const zEt={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. 🎉"}},OZe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function sNe(t){return OZe.map(s=>{if(s==="Active")return{key:"Active",label:REt(t),description:FEt(t)};const r=zEt[s];return{key:s,label:r.label,description:r.description}})}function GPe(t){if(!t)return 0;const s=OZe.indexOf(t);return s>=0?s:0}function BEt(t,s){return mt({queryKey:["client-portal-public",t],queryFn:async()=>{if(!t)return null;const{data:r,error:n}=await H.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("slug",t).eq("is_enabled",!0).maybeSingle();if(n)throw n;return r},enabled:s})}function $Et(t){return mt({queryKey:["client-portal-by-id",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("id",t).eq("is_enabled",!0).maybeSingle();if(r)throw r;return s},enabled:!!t})}function RZe({slug:t}){var ee,X,ie,re,oe,ce;const[s,r]=k.useState(!1),[n,a]=k.useState("primary"),[o]=k.useState(()=>{const ge=`portal_fp_${t}`;let ye=localStorage.getItem(ge);return ye||(ye=localStorage.getItem("portal_fp"),ye?localStorage.setItem(ge,ye):(ye=crypto.randomUUID(),localStorage.setItem(ge,ye),localStorage.setItem("portal_fp",ye))),ye});k.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:c}=BEt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=$Et(u),f=(ee=l==null?void 0:l.deal_pipeline)==null?void 0:ee.owner_user_id,{data:g}=mt({queryKey:["portal-stages",f],queryFn:async()=>{const{data:ge,error:ye}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(ye)throw ye;return ge},enabled:!!f}),{data:b}=mt({queryKey:["portal-agent",f],queryFn:async()=>{const{data:ge,error:ye}=await H.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(ye)throw ye;return ge},enabled:!!f}),_=n==="linked"&&p?p:l,j=_==null?void 0:_.id,{data:w}=mt({queryKey:["portal-updates-public",j],queryFn:async()=>{const{data:ge,error:ye}=await H.from("portal_updates").select("*").eq("portal_id",j).order("created_at",{ascending:!1});if(ye)throw ye;return ge},enabled:!!j}),N=(X=_==null?void 0:_.deal_pipeline)==null?void 0:X.id,{data:S}=mt({queryKey:["portal-documents",N],queryFn:async()=>{const{data:ge,error:ye}=await H.from("deal_files").select("*").eq("deal_id",N).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(ye)throw ye;return ge},enabled:!!N}),M=l==null?void 0:l.id,{data:L,isLoading:I}=mt({queryKey:["portal-onboarding-check",M,o],queryFn:async()=>{const{data:ge,error:ye}=await H.from("portal_onboarding_submissions").select("id").eq("portal_id",M).eq("device_fingerprint",o).maybeSingle();if(ye)throw ye;return ge},enabled:!!M&&!!(l!=null&&l.require_onboarding)}),{data:O}=mt({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:ge,error:ye}=await H.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(ye)throw ye;return ge},enabled:!!f&&!!(l!=null&&l.require_onboarding)}),q=!!L||s||!(l!=null&&l.require_onboarding);if(i||l!=null&&l.require_onboarding&&I)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-lg mx-auto p-6 space-y-6",children:[e.jsx(ys,{className:"h-48 w-full rounded-2xl"}),e.jsx(ys,{className:"h-10 w-48 mx-auto"}),e.jsx(ys,{className:"h-32 w-full rounded-2xl"}),e.jsx(ys,{className:"h-24 w-full rounded-2xl"})]})});if(c||!l)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("span",{className:"text-2xl",children:"🔒"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Available"}),e.jsx("p",{className:"text-slate-500",children:"This portal is no longer active or doesn't exist."})]})});if(!q){const ge=l==null?void 0:l.deal_pipeline;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:e.jsx(OEt,{portal:l,dealData:ge,agentProfile:b,customQuestions:O||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const U=(ie=l==null?void 0:l.deal_pipeline)==null?void 0:ie.deal_type,B=(re=p==null?void 0:p.deal_pipeline)==null?void 0:re.deal_type,V=!!p,Y=ge=>ge==="listing"?"Your Sale":ge==="buy-side"?"Your Purchase":"Transaction",Q=ge=>ge==="listing"?e.jsx(bn,{className:"w-3.5 h-3.5"}):e.jsx(Sp,{className:"w-3.5 h-3.5"});return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white pb-12",children:[e.jsx(CEt,{dealData:_==null?void 0:_.deal_pipeline,agentProfile:b,welcomeMessage:_==null?void 0:_.welcome_message,isWon:(ce=(oe=_==null?void 0:_.deal_pipeline)==null?void 0:oe.deal_pipeline_stages)==null?void 0:ce.is_won_stage}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[V&&e.jsxs("div",{className:"flex gap-1 bg-slate-100 rounded-xl p-1",children:[e.jsxs("button",{onClick:()=>a("primary"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="primary"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[Q(U),Y(U)]}),e.jsxs("button",{onClick:()=>a("linked"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="linked"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[Q(B),Y(B)]})]}),e.jsx(qEt,{portal:_,updates:w,documents:S}),e.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[e.jsx(th,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),b&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:b.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]})}function qEt({portal:t,updates:s,documents:r}){const n=t,a=n==null?void 0:n.deal_pipeline,o=a==null?void 0:a.deal_pipeline_stages,l=o==null?void 0:o.is_won_stage,i=a==null?void 0:a.deal_type,c=t.stage_mapping;let u=sNe(i);c&&c.length>0&&(u=c.map((b,_)=>{var j,w;return{key:`custom-${_}`,label:b.label||((j=u[_])==null?void 0:j.label)||`Stage ${_+1}`,description:b.description||((w=u[_])==null?void 0:w.description)||"",video_url:b.video_url||void 0}}));const p=c&&c.length>0?Math.min(GPe(o==null?void 0:o.name),u.length-1):GPe(o==null?void 0:o.name),f=u[p],g=f==null?void 0:f.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(TEt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(MEt,{journeyStages:u,currentIndex:p}),f&&e.jsx(AEt,{currentStage:f,nextStepText:t.next_step_text,nextStepVideoUrl:g||t.next_step_video_url}),e.jsx(IEt,{targetCloseDate:a==null?void 0:a.target_close_date,contractDate:a==null?void 0:a.contract_date,inspectionDate:t.inspection_date,appraisalDate:t.appraisal_date,actualCloseDate:a==null?void 0:a.actual_close_date}),r&&r.length>0&&e.jsx(LEt,{documents:r}),s&&s.length>0&&e.jsx(DEt,{updates:s}),l&&t.show_post_close_tips&&e.jsxs("div",{className:"bg-gradient-to-br from-emerald-50 to-teal-50 rounded-2xl p-6 border border-emerald-100 text-center",children:[e.jsx("span",{className:"text-4xl mb-3 block",children:"🎉"}),e.jsx("h3",{className:"text-lg font-bold text-emerald-900 mb-2",children:"Congratulations!"}),e.jsx("p",{className:"text-sm text-emerald-700",children:"Your transaction has been completed. Welcome to your new home!"}),t.review_url&&e.jsx("a",{href:t.review_url,target:"_blank",rel:"noopener noreferrer",className:"mt-4 inline-block bg-emerald-600 text-white text-sm font-medium px-6 py-2.5 rounded-full hover:bg-emerald-700 transition-colors",children:"Leave a Review ⭐"})]})]})}function UEt(){const s=id().pathname.slice(1);return k.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>{document.body.classList.remove("client-portal-page")}),[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Client Portal"}),e.jsx("p",{className:"text-slate-500",children:"Visit your personalized portal link to view your transaction details."})]})}):e.jsx(RZe,{slug:s})}const m1e="levelup_affiliate_ref",VEt=30,HEt=()=>{const[t]=Cc();k.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(m1e,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},WEt=()=>{try{const t=localStorage.getItem(m1e);if(!t)return null;const s=JSON.parse(t),r=VEt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(m1e),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},qoe="/assets/levelup-logo-header-_ZX7DvlA.png",GEt="/assets/scale-your-team-ku4MPatU.png";function KEt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(_s,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-[#4a6b6d]/10 rounded-lg",children:e.jsx(ka,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(vs,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(Gr,{children:"Learn how LevelUp can empower your entire team"})]})]})}),t&&e.jsx("iframe",{src:"https://tidycal.com/jeremycollins/brokerinterestmeeting",className:"w-full border-0 rounded-lg",style:{height:"600px",minHeight:"500px"},title:"Schedule Brokerage Interest Meeting"})]})})}const qu={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"]}},ZEt=[{icon:pp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:ic,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:hn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:$c,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Sn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:ko,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],YEt=[{icon:pr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:pn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Un,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ch,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:ma,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:No,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:ni,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Zh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],XEt=[{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."}],QEt=()=>{const{user:t,loading:s}=Ds(),r=fr(),[n]=Cc();k.useEffect(()=>{const q=window.location.host==="listings.relevelup.com",U=window.location.pathname==="/";if(q&&U){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=k.useState(null),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(""),[w,N]=k.useState(!1),[S,M]=k.useState(!1),L=(q,U=!1)=>{i({tier:q,skipTrial:U}),u(!0)};HEt(),k.useEffect(()=>{const q=window.location.host==="listings.relevelup.com",U=location.pathname.startsWith("/public/");!s&&t&&!q&&!U&&r("/dashboard")},[t,s,r,location.pathname]),k.useEffect(()=>{n.get("canceled")==="true"&&me.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const I=async(q,U=!1)=>{if(!p){me.error("Please enter your email address");return}if(!g.trim()){me.error("Please enter your full name");return}N(!0),o(q+(U?"_direct":""));const B=WEt();try{const{data:V,error:Y}=await H.functions.invoke("create-checkout",{body:{tier:q,email:p,name:g.trim(),couponCode:_.trim()||void 0,skipTrial:U,referralCode:B}});if(Y)throw Y;if(V!=null&&V.url)window.open(V.url,"_blank","noopener,noreferrer"),me.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(V){console.error("Checkout error:",V),me.error(V.message||"Failed to start checkout. Please try again.")}finally{N(!1),o(null),u(!1),i(null)}},O=()=>{l&&I(l.tier,l.skipTrial)};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#4a6b6d]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-white border-t-transparent"})}):e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:qoe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var q;return(q=document.getElementById("features"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},children:"Pricing"}),e.jsx(K,{onClick:()=>r("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-8",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-[136px] md:h-[164px] drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("p",{className:"text-lg text-white/80 max-w-3xl mx-auto leading-relaxed font-sans font-bold md:text-4xl",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center items-center pt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("free-trial"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",children:["Start Your Free Trial",e.jsx(Qa,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{size:"lg",variant:"outline",onClick:()=>{var q;return(q=document.getElementById("features"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#1e3a4c] rounded-full",children:"See What's Included"})]})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Learn how we support agents and empower brokerages to grow—together."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center pt-4",children:[e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>{var q;return(q=document.getElementById("brokerage"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(ka,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(to,{className:"mr-2 h-5 w-5"}),"Individual Membership"]})]})]})})}),e.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:ZEt.map((q,U)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Pt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(q.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Rt,{className:"text-xl font-sans",children:q.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:q.description})})]},U))})]})}),e.jsxs("section",{id:"agent-os",className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(pn,{className:"w-4 h-4"}),"Included with Membership"]}),e.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",e.jsx("span",{className:"italic",children:"Agent OS"})]}),e.jsx("p",{className:"text-lg text-white/80",children:"Your relationship-first operating system. Never forget a follow-up, track every touchpoint, and turn your sphere into a referral machine."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:YEt.map((q,U)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx(q.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Rt,{className:"text-lg font-semibold text-white",children:q.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:q.description})})]},U))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"bg-white text-[#4a6b6d] hover:bg-white/90 shadow-xl transition-all hover:scale-105",children:["Get Agent OS with Your Membership",e.jsx(Qa,{className:"ml-2 w-5 h-5"})]})})]})]}),e.jsx("section",{id:"brokerage",className:"py-20 bg-[#4a6b6d]/5",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsx("div",{className:"max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[#4a6b6d]/10 text-[#4a6b6d] text-sm font-medium",children:[e.jsx(ka,{className:"w-4 h-4"}),"For Brokerages"]}),e.jsxs("h2",{className:"text-3xl font-sans font-bold md:text-6xl",children:["Empower Your"," ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Entire Team"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Give every agent on your team access to world-class training and resources. Track performance, streamline onboarding, and watch your brokerage thrive."}),e.jsx("ul",{className:"space-y-4",children:["Dedicated brokerage manager dashboard","Invite and manage agents with one click","Exclusive brokerage-only resources","Team analytics and performance tracking","Simplified agent onboarding","Share resources across your team"].map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center flex-shrink-0",children:e.jsx(va,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:q})]},U))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(da,{className:"ml-2 w-5 h-5"})]}),e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>M(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(hn,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:GEt,alt:"Scale Your Team from 5 to 500 Agents",className:"w-full rounded-3xl shadow-lg"})})]})})})}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Agents Love ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"LevelUp"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what top producers are saying about the platform."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 max-w-6xl mx-auto",children:XEt.map((q,U)=>e.jsx(Ee,{className:"bg-muted/30 border-0",children:e.jsxs(Oe,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(B=>e.jsx(Jn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},B))}),e.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',q.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:q.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.role})]})]})},U))})]})}),e.jsxs("section",{id:"free-trial",className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-8",children:[e.jsxs("h2",{className:"text-3xl md:text-5xl font-bold text-white",children:["Start Your Free Trial ",e.jsx("span",{className:"italic",children:"Today"})]}),e.jsx("p",{className:"text-lg md:text-xl text-white/80 leading-relaxed",children:"Get instant access to 7 days of trainings, templates, and tools — designed to give you quick wins now and resources you'll keep forever."}),e.jsx("div",{className:"pt-4",children:e.jsxs(K,{size:"lg",className:"px-12 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",onClick:()=>L("individual_agent"),children:["Start Free Trial",e.jsx(Qa,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]})})]}),e.jsx("section",{id:"pricing",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Simple, Transparent ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Pricing"})]}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Choose the plan that fits your needs. All plans include everything you need to succeed."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:[e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Pt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(to,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Rt,{className:"text-xl font-sans",children:qu.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:qu.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:qu.individual_agent.period})]}),e.jsx(gr,{className:"text-base mt-2",children:qu.individual_agent.description}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-green-500/10 text-green-600 text-sm font-medium mt-4",children:[e.jsx(un,{className:"w-4 h-4"}),qu.individual_agent.trial]})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:qu.individual_agent.features.map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(va,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},U))})}),e.jsxs(VL,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("individual_agent"),children:"Start Free Trial"}),e.jsx(K,{variant:"outline",className:"w-full rounded-full border-2 border-[#4a6b6d] text-[#4a6b6d] bg-white hover:bg-[#4a6b6d]/5 uppercase text-sm font-medium tracking-wide",onClick:()=>L("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Ee,{className:"relative flex flex-col border-2 border-[#4a6b6d] shadow-2xl scale-105 bg-background",children:[e.jsx("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 px-6 py-2 bg-[#4a6b6d] text-white text-sm font-semibold rounded-full shadow-lg",children:"Most Popular"}),e.jsxs(Pt,{className:"pb-4 pt-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(ka,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-xl font-sans",children:qu.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:qu.brokerage_under_25.subtitle})]})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:qu.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:qu.brokerage_under_25.period})]}),e.jsx(gr,{className:"text-base mt-2",children:qu.brokerage_under_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:qu.brokerage_under_25.features.map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(va,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},U))})}),e.jsx(VL,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Pt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(ka,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-xl font-sans",children:qu.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:qu.brokerage_over_25.subtitle})]})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:qu.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:qu.brokerage_over_25.period})]}),e.jsx(gr,{className:"text-base mt-2",children:qu.brokerage_over_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:qu.brokerage_over_25.features.map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(va,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},U))})}),e.jsx(VL,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("brokerage_over_25"),children:"Get Started"})})]})]})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl text-white font-sans md:text-5xl",children:"Ready to Level Up?"}),e.jsx("p",{className:"text-lg text-white/80 max-w-2xl mx-auto",children:"Join thousands of agents who are closing more deals, saving time, and growing their business with LevelUp."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"px-10 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105",children:["Start Your Free Trial",e.jsx(Qa,{className:"ml-2 w-5 h-5"})]}),e.jsx(K,{size:"lg",onClick:()=>r("/auth"),className:"px-10 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#4a6b6d]",children:"Sign In"})]})]})})]}),e.jsx("footer",{className:"py-12 bg-[#3d5a5c] text-white/80",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("img",{src:qoe,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("a",{href:"/privacy-policy",className:"text-white/60 hover:text-white transition-colors text-sm",children:"Privacy Policy"}),e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-white/60 hover:text-white transition-colors text-sm",children:"Contact Support"})]})]})})}),e.jsx(KEt,{open:S,onOpenChange:M}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),e.jsx(Gr,{children:(l==null?void 0:l.tier)==="individual_agent"&&!(l!=null&&l.skipTrial)?"Start your 7-day free trial":(l==null?void 0:l.tier)==="individual_agent"?"Subscribe to Individual Agent":(l==null?void 0:l.tier)==="brokerage_under_25"?"Subscribe to Brokerage (Under 25 Agents)":"Subscribe to Brokerage (Over 25 Agents)"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsxs(be,{htmlFor:"dialog-name",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ze,{id:"dialog-name",type:"text",placeholder:"John Smith",value:g,onChange:q=>b(q.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(be,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ze,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:p,onChange:q=>f(q.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(be,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(ze,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:_,onChange:q=>j(q.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:O,disabled:w,children:w?"Loading...":"Continue to Checkout"})]})})]})},JEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsx("title",{children:"Privacy Policy | LevelUp"}),e.jsx("meta",{name:"description",content:"Privacy Policy for LevelUp platform"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Privacy Policy"}),e.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"1. Introduction"}),e.jsx("p",{children:'Welcome to LevelUp ("we," "our," or "us"). We are committed to protecting your personal information and your right to privacy. This Privacy Policy explains how we collect, use, disclose, and safeguard your information when you use our platform.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"2. Information We Collect"}),e.jsx("p",{children:"We collect information that you provide directly to us, including:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Name and contact information (email address, phone number)"}),e.jsx("li",{children:"Account credentials"}),e.jsx("li",{children:"Profile information"}),e.jsx("li",{children:"Transaction and billing information"}),e.jsx("li",{children:"Communications you send to us"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"3. How We Use Your Information"}),e.jsx("p",{children:"We use the information we collect to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Provide, maintain, and improve our services"}),e.jsx("li",{children:"Process transactions and send related information"}),e.jsx("li",{children:"Send you technical notices and support messages"}),e.jsx("li",{children:"Respond to your comments and questions"}),e.jsx("li",{children:"Communicate with you about products, services, and events"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"4. Information Sharing"}),e.jsx("p",{children:"We do not sell, trade, or otherwise transfer your personal information to third parties without your consent, except as described in this policy or as required by law."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"5. Data Security"}),e.jsx("p",{children:"We implement appropriate technical and organizational measures to protect the security of your personal information. However, no method of transmission over the Internet is 100% secure."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"6. Your Rights"}),e.jsx("p",{children:"You have the right to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Access your personal information"}),e.jsx("li",{children:"Correct inaccurate data"}),e.jsx("li",{children:"Request deletion of your data"}),e.jsx("li",{children:"Opt-out of marketing communications"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"7. Third-Party Services"}),e.jsx("p",{children:"Our platform may integrate with third-party services such as Facebook and Instagram for social media posting features. When you connect these accounts, you are subject to their respective privacy policies."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. Contact Us"}),e.jsxs("p",{children:["If you have questions about this Privacy Policy, please contact us at"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),e6t=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsx("title",{children:"Terms of Service | LevelUp"}),e.jsx("meta",{name:"description",content:"Terms of Service for LevelUp platform"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Terms of Service"}),e.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"1. Acceptance of Terms"}),e.jsx("p",{children:'By accessing or using the LevelUp platform ("Service"), you agree to be bound by these Terms of Service. If you do not agree to these terms, please do not use our Service.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"2. Description of Service"}),e.jsx("p",{children:"LevelUp provides a platform for real estate professionals to access training, resources, marketing tools, and community features. We reserve the right to modify or discontinue the Service at any time."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"3. User Accounts"}),e.jsx("p",{children:"To use certain features, you must create an account. You agree to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Provide accurate and complete information"}),e.jsx("li",{children:"Maintain the security of your account credentials"}),e.jsx("li",{children:"Notify us immediately of any unauthorized access"}),e.jsx("li",{children:"Accept responsibility for all activities under your account"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"4. Acceptable Use"}),e.jsx("p",{children:"You agree not to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Violate any applicable laws or regulations"}),e.jsx("li",{children:"Infringe on the rights of others"}),e.jsx("li",{children:"Upload malicious code or interfere with the Service"}),e.jsx("li",{children:"Attempt to gain unauthorized access to any part of the Service"}),e.jsx("li",{children:"Use the Service for any unlawful purpose"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"5. Intellectual Property"}),e.jsx("p",{children:"The Service and its original content, features, and functionality are owned by LevelUp and are protected by international copyright, trademark, and other intellectual property laws."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"6. Third-Party Integrations"}),e.jsx("p",{children:"Our Service may integrate with third-party platforms such as Facebook and Instagram. Your use of these integrations is subject to the terms and policies of those third parties. We are not responsible for the content or practices of any third-party services."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"7. Payment Terms"}),e.jsx("p",{children:"Certain features may require payment. By subscribing to paid features, you agree to pay all applicable fees. All payments are non-refundable unless otherwise specified."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. Limitation of Liability"}),e.jsx("p",{children:"To the maximum extent permitted by law, LevelUp shall not be liable for any indirect, incidental, special, consequential, or punitive damages resulting from your use of the Service."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"9. Termination"}),e.jsx("p",{children:"We may terminate or suspend your account at any time, without prior notice, for conduct that we believe violates these Terms or is harmful to other users, us, or third parties."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"10. Changes to Terms"}),e.jsx("p",{children:"We reserve the right to modify these Terms at any time. We will notify you of significant changes by posting a notice on our platform. Continued use of the Service constitutes acceptance of the modified terms."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"11. Contact Us"}),e.jsxs("p",{children:["If you have questions about these Terms, please contact us at"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),t6t=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsx("title",{children:"Data Deletion | LevelUp"}),e.jsx("meta",{name:"description",content:"Data deletion instructions for LevelUp platform"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Data Deletion Instructions"}),e.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"How to Request Data Deletion"}),e.jsx("p",{children:"If you wish to have your data deleted from LevelUp, you can request deletion through one of the following methods:"})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Option 1: Email Request"}),e.jsxs("p",{children:["Send an email to"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})," ",'with the subject line "Data Deletion Request" and include:']}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Your full name"}),e.jsx("li",{children:"The email address associated with your account"}),e.jsx("li",{children:"A clear statement requesting deletion of your data"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Option 2: Account Settings"}),e.jsx("p",{children:"If you have an active account, you can request data deletion through your account settings:"}),e.jsxs("ol",{className:"list-decimal pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Log in to your LevelUp account"}),e.jsx("li",{children:"Navigate to your Profile settings"}),e.jsx("li",{children:"Contact support through the Support page to request account deletion"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"What Data Will Be Deleted"}),e.jsx("p",{children:"Upon a valid deletion request, we will delete:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Your account information (name, email, profile data)"}),e.jsx("li",{children:"Any content you have created or uploaded"}),e.jsx("li",{children:"Your activity history and preferences"}),e.jsx("li",{children:"Connected social media account tokens and data"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Data Retention"}),e.jsx("p",{children:"Some data may be retained for legal or legitimate business purposes, such as:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Transaction records required for financial reporting"}),e.jsx("li",{children:"Data necessary to comply with legal obligations"}),e.jsx("li",{children:"Anonymized or aggregated data that cannot identify you"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Facebook/Instagram Data"}),e.jsx("p",{children:"If you have connected your Facebook or Instagram account to LevelUp, you can also manage your data through Facebook's settings:"}),e.jsxs("ol",{className:"list-decimal pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Go to your Facebook Settings & Privacy → Settings"}),e.jsx("li",{children:'Click on "Apps and Websites"'}),e.jsx("li",{children:'Find LevelUp and click "Remove"'}),e.jsx("li",{children:"This will revoke our access to your Facebook/Instagram data"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Processing Time"}),e.jsx("p",{children:"We will process your data deletion request within 30 days of receiving it. You will receive a confirmation email once your data has been deleted."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Contact Us"}),e.jsxs("p",{children:["If you have questions about data deletion, please contact us at"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),s6t=yC({email:gc().email("Invalid email address"),password:gc().min(6,"Password must be at least 6 characters")}),r6t=()=>{const{signIn:t,user:s}=Ds(),r=fr(),[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,c]=k.useState(""),[u,p]=k.useState(!1),[f,g]=k.useState(!1);k.useEffect(()=>{if(s){const j=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),r(j)}},[s,r]);const b=async j=>{j.preventDefault(),l({}),a(!0);const w=new FormData(j.currentTarget),N=w.get("email"),S=w.get("password");try{s6t.parse({email:N,password:S}),await t(N,S)}catch(M){if(M instanceof T0){const L={};M.errors.forEach(I=>{I.path[0]&&(L[I.path[0]]=I.message)}),l(L)}}finally{a(!1)}},_=async()=>{if(!i){me.error("Please enter your email address");return}p(!0);try{const{error:j}=await H.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(j)throw j;me.success("Password reset email sent! Check your inbox."),g(!1),c("")}catch(j){me.error(j.message||"Failed to send reset email")}finally{p(!1)}};return e.jsxs("div",{className:"min-h-screen relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#4a6b6d] via-[#3d5a5c] to-[#2a4347]",children:e.jsxs("div",{className:"absolute inset-0 opacity-30",children:[e.jsx("div",{className:"absolute top-0 left-0 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-96 h-96 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"2s"}})]})}),e.jsxs("div",{className:"relative z-10 flex flex-col min-h-screen",children:[e.jsx("header",{className:"p-6",children:e.jsxs(Pi,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Home"]})}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("div",{className:"bg-white rounded-xl p-4 shadow-2xl",children:e.jsx("img",{src:pWe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Ee,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Pt,{className:"space-y-1 text-center pb-4",children:[e.jsx(Rt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(gr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),e.jsx(ze,{id:"signin-email",name:"email",type:"email",placeholder:"your@email.com",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.email&&e.jsx("p",{className:"text-sm text-red-600",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(ze,{id:"signin-password",name:"password",type:"password",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.password&&e.jsx("p",{className:"text-sm text-red-600",children:o.password})]}),e.jsx(K,{type:"submit",className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white font-semibold py-6 text-lg transition-all duration-200 shadow-lg hover:shadow-xl",disabled:n,children:n?"Signing in...":"Sign In"}),e.jsxs(fs,{open:f,onOpenChange:g,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(ps,{className:"bg-white",children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),e.jsx(Gr,{className:"text-gray-600",children:"Enter your email address and we'll send you a link to reset your password."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(ze,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:j=>c(j.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(K,{onClick:_,className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white",disabled:u,children:u?"Sending...":"Send Reset Link"})]})]})]})]})})]}),e.jsxs("p",{className:"text-center text-white/70 text-sm mt-6",children:["Don't have an account?"," ",e.jsx(Pi,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},n6t=()=>{const[t]=Cc(),s=t.get("tier"),r=s==null?void 0:s.includes("brokerage");return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4",children:e.jsx(xi,{className:"w-10 h-10 text-green-500"})}),e.jsx(Rt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(gr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-primary/10 border border-primary/20 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(cr,{className:"w-5 h-5"}),e.jsx("span",{className:"font-semibold",children:"Check your email to sign in"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We've sent you an email with a secure link to access your account. Click the link in your email to get started."})]}),r?e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold",children:"What's next?"}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"1."}),"Click the link in your email to sign in"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"2."}),"Create and name your brokerage"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"3."}),"Set your password and complete your profile"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"4."}),"Start inviting agents to join your team"]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold",children:"What's next?"}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"1."}),"Click the link in your email to sign in"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"2."}),"Set your password and complete your profile"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"3."}),"Start exploring templates, training videos, and more!"]})]}),e.jsx("p",{className:"text-sm text-green-600 font-medium mt-4",children:"🎉 Your 7-day free trial has started!"})]}),e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Didn't receive the email? Check your spam folder or contact support."})})]})]})})},FZe=t=>{const[s,r]=k.useState(null),[n,a]=k.useState(!0);return k.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await H.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:c}=H.storage.from("avatars").getPublicUrl(`${t}/${i[0].name}`);r(`${c.publicUrl}?t=${Date.now()}`)}else r(null)}catch(i){console.error("Error fetching avatar:",i),r(null)}finally{a(!1)}})()},[t]),{avatarUrl:s,loading:n,refreshAvatar:async()=>{if(t)try{const{data:l}=await H.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=H.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},zZe=async t=>{const s=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await H.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:a}=H.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);s.set(r,a.publicUrl)}}catch{}})),s},a6t=t=>{const[s,r]=k.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return k.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await H.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",t).single();if(o){console.error("Error fetching trial status:",o),r(c=>({...c,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 c=new Date().getTime(),u=new Date(a.subscription_end_date).getTime(),p=Math.ceil((u-c)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.subscription_end_date,daysLeft:f?0:p,loading:!1})}else if(i){const c=new Date().getTime(),u=new Date(a.trial_expires_at).getTime(),p=Math.ceil((u-c)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.trial_expires_at,daysLeft:f?0:p,loading:!1})}else r({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!1})}catch(a){console.error("Error in useTrialStatus:",a),r(o=>({...o,loading:!1}))}})()},[t]),s},BZe=()=>{const{data:t,isLoading:s}=mt({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await H.from("feature_flags").select("*");if(a)throw a;return n}}),r=n=>{if(!t)return!1;const a=t.find(o=>o.key===n);return(a==null?void 0:a.enabled)??!1};return{flags:t,isLoading:s,isFeatureEnabled:r,isAgentOSEnabled:r("agent_os_enabled"),isInnerCircleEnabled:r("innercircle_enabled"),isMarketplaceEnabled:r("marketplace")}},KPe="community_last_seen_post_at";function i6t(){const{user:t}=Ds(),s=id(),[r,n]=k.useState(0),[a,o]=k.useState(null);k.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${KPe}_${t.id}`);o(i)},[t]),k.useEffect(()=>{if(!t)return;(async()=>{let c=H.from("community_posts").select("id",{count:"exact",head:!0});a&&(c=c.gt("created_at",a));const{data:u}=await H.from("profiles").select("brokerage_id").eq("id",t.id).single(),{count:p,error:f}=await c;!f&&p!==null&&n(p)})()},[t,a]),k.useEffect(()=>{if(!t)return;const i=H.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async c=>{const u=c.new;if(u.user_id===t.id)return;const p=s.pathname==="/community";p||n(j=>j+1);const{data:f}=await H.from("profiles").select("name").eq("id",u.user_id).single(),g=(f==null?void 0:f.name)||"Someone",b=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),_=b.length>50?b.substring(0,50)+"...":b;p||me("New Community Post",{description:`${g}: ${_}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{H.removeChannel(i)}},[t,s.pathname]);const l=k.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${KPe}_${t.id}`,i),o(i),n(0)},[t]);return k.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function o6t(){const{isAdmin:t}=Ds(),{data:s=0}=mt({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await H.from("wishlist_items").select("*",{count:"exact",head:!0}).eq("status","open");if(n)throw n;return r||0},enabled:t,staleTime:6e4});return{openCount:t?s:0}}const eE=Ude,rNe=lje,l6t=Vde,$Ze=k.forwardRef(({className:t,...s},r)=>e.jsx(KA,{className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));$Ze.displayName=KA.displayName;const c6t=pC("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"}}),vC=k.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(l6t,{children:[e.jsx($Ze,{}),e.jsxs(ZA,{ref:a,className:It(c6t({side:t}),s),...n,children:[r,e.jsxs(IO,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Rr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vC.displayName=ZA.displayName;const tE=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-2 text-center sm:text-left",t),...s});tE.displayName="SheetHeader";const sE=k.forwardRef(({className:t,...s},r)=>e.jsx(EO,{ref:r,className:It("text-lg font-semibold text-foreground",t),...s}));sE.displayName=EO.displayName;const qZe=k.forwardRef(({className:t,...s},r)=>e.jsx(PO,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));qZe.displayName=PO.displayName;var uue="Collapsible",[d6t]=ad(uue),[u6t,nNe]=d6t(uue),UZe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[c,u]=ah({prop:n,defaultProp:a??!1,onChange:l,caller:uue});return e.jsx(u6t,{scope:r,disabled:o,contentId:Tu(),open:c,onOpenToggle:k.useCallback(()=>u(p=>!p),[u]),children:e.jsx(nn.div,{"data-state":iNe(c),"data-disabled":o?"":void 0,...i,ref:s})})});UZe.displayName=uue;var VZe="CollapsibleTrigger",HZe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=nNe(VZe,r);return e.jsx(nn.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":iNe(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Ir(t.onClick,a.onOpenToggle)})});HZe.displayName=VZe;var aNe="CollapsibleContent",WZe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=nNe(aNe,t.__scopeCollapsible);return e.jsx(zd,{present:r||a.open,children:({present:o})=>e.jsx(h6t,{...n,ref:s,present:o})})});WZe.displayName=aNe;var h6t=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=nNe(aNe,r),[i,c]=k.useState(n),u=k.useRef(null),p=qa(s,u),f=k.useRef(0),g=f.current,b=k.useRef(0),_=b.current,j=l.open||i,w=k.useRef(j),N=k.useRef(void 0);return k.useEffect(()=>{const S=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(S)},[]),jd(()=>{const S=u.current;if(S){N.current=N.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const M=S.getBoundingClientRect();f.current=M.height,b.current=M.width,w.current||(S.style.transitionDuration=N.current.transitionDuration,S.style.animationName=N.current.animationName),c(n)}},[l.open,n]),e.jsx(nn.div,{"data-state":iNe(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!j,...o,ref:p,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":_?`${_}px`:void 0,...t.style},children:j&&a})});function iNe(t){return t?"open":"closed"}var m6t=UZe;const yf=m6t,vf=HZe,bf=WZe,p6t="/assets/levelup-logo-Eif24dqY.png",f6t="/assets/levelup-logo-icon-C-7iromj.png",x6t="/assets/levelup-logo-mobile-B9skSjUG.png";var BO=t=>t.type==="checkbox",w4=t=>t instanceof Date,wm=t=>t==null;const GZe=t=>typeof t=="object";var Fd=t=>!wm(t)&&!Array.isArray(t)&&GZe(t)&&!w4(t),KZe=t=>Fd(t)&&t.target?BO(t.target)?t.target.checked:t.target.value:t,g6t=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,ZZe=(t,s)=>t.has(g6t(s)),y6t=t=>{const s=t.constructor&&t.constructor.prototype;return Fd(s)&&s.hasOwnProperty("isPrototypeOf")},oNe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function pu(t){let s;const r=Array.isArray(t),n=typeof FileList<"u"?t instanceof FileList:!1;if(t instanceof Date)s=new Date(t);else if(!(oNe&&(t instanceof Blob||n))&&(r||Fd(t)))if(s=r?[]:{},!r&&!y6t(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=pu(t[a]));else return t;return s}var hue=t=>/^\w*$/.test(t),Ed=t=>t===void 0,lNe=t=>Array.isArray(t)?t.filter(Boolean):[],cNe=t=>lNe(t.replace(/["|']|\]/g,"").split(/\.|\[/)),Tn=(t,s,r)=>{if(!s||!Fd(t))return r;const n=(hue(s)?[s]:cNe(s)).reduce((a,o)=>wm(a)?a:a[o],t);return Ed(n)||n===t?Ed(t[s])?r:t[s]:n},rf=t=>typeof t=="boolean",pl=(t,s,r)=>{let n=-1;const a=hue(s)?[s]:cNe(s),o=a.length,l=o-1;for(;++nht.useContext(dNe),v6t=t=>{const{children:s,...r}=t;return ht.createElement(dNe.Provider,{value:r},s)};var YZe=(t,s,r,n=!0)=>{const a={defaultValues:s._defaultValues};for(const o in t)Object.defineProperty(a,o,{get:()=>{const l=o;return s._proxyFormState[l]!==qg.all&&(s._proxyFormState[l]=!n||qg.all),r&&(r[l]=!0),t[l]}});return a};const uNe=typeof window<"u"?ht.useLayoutEffect:ht.useEffect;function b6t(t){const s=mue(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=ht.useState(r._formState),c=ht.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return uNe(()=>r._subscribe({name:a,formState:c.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),ht.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),ht.useMemo(()=>YZe(l,r,c.current,!1),[l,r])}var o0=t=>typeof t=="string",XZe=(t,s,r,n,a)=>o0(t)?(n&&s.watch.add(t),Tn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),Tn(r,o))):(n&&(s.watchAll=!0),r),p1e=t=>wm(t)||!GZe(t);function Hv(t,s,r=new WeakSet){if(p1e(t)||p1e(s))return t===s;if(w4(t)&&w4(s))return t.getTime()===s.getTime();const n=Object.keys(t),a=Object.keys(s);if(n.length!==a.length)return!1;if(r.has(t)||r.has(s))return!0;r.add(t),r.add(s);for(const o of n){const l=t[o];if(!a.includes(o))return!1;if(o!=="ref"){const i=s[o];if(w4(l)&&w4(i)||Fd(l)&&Fd(i)||Array.isArray(l)&&Array.isArray(i)?!Hv(l,i,r):l!==i)return!1}}return!0}function _6t(t){const s=mue(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},c=ht.useRef(a),u=ht.useRef(i),p=ht.useRef(void 0);u.current=i;const f=ht.useMemo(()=>r._getWatch(n,c.current),[r,n]),[g,b]=ht.useState(u.current?u.current(f):f);return uNe(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:_=>{if(!o){const j=XZe(n,r._names,_.values||r._formValues,!1,c.current);if(u.current){const w=u.current(j);Hv(w,p.current)||(b(w),p.current=w)}else b(j)}}}),[r,o,n,l]),ht.useEffect(()=>r._removeUnmounted()),g}function w6t(t){const s=mue(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=ZZe(a._names.array,r),c=ht.useMemo(()=>Tn(a._formValues,r,Tn(a._defaultValues,r,l)),[a,r,l]),u=_6t({control:a,name:r,defaultValue:c,exact:!0}),p=b6t({control:a,name:r,exact:!0}),f=ht.useRef(t),g=ht.useRef(a.register(r,{...t.rules,value:u,...rf(t.disabled)?{disabled:t.disabled}:{}}));f.current=t;const b=ht.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Tn(p.errors,r)},isDirty:{enumerable:!0,get:()=>!!Tn(p.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!Tn(p.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!Tn(p.validatingFields,r)},error:{enumerable:!0,get:()=>Tn(p.errors,r)}}),[p,r]),_=ht.useCallback(S=>g.current.onChange({target:{value:KZe(S),name:r},type:Uoe.CHANGE}),[r]),j=ht.useCallback(()=>g.current.onBlur({target:{value:Tn(a._formValues,r),name:r},type:Uoe.BLUR}),[r,a._formValues]),w=ht.useCallback(S=>{const M=Tn(a._fields,r);M&&S&&(M._f.ref={focus:()=>S.focus&&S.focus(),select:()=>S.select&&S.select(),setCustomValidity:L=>S.setCustomValidity(L),reportValidity:()=>S.reportValidity()})},[a._fields,r]),N=ht.useMemo(()=>({name:r,value:u,...rf(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:_,onBlur:j,ref:w}),[r,n,p.disabled,_,j,w,u]);return ht.useEffect(()=>{const S=a._options.shouldUnregister||o;a.register(r,{...f.current.rules,...rf(f.current.disabled)?{disabled:f.current.disabled}:{}});const M=(L,I)=>{const O=Tn(a._fields,L);O&&O._f&&(O._f.mount=I)};if(M(r,!0),S){const L=pu(Tn(a._options.defaultValues,r));pl(a._defaultValues,r,L),Ed(Tn(a._formValues,r))&&pl(a._formValues,r,L)}return!i&&a.register(r),()=>{(i?S&&!a._state.action:S)?a.unregister(r):M(r,!1)}},[r,a,i,o]),ht.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ht.useMemo(()=>({field:N,formState:p,fieldState:b}),[N,p,b])}const j6t=t=>t.render(w6t(t));var QZe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},QL=t=>Array.isArray(t)?t:[t],ZPe=()=>{let t=[];return{get observers(){return t},next:a=>{for(const o of t)o.next&&o.next(a)},subscribe:a=>(t.push(a),{unsubscribe:()=>{t=t.filter(o=>o!==a)}}),unsubscribe:()=>{t=[]}}},dp=t=>Fd(t)&&!Object.keys(t).length,hNe=t=>t.type==="file",Ug=t=>typeof t=="function",Voe=t=>{if(!oNe)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},JZe=t=>t.type==="select-multiple",mNe=t=>t.type==="radio",N6t=t=>mNe(t)||BO(t),Wxe=t=>Voe(t)&&t.isConnected;function k6t(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(Ug(t[s]))return!0;return!1};function Hoe(t,s={}){const r=Array.isArray(t);if(Fd(t)||r)for(const n in t)Array.isArray(t[n])||Fd(t[n])&&!eYe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},Hoe(t[n],s[n])):wm(t[n])||(s[n]=!0);return s}function tYe(t,s,r){const n=Array.isArray(t);if(Fd(t)||n)for(const a in t)Array.isArray(t[a])||Fd(t[a])&&!eYe(t[a])?Ed(s)||p1e(r[a])?r[a]=Array.isArray(t[a])?Hoe(t[a],[]):{...Hoe(t[a])}:tYe(t[a],wm(s)?{}:s[a],r[a]):r[a]=!Hv(t[a],s[a]);return r}var WP=(t,s)=>tYe(t,s,Hoe(s));const YPe={value:!1,isValid:!1},XPe={value:!0,isValid:!0};var sYe=t=>{if(Array.isArray(t)){if(t.length>1){const s=t.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:s,isValid:!!s.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!Ed(t[0].attributes.value)?Ed(t[0].value)||t[0].value===""?XPe:{value:t[0].value,isValid:!0}:XPe:YPe}return YPe},rYe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>Ed(t)?t:s?t===""?NaN:t&&+t:r&&o0(t)?new Date(t):n?n(t):t;const QPe={isValid:!1,value:null};var nYe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,QPe):QPe;function JPe(t){const s=t.ref;return hNe(s)?s.files:mNe(s)?nYe(t.refs).value:JZe(s)?[...s.selectedOptions].map(({value:r})=>r):BO(s)?sYe(t.refs).value:rYe(Ed(s.value)?t.ref.value:s.value,t)}var C6t=(t,s,r,n)=>{const a={};for(const o of t){const l=Tn(s,o);l&&pl(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},Woe=t=>t instanceof RegExp,GP=t=>Ed(t)?t:Woe(t)?t.source:Fd(t)?Woe(t.value)?t.value.source:t.value:t,eIe=t=>({isOnSubmit:!t||t===qg.onSubmit,isOnBlur:t===qg.onBlur,isOnChange:t===qg.onChange,isOnAll:t===qg.all,isOnTouch:t===qg.onTouched});const tIe="AsyncFunction";var M6t=t=>!!t&&!!t.validate&&!!(Ug(t.validate)&&t.validate.constructor.name===tIe||Fd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===tIe)),T6t=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),sIe=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const JL=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=Tn(t,a);if(o){const{_f:l,...i}=o;if(l){if(l.refs&&l.refs[0]&&s(l.refs[0],a)&&!n)return!0;if(l.ref&&s(l.ref,l.name)&&!n)return!0;if(JL(i,s))break}else if(Fd(i)&&JL(i,s))break}}};function rIe(t,s,r){const n=Tn(t,r);if(n||hue(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=Tn(s,o),i=Tn(t,o);if(l&&!Array.isArray(l)&&r!==o)return{name:r};if(i&&i.type)return{name:o,error:i};if(i&&i.root&&i.root.type)return{name:`${o}.root`,error:i.root};a.pop()}return{name:r}}var A6t=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return dp(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||qg.all))},E6t=(t,s,r)=>!t||!s||t===s||QL(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),P6t=(t,s,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(s||t):(r?n.isOnBlur:a.isOnBlur)?!t:(r?n.isOnChange:a.isOnChange)?t:!0,I6t=(t,s)=>!lNe(Tn(t,s)).length&&Gd(t,s),L6t=(t,s,r)=>{const n=QL(Tn(t,r));return pl(n,"root",s[r]),pl(t,r,n),t},wie=t=>o0(t);function nIe(t,s,r="validate"){if(wie(t)||Array.isArray(t)&&t.every(wie)||rf(t)&&!t)return{type:r,message:wie(t)?t:"",ref:s}}var w5=t=>Fd(t)&&!Woe(t)?t:{value:t,message:""},aIe=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:c,maxLength:u,minLength:p,min:f,max:g,pattern:b,validate:_,name:j,valueAsNumber:w,mount:N}=t._f,S=Tn(r,j);if(!N||s.has(j))return{};const M=i?i[0]:l,L=Q=>{a&&M.reportValidity&&(M.setCustomValidity(rf(Q)?"":Q||""),M.reportValidity())},I={},O=mNe(l),q=BO(l),U=O||q,B=(w||hNe(l))&&Ed(l.value)&&Ed(S)||Voe(l)&&l.value===""||S===""||Array.isArray(S)&&!S.length,V=QZe.bind(null,j,n,I),Y=(Q,ee,X,ie=wv.maxLength,re=wv.minLength)=>{const oe=Q?ee:X;I[j]={type:Q?ie:re,message:oe,ref:l,...V(Q?ie:re,oe)}};if(o?!Array.isArray(S)||!S.length:c&&(!U&&(B||wm(S))||rf(S)&&!S||q&&!sYe(i).isValid||O&&!nYe(i).isValid)){const{value:Q,message:ee}=wie(c)?{value:!!c,message:c}:w5(c);if(Q&&(I[j]={type:wv.required,message:ee,ref:M,...V(wv.required,ee)},!n))return L(ee),I}if(!B&&(!wm(f)||!wm(g))){let Q,ee;const X=w5(g),ie=w5(f);if(!wm(S)&&!isNaN(S)){const re=l.valueAsNumber||S&&+S;wm(X.value)||(Q=re>X.value),wm(ie.value)||(ee=renew Date(new Date().toDateString()+" "+ye),ce=l.type=="time",ge=l.type=="week";o0(X.value)&&S&&(Q=ce?oe(S)>oe(X.value):ge?S>X.value:re>new Date(X.value)),o0(ie.value)&&S&&(ee=ce?oe(S)+Q.value,ie=!wm(ee.value)&&S.length<+ee.value;if((X||ie)&&(Y(X,Q.message,ee.message),!n))return L(I[j].message),I}if(b&&!B&&o0(S)){const{value:Q,message:ee}=w5(b);if(Woe(Q)&&!S.match(Q)&&(I[j]={type:wv.pattern,message:ee,ref:l,...V(wv.pattern,ee)},!n))return L(ee),I}if(_){if(Ug(_)){const Q=await _(S,r),ee=nIe(Q,M);if(ee&&(I[j]={...ee,...V(wv.validate,ee.message)},!n))return L(ee.message),I}else if(Fd(_)){let Q={};for(const ee in _){if(!dp(Q)&&!n)break;const X=nIe(await _[ee](S,r),M,ee);X&&(Q={...X,...V(ee,X.message)},L(X.message),n&&(I[j]=Q))}if(!dp(Q)&&(I[j]={ref:M,...Q},!n))return I}}return L(!0),I};const D6t={mode:qg.onSubmit,reValidateMode:qg.onChange,shouldFocusError:!0};function O6t(t={}){let s={...D6t,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ug(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=Fd(s.defaultValues)||Fd(s.values)?pu(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:pu(a),l={action:!1,mount:!1,watch:!1},i={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,u=0;const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...p};const g={array:ZPe(),state:ZPe()},b=s.criteriaMode===qg.all,_=He=>ct=>{clearTimeout(u),u=setTimeout(He,ct)},j=async He=>{if(!s.disabled&&(p.isValid||f.isValid||He)){const ct=s.resolver?dp((await q()).errors):await B(n,!0);ct!==r.isValid&&g.state.next({isValid:ct})}},w=(He,ct)=>{!s.disabled&&(p.isValidating||p.validatingFields||f.isValidating||f.validatingFields)&&((He||Array.from(i.mount)).forEach(Ue=>{Ue&&(ct?pl(r.validatingFields,Ue,ct):Gd(r.validatingFields,Ue))}),g.state.next({validatingFields:r.validatingFields,isValidating:!dp(r.validatingFields)}))},N=(He,ct=[],Ue,Ze,Qe=!0,We=!0)=>{if(Ze&&Ue&&!s.disabled){if(l.action=!0,We&&Array.isArray(Tn(n,He))){const Je=Ue(Tn(n,He),Ze.argA,Ze.argB);Qe&&pl(n,He,Je)}if(We&&Array.isArray(Tn(r.errors,He))){const Je=Ue(Tn(r.errors,He),Ze.argA,Ze.argB);Qe&&pl(r.errors,He,Je),I6t(r.errors,He)}if((p.touchedFields||f.touchedFields)&&We&&Array.isArray(Tn(r.touchedFields,He))){const Je=Ue(Tn(r.touchedFields,He),Ze.argA,Ze.argB);Qe&&pl(r.touchedFields,He,Je)}(p.dirtyFields||f.dirtyFields)&&(r.dirtyFields=WP(a,o)),g.state.next({name:He,isDirty:Y(He,ct),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else pl(o,He,ct)},S=(He,ct)=>{pl(r.errors,He,ct),g.state.next({errors:r.errors})},M=He=>{r.errors=He,g.state.next({errors:r.errors,isValid:!1})},L=(He,ct,Ue,Ze)=>{const Qe=Tn(n,He);if(Qe){const We=Tn(o,He,Ed(Ue)?Tn(a,He):Ue);Ed(We)||Ze&&Ze.defaultChecked||ct?pl(o,He,ct?We:JPe(Qe._f)):X(He,We),l.mount&&j()}},I=(He,ct,Ue,Ze,Qe)=>{let We=!1,Je=!1;const it={name:He};if(!s.disabled){if(!Ue||Ze){(p.isDirty||f.isDirty)&&(Je=r.isDirty,r.isDirty=it.isDirty=Y(),We=Je!==it.isDirty);const Dt=Hv(Tn(a,He),ct);Je=!!Tn(r.dirtyFields,He),Dt?Gd(r.dirtyFields,He):pl(r.dirtyFields,He,!0),it.dirtyFields=r.dirtyFields,We=We||(p.dirtyFields||f.dirtyFields)&&Je!==!Dt}if(Ue){const Dt=Tn(r.touchedFields,He);Dt||(pl(r.touchedFields,He,Ue),it.touchedFields=r.touchedFields,We=We||(p.touchedFields||f.touchedFields)&&Dt!==Ue)}We&&Qe&&g.state.next(it)}return We?it:{}},O=(He,ct,Ue,Ze)=>{const Qe=Tn(r.errors,He),We=(p.isValid||f.isValid)&&rf(ct)&&r.isValid!==ct;if(s.delayError&&Ue?(c=_(()=>S(He,Ue)),c(s.delayError)):(clearTimeout(u),c=null,Ue?pl(r.errors,He,Ue):Gd(r.errors,He)),(Ue?!Hv(Qe,Ue):Qe)||!dp(Ze)||We){const Je={...Ze,...We&&rf(ct)?{isValid:ct}:{},errors:r.errors,name:He};r={...r,...Je},g.state.next(Je)}},q=async He=>{w(He,!0);const ct=await s.resolver(o,s.context,C6t(He||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return w(He),ct},U=async He=>{const{errors:ct}=await q(He);if(He)for(const Ue of He){const Ze=Tn(ct,Ue);Ze?pl(r.errors,Ue,Ze):Gd(r.errors,Ue)}else r.errors=ct;return ct},B=async(He,ct,Ue={valid:!0})=>{for(const Ze in He){const Qe=He[Ze];if(Qe){const{_f:We,...Je}=Qe;if(We){const it=i.array.has(We.name),Dt=Qe._f&&M6t(Qe._f);Dt&&p.validatingFields&&w([Ze],!0);const Vt=await aIe(Qe,i.disabled,o,b,s.shouldUseNativeValidation&&!ct,it);if(Dt&&p.validatingFields&&w([Ze]),Vt[We.name]&&(Ue.valid=!1,ct))break;!ct&&(Tn(Vt,We.name)?it?L6t(r.errors,Vt,We.name):pl(r.errors,We.name,Vt[We.name]):Gd(r.errors,We.name))}!dp(Je)&&await B(Je,ct,Ue)}}return Ue.valid},V=()=>{for(const He of i.unMount){const ct=Tn(n,He);ct&&(ct._f.refs?ct._f.refs.every(Ue=>!Wxe(Ue)):!Wxe(ct._f.ref))&&Ce(He)}i.unMount=new Set},Y=(He,ct)=>!s.disabled&&(He&&ct&&pl(o,He,ct),!Hv(ye(),a)),Q=(He,ct,Ue)=>XZe(He,i,{...l.mount?o:Ed(ct)?a:o0(He)?{[He]:ct}:ct},Ue,ct),ee=He=>lNe(Tn(l.mount?o:a,He,s.shouldUnregister?Tn(a,He,[]):[])),X=(He,ct,Ue={})=>{const Ze=Tn(n,He);let Qe=ct;if(Ze){const We=Ze._f;We&&(!We.disabled&&pl(o,He,rYe(ct,We)),Qe=Voe(We.ref)&&wm(ct)?"":ct,JZe(We.ref)?[...We.ref.options].forEach(Je=>Je.selected=Qe.includes(Je.value)):We.refs?BO(We.ref)?We.refs.forEach(Je=>{(!Je.defaultChecked||!Je.disabled)&&(Array.isArray(Qe)?Je.checked=!!Qe.find(it=>it===Je.value):Je.checked=Qe===Je.value||!!Qe)}):We.refs.forEach(Je=>Je.checked=Je.value===Qe):hNe(We.ref)?We.ref.value="":(We.ref.value=Qe,We.ref.type||g.state.next({name:He,values:pu(o)})))}(Ue.shouldDirty||Ue.shouldTouch)&&I(He,Qe,Ue.shouldTouch,Ue.shouldDirty,!0),Ue.shouldValidate&&ge(He)},ie=(He,ct,Ue)=>{for(const Ze in ct){if(!ct.hasOwnProperty(Ze))return;const Qe=ct[Ze],We=He+"."+Ze,Je=Tn(n,We);(i.array.has(He)||Fd(Qe)||Je&&!Je._f)&&!w4(Qe)?ie(We,Qe,Ue):X(We,Qe,Ue)}},re=(He,ct,Ue={})=>{const Ze=Tn(n,He),Qe=i.array.has(He),We=pu(ct);pl(o,He,We),Qe?(g.array.next({name:He,values:pu(o)}),(p.isDirty||p.dirtyFields||f.isDirty||f.dirtyFields)&&Ue.shouldDirty&&g.state.next({name:He,dirtyFields:WP(a,o),isDirty:Y(He,We)})):Ze&&!Ze._f&&!wm(We)?ie(He,We,Ue):X(He,We,Ue),sIe(He,i)&&g.state.next({...r,name:He}),g.state.next({name:l.mount?He:void 0,values:pu(o)})},oe=async He=>{l.mount=!0;const ct=He.target;let Ue=ct.name,Ze=!0;const Qe=Tn(n,Ue),We=Dt=>{Ze=Number.isNaN(Dt)||w4(Dt)&&isNaN(Dt.getTime())||Hv(Dt,Tn(o,Ue,Dt))},Je=eIe(s.mode),it=eIe(s.reValidateMode);if(Qe){let Dt,Vt;const hs=ct.type?JPe(Qe._f):KZe(He),Ts=He.type===Uoe.BLUR||He.type===Uoe.FOCUS_OUT,Cs=!T6t(Qe._f)&&!s.resolver&&!Tn(r.errors,Ue)&&!Qe._f.deps||P6t(Ts,Tn(r.touchedFields,Ue),r.isSubmitted,it,Je),cs=sIe(Ue,i,Ts);pl(o,Ue,hs),Ts?(Qe._f.onBlur&&Qe._f.onBlur(He),c&&c(0)):Qe._f.onChange&&Qe._f.onChange(He);const er=I(Ue,hs,Ts),xt=!dp(er)||cs;if(!Ts&&g.state.next({name:Ue,type:He.type,values:pu(o)}),Cs)return(p.isValid||f.isValid)&&(s.mode==="onBlur"?Ts&&j():Ts||j()),xt&&g.state.next({name:Ue,...cs?{}:er});if(!Ts&&cs&&g.state.next({...r}),s.resolver){const{errors:Es}=await q([Ue]);if(We(hs),Ze){const ur=rIe(r.errors,n,Ue),Mr=rIe(Es,n,ur.name||Ue);Dt=Mr.error,Ue=Mr.name,Vt=dp(Es)}}else w([Ue],!0),Dt=(await aIe(Qe,i.disabled,o,b,s.shouldUseNativeValidation))[Ue],w([Ue]),We(hs),Ze&&(Dt?Vt=!1:(p.isValid||f.isValid)&&(Vt=await B(n,!0)));Ze&&(Qe._f.deps&&ge(Qe._f.deps),O(Ue,Vt,Dt,er))}},ce=(He,ct)=>{if(Tn(r.errors,ct)&&He.focus)return He.focus(),1},ge=async(He,ct={})=>{let Ue,Ze;const Qe=QL(He);if(s.resolver){const We=await U(Ed(He)?He:Qe);Ue=dp(We),Ze=He?!Qe.some(Je=>Tn(We,Je)):Ue}else He?(Ze=(await Promise.all(Qe.map(async We=>{const Je=Tn(n,We);return await B(Je&&Je._f?{[We]:Je}:Je)}))).every(Boolean),!(!Ze&&!r.isValid)&&j()):Ze=Ue=await B(n);return g.state.next({...!o0(He)||(p.isValid||f.isValid)&&Ue!==r.isValid?{}:{name:He},...s.resolver||!He?{isValid:Ue}:{},errors:r.errors}),ct.shouldFocus&&!Ze&&JL(n,ce,He?Qe:i.mount),Ze},ye=He=>{const ct={...l.mount?o:a};return Ed(He)?ct:o0(He)?Tn(ct,He):He.map(Ue=>Tn(ct,Ue))},ue=(He,ct)=>({invalid:!!Tn((ct||r).errors,He),isDirty:!!Tn((ct||r).dirtyFields,He),error:Tn((ct||r).errors,He),isValidating:!!Tn(r.validatingFields,He),isTouched:!!Tn((ct||r).touchedFields,He)}),pe=He=>{He&&QL(He).forEach(ct=>Gd(r.errors,ct)),g.state.next({errors:He?r.errors:{}})},_e=(He,ct,Ue)=>{const Ze=(Tn(n,He,{_f:{}})._f||{}).ref,Qe=Tn(r.errors,He)||{},{ref:We,message:Je,type:it,...Dt}=Qe;pl(r.errors,He,{...Dt,...ct,ref:Ze}),g.state.next({name:He,errors:r.errors,isValid:!1}),Ue&&Ue.shouldFocus&&Ze&&Ze.focus&&Ze.focus()},$e=(He,ct)=>Ug(He)?g.state.subscribe({next:Ue=>"values"in Ue&&He(Q(void 0,ct),Ue)}):Q(He,ct,!0),Ae=He=>g.state.subscribe({next:ct=>{E6t(He.name,ct.name,He.exact)&&A6t(ct,He.formState||p,et,He.reRenderRoot)&&He.callback({values:{...o},...r,...ct,defaultValues:a})}}).unsubscribe,Ie=He=>(l.mount=!0,f={...f,...He.formState},Ae({...He,formState:f})),Ce=(He,ct={})=>{for(const Ue of He?QL(He):i.mount)i.mount.delete(Ue),i.array.delete(Ue),ct.keepValue||(Gd(n,Ue),Gd(o,Ue)),!ct.keepError&&Gd(r.errors,Ue),!ct.keepDirty&&Gd(r.dirtyFields,Ue),!ct.keepTouched&&Gd(r.touchedFields,Ue),!ct.keepIsValidating&&Gd(r.validatingFields,Ue),!s.shouldUnregister&&!ct.keepDefaultValue&&Gd(a,Ue);g.state.next({values:pu(o)}),g.state.next({...r,...ct.keepDirty?{isDirty:Y()}:{}}),!ct.keepIsValid&&j()},xe=({disabled:He,name:ct})=>{(rf(He)&&l.mount||He||i.disabled.has(ct))&&(He?i.disabled.add(ct):i.disabled.delete(ct))},we=(He,ct={})=>{let Ue=Tn(n,He);const Ze=rf(ct.disabled)||rf(s.disabled);return pl(n,He,{...Ue||{},_f:{...Ue&&Ue._f?Ue._f:{ref:{name:He}},name:He,mount:!0,...ct}}),i.mount.add(He),Ue?xe({disabled:rf(ct.disabled)?ct.disabled:s.disabled,name:He}):L(He,!0,ct.value),{...Ze?{disabled:ct.disabled||s.disabled}:{},...s.progressive?{required:!!ct.required,min:GP(ct.min),max:GP(ct.max),minLength:GP(ct.minLength),maxLength:GP(ct.maxLength),pattern:GP(ct.pattern)}:{},name:He,onChange:oe,onBlur:oe,ref:Qe=>{if(Qe){we(He,ct),Ue=Tn(n,He);const We=Ed(Qe.value)&&Qe.querySelectorAll&&Qe.querySelectorAll("input,select,textarea")[0]||Qe,Je=N6t(We),it=Ue._f.refs||[];if(Je?it.find(Dt=>Dt===We):We===Ue._f.ref)return;pl(n,He,{_f:{...Ue._f,...Je?{refs:[...it.filter(Wxe),We,...Array.isArray(Tn(a,He))?[{}]:[]],ref:{type:We.type,name:He}}:{ref:We}}}),L(He,!1,void 0,We)}else Ue=Tn(n,He,{}),Ue._f&&(Ue._f.mount=!1),(s.shouldUnregister||ct.shouldUnregister)&&!(ZZe(i.array,He)&&l.action)&&i.unMount.add(He)}}},Le=()=>s.shouldFocusError&&JL(n,ce,i.mount),tt=He=>{rf(He)&&(g.state.next({disabled:He}),JL(n,(ct,Ue)=>{const Ze=Tn(n,Ue);Ze&&(ct.disabled=Ze._f.disabled||He,Array.isArray(Ze._f.refs)&&Ze._f.refs.forEach(Qe=>{Qe.disabled=Ze._f.disabled||He}))},0,!1))},Te=(He,ct)=>async Ue=>{let Ze;Ue&&(Ue.preventDefault&&Ue.preventDefault(),Ue.persist&&Ue.persist());let Qe=pu(o);if(g.state.next({isSubmitting:!0}),s.resolver){const{errors:We,values:Je}=await q();r.errors=We,Qe=pu(Je)}else await B(n);if(i.disabled.size)for(const We of i.disabled)Gd(Qe,We);if(Gd(r.errors,"root"),dp(r.errors)){g.state.next({errors:{}});try{await He(Qe,Ue)}catch(We){Ze=We}}else ct&&await ct({...r.errors},Ue),Le(),setTimeout(Le);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:dp(r.errors)&&!Ze,submitCount:r.submitCount+1,errors:r.errors}),Ze)throw Ze},pt=(He,ct={})=>{Tn(n,He)&&(Ed(ct.defaultValue)?re(He,pu(Tn(a,He))):(re(He,ct.defaultValue),pl(a,He,pu(ct.defaultValue))),ct.keepTouched||Gd(r.touchedFields,He),ct.keepDirty||(Gd(r.dirtyFields,He),r.isDirty=ct.defaultValue?Y(He,pu(Tn(a,He))):Y()),ct.keepError||(Gd(r.errors,He),p.isValid&&j()),g.state.next({...r}))},fe=(He,ct={})=>{const Ue=He?pu(He):a,Ze=pu(Ue),Qe=dp(He),We=Qe?a:Ze;if(ct.keepDefaultValues||(a=Ue),!ct.keepValues){if(ct.keepDirtyValues){const Je=new Set([...i.mount,...Object.keys(WP(a,o))]);for(const it of Array.from(Je))Tn(r.dirtyFields,it)?pl(We,it,Tn(o,it)):re(it,Tn(We,it))}else{if(oNe&&Ed(He))for(const Je of i.mount){const it=Tn(n,Je);if(it&&it._f){const Dt=Array.isArray(it._f.refs)?it._f.refs[0]:it._f.ref;if(Voe(Dt)){const Vt=Dt.closest("form");if(Vt){Vt.reset();break}}}}if(ct.keepFieldsRef)for(const Je of i.mount)re(Je,Tn(We,Je));else n={}}o=s.shouldUnregister?ct.keepDefaultValues?pu(a):{}:pu(We),g.array.next({values:{...We}}),g.state.next({values:{...We}})}i={mount:ct.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!ct.keepIsValid||!!ct.keepDirtyValues,l.watch=!!s.shouldUnregister,g.state.next({submitCount:ct.keepSubmitCount?r.submitCount:0,isDirty:Qe?!1:ct.keepDirty?r.isDirty:!!(ct.keepDefaultValues&&!Hv(He,a)),isSubmitted:ct.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:Qe?{}:ct.keepDirtyValues?ct.keepDefaultValues&&o?WP(a,o):r.dirtyFields:ct.keepDefaultValues&&He?WP(a,He):ct.keepDirty?r.dirtyFields:{},touchedFields:ct.keepTouched?r.touchedFields:{},errors:ct.keepErrors?r.errors:{},isSubmitSuccessful:ct.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},qe=(He,ct)=>fe(Ug(He)?He(o):He,ct),at=(He,ct={})=>{const Ue=Tn(n,He),Ze=Ue&&Ue._f;if(Ze){const Qe=Ze.refs?Ze.refs[0]:Ze.ref;Qe.focus&&(Qe.focus(),ct.shouldSelect&&Ug(Qe.select)&&Qe.select())}},et=He=>{r={...r,...He}},rt={control:{register:we,unregister:Ce,getFieldState:ue,handleSubmit:Te,setError:_e,_subscribe:Ae,_runSchema:q,_focusError:Le,_getWatch:Q,_getDirty:Y,_setValid:j,_setFieldArray:N,_setDisabledField:xe,_setErrors:M,_getFieldArray:ee,_reset:fe,_resetDefaultValues:()=>Ug(s.defaultValues)&&s.defaultValues().then(He=>{qe(He,s.resetOptions),g.state.next({isLoading:!1})}),_removeUnmounted:V,_disableForm:tt,_subjects:g,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(He){l=He},get _defaultValues(){return a},get _names(){return i},set _names(He){i=He},get _formState(){return r},get _options(){return s},set _options(He){s={...s,...He}}},subscribe:Ie,trigger:ge,register:we,handleSubmit:Te,watch:$e,setValue:re,getValues:ye,reset:qe,resetField:pt,clearErrors:pe,unregister:Ce,setError:_e,setFocus:at,getFieldState:ue};return{...rt,formControl:rt}}function pue(t={}){const s=ht.useRef(void 0),r=ht.useRef(void 0),[n,a]=ht.useState({isDirty:!1,isValidating:!1,isLoading:Ug(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:Ug(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!Ug(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=O6t(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,uNe(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>a({...o._formState}),reRenderRoot:!0});return a(i=>({...i,isReady:!0})),o._formState.isReady=!0,l},[o]),ht.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),ht.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),ht.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),ht.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),ht.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),ht.useEffect(()=>{t.values&&!Hv(t.values,r.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),r.current=t.values,a(l=>({...l}))):o._resetDefaultValues()},[o,t.values]),ht.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=YZe(n,o),s.current}const iIe=(t,s,r)=>{if(t&&"reportValidity"in t){const n=Tn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},aYe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?iIe(n.ref,r,t):n.refs&&n.refs.forEach(a=>iIe(a,r,t))}},R6t=(t,s)=>{s.shouldUseNativeValidation&&aYe(t,s);const r={};for(const n in t){const a=Tn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(F6t(s.names||Object.keys(t),n)){const l=Object.assign({},Tn(r,n));pl(l,"root",o),pl(r,n,l)}else pl(r,n,o)}return r},F6t=(t,s)=>t.some(r=>r.startsWith(s+"."));var z6t=function(t,s){for(var r={};t.length;){var n=t[0],a=n.code,o=n.message,l=n.path.join(".");if(!r[l])if("unionErrors"in n){var i=n.unionErrors[0].errors[0];r[l]={message:i.message,type:i.code}}else r[l]={message:o,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(p){return p.errors.forEach(function(f){return t.push(f)})}),s){var c=r[l].types,u=c&&c[n.code];r[l]=QZe(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},fue=function(t,s,r){return r===void 0&&(r={}),function(n,a,o){try{return Promise.resolve(function(l,i){try{var c=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](n,s)).then(function(u){return o.shouldUseNativeValidation&&aYe({},o),{errors:{},values:r.raw?n:u}})}catch(u){return i(u)}return c&&c.then?c.then(void 0,i):c}(0,function(l){if(function(i){return Array.isArray(i==null?void 0:i.errors)}(l))return{values:{},errors:R6t(z6t(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const xue=v6t,iYe=k.createContext({}),Zc=({...t})=>e.jsx(iYe.Provider,{value:{name:t.name},children:e.jsx(j6t,{...t})}),gue=()=>{const t=k.useContext(iYe),s=k.useContext(oYe),{getFieldState:r,formState:n}=mue(),a=r(t.name,n);if(!t)throw new Error("useFormField should be used within ");const{id:o}=s;return{id:o,name:t.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...a}},oYe=k.createContext({}),Lc=k.forwardRef(({className:t,...s},r)=>{const n=k.useId();return e.jsx(oYe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:It("space-y-2",t),...s})})});Lc.displayName="FormItem";const Dc=k.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=gue();return e.jsx(be,{ref:r,className:It(n&&"text-destructive",t),htmlFor:a,...s})});Dc.displayName="FormLabel";const Oc=k.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=gue();return e.jsx(h2e,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});Oc.displayName="FormControl";const jie=k.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=gue();return e.jsx("p",{ref:r,id:n,className:It("text-sm text-muted-foreground",t),...s})});jie.displayName="FormDescription";const Sm=k.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=gue(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:It("text-sm font-medium text-destructive",t),...r,children:l}):null});Sm.displayName="FormMessage";const B6t=yC({category:DGe(["general","technology","crm","marketing"]),subject:gc().min(5,"Subject must be at least 5 characters").max(200),description:gc().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),$6t={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function f1e({trigger:t}){const[s,r]=k.useState(!1),[n,a]=k.useState(!1),{user:o}=Ds(),l=pue({resolver:fue(B6t),defaultValues:{category:"general",subject:"",description:""}}),i=async c=>{if(!o){me.error("You must be logged in to submit a ticket");return}a(!0);try{const{error:u}=await H.from("support_tickets").insert({user_id:o.id,category:c.category,subject:c.subject,description:c.description});if(u)throw u;try{await H.functions.invoke("support-ticket-notify",{body:{category:$6t[c.category],subject:c.subject}})}catch(p){console.log("Notification send attempted:",p)}me.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(u){console.error("Error submitting ticket:",u),me.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return e.jsxs(fs,{open:s,onOpenChange:r,children:[e.jsx(qi,{asChild:!0,children:t||e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(fL,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(ps,{className:"sm:max-w-[500px]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Need Help?"}),e.jsx(Gr,{children:"Submit a support ticket and we'll get back to you as soon as possible."})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg mb-4",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["You can also text us at: ",e.jsx("span",{className:"font-medium text-foreground",children:"1-866-527-8668"})]})]}),e.jsx(xue,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Zc,{control:l.control,name:"category",render:({field:c})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Category"}),e.jsxs(Ks,{onValueChange:c.onChange,defaultValue:c.value,children:[e.jsx(Oc,{children:e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select a category"})})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"general",children:"General Support"}),e.jsx(Mt,{value:"technology",children:"Technology Support"}),e.jsx(Mt,{value:"crm",children:"CRM Support"}),e.jsx(Mt,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:l.control,name:"subject",render:({field:c})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Subject"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"Brief description of your issue",...c})}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:l.control,name:"description",render:({field:c})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Description"}),e.jsx(Oc,{children:e.jsx(Er,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...c})}),e.jsx(Sm,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const q6t=()=>{const{user:t}=Ds(),s=fr(),[r,n]=k.useState([]),[a,o]=k.useState(0),[l,i]=k.useState(!1),[c,u]=k.useState(null);k.useEffect(()=>{if(!t)return;const _=`notification_last_read_${t.id}`;let j=c;if(!j){const S=localStorage.getItem(_);S&&(j=S,u(S))}(async()=>{const{data:S,error:M}=await H.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!M&&S){n(S);const L=j?new Date(j):null,I=S.filter(O=>L?new Date(O.created_at)>L:!0);o(I.length)}})();const N=H.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},S=>{const M=S.new;n(I=>[M,...I].slice(0,20));const L=j?new Date(j):null;(!L||new Date(M.created_at)>L)&&o(I=>I+1),Notification.permission==="granted"&&new Notification(M.title,{body:M.body,icon:"/favicon.ico"})}).subscribe();return()=>{H.removeChannel(N)}},[t,c]);const p=_=>{const j=_.toLowerCase();return j.includes("community")||j.includes("post")?so:j.includes("academy")||j.includes("video")?An:j.includes("template")?ic:j.includes("event")?hn:j.includes("newsletter")?d1:j.includes("brokerage")?Gh:j.includes("swag")||j.includes("social")?ko:j.includes("toolbox")||j.includes("tool")?ty:j.includes("brief")?pn:so},f=_=>{i(!1),_.url&&_.url!=="/"&&s(_.url)},g=()=>{if(!t)return;const _=new Date().toISOString(),j=`notification_last_read_${t.id}`;localStorage.setItem(j,_),u(_),o(0)},b=_=>{i(_),_&&a>0&&g()};return e.jsxs(iu,{open:l,onOpenChange:b,children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(Lm,{className:"h-5 w-5"}),a>0&&e.jsx(st,{variant:"destructive",className:"absolute -top-1 -right-1 h-5 w-5 flex items-center justify-center p-0 text-xs",children:a>9?"9+":a})]})}),e.jsxs(Bd,{align:"end",className:"w-80",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[e.jsx("span",{className:"font-semibold",children:"Notifications"}),r.length>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:g,children:"Mark all read"})]}),e.jsx(Gi,{className:"h-[300px]",children:r.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No notifications yet"}):r.map(_=>{const j=p(_.title);return e.jsxs(Ma,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>f(_),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(j,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children:_.title}),e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:_.body}),e.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:Uc(new Date(_.created_at),{addSuffix:!0})})]})]},_.id)})})]})]})};var oIe=1,U6t=.9,V6t=.8,H6t=.17,Gxe=.1,Kxe=.999,W6t=.9999,G6t=.99,K6t=/[\\\/_+.#"@\[\(\{&]/,Z6t=/[\\\/_+.#"@\[\(\{&]/g,Y6t=/[\s-]/,lYe=/[\s-]/g;function x1e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?oIe:G6t;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var c=n.charAt(o),u=r.indexOf(c,a),p=0,f,g,b,_;u>=0;)f=x1e(t,s,r,n,u+1,o+1,l),f>p&&(u===a?f*=oIe:K6t.test(t.charAt(u-1))?(f*=V6t,b=t.slice(a,u-1).match(Z6t),b&&a>0&&(f*=Math.pow(Kxe,b.length))):Y6t.test(t.charAt(u-1))?(f*=U6t,_=t.slice(a,u-1).match(lYe),_&&a>0&&(f*=Math.pow(Kxe,_.length))):(f*=H6t,a>0&&(f*=Math.pow(Kxe,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=W6t)),(ff&&(f=g*Gxe)),f>p&&(p=f),u=r.indexOf(c,u+1);return l[i]=p,p}function lIe(t){return t.toLowerCase().replace(lYe," ")}function X6t(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,x1e(t,s,lIe(t),lIe(s),0,0,{})}var KP='[cmdk-group=""]',Zxe='[cmdk-group-items=""]',Q6t='[cmdk-group-heading=""]',cYe='[cmdk-item=""]',cIe=`${cYe}:not([aria-disabled="true"])`,g1e="cmdk-item-select",$5="data-value",J6t=(t,s,r)=>X6t(t,s,r),dYe=k.createContext(void 0),$O=()=>k.useContext(dYe),uYe=k.createContext(void 0),pNe=()=>k.useContext(uYe),hYe=k.createContext(void 0),mYe=k.forwardRef((t,s)=>{let r=q5(()=>{var pe,_e;return{search:"",value:(_e=(pe=t.value)!=null?pe:t.defaultValue)!=null?_e:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=q5(()=>new Set),a=q5(()=>new Map),o=q5(()=>new Map),l=q5(()=>new Set),i=pYe(t),{label:c,children:u,value:p,onValueChange:f,filter:g,shouldFilter:b,loop:_,disablePointerSelection:j=!1,vimBindings:w=!0,...N}=t,S=Tu(),M=Tu(),L=Tu(),I=k.useRef(null),O=dPt();WS(()=>{if(p!==void 0){let pe=p.trim();r.current.value=pe,q.emit()}},[p]),WS(()=>{O(6,ee)},[]);let q=k.useMemo(()=>({subscribe:pe=>(l.current.add(pe),()=>l.current.delete(pe)),snapshot:()=>r.current,setState:(pe,_e,$e)=>{var Ae,Ie,Ce,xe;if(!Object.is(r.current[pe],_e)){if(r.current[pe]=_e,pe==="search")Q(),V(),O(1,Y);else if(pe==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let we=document.getElementById(L);we?we.focus():(Ae=document.getElementById(S))==null||Ae.focus()}if(O(7,()=>{var we;r.current.selectedItemId=(we=X())==null?void 0:we.id,q.emit()}),$e||O(5,ee),((Ie=i.current)==null?void 0:Ie.value)!==void 0){let we=_e??"";(xe=(Ce=i.current).onValueChange)==null||xe.call(Ce,we);return}}q.emit()}},emit:()=>{l.current.forEach(pe=>pe())}}),[]),U=k.useMemo(()=>({value:(pe,_e,$e)=>{var Ae;_e!==((Ae=o.current.get(pe))==null?void 0:Ae.value)&&(o.current.set(pe,{value:_e,keywords:$e}),r.current.filtered.items.set(pe,B(_e,$e)),O(2,()=>{V(),q.emit()}))},item:(pe,_e)=>(n.current.add(pe),_e&&(a.current.has(_e)?a.current.get(_e).add(pe):a.current.set(_e,new Set([pe]))),O(3,()=>{Q(),V(),r.current.value||Y(),q.emit()}),()=>{o.current.delete(pe),n.current.delete(pe),r.current.filtered.items.delete(pe);let $e=X();O(4,()=>{Q(),($e==null?void 0:$e.getAttribute("id"))===pe&&Y(),q.emit()})}),group:pe=>(a.current.has(pe)||a.current.set(pe,new Set),()=>{o.current.delete(pe),a.current.delete(pe)}),filter:()=>i.current.shouldFilter,label:c||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:L,labelId:M,listInnerRef:I}),[]);function B(pe,_e){var $e,Ae;let Ie=(Ae=($e=i.current)==null?void 0:$e.filter)!=null?Ae:J6t;return pe?Ie(pe,r.current.search,_e):0}function V(){if(!r.current.search||i.current.shouldFilter===!1)return;let pe=r.current.filtered.items,_e=[];r.current.filtered.groups.forEach(Ae=>{let Ie=a.current.get(Ae),Ce=0;Ie.forEach(xe=>{let we=pe.get(xe);Ce=Math.max(we,Ce)}),_e.push([Ae,Ce])});let $e=I.current;ie().sort((Ae,Ie)=>{var Ce,xe;let we=Ae.getAttribute("id"),Le=Ie.getAttribute("id");return((Ce=pe.get(Le))!=null?Ce:0)-((xe=pe.get(we))!=null?xe:0)}).forEach(Ae=>{let Ie=Ae.closest(Zxe);Ie?Ie.appendChild(Ae.parentElement===Ie?Ae:Ae.closest(`${Zxe} > *`)):$e.appendChild(Ae.parentElement===$e?Ae:Ae.closest(`${Zxe} > *`))}),_e.sort((Ae,Ie)=>Ie[1]-Ae[1]).forEach(Ae=>{var Ie;let Ce=(Ie=I.current)==null?void 0:Ie.querySelector(`${KP}[${$5}="${encodeURIComponent(Ae[0])}"]`);Ce==null||Ce.parentElement.appendChild(Ce)})}function Y(){let pe=ie().find($e=>$e.getAttribute("aria-disabled")!=="true"),_e=pe==null?void 0:pe.getAttribute($5);q.setState("value",_e||void 0)}function Q(){var pe,_e,$e,Ae;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Ie=0;for(let Ce of n.current){let xe=(_e=(pe=o.current.get(Ce))==null?void 0:pe.value)!=null?_e:"",we=(Ae=($e=o.current.get(Ce))==null?void 0:$e.keywords)!=null?Ae:[],Le=B(xe,we);r.current.filtered.items.set(Ce,Le),Le>0&&Ie++}for(let[Ce,xe]of a.current)for(let we of xe)if(r.current.filtered.items.get(we)>0){r.current.filtered.groups.add(Ce);break}r.current.filtered.count=Ie}function ee(){var pe,_e,$e;let Ae=X();Ae&&(((pe=Ae.parentElement)==null?void 0:pe.firstChild)===Ae&&(($e=(_e=Ae.closest(KP))==null?void 0:_e.querySelector(Q6t))==null||$e.scrollIntoView({block:"nearest"})),Ae.scrollIntoView({block:"nearest"}))}function X(){var pe;return(pe=I.current)==null?void 0:pe.querySelector(`${cYe}[aria-selected="true"]`)}function ie(){var pe;return Array.from(((pe=I.current)==null?void 0:pe.querySelectorAll(cIe))||[])}function re(pe){let _e=ie()[pe];_e&&q.setState("value",_e.getAttribute($5))}function oe(pe){var _e;let $e=X(),Ae=ie(),Ie=Ae.findIndex(xe=>xe===$e),Ce=Ae[Ie+pe];(_e=i.current)!=null&&_e.loop&&(Ce=Ie+pe<0?Ae[Ae.length-1]:Ie+pe===Ae.length?Ae[0]:Ae[Ie+pe]),Ce&&q.setState("value",Ce.getAttribute($5))}function ce(pe){let _e=X(),$e=_e==null?void 0:_e.closest(KP),Ae;for(;$e&&!Ae;)$e=pe>0?lPt($e,KP):cPt($e,KP),Ae=$e==null?void 0:$e.querySelector(cIe);Ae?q.setState("value",Ae.getAttribute($5)):oe(pe)}let ge=()=>re(ie().length-1),ye=pe=>{pe.preventDefault(),pe.metaKey?ge():pe.altKey?ce(1):oe(1)},ue=pe=>{pe.preventDefault(),pe.metaKey?re(0):pe.altKey?ce(-1):oe(-1)};return k.createElement(nn.div,{ref:s,tabIndex:-1,...N,"cmdk-root":"",onKeyDown:pe=>{var _e;(_e=N.onKeyDown)==null||_e.call(N,pe);let $e=pe.nativeEvent.isComposing||pe.keyCode===229;if(!(pe.defaultPrevented||$e))switch(pe.key){case"n":case"j":{w&&pe.ctrlKey&&ye(pe);break}case"ArrowDown":{ye(pe);break}case"p":case"k":{w&&pe.ctrlKey&&ue(pe);break}case"ArrowUp":{ue(pe);break}case"Home":{pe.preventDefault(),re(0);break}case"End":{pe.preventDefault(),ge();break}case"Enter":{pe.preventDefault();let Ae=X();if(Ae){let Ie=new Event(g1e);Ae.dispatchEvent(Ie)}}}}},k.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:hPt},c),yue(t,pe=>k.createElement(uYe.Provider,{value:q},k.createElement(dYe.Provider,{value:U},pe))))}),ePt=k.forwardRef((t,s)=>{var r,n;let a=Tu(),o=k.useRef(null),l=k.useContext(hYe),i=$O(),c=pYe(t),u=(n=(r=c.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;WS(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=fYe(a,o,[t.value,t.children,o],t.keywords),f=pNe(),g=gw(O=>O.value&&O.value===p.current),b=gw(O=>u||i.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);k.useEffect(()=>{let O=o.current;if(!(!O||t.disabled))return O.addEventListener(g1e,_),()=>O.removeEventListener(g1e,_)},[b,t.onSelect,t.disabled]);function _(){var O,q;j(),(q=(O=c.current).onSelect)==null||q.call(O,p.current)}function j(){f.setState("value",p.current,!0)}if(!b)return null;let{disabled:w,value:N,onSelect:S,forceMount:M,keywords:L,...I}=t;return k.createElement(nn.div,{ref:C1(o,s),...I,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!g,"data-disabled":!!w,"data-selected":!!g,onPointerMove:w||i.getDisablePointerSelection()?void 0:j,onClick:w?void 0:_},t.children)}),tPt=k.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Tu(),i=k.useRef(null),c=k.useRef(null),u=Tu(),p=$O(),f=gw(b=>a||p.filter()===!1?!0:b.search?b.filtered.groups.has(l):!0);WS(()=>p.group(l),[]),fYe(l,i,[t.value,t.heading,c]);let g=k.useMemo(()=>({id:l,forceMount:a}),[a]);return k.createElement(nn.div,{ref:C1(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&k.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),yue(t,b=>k.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},k.createElement(hYe.Provider,{value:g},b))))}),sPt=k.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=k.useRef(null),o=gw(l=>!l.search);return!r&&!o?null:k.createElement(nn.div,{ref:C1(a,s),...n,"cmdk-separator":"",role:"separator"})}),rPt=k.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=pNe(),l=gw(u=>u.search),i=gw(u=>u.selectedItemId),c=$O();return k.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),k.createElement(nn.input,{ref:s,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":i,id:c.inputId,type:"text",value:a?t.value:l,onChange:u=>{a||o.setState("search",u.target.value),r==null||r(u.target.value)}})}),nPt=k.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=k.useRef(null),l=k.useRef(null),i=gw(u=>u.selectedItemId),c=$O();return k.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,f,g=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let b=u.offsetHeight;p.style.setProperty("--cmdk-list-height",b.toFixed(1)+"px")})});return g.observe(u),()=>{cancelAnimationFrame(f),g.unobserve(u)}}},[]),k.createElement(nn.div,{ref:C1(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:c.listId},yue(t,u=>k.createElement("div",{ref:C1(l,c.listInnerRef),"cmdk-list-sizer":""},u)))}),aPt=k.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return k.createElement(Ude,{open:r,onOpenChange:n},k.createElement(Vde,{container:l},k.createElement(KA,{"cmdk-overlay":"",className:a}),k.createElement(ZA,{"aria-label":t.label,"cmdk-dialog":"",className:o},k.createElement(mYe,{ref:s,...i}))))}),iPt=k.forwardRef((t,s)=>gw(r=>r.filtered.count===0)?k.createElement(nn.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),oPt=k.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return k.createElement(nn.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},yue(t,l=>k.createElement("div",{"aria-hidden":!0},l)))}),Ep=Object.assign(mYe,{List:nPt,Item:ePt,Input:rPt,Group:tPt,Separator:sPt,Dialog:aPt,Empty:iPt,Loading:oPt});function lPt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function cPt(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function pYe(t){let s=k.useRef(t);return WS(()=>{s.current=t}),s}var WS=typeof window>"u"?k.useEffect:k.useLayoutEffect;function q5(t){let s=k.useRef();return s.current===void 0&&(s.current=t()),s}function gw(t){let s=pNe(),r=()=>t(s.snapshot());return k.useSyncExternalStore(s.subscribe,r,r)}function fYe(t,s,r,n=[]){let a=k.useRef(),o=$O();return WS(()=>{var l;let i=(()=>{var u;for(let p of r){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(u=p.current.textContent)==null?void 0:u.trim():a.current}})(),c=n.map(u=>u.trim());o.value(t,i,c),(l=s.current)==null||l.setAttribute($5,i),a.current=i}),a}var dPt=()=>{let[t,s]=k.useState(),r=q5(()=>new Map);return WS(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function uPt(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function yue({asChild:t,children:s},r){return t&&k.isValidElement(s)?k.cloneElement(uPt(s),{ref:s.ref},r(s.props.children)):r(s)}var hPt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Dx=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep,{ref:r,className:It("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Dx.displayName=Ep.displayName;const mPt=({children:t,...s})=>e.jsx(fs,{...s,children:e.jsx(ps,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(Dx,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})})}),Ox=k.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(cn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Ep.Input,{ref:r,className:It("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));Ox.displayName=Ep.Input.displayName;const Rx=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep.List,{ref:r,className:It("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Rx.displayName=Ep.List.displayName;const Fx=k.forwardRef((t,s)=>e.jsx(Ep.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Fx.displayName=Ep.Empty.displayName;const zx=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Group,{ref:r,className:It("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));zx.displayName=Ep.Group.displayName;const pPt=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Separator,{ref:r,className:It("-mx-1 h-px bg-border",t),...s}));pPt.displayName=Ep.Separator.displayName;const bp=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Item,{ref:r,className:It("group relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-primary/80 data-[selected=true]:text-primary-foreground data-[disabled=true]:opacity-50",t),...s}));bp.displayName=Ep.Item.displayName;const fPt={event:{label:"Events",icon:Od,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:ic,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:Kh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:ty,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:pn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},dIe=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(""),[a,o]=k.useState([]),[l,i]=k.useState(!1),c=fr();k.useEffect(()=>{const g=b=>{b.key==="k"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),s(_=>!_))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[]);const u=k.useCallback(async g=>{if(!g.trim()){o([]);return}i(!0);const b=`%${g}%`;try{const[_,j,w,N,S]=await Promise.all([H.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${b},description.ilike.${b}`).limit(5),H.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${b},description.ilike.${b}`).limit(5),H.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${b},description.ilike.${b}`).limit(5),H.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${b},description.ilike.${b}`).limit(5),H.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${b},description.ilike.${b}`).limit(5)]),M=[];_.data&&_.data.forEach(L=>{M.push({id:L.id,title:L.title,description:L.description,type:"event",date:L.event_date,path:`/event/${L.id}`})}),j.data&&j.data.forEach(L=>{M.push({id:L.id,title:L.name,description:L.description,type:"template",date:L.publish_date,path:`/templates/${L.id}`})}),w.data&&w.data.forEach(L=>{M.push({id:L.id,title:L.title,description:L.description,type:"academy",date:L.publish_date,path:`/academy/${L.id}`})}),N.data&&N.data.forEach(L=>{M.push({id:L.id,title:L.name,description:L.description,type:"toolbox",date:L.publish_date,path:`/toolbox/${L.id}`})}),S.data&&S.data.forEach(L=>{M.push({id:L.id,title:L.title,description:L.description,type:"social-swag",date:L.publish_date,path:`/social-swag/${L.id}`})}),o(M)}catch(_){console.error("Search error:",_)}finally{i(!1)}},[]);k.useEffect(()=>{const g=setTimeout(()=>{u(r)},300);return()=>clearTimeout(g)},[r,u]);const p=g=>{s(!1),n(""),c(g)},f=a.reduce((g,b)=>(g[b.type]||(g[b.type]=[]),g[b.type].push(b),g),{});return e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-9 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>s(!0),children:[e.jsx(cn,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex text-muted-foreground text-sm",children:"Search..."}),e.jsxs("kbd",{className:"pointer-events-none absolute right-1.5 top-1.5 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsxs(mPt,{open:t,onOpenChange:s,children:[e.jsx(Ox,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(Rx,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Fx,{children:['No results found for "',r,'"']}),!l&&!r&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Start typing to search across all content..."}),Object.entries(f).map(([g,b])=>{const _=fPt[g],j=_.icon;return e.jsx(zx,{heading:_.label,children:b.map(w=>e.jsxs(bp,{value:`${w.type}-${w.id}-${w.title}`,onSelect:()=>p(w.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${_.color}`,children:e.jsx(j,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:w.title}),w.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:w.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(st,{variant:"secondary",className:"text-xs",children:_.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Uc(new Date(w.date),{addSuffix:!0})})]})]},`${w.type}-${w.id}`))},g)})]})]})]})},xPt=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=k.useState(null),o=fr();if(k.useEffect(()=>{const u=()=>{const f=new Date().getTime(),b=new Date(t).getTime()-f;if(b<=0){a({days:0,hours:0,minutes:0});return}const _=Math.floor(b/(1e3*60*60*24)),j=Math.floor(b%(1e3*60*60*24)/(1e3*60*60)),w=Math.floor(b%(1e3*60*60)/(1e3*60));a({days:_,hours:j,minutes:w})};u();const p=setInterval(u,6e4);return()=>clearInterval(p)},[t]),!n)return null;const l=n.days===0&&n.hours===0&&n.minutes===0,i=n.days<=1,c=n.days<=3&&!i;return l?e.jsxs("div",{className:It("flex items-center justify-between gap-3 px-4 py-2 rounded-lg bg-destructive/10 border border-destructive/20",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ku,{className:"h-4 w-4 text-destructive"}),e.jsx("span",{className:"text-sm font-medium text-destructive",children:"Your free trial has expired"})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[e.jsx(pn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:It("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",i?"bg-destructive/10 border-destructive/20":c?"bg-amber-500/10 border-amber-500/20":"bg-primary/10 border-primary/20",s),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(un,{className:It("h-4 w-4",i?"text-destructive":c?"text-amber-500":"text-primary")}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:It("text-sm font-medium",i?"text-destructive":c?"text-amber-600":"text-primary"),children:"Free Trial:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[n.days>0&&e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:It("text-xs",i?"text-destructive/70":c?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":c?"default":"outline",className:It("text-xs h-7 px-3",c&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(pn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},gPt=()=>{const t=fr();return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center p-4 overflow-y-auto",children:e.jsxs(Ee,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-4 h-16 w-16 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Ku,{className:"h-8 w-8 text-destructive"})}),e.jsx(Rt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(gr,{className:"text-base",children:"Your 7-day free trial has expired. Upgrade now to continue accessing all the powerful tools and resources LevelUp has to offer!"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(pr,{className:"h-6 w-6 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Individual Agent"}),e.jsxs("p",{className:"text-2xl font-bold text-primary mb-2",children:["$39",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Perfect for solo agents ready to level up"}),e.jsxs(K,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(pn,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(ka,{className:"h-6 w-6 text-amber-600"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Brokerage"}),e.jsxs("p",{className:"text-2xl font-bold text-amber-600 mb-2",children:["$299",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"For teams and brokerages"}),e.jsxs(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Choose Brokerage"]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"With a full membership, you'll get:"}),e.jsxs("ul",{className:"text-sm space-y-1 text-muted-foreground grid sm:grid-cols-2 gap-x-4",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Unlimited access to all marketing templates"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Complete Academy training library"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," AI-powered tools and resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Community forums and support"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Exclusive member events and workshops"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Deal pipeline & scorecard tracking"]})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-center",children:"Questions? Contact us:"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{children:"1-866-527-8668"})]}),e.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},yPt=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:It("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(Ah,{className:"h-5 w-5"}),t&&e.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-primary animate-pulse"})]})}),e.jsx(Xl,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var vue="Checkbox",[vPt]=ad(vue),[bPt,fNe]=vPt(vue);function _Pt(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:c,required:u,value:p="on",internal_do_not_use_render:f}=t,[g,b]=ah({prop:r,defaultProp:a??!1,onChange:c,caller:vue}),[_,j]=k.useState(null),[w,N]=k.useState(null),S=k.useRef(!1),M=_?!!l||!!_.closest("form"):!0,L={checked:g,disabled:o,setChecked:b,control:_,setControl:j,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:S,required:u,defaultChecked:Q_(a)?!1:a,isFormControl:M,bubbleInput:w,setBubbleInput:N};return e.jsx(bPt,{scope:s,...L,children:wPt(f)?f(L):n})}var xYe="CheckboxTrigger",gYe=k.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:c,required:u,setControl:p,setChecked:f,hasConsumerStoppedPropagationRef:g,isFormControl:b,bubbleInput:_}=fNe(xYe,t),j=qa(a,p),w=k.useRef(c);return k.useEffect(()=>{const N=o==null?void 0:o.form;if(N){const S=()=>f(w.current);return N.addEventListener("reset",S),()=>N.removeEventListener("reset",S)}},[o,f]),e.jsx(nn.button,{type:"button",role:"checkbox","aria-checked":Q_(c)?"mixed":c,"aria-required":u,"data-state":wYe(c),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:j,onKeyDown:Ir(s,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:Ir(r,N=>{f(S=>Q_(S)?!0:!S),_&&b&&(g.current=N.isPropagationStopped(),g.current||N.stopPropagation())})})});gYe.displayName=xYe;var xNe=k.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:c,onCheckedChange:u,form:p,...f}=t;return e.jsx(_Pt,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:p,value:c,internal_do_not_use_render:({isFormControl:g})=>e.jsxs(e.Fragment,{children:[e.jsx(gYe,{...f,ref:s,__scopeCheckbox:r}),g&&e.jsx(_Ye,{__scopeCheckbox:r})]})})});xNe.displayName=vue;var yYe="CheckboxIndicator",vYe=k.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=fNe(yYe,r);return e.jsx(zd,{present:n||Q_(o.checked)||o.checked===!0,children:e.jsx(nn.span,{"data-state":wYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});vYe.displayName=yYe;var bYe="CheckboxBubbleInput",_Ye=k.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:c,name:u,value:p,form:f,bubbleInput:g,setBubbleInput:b}=fNe(bYe,t),_=qa(r,b),j=LO(o),w=_O(n);k.useEffect(()=>{const S=g;if(!S)return;const M=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(M,"checked").set,O=!a.current;if(j!==o&&I){const q=new Event("click",{bubbles:O});S.indeterminate=Q_(o),I.call(S,Q_(o)?!1:o),S.dispatchEvent(q)}},[g,j,o,a]);const N=k.useRef(Q_(o)?!1:o);return e.jsx(nn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??N.current,required:i,disabled:c,name:u,value:p,form:f,...s,tabIndex:-1,ref:_,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});_Ye.displayName=bYe;function wPt(t){return typeof t=="function"}function Q_(t){return t==="indeterminate"}function wYe(t){return Q_(t)?"indeterminate":t?"checked":"unchecked"}const Oo=k.forwardRef(({className:t,...s},r)=>e.jsx(xNe,{ref:r,className:It("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(vYe,{className:It("flex items-center justify-center text-current"),children:e.jsx(va,{className:"h-4 w-4"})})}));Oo.displayName=xNe.displayName;var gNe="Radio",[jPt,jYe]=ad(gNe),[NPt,kPt]=jPt(gNe),NYe=k.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:c,form:u,...p}=t,[f,g]=k.useState(null),b=qa(s,w=>g(w)),_=k.useRef(!1),j=f?u||!!f.closest("form"):!0;return e.jsxs(NPt,{scope:r,checked:a,disabled:l,children:[e.jsx(nn.button,{type:"button",role:"radio","aria-checked":a,"data-state":MYe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:b,onClick:Ir(t.onClick,w=>{a||c==null||c(),j&&(_.current=w.isPropagationStopped(),_.current||w.stopPropagation())})}),j&&e.jsx(CYe,{control:f,bubbles:!_.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});NYe.displayName=gNe;var kYe="RadioIndicator",SYe=k.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=kPt(kYe,r);return e.jsx(zd,{present:n||o.checked,children:e.jsx(nn.span,{"data-state":MYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});SYe.displayName=kYe;var SPt="RadioBubbleInput",CYe=k.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=qa(l,o),c=LO(r),u=_O(s);return k.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&b){const _=new Event("click",{bubbles:n});b.call(p,r),p.dispatchEvent(_)}},[c,r,n]),e.jsx(nn.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});CYe.displayName=SPt;function MYe(t){return t?"checked":"unchecked"}var CPt=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],bue="RadioGroup",[MPt]=ad(bue,[Aw,jYe]),TYe=Aw(),AYe=jYe(),[TPt,APt]=MPt(bue),EYe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:c,dir:u,loop:p=!0,onValueChange:f,...g}=t,b=TYe(r),_=Tw(u),[j,w]=ah({prop:o,defaultProp:a??null,onChange:f,caller:bue});return e.jsx(TPt,{scope:r,name:n,required:l,disabled:i,value:j,onValueChange:w,children:e.jsx(Dde,{asChild:!0,...b,orientation:c,dir:_,loop:p,children:e.jsx(nn.div,{role:"radiogroup","aria-required":l,"aria-orientation":c,"data-disabled":i?"":void 0,dir:_,...g,ref:s})})})});EYe.displayName=bue;var PYe="RadioGroupItem",IYe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=APt(PYe,r),l=o.disabled||n,i=TYe(r),c=AYe(r),u=k.useRef(null),p=qa(s,u),f=o.value===a.value,g=k.useRef(!1);return k.useEffect(()=>{const b=j=>{CPt.includes(j.key)&&(g.current=!0)},_=()=>g.current=!1;return document.addEventListener("keydown",b),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",_)}},[]),e.jsx(Ode,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(NYe,{disabled:l,required:o.required,checked:f,...c,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Ir(b=>{b.key==="Enter"&&b.preventDefault()}),onFocus:Ir(a.onFocus,()=>{var b;g.current&&((b=u.current)==null||b.click())})})})});IYe.displayName=PYe;var EPt="RadioGroupIndicator",LYe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=AYe(r);return e.jsx(SYe,{...a,...n,ref:s})});LYe.displayName=EPt;var DYe=EYe,OYe=IYe,PPt=LYe;const yNe=k.forwardRef(({className:t,...s},r)=>e.jsx(DYe,{className:It("grid gap-2",t),...s,ref:r}));yNe.displayName=DYe.displayName;const Goe=k.forwardRef(({className:t,...s},r)=>e.jsx(OYe,{ref:r,className:It("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(PPt,{className:"flex items-center justify-center",children:e.jsx(_d,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Goe.displayName=OYe.displayName;const IPt=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Ds(),[o,l]=k.useState({}),[i,c]=k.useState({}),[u,p]=k.useState([]);k.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const w=t.polls.map(S=>S.id),{data:N}=await H.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",w);if(N){const S={};N.forEach(M=>{S[M.poll_id]||(S[M.poll_id]=[]),S[M.poll_id].push(M.option_id)}),c(S)}},g=(w,N)=>{l(S=>({...S,[w]:N}))},b=(w,N,S)=>{l(M=>{const L=M[w]||[];return S?{...M,[w]:[...L,N]}:{...M,[w]:L.filter(I=>I!==N)}})},_=async w=>{if(!a)return;const N=o[w];if(!N||Array.isArray(N)&&N.length===0){me.error("Please select an option");return}p(S=>[...S,w]);try{await H.from("levelup_brief_poll_responses").delete().eq("poll_id",w).eq("user_id",a.id);const S=Array.isArray(N)?N:[N],M=S.map(I=>({poll_id:w,option_id:I,user_id:a.id})),{error:L}=await H.from("levelup_brief_poll_responses").insert(M);if(L)throw L;c(I=>({...I,[w]:S})),me.success("Response submitted!")}catch(S){console.error("Error submitting poll response:",S),me.error("Failed to submit response")}finally{p(S=>S.filter(M=>M!==w))}},j=w=>(w.includes("mediadelivery.net")||w.includes("bunny"),w);return e.jsx(fs,{open:s,onOpenChange:w=>!w&&r(),children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] p-0 overflow-hidden [&>button]:hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/80 p-4 pr-12 text-primary-foreground relative",children:[e.jsx("button",{onClick:r,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/30 hover:bg-white/50 transition-colors","aria-label":"Close",children:e.jsx(Rr,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-white/20 rounded-lg",children:e.jsx(Ah,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(st,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(vs,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Gi,{className:"max-h-[calc(90vh-240px)]",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:j(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(w=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.open(w.url,"_blank"),className:"gap-2",children:[e.jsx(tn,{className:"h-4 w-4"}),w.title]},w.id))})]}),t.polls.map(w=>{var M,L;const N=((M=i[w.id])==null?void 0:M.length)>0,S=u.includes(w.id);return e.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:w.question}),N&&e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(sa,{className:"h-3 w-3"}),"Responded"]})]}),w.poll_type==="single"?e.jsx(yNe,{value:o[w.id]||((L=i[w.id])==null?void 0:L[0])||"",onValueChange:I=>g(w.id,I),className:"space-y-2",children:w.options.map(I=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Goe,{value:I.id,id:I.id}),e.jsx(be,{htmlFor:I.id,className:"cursor-pointer",children:I.option_text})]},I.id))}):e.jsx("div",{className:"space-y-2",children:w.options.map(I=>{const q=(o[w.id]||i[w.id]||[]).includes(I.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Oo,{id:I.id,checked:q,onCheckedChange:U=>b(w.id,I.id,U)}),e.jsx(be,{htmlFor:I.id,className:"cursor-pointer",children:I.option_text})]},I.id)})}),e.jsx(K,{size:"sm",onClick:()=>_(w.id),disabled:S,children:S?"Submitting...":N?"Update Response":"Submit"})]},w.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(K,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},LPt=()=>{const{user:t}=Ds(),[s,r]=k.useState(null),[n,a]=k.useState(!1),[o,l]=k.useState(!0),[i,c]=k.useState(!1),u=k.useCallback(async()=>{if(!t){l(!1);return}try{const{data:_,error:j}=await H.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(j||!_){l(!1);return}const{data:w}=await H.from("levelup_brief_views").select("*").eq("brief_id",_.id).eq("user_id",t.id).maybeSingle(),[N,S]=await Promise.all([H.from("levelup_brief_links").select("*").eq("brief_id",_.id).order("sort_order"),H.from("levelup_brief_polls").select("*").eq("brief_id",_.id).order("sort_order")]),M=[];if(S.data)for(const U of S.data){const{data:B}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",U.id).order("sort_order");M.push({...U,options:B||[]})}const L={brief:_,links:N.data||[],polls:M};r(L);const I=!!w,O=(w==null?void 0:w.dismissed_at)!=null,q=localStorage.getItem(`brief-dismissed-${_.id}`)==="true";if(O||q)c(!1),a(!1);else if(!I)a(!0),c(!0);else if(_.show_frequency==="every_login")a(!0),c(!0);else if(_.show_frequency==="daily"){const U=new Date(w.viewed_at);(new Date().getTime()-U.getTime())/(1e3*60*60)>=24&&(a(!0),c(!0))}else c(!1)}catch(_){console.error("Error fetching brief:",_)}finally{l(!1)}},[t]);k.useEffect(()=>{u()},[u]);const p=async()=>{if(!(!t||!s))try{const{data:_}=await H.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();_?await H.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",_.id):await H.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(_){console.error("Error marking brief as viewed:",_)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),p()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),c(!1);try{const{data:_,error:j}=await H.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(j&&console.error("Error checking existing brief view:",j),_){const{error:w}=await H.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",_.id).eq("user_id",t.id);w&&console.error("Error updating brief dismiss:",w)}else{const{error:w}=await H.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});w&&console.error("Error inserting brief dismiss:",w)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(_){console.error("Error dismissing brief:",_),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function DPt(){const[t,s]=k.useState(!1),[r,n]=k.useState(!1),[a,o]=k.useState(null);k.useEffect(()=>{if(localStorage.getItem("install-banner-dismissed")||window.matchMedia("(display-mode: standalone)").matches||!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const f=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(f),s(!0);const g=b=>{b.preventDefault(),o(b)};return window.addEventListener("beforeinstallprompt",g),()=>{window.removeEventListener("beforeinstallprompt",g)}},[]);const l=()=>{localStorage.setItem("install-banner-dismissed","true"),s(!1)},i=async()=>{if(a){await a.prompt();const{outcome:c}=await a.userChoice;c==="accepted"&&l(),o(null)}};return t?e.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 p-4 bg-primary text-primary-foreground shadow-lg animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-primary-foreground/10 rounded-full",children:e.jsx(yi,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Add LevelUp to your home screen"}),r?e.jsxs("p",{className:"text-xs opacity-80 flex items-center gap-1",children:["Tap ",e.jsx(TL,{className:"h-3 w-3 inline"}),' then "Add to Home Screen"']}):e.jsx("p",{className:"text-xs opacity-80",children:"Quick access anytime"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!r&&a&&e.jsx(K,{size:"sm",variant:"secondary",onClick:i,className:"text-xs",children:"Install"}),e.jsx("button",{onClick:l,className:"p-1.5 hover:bg-primary-foreground/10 rounded-full transition-colors","aria-label":"Dismiss",children:e.jsx(Rr,{className:"h-4 w-4"})})]})]})}):null}const OPt=({children:t,onRefresh:s})=>{const[r,n]=k.useState(!1),[a,o]=k.useState(0),[l,i]=k.useState(!1),c=k.useRef(null),u=k.useRef(0),p=Qt(),f=80,g=120,b=k.useCallback(S=>{const M=c.current;M&&M.scrollTop<=0&&(u.current=S.touches[0].clientY,n(!0))},[]),_=k.useCallback(S=>{if(!r||l)return;const M=c.current;if(!M||M.scrollTop>0){n(!1),o(0);return}const I=S.touches[0].clientY-u.current;if(I>0){const q=Math.min(I*.5,g);o(q),q>10&&S.preventDefault()}},[r,l]),j=k.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await p.invalidateQueries()}catch(S){console.error("Refresh failed:",S)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),w=Math.min(a/f,1),N=w*180;return e.jsxs("div",{ref:c,className:"h-full overflow-auto",onTouchStart:b,onTouchMove:_,onTouchEnd:j,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:w},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${N}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(Go,{className:"h-5 w-5 text-primary"})})}),e.jsx("div",{style:{transform:a>0?`translateY(${Math.max(0,a-60)}px)`:void 0,transition:r?void 0:"transform 0.2s ease-out"},children:t})]})},RYe=()=>{const{user:t}=Ds(),[s,r]=k.useState(!1),[n,a]=k.useState(!1),[o,l]=k.useState(0),[i,c]=k.useState(!0);k.useEffect(()=>{(async()=>{if(!t){c(!1);return}try{const{data:b}=await H.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(b){a(!0),r(!1),c(!1);return}const{data:_}=await H.from("profiles").select("login_count").eq("id",t.id).single(),j=(_==null?void 0:_.login_count)||0;l(j);const w=sessionStorage.getItem("review-prompt-dismissed");r(j>=4&&!w)}catch(b){console.error("Error checking review eligibility:",b)}finally{c(!1)}})()},[t]);const u=k.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=k.useCallback(async(g,b)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:_}=await H.from("membership_reviews").insert({user_id:t.id,rating:g,review_text:b});if(_)throw _;return a(!0),r(!1),{success:!0,pointsAwarded:25}}catch(_){return console.error("Error submitting review:",_),{success:!1,error:_.message}}},[t]),f=k.useCallback(async()=>{if(t)try{await H.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(g){console.error("Error updating Google review status:",g)}},[t]);return{shouldShowPrompt:s,hasSubmittedReview:n,loginCount:o,isLoading:i,dismissPrompt:u,submitReview:p,markPostedToGoogle:f}},RPt="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",FPt=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=RYe(),[o,l]=k.useState(!1),[i,c]=k.useState("review"),[u,p]=k.useState(0),[f,g]=k.useState(0),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,S]=k.useState(!1);if(s||!t&&!N)return null;const M=async()=>{if(u===0){wn({title:"Please select a rating",variant:"destructive"});return}w(!0);const O=await n(u,b);w(!1),O.success?(S(!0),wn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),c("google")):wn({title:"Error submitting review",description:O.error,variant:"destructive"})},L=async O=>{O&&(await navigator.clipboard.writeText(b||`${u} star rating for LevelUp!`),wn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(RPt,"_blank")),l(!1),r()},I=()=>{l(!1),r()};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>l(!0),className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-40 flex items-center gap-2 rounded-full bg-primary/90 px-3 py-2 text-xs text-primary-foreground shadow-lg backdrop-blur-sm transition-all hover:bg-primary hover:scale-105 md:bottom-6",children:[e.jsx(Jn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(fs,{open:o,onOpenChange:I,children:e.jsx(ps,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-center",children:"How are you enjoying LevelUp?"}),e.jsx(Gr,{className:"text-center",children:"Your feedback helps us improve the experience for all members."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(O=>e.jsx("button",{type:"button",onClick:()=>p(O),onMouseEnter:()=>g(O),onMouseLeave:()=>g(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Jn,{className:It("h-8 w-8 transition-colors",(f||u)>=O?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},O))}),e.jsx(Er,{placeholder:"Tell us about your experience (optional)",value:b,onChange:O=>_(O.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:I,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:M,disabled:j||u===0,className:"flex-1",children:j?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-center",children:"🎉 Thank you!"}),e.jsx(Gr,{className:"text-center",children:"Would you mind sharing your review on Google? It really helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"We'll copy your review so you can easily paste it."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),className:"flex-1",children:"No Thanks"}),e.jsx(K,{onClick:()=>L(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function zPt(t){const s="=".repeat((4-t.length%4)%4),r=(t+s).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),a=new Uint8Array(n.length);for(let o=0;o{if(!f){l(!1);return}(async()=>{try{const j="vapid_public_key";let w=localStorage.getItem(j);if(!w){const{data:M,error:L}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(L)throw L;if(w=(M==null?void 0:M.vapidPublicKey)??null,!w)throw new Error("Missing VAPID public key");localStorage.setItem(j,w)}p(w);const N=await navigator.serviceWorker.register("/push-sw.js");c(N),r(Notification.permission);const S=await N.pushManager.getSubscription();a(!!S)}catch(j){console.error("Error initializing push notifications:",j)}finally{l(!1)}})()},[f]);const g=k.useCallback(async()=>{if(!f||!i||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!u)return me.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{l(!0);const _=await i.pushManager.getSubscription();if(_){try{await _.unsubscribe()}catch(L){console.warn("Failed to unsubscribe existing push subscription:",L)}const{error:M}=await H.from("push_subscriptions").delete().eq("user_id",t.id);M&&console.warn("Failed to cleanup push_subscriptions rows:",M)}if(Notification.permission!=="granted"){const M=await Notification.requestPermission();if(r(M),M!=="granted")return M==="denied"?me.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):me.error("Notification permission was dismissed. Please try again."),!1}const j=zPt(u);let w;try{w=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:j})}catch(M){console.error("PushManager.subscribe() failed:",M);const L=(M==null?void 0:M.message)||String(M);return L.includes("permission")?me.error("Push permission denied. Check your browser notification settings."):L.includes("key")||L.includes("VAPID")?me.error("Push configuration error. Please contact support."):L.includes("AbortError")?me.error("Push subscription was cancelled. Please try again."):me.error(`Failed to subscribe: ${L}`),!1}const N=w.toJSON(),{error:S}=await H.from("push_subscriptions").upsert({user_id:t.id,endpoint:N.endpoint,p256dh_key:N.keys.p256dh,auth_key:N.keys.auth},{onConflict:"user_id,endpoint"});if(S)throw console.error("Error saving subscription:",S),me.error("Failed to save notification preferences. Please try again."),S;return a(!0),me.success("Push notifications enabled!"),!0}catch(_){if(console.error("Error subscribing to push notifications:",_),!(_ instanceof Error&&_.message.includes("toast"))){const j=_ instanceof Error?_.message:"Unknown error";me.error("Failed to enable push notifications: "+j)}return!1}finally{l(!1)}},[f,i,t,u]),b=k.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const _=await i.pushManager.getSubscription();return _&&await _.unsubscribe(),await H.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),me.success("Push notifications disabled"),!0}catch(_){console.error("Error unsubscribing:",_);const j=_ instanceof Error?_.message:"Unknown error";return me.error("Failed to disable push notifications: "+j),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:g,unsubscribe:b}}const Yxe="push_notification_prompt_dismissed",BPt=()=>{const{user:t}=Ds(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=FYe(),[o,l]=k.useState(!1),[i,c]=k.useState(!1);k.useEffect(()=>{if(!t||!s||r||n||localStorage.getItem(`${Yxe}_${t.id}`))return;const g=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(g)},[t,s,r,n]);const u=async()=>{c(!0);const f=await a();c(!1),f&&(t&&localStorage.setItem(`${Yxe}_${t.id}`,"true"),l(!1))},p=()=>{t&&localStorage.setItem(`${Yxe}_${t.id}`,"true"),l(!1)};return!s||r?null:e.jsx(fs,{open:o,onOpenChange:f=>!f&&p(),children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:e.jsx(Lm,{className:"h-6 w-6 text-primary"})}),e.jsx(vs,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(Gr,{className:"text-center",children:"Enable push notifications to get alerted when:"})]}),e.jsxs("ul",{className:"my-4 space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," New events go live"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," Fresh templates are added"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," New toolbox resources drop"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," Social swag updates"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," New newsletters arrive"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," Posts in your community groups"]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(K,{onClick:u,disabled:i,className:"w-full",children:i?"Enabling...":"Enable Notifications"}),e.jsx(K,{variant:"ghost",onClick:p,className:"w-full",children:"Not Now"})]}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"You can always change this in your Profile settings."})]})})},uIe=t=>{let s;const r=new Set,n=(u,p)=>{const f=typeof u=="function"?u(s):u;if(!Object.is(f,s)){const g=s;s=p??(typeof f!="object"||f===null)?f:Object.assign({},s,f),r.forEach(b=>b(s,g))}},a=()=>s,i={setState:n,getState:a,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=s=t(n,a,i);return i},$Pt=t=>t?uIe(t):uIe,qPt=t=>t;function UPt(t,s=qPt){const r=ht.useSyncExternalStore(t.subscribe,ht.useCallback(()=>s(t.getState()),[t,s]),ht.useCallback(()=>s(t.getInitialState()),[t,s]));return ht.useDebugValue(r),r}const hIe=t=>{const s=$Pt(t),r=n=>UPt(s,n);return Object.assign(r,s),r},VPt=t=>t?hIe(t):hIe;function HPt(t,s){let r;try{r=t()}catch{return}return{getItem:a=>{var o;const l=c=>c===null?null:JSON.parse(c,void 0),i=(o=r.getItem(a))!=null?o:null;return i instanceof Promise?i.then(l):l(i)},setItem:(a,o)=>r.setItem(a,JSON.stringify(o,void 0)),removeItem:a=>r.removeItem(a)}}const y1e=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return y1e(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return y1e(n)(r)}}}},WPt=(t,s)=>(r,n,a)=>{let o={storage:HPt(()=>localStorage),partialize:j=>j,version:0,merge:(j,w)=>({...w,...j}),...s},l=!1;const i=new Set,c=new Set;let u=o.storage;if(!u)return t((...j)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...j)},n,a);const p=()=>{const j=o.partialize({...n()});return u.setItem(o.name,{state:j,version:o.version})},f=a.setState;a.setState=(j,w)=>(f(j,w),p());const g=t((...j)=>(r(...j),p()),n,a);a.getInitialState=()=>g;let b;const _=()=>{var j,w;if(!u)return;l=!1,i.forEach(S=>{var M;return S((M=n())!=null?M:g)});const N=((w=o.onRehydrateStorage)==null?void 0:w.call(o,(j=n())!=null?j:g))||void 0;return y1e(u.getItem.bind(u))(o.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==o.version){if(o.migrate){const M=o.migrate(S.state,S.version);return M instanceof Promise?M.then(L=>[!0,L]):[!0,M]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var M;const[L,I]=S;if(b=o.merge(I,(M=n())!=null?M:g),r(b,!0),L)return p()}).then(()=>{N==null||N(b,void 0),b=n(),l=!0,c.forEach(S=>S(b))}).catch(S=>{N==null||N(void 0,S)})};return a.persist={setOptions:j=>{o={...o,...j},j.storage&&(u=j.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>_(),hasHydrated:()=>l,onHydrate:j=>(i.add(j),()=>{i.delete(j)}),onFinishHydration:j=>(c.add(j),()=>{c.delete(j)})},o.skipHydration||_(),b||g},GPt=WPt,_ue=VPt()(GPt((t,s)=>({cartItems:[],addToCart:(r,n,a=1,o)=>{t(l=>{const i=l.cartItems.findIndex(c=>{var u;return c.product.id===r.id&&((u=c.variant)==null?void 0:u.id)===(n==null?void 0:n.id)});if(i>=0){const c=[...l.cartItems];return c[i].quantity+=a,o&&(c[i].artworkUrl=o),{cartItems:c}}return{cartItems:[...l.cartItems,{product:r,variant:n,quantity:a,artworkUrl:o}]}})},removeFromCart:(r,n)=>{t(a=>({cartItems:a.cartItems.filter(o=>{var l;return!(o.product.id===r&&((l=o.variant)==null?void 0:l.id)===n)})}))},updateQuantity:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,quantity:Math.max(1,a)}:l})}))},updateArtwork:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,artworkUrl:a}:l})}))},clearCart:()=>t({cartItems:[]}),getItemPrice:r=>{const n=Number(r.product.base_price),a=r.variant?Number(r.variant.price_adjustment):0;return n+a},getSubtotal:()=>{const{cartItems:r,getItemPrice:n}=s();return r.reduce((a,o)=>a+n(o)*o.quantity,0)},getShippingTotal:()=>{const{cartItems:r}=s();return r.reduce((n,a)=>n+Number(a.product.shipping_fee)*a.quantity,0)},getTotal:()=>{const{getSubtotal:r,getShippingTotal:n}=s();return r()+n()}}),{name:"marketplace-cart",partialize:t=>({cartItems:t.cartItems})}));function rE(){const{user:t}=Ds(),{data:s,isLoading:r}=mt({queryKey:["agent-lead-site",t==null?void 0:t.id],queryFn:async()=>{const{data:n,error:a}=await H.from("lead_sites").select("id, subdomain_slug, site_title, is_active").eq("agent_id",t.id).eq("is_active",!0).maybeSingle();if(a)throw a;return n},enabled:!!t,staleTime:5*60*1e3});return{leadSite:s??null,hasLeadSite:!!s,isLoading:r,siteUrl:s?`https://${s.subdomain_slug}.thelocalmove.com`:null}}const zYe=k.createContext({onlineUsers:[],totalOnline:0}),KPt=async t=>{try{const{data:s}=await H.storage.from("avatars").list(`${t}`);if(s&&s.length>0){const{data:r}=H.storage.from("avatars").getPublicUrl(`${t}/${s[0].name}`);return r.publicUrl}}catch{}},ZPt=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Ds(),[a,o]=k.useState([]),[l,i]=k.useState(null);k.useEffect(()=>{if(!s)return;const u=H.channel("app-presence",{config:{presence:{key:s.id}}});return u.on("presence",{event:"sync"},()=>{const p=u.presenceState(),f=[];Object.entries(p).forEach(([g,b])=>{if(b&&b.length>0){const _=b[0];f.push({id:g,name:_.name||"Unknown",avatarUrl:_.avatarUrl,brokerageId:_.brokerageId,onlineSince:_.onlineSince})}}),o(f)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var f;if(p==="SUBSCRIBED"){const{data:g}=await H.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),b=await KPt(s.id);await u.track({name:(g==null?void 0:g.name)||((f=s.email)==null?void 0:f.split("@")[0])||"User",avatarUrl:b,brokerageId:g==null?void 0:g.brokerage_id,onlineSince:new Date().toISOString()})}}),i(u),()=>{u.unsubscribe()}},[s]);const c=a.filter(u=>u.id===(s==null?void 0:s.id)?!1:!!(n||r&&u.brokerageId===r||!r&&!u.brokerageId));return e.jsx(zYe.Provider,{value:{onlineUsers:c,totalOnline:a.length},children:t})},BYe=()=>k.useContext(zYe),mIe="dashboard-sidebar-collapsed",Ms=({children:t,title:s})=>{var pt;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Ds(),{isAssistant:i,actingAsAgent:c,hasPermission:u}=Z2e(),{isImpersonating:p}=Ide(),g=(i&&!!c?40:0)+(p?40:0),{avatarUrl:b}=FZe(r==null?void 0:r.id),{isTrial:_,isExpired:j,expiresAt:w}=a6t(r==null?void 0:r.id),{isMarketplaceEnabled:N}=BZe(),{currentBrief:S,shouldShowPopup:M,hasUnseenBrief:L,openBrief:I,closeBrief:O,dismissBrief:q}=LPt(),{unreadCount:U}=i6t(),{openCount:B}=o6t(),{data:V}=$x(),Y=!!V,ee=_ue(fe=>fe.cartItems).reduce((fe,qe)=>fe+qe.quantity,0),{leadSite:X,hasLeadSite:ie,siteUrl:re}=rE(),oe=fr(),ce=id(),[ge,ye]=k.useState(null);k.useEffect(()=>{r!=null&&r.id&&H.from("profiles").select("name").eq("id",r.id).single().then(({data:fe})=>{fe!=null&&fe.name&&ye(fe.name)})},[r==null?void 0:r.id]);const ue=ge||((pt=r==null?void 0:r.user_metadata)==null?void 0:pt.name)||(r==null?void 0:r.email)||"User",[pe,_e]=k.useState(()=>typeof window<"u"?localStorage.getItem(mIe)==="true":!1);k.useEffect(()=>{localStorage.setItem(mIe,String(pe))},[pe]);const[$e,Ae]=k.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,website:!0,help:!1}),Ie=fe=>{Ae(qe=>({...qe,[fe]:!qe[fe]}))},Ce=fe=>fe.split(" ").map(qe=>qe[0]).join("").toUpperCase().slice(0,2),xe=fe=>ce.pathname===fe,we=fe=>fe.some(qe=>ce.pathname===qe),Le=({path:fe,icon:qe,label:at,badgeCount:et})=>{const Me=e.jsxs(K,{variant:"ghost",size:"sm",className:It("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",xe(fe)&&"bg-sidebar-accent text-sidebar-accent-foreground",pe?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>oe(fe),children:[e.jsxs("div",{className:"relative",children:[e.jsx(qe,{className:"h-4 w-4 shrink-0"}),pe&&et!=null&&et>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!pe&&at,!pe&&et!=null&&et>0&&e.jsx("span",{className:"ml-auto flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:et>9?"9+":et})]});return pe?e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:Me}),e.jsxs(Xl,{side:"right",className:"flex items-center gap-2",children:[at,et!=null&&et>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:et>9?"9+":et})]})]}):Me},tt=({id:fe,label:qe,icon:at,children:et,activePaths:Me,showBetaBadge:rt,defaultPath:He,badgeCount:ct})=>{if(pe){const Ue=He||Me[0];return e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:It("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",we(Me)&&"text-primary"),onClick:()=>oe(Ue),children:e.jsxs("div",{className:"relative",children:[e.jsx(at,{className:"h-4 w-4"}),ct!=null&&ct>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]})})}),e.jsxs(Xl,{side:"right",className:"flex items-center gap-2",children:[qe,rt&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600",children:"Beta"}),ct!=null&&ct>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:ct>9?"9+":ct})]})]})}return e.jsxs(yf,{open:$e[fe],onOpenChange:()=>Ie(fe),children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we(Me)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(at,{className:"h-4 w-4"}),qe,rt&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[ct!=null&&ct>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:ct>9?"9+":ct}),e.jsx(Eo,{className:It("h-4 w-4 transition-transform duration-200",$e[fe]&&"rotate-180")})]})]})}),e.jsx(bf,{className:"pl-4 space-y-1 mt-1",children:et})]})},Te=({isMobile:fe=!1})=>{const qe=fe?!1:pe;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:It("p-3 border-b border-sidebar-border",qe?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[qe?e.jsx("img",{src:f6t,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:p6t,alt:"LevelUp",className:"h-8 w-auto"}),!fe&&e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>_e(!qe),children:e.jsx(cl,{className:It("h-4 w-4 transition-transform duration-300",qe&&"rotate-180")})})}),e.jsx(Xl,{side:"right",children:qe?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Gi,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:It("p-3 space-y-1",qe&&"flex flex-col items-center"),children:[e.jsx(Le,{path:"/dashboard",icon:nS,label:"Dashboard"}),e.jsx(Le,{path:"/apps",icon:ax,label:"Apps & Tools"}),pe?e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/levelup-u"),children:[e.jsx(Kh,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full bg-primary animate-pulse"})]})}),e.jsxs(Xl,{side:"right",className:"flex items-center gap-2",children:["LevelUp U",e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1 py-0.5",children:"New"})]})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/levelup-u"),children:[e.jsx(Kh,{className:"h-4 w-4 shrink-0"}),"LevelUp U",e.jsx("span",{className:"ml-auto text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1.5 py-0.5",children:"New"})]}),e.jsx(Le,{path:"/events",icon:Od,label:"Events"}),e.jsxs(tt,{id:"agentos",label:"Agent OS",icon:SM,activePaths:["/mission-control","/mission-control/contacts","/mission-control/plans","/mission-control/popbys","/mission-control/video-library","/mission-control/scorecard","/mission-control/listings","/mission-control/pipeline","/mission-control/tasks","/mission-control/smart-drips","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"],showBetaBadge:!0,defaultPath:"/mission-control",children:[u("contacts")&&e.jsx(Le,{path:"/mission-control",icon:ni,label:"Mission Control"}),u("contacts")&&!qe&&e.jsxs(yf,{open:$e.contacts,onOpenChange:()=>Ie("contacts"),children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we(["/mission-control/contacts","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"])&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(Eo,{className:It("h-3.5 w-3.5 transition-transform duration-200",$e.contacts&&"rotate-180")})]})}),e.jsxs(bf,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Le,{path:"/mission-control/contacts",icon:pr,label:"All Contacts"}),e.jsx(Le,{path:"/mission-control/relationship-scorecard",icon:kh,label:"Relationship Report"}),e.jsx(Le,{path:"/mission-control/sphere-gaps",icon:CL,label:"Sphere Gaps"}),e.jsx(Le,{path:"/mission-control/connect-page",icon:dl,label:"Connect Page"})]})]}),u("contacts")&&qe&&e.jsx(Le,{path:"/mission-control/contacts",icon:pr,label:"Contacts"}),u("contacts")&&e.jsx(Le,{path:"/mission-control/plans",icon:Od,label:"TouchPlans"}),u("pipeline")&&e.jsx(Le,{path:"/mission-control/pipeline",icon:m0,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Le,{path:"/mission-control/tasks",icon:$v,label:"Tasks"}),u("popbys")&&e.jsx(Le,{path:"/mission-control/popbys",icon:ko,label:"Popbys"}),u("videos")&&e.jsx(Le,{path:"/mission-control/video-library",icon:An,label:"Video Library"}),u("scorecard")&&e.jsx(Le,{path:"/mission-control/scorecard",icon:No,label:"Scorecard"}),u("listings")&&e.jsx(Le,{path:"/mission-control/listings",icon:ka,label:"Listing Exchange"}),!qe&&e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/mission-control/smart-drips"),children:[e.jsx(Zh,{className:"h-4 w-4"}),"Smart Drips",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),qe&&e.jsx(Le,{path:"/mission-control/smart-drips",icon:Zh,label:"Smart Drips"})]}),ie&&X&&e.jsxs(tt,{id:"website",label:"My Website",icon:su,activePaths:[`/admin/lead-sites/${X.id}/edit`],defaultPath:`/admin/lead-sites/${X.id}/edit`,children:[qe?e.jsxs(bc,{delayDuration:0,children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(re||"#","_blank"),children:e.jsx(Ln,{className:"h-4 w-4"})})}),e.jsx(Xl,{side:"right",children:"View Site"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(re||"#","_blank"),children:[e.jsx(Ln,{className:"h-4 w-4"}),"View Site",e.jsx(tn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsx(Le,{path:`/my-website/${X.id}/edit`,icon:Ra,label:"Edit Website"}),e.jsx(Le,{path:"/my-website/mls-listings",icon:bn,label:"MLS Listings"}),e.jsx(Le,{path:"/my-website/market-report",icon:No,label:"Market Reports"}),e.jsx(Le,{path:"/mission-control/website-activity",icon:kh,label:"Website Activity"}),e.jsx(Le,{path:"/m",icon:v0,label:"Mobile Command"})]}),e.jsxs(tt,{id:"marketing",label:"Marketing",icon:Ah,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Le,{path:"/templates",icon:ic,label:"Templates"}),e.jsx(Le,{path:"/social-swag-2",icon:v0,label:"Social Swag"}),e.jsx(Le,{path:"/newsletters",icon:d1,label:"Newsletters"})]}),e.jsxs(tt,{id:"learning",label:"Learning",icon:Sh,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Le,{path:"/academy",icon:Kh,label:"Academy"}),e.jsx(Le,{path:"/toolbox",icon:ty,label:"Toolbox"})]}),e.jsxs(tt,{id:"community",label:"Community",icon:so,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:U,children:[e.jsx(Le,{path:"/community",icon:pr,label:"Community",badgeCount:U}),e.jsx(Le,{path:"/wishlist",icon:q_,label:"Wishlist",badgeCount:B}),!qe&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open("https://www.facebook.com/share/g/1CC6thti2V/","_blank"),children:[e.jsx(tn,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(tt,{id:"goods",label:"The Goods",icon:vp,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[N&&!qe&&e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ce.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/marketplace"),children:[e.jsx(vp,{className:"h-4 w-4"}),"Marketplace",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-primary text-primary-foreground",children:"New"})]}),N&&qe&&e.jsx(Le,{path:"/marketplace",icon:vp,label:"Marketplace"}),e.jsx(Le,{path:"/reward-store",icon:xo,label:"Reward Store"})]}),e.jsxs(tt,{id:"help",label:"Help & Services",icon:Rv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Le,{path:"/support",icon:OM,label:"Support"}),e.jsx(Le,{path:"/additional-services",icon:pn,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!qe&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Admin"})}),qe?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Le,{path:"/admin",icon:Th,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ce.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/admin"),children:[e.jsx(Th,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!qe&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"My Brokerage"})}),qe?e.jsxs("div",{className:"border-t border-sidebar-border mt-3 pt-3 space-y-1",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{path:"/my-brokerage",icon:ka,label:"My Brokerage"}),e.jsx(Le,{path:"/brokerage-content",icon:Sh,label:"Brokerage Content"})]}),Y&&!o&&e.jsx(Le,{path:"/my-team",icon:pr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{path:"/brokerage/dashboard",icon:Xo,label:"Manage Brokerages"}),e.jsx(Le,{path:"/brokerage/teams",icon:pr,label:"Teams"}),e.jsx(Le,{path:"/brokerage/recruiting",icon:Ah,label:"Recruiting"}),e.jsx(Le,{path:"/brokerage-resources",icon:Gh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/my-brokerage"),children:[e.jsx(ka,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage-content"),children:[e.jsx(Sh,{className:"h-4 w-4"}),"Brokerage Content"]})]}),Y&&!o&&e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/my-team"),children:[e.jsx(pr,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/dashboard"),children:[e.jsx(Xo,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/teams"),children:[e.jsx(pr,{className:"h-4 w-4"}),"Teams",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"New"})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/brokerage/recruiting")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/recruiting"),children:[e.jsx(Ah,{className:"h-4 w-4"}),"Recruiting"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage-resources"),children:[e.jsx(Gh,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",xe("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/profile"),children:[e.jsx(to,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:n,children:[e.jsx(oS,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(ZPt,{children:e.jsx(B1,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[_&&j&&e.jsx(gPt,{}),typeof document<"u"&&yp.createPortal(e.jsx("aside",{className:It("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",pe?"w-16":"w-56"),style:{top:`${g}px`,height:`calc(100vh - ${g}px)`},children:e.jsx(Te,{})}),document.body),e.jsxs("div",{className:It("flex-1 flex flex-col overflow-hidden transition-all duration-300",pe?"md:ml-16":"md:ml-56"),style:{height:`calc(100vh - ${g}px)`,marginTop:`${g}px`},children:[e.jsx("header",{className:"sticky top-0 z-40 bg-card border-b border-border flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between px-6 py-3",children:[e.jsxs(eE,{children:[e.jsx(rNe,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(RM,{className:"h-5 w-5"})})}),e.jsx(vC,{side:"left",className:"w-56 p-0 bg-card",children:e.jsx(Te,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:x6t,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(dIe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[_&&!j&&w&&e.jsx(xPt,{expiresAt:w,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(dIe,{})}),S&&e.jsx(yPt,{hasUnseenBrief:L,onClick:I}),N&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>oe("/marketplace/cart"),children:[e.jsx(vp,{className:"h-5 w-5"}),ee>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-5 w-5 rounded-full bg-primary text-primary-foreground text-xs font-medium flex items-center justify-center",children:ee>99?"99+":ee})]}),e.jsx(q6t,{}),e.jsx(f1e,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",ue.split(" ")[0],"!"]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx("button",{className:"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-full",children:e.jsxs(Nn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx($a,{src:b||void 0}),e.jsx(kn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Ce(ue)})]})})}),e.jsxs(Bd,{align:"end",className:"w-48",children:[e.jsxs(Ma,{onClick:()=>oe("/profile"),className:"cursor-pointer",children:[e.jsx(to,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Ma,{onClick:()=>oe("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(bL,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(uw,{}),e.jsxs(Ma,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(oS,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(OPt,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),S&&e.jsx(IPt,{brief:S,open:M,onClose:O,onDismiss:q}),e.jsx(DPt,{}),e.jsx(FPt,{}),e.jsx(BPt,{})]})]})})})},YPt=()=>{const{user:t}=Ds(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(""),i=async f=>{var g;if(!(t!=null&&t.email)){me.error("Please sign in to upgrade");return}r(!0),a(f);try{const{data:b,error:_}=await H.functions.invoke("create-checkout",{body:{tier:f,email:t.email,name:((g=t.user_metadata)==null?void 0:g.full_name)||t.email,couponCode:o.trim()||void 0,skipTrial:!0}});if(_)throw _;if(b!=null&&b.url)window.open(b.url,"_blank","noopener,noreferrer"),me.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(b){console.error("Checkout error:",b),me.error(b.message||"Failed to start checkout. Please try again.")}finally{r(!1),a(null)}},c=["Unlimited access to all marketing templates","Complete Academy training library","AI-powered tools and resources","Community forums and support","Exclusive member events and workshops","Deal pipeline & scorecard tracking","Listing exchange access","Social media content library"],u=["Everything in Individual plan","Up to 25 agent seats","Brokerage admin dashboard","Team performance analytics","Custom branding options","Priority support","Agent onboarding tools","Brokerage-wide announcements"],p=["Everything in Brokerage plan","Unlimited agent seats","Dedicated account manager","Advanced analytics & reporting","White-label options","API access","Custom integrations","Enterprise-level support"];return e.jsx(Ms,{children:e.jsxs("div",{className:"container max-w-6xl py-8 px-4",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Upgrade Your Membership"}),e.jsx("p",{className:"text-muted-foreground text-lg",children:"Choose the plan that's right for you and unlock the full power of LevelUp"})]}),e.jsxs("div",{className:"max-w-md mx-auto mb-8",children:[e.jsx(be,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(ze,{id:"coupon",placeholder:"Enter discount code",value:o,onChange:f=>l(f.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-8",children:[e.jsxs(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 bg-primary text-primary-foreground text-xs px-3 py-1 rounded-bl-lg font-medium",children:"Popular"}),e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(pr,{className:"h-7 w-7 text-primary"})}),e.jsx(Rt,{className:"text-xl",children:"Individual Agent"}),e.jsx(gr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-primary",children:"$39"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:c.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(va,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(K,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(pn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(ka,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Rt,{className:"text-xl",children:"Brokerage"}),e.jsx(gr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-amber-600",children:"$299"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:u.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(va,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",size:"lg",onClick:()=>i("brokerage_under_25"),disabled:s,children:[s&&n==="brokerage_under_25"?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-purple-500/10 flex items-center justify-center",children:e.jsx(ka,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Rt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(gr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-purple-600",children:"$499"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:p.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(va,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(K,{variant:"outline",className:"w-full border-purple-500 text-purple-600 hover:bg-purple-50",size:"lg",onClick:()=>i("brokerage_over_25"),disabled:s,children:[s&&n==="brokerage_over_25"?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ka,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsxs(Oe,{className:"py-6",children:[e.jsx("p",{className:"text-center font-medium mb-4",children:"Questions? We're here to help!"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{children:"1-866-527-8668"})]}),e.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},XPt=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Ds(),a=fr(),[o,l]=k.useState(""),[i,c]=k.useState(!1),[u,p]=k.useState(!1);k.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),k.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const f=async()=>{if(!o.trim()){me.error("Please enter a brokerage name");return}const{data:g}=await H.auth.getSession(),b=g.session;if(!t||!b){me.error("Please sign in again to create your brokerage."),a("/auth");return}c(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!b,userId:t==null?void 0:t.id});const{data:_,error:j}=await H.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:_,error:j}),j)throw j;if(!(_!=null&&_.ok))throw new Error((_==null?void 0:_.error)||"Failed to create brokerage");c(!1),p(!0),me.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(_){console.error("Error creating brokerage:",_),me.error(_.message||"Failed to create brokerage"),c(!1)}};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ws,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Rt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(gr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(xi,{className:"w-5 h-5 text-green-500"}),e.jsx("span",{children:"Brokerage created"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(ws,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{children:"Assigning you as manager..."})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground mt-4",children:"You'll be redirected to complete your profile setup in a moment."})]})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ka,{className:"w-10 h-10 text-primary"})}),e.jsx(Rt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(gr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(ze,{id:"brokerage-name",placeholder:"Enter your brokerage name",value:o,onChange:g=>l(g.target.value),onKeyDown:g=>g.key==="Enter"&&f()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is how your brokerage will appear to your agents"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50 space-y-3",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(pr,{className:"w-4 h-4 text-primary"}),"What you can do as a Brokerage Manager:"]}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"w-4 h-4 text-green-500"}),"Invite agents to join your brokerage"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"w-4 h-4 text-green-500"}),"Track your team's activity and engagement"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(K,{onClick:f,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(Qa,{className:"w-4 h-4 ml-2"})]})]})]})})},pIe=()=>{const t=fr(),[s,r]=k.useState("verifying"),[n,a]=k.useState("");k.useEffect(()=>{(async()=>{try{const{data:{session:i},error:c}=await H.auth.getSession();if(c)throw c;if(i!=null&&i.user){const{data:u}=await H.from("profiles").select("login_count").eq("id",i.user.id).single();if(((u==null?void 0:u.login_count)||0)>1){console.log("Account already claimed, redirecting to dashboard"),r("already_claimed");return}console.log("User logged in successfully:",i.user.email),r("success");try{await H.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{t("/profile?setup=true")},1500)}else setTimeout(()=>{r("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),r("already_claimed")}})()},[t]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"space-y-1 text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:[s==="verifying"&&e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),s==="success"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),s==="already_claimed"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),s==="error"&&e.jsx("svg",{className:"h-8 w-8 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]}),e.jsxs(Rt,{className:"text-2xl",children:[s==="verifying"&&"Claiming Your Account...",s==="success"&&"Account Claimed!",s==="already_claimed"&&"Account Already Claimed",s==="error"&&"Claim Failed"]}),e.jsxs(gr,{children:[s==="verifying"&&"Please wait while we verify your account...",s==="success"&&"Redirecting you to complete your profile...",s==="already_claimed"&&"This account has already been set up. Please log in to access your dashboard.",s==="error"&&n]})]}),(s==="already_claimed"||s==="error")&&e.jsx(Oe,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},QPt=()=>{const t=fr(),[s]=Cc(),[r,n]=k.useState(s.get("code")||""),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState(""),[p,f]=k.useState(!1),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(!1),[S,M]=k.useState(null),[L,I]=k.useState(null),[O,q]=k.useState(null),[U,B]=k.useState(null);k.useEffect(()=>{const ee=s.get("code");ee&&(n(ee),V(ee))},[s]);const V=async ee=>{j(!0);const{data:X,error:ie}=await H.from("invite_codes").select("id, code, max_uses, uses_count, expires_at, is_active, brokerage_id, trial_days").eq("code",ee.toUpperCase().trim()).single();if(ie||!X){me.error("Invalid invite code"),j(!1);return}if(!X.is_active){me.error("This invite code is no longer active"),j(!1);return}if(X.max_uses&&X.uses_count>=X.max_uses){me.error("This invite code has reached its maximum uses"),j(!1);return}if(X.expires_at&&new Date(X.expires_at){ee.preventDefault(),V(r)},Q=async ee=>{var X;if(ee.preventDefault(),!c.trim()){me.error("Please enter your name");return}if(l.length<6){me.error("Password must be at least 6 characters");return}b(!0);try{const ie=`${window.location.origin}/`,{data:re,error:oe}=await H.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:ie,data:{name:c.trim()}}});if(oe){oe.message.includes("already registered")?me.error("This email is already registered. Please sign in instead."):me.error(oe.message);return}re.user&&(await H.rpc("add_default_signup_tag",{user_id:re.user.id}),L?await H.functions.invoke("assign-brokerage",{body:{userId:re.user.id,brokerageId:L}}):U?await H.functions.invoke("assign-brokerage",{body:{userId:re.user.id,trialDays:U}}):await H.functions.invoke("assign-brokerage",{body:{userId:re.user.id,grandfathered:!0}}),S&&await H.from("invite_codes").update({uses_count:((X=(await H.from("invite_codes").select("uses_count").eq("id",S).single()).data)==null?void 0:X.uses_count)+1}).eq("id",S),me.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(ie){console.error("Signup error:",ie),me.error("An unexpected error occurred")}finally{b(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx(Rt,{className:"text-2xl font-bold text-primary",children:O?`Join ${O}`:"Join LevelUp"}),e.jsx(gr,{children:w?O?`Create your account to join ${O}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Oe,{children:w?e.jsxs("form",{onSubmit:Q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Full Name"}),e.jsx(ze,{id:"name",type:"text",placeholder:"John Doe",value:c,onChange:ee=>u(ee.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:ee=>o(ee.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{id:"password",type:p?"text":"password",placeholder:"••••••••",value:l,onChange:ee=>i(ee.target.value),required:!0,minLength:6}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>f(!p),children:p?e.jsx(kp,{className:"h-4 w-4"}):e.jsx(Ln,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(ze,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:ee=>n(ee.target.value),required:!0,autoFocus:!0})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},JPt="/assets/testimonial-avatar-1-BsCQFauB.jpg",eIt="/assets/testimonial-avatar-2-B6VPVc2t.jpg",tIt="/assets/testimonial-avatar-3-GuEFwYUE.jpg",sIt="/assets/testimonial-avatar-4-98iKMtkB.jpg",rIt="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",nIt=[JPt,eIt,tIt,sIt,rIt],aIt=yC({name:gc().trim().min(2,"Name must be at least 2 characters").max(100),email:gc().trim().email("Please enter a valid email address").max(255),phone:gc().trim().min(10,"Please enter a valid phone number").max(20).optional().or(Aoe("")),brokerage:gc().trim().max(200).optional().or(Aoe(""))}),iIt=[{icon:pp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:ic,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:hn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:$c,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Sn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:ko,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],oIt=[{icon:pr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:pn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Un,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ch,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:ma,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:No,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:ni,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Zh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],lIt=[{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."}],cIt=()=>{const t=fr(),[s,r]=k.useState(!1),[n,a]=k.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=k.useState({}),i=async c=>{var p,f;c.preventDefault(),l({});const u=aIt.safeParse(n);if(!u.success){const g={};u.error.errors.forEach(b=>{b.path[0]&&(g[b.path[0]]=b.message)}),l(g);return}r(!0);try{const{data:g,error:b}=await H.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((p=n.phone)==null?void 0:p.trim())||void 0,brokerage:((f=n.brokerage)==null?void 0:f.trim())||void 0}});if(b){console.error("Trial signup error:",b),me.error(b.message||"Something went wrong. Please try again.");return}if(g!=null&&g.error){me.error(g.error);return}me.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(g){console.error("Trial signup error:",g),me.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsx("title",{children:"Start Your Free 7-Day Trial | LevelUp Dashboard"}),e.jsx("meta",{name:"description",content:"Take LevelUp for a free 7-day test drive. No credit card required. The all-in-one platform for real estate agents and brokerages."}),e.jsx("meta",{property:"og:title",content:"Start Your Free 7-Day Trial | LevelUp"}),e.jsx("meta",{property:"og:description",content:"Take LevelUp for a free 7-day test drive. No credit card required."}),e.jsx("meta",{property:"og:type",content:"website"})]}),e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:qoe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var c;return(c=document.getElementById("features"))==null?void 0:c.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-8 text-center lg:text-left",children:[e.jsx("div",{className:"flex justify-center lg:justify-start",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-24 md:h-32 drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium",children:[e.jsx(pn,{className:"h-4 w-4 text-yellow-400"}),e.jsx("span",{children:"7-Day Free Trial • No Credit Card Required"})]}),e.jsxs("h1",{className:"text-3xl md:text-4xl lg:text-5xl font-bold text-white leading-tight font-sans",children:["Take LevelUp for a"," ",e.jsx("span",{className:"italic",children:"Free Test Drive"})]}),e.jsxs("p",{className:"text-lg md:text-xl text-white/80 max-w-xl mx-auto lg:mx-0 font-sans",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center lg:justify-start",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[e.jsx(sa,{className:"h-5 w-5 text-green-400"}),e.jsx("span",{children:"No credit card required"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[e.jsx(sa,{className:"h-5 w-5 text-green-400"}),e.jsx("span",{children:"Full access to all features"})]})]}),e.jsxs("div",{className:"flex items-center gap-4 justify-center lg:justify-start pt-4",children:[e.jsx("div",{className:"flex -space-x-3",children:nIt.map((c,u)=>e.jsx("img",{src:c,alt:`Agent ${u+1}`,className:"w-10 h-10 rounded-full border-2 border-white/20 object-cover"},u))}),e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(c=>e.jsx(Jn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},c))}),e.jsx("p",{className:"text-sm text-white/60",children:"Trusted by 3,000+ agents"})]})]})]}),e.jsx("div",{className:"lg:pl-8",children:e.jsx(Ee,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-[#4a6b6d] mb-4",children:e.jsx(x0,{className:"h-8 w-8 text-white"})}),e.jsx("h2",{className:"text-2xl font-bold text-foreground font-sans",children:"Start Your Free Trial"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Get instant access • No credit card needed"})]}),e.jsxs("form",{onSubmit:i,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Full Name *"}),e.jsx(ze,{id:"name",type:"text",placeholder:"John Smith",value:n.name,onChange:c=>a({...n,name:c.target.value}),required:!0}),o.name&&e.jsx("p",{className:"text-sm text-destructive",children:o.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email Address *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"john@example.com",value:n.email,onChange:c=>a({...n,email:c.target.value}),required:!0}),o.email&&e.jsx("p",{className:"text-sm text-destructive",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"phone",children:"Phone Number"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:c=>a({...n,phone:c.target.value})}),o.phone&&e.jsx("p",{className:"text-sm text-destructive",children:o.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(ze,{id:"brokerage",type:"text",placeholder:"Your brokerage or team name",value:n.brokerage,onChange:c=>a({...n,brokerage:c.target.value})}),o.brokerage&&e.jsx("p",{className:"text-sm text-destructive",children:o.brokerage})]}),e.jsx(K,{type:"submit",className:"w-full h-12 text-lg font-semibold bg-[#4a6b6d] hover:bg-[#3d5a5c]",disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(Qa,{className:"ml-2 h-5 w-5"})]})}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["By signing up, you agree to our"," ",e.jsx("a",{href:"/terms-of-service",className:"text-[#4a6b6d] hover:underline",children:"Terms"})," ","and"," ",e.jsx("a",{href:"/privacy-policy",className:"text-[#4a6b6d] hover:underline",children:"Privacy Policy"})]})]})]})})})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."})]})})}),e.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:iIt.map((c,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Pt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(c.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Rt,{className:"text-xl font-sans",children:c.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:c.description})})]},u))})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(pn,{className:"w-4 h-4"}),"Included with Your Trial"]}),e.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",e.jsx("span",{className:"italic",children:"Agent OS"})]}),e.jsx("p",{className:"text-lg text-white/80",children:"Your relationship-first operating system. Never forget a follow-up, track every touchpoint, and turn your sphere into a referral machine."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:oIt.map((c,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx(c.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Rt,{className:"text-lg font-semibold text-white",children:c.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:c.description})})]},u))})]})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 font-sans",children:"Loved by Top Producers"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what agents are saying about LevelUp"})]}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:lIt.map((c,u)=>e.jsx(Ee,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>e.jsx(Jn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},p))}),e.jsxs("p",{className:"text-muted-foreground mb-4 italic",children:['"',c.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:c.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.role})]})]})},u))})]})}),e.jsx("section",{className:"py-16 bg-muted/30",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-wrap justify-center gap-8 md:gap-16",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(th,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Secure & Private"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Bank-level encryption"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Zh,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Fast Setup"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Start in 2 minutes"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(pr,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Expert Support"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Real estate pros"})]})]})]})})}),e.jsx("section",{id:"free-trial",className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs(Ee,{className:"bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] border-0 shadow-2xl overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs(Oe,{className:"p-12 text-center relative",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-4 font-sans",children:"Ready to Level Up Your Business?"}),e.jsx("p",{className:"text-xl text-white/80 mb-8 max-w-2xl mx-auto",children:"Join thousands of successful agents. Start your free 7-day trial today."}),e.jsxs(K,{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),size:"lg",className:"h-14 px-8 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 rounded-full",children:["Start Your Free Trial Now",e.jsx(Qa,{className:"ml-2 h-5 w-5"})]})]})]})})}),e.jsx("footer",{className:"bg-[#1e3a4c] py-12",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-6",children:[e.jsx("img",{src:cje,alt:"LevelUp",className:"h-8"}),e.jsxs("div",{className:"flex gap-6 text-sm text-white/60",children:[e.jsx("a",{href:"/privacy-policy",className:"hover:text-white transition-colors",children:"Privacy Policy"}),e.jsx("a",{href:"/terms-of-service",className:"hover:text-white transition-colors",children:"Terms of Service"})]}),e.jsx("p",{className:"text-sm text-white/40",children:"© 2025 LevelUp Consulting Group. All rights reserved."})]})})})]})]})},dIt=()=>{const t=fr();return e.jsxs(e.Fragment,{children:[e.jsx(Sc,{children:e.jsx("title",{children:"Welcome to LevelUp! | Check Your Email"})}),e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:qoe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})}),e.jsxs("section",{className:"relative pt-24 pb-12 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden flex-1 flex items-center",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(Ee,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8 md:p-12 text-center",children:[e.jsxs("div",{className:"relative inline-block mb-8",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] flex items-center justify-center",children:e.jsx(sa,{className:"h-12 w-12 text-white"})}),e.jsx("div",{className:"absolute -top-2 -right-2 w-10 h-10 rounded-full bg-yellow-500 flex items-center justify-center animate-bounce",children:e.jsx(ru,{className:"h-5 w-5 text-white"})})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4 font-sans",children:"You're In! 🎉"}),e.jsx("p",{className:"text-xl text-muted-foreground mb-8",children:"Your 7-day LevelUp adventure starts now!"}),e.jsxs("div",{className:"bg-[#4a6b6d]/10 rounded-xl p-6 mb-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(cr,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Check Your Inbox"})]}),e.jsx("p",{className:"text-muted-foreground",children:"We just sent you a magic link to claim your account and set up your password. Click the link in your email to get started!"})]}),e.jsxs("div",{className:"text-left space-y-3 mb-8",children:[e.jsx("p",{className:"text-sm text-muted-foreground font-medium uppercase tracking-wide",children:"What happens next:"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"1"})}),e.jsx("p",{className:"text-foreground",children:"Check your email for the welcome message"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"2"})}),e.jsx("p",{className:"text-foreground",children:'Click "Claim Your Account" to set your password'})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"3"})}),e.jsx("p",{className:"text-foreground",children:"Start exploring all the features!"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Didn't receive the email? Check your spam folder or"," ",e.jsx("button",{onClick:()=>t("/trial"),className:"text-[#4a6b6d] hover:underline font-medium",children:"try again"})]}),e.jsxs(K,{onClick:()=>t("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",e.jsx(Qa,{className:"ml-2 h-4 w-4"})]})]})})})})]}),e.jsx("footer",{className:"bg-[#1e3a4c] py-8",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4",children:[e.jsx("img",{src:cje,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},uIt=yC({viewerName:gc().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:gc().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:gc().max(20,"Phone must be less than 20 characters").optional(),message:gc().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function hIt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(null),u=pue({resolver:fue(uIt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async f=>{a(!0),c(null);try{const{data:g,error:b}=await H.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:f.viewerName,viewerEmail:f.viewerEmail,viewerPhone:f.viewerPhone||void 0,message:f.message}});if(b)throw new Error(b.message);if(!(g!=null&&g.success))throw new Error((g==null?void 0:g.error)||"Failed to send reply");l(!0)}catch(g){console.error("Failed to submit reply:",g),c(g.message||"Something went wrong. Please try again.")}finally{a(!1)}};return o?e.jsx(Ee,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(Oe,{className:"py-8 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/20 mb-4",children:e.jsx(sa,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:"Message Sent!"}),e.jsxs("p",{className:"text-muted-foreground",children:[s?`${s} will`:"They'll"," get back to you soon."]})]})}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx($c,{className:"h-5 w-5 text-primary"}),e.jsx(Rt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(gr,{children:r?`Have a question or want to connect? Send ${s||"them"} a message.`:`Interested? Share your info and ${s||"your agent"} will be in touch.`})]}),e.jsx(Oe,{children:e.jsx(xue,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(p),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Zc,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Your Name *"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"John Smith",...f})}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Email *"}),e.jsx(Oc,{children:e.jsx(ze,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(Sm,{})]})})]}),!r&&e.jsx(Zc,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Phone (optional)"}),e.jsx(Oc,{children:e.jsx(ze,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:u.control,name:"message",render:({field:f})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Message *"}),e.jsx(Oc,{children:e.jsx(Er,{placeholder:r?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...f})}),e.jsx(Sm,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(K,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const mIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsxs("div",{className:"absolute inset-0 opacity-[0.08]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[16%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[32%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[48%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[64%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[80%] left-0 right-0 h-[8%] bg-red-600"})]}),e.jsx("div",{className:"absolute top-0 left-0 w-[35%] h-[45%] bg-blue-900/10 rounded-br-3xl"}),e.jsx(Jn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(Jn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(Jn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(Jn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(Jn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(i1,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),pIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-500/5 via-transparent to-blue-500/5"}),e.jsxs("div",{className:"absolute top-[10%] left-[15%] w-32 h-32",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-red-400/20 animate-ping",style:{animationDuration:"3s"}}),e.jsx(pn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 text-red-400/40"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[20%] w-24 h-24",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-400/20 animate-ping",style:{animationDuration:"4s",animationDelay:"1s"}}),e.jsx(Jn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6 text-blue-400/40 fill-blue-400/20"})]}),e.jsxs("div",{className:"absolute top-[20%] left-[50%] w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border border-white/10 animate-ping",style:{animationDuration:"3.5s",animationDelay:"0.5s"}}),e.jsx(pn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-5 h-5 text-amber-400/40"})]}),e.jsx(Jn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(Jn,{className:"absolute bottom-[15%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse",style:{animationDelay:"0.5s"}}),e.jsx(i1,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),fIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-200/20 via-rose-100/10 to-purple-200/15"}),e.jsx("div",{className:"absolute top-[5%] left-[5%] opacity-20",children:e.jsx(Wg,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Wg,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Wg,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Wg,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(ni,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(ni,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-300/40 fill-pink-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(ni,{className:"absolute top-[10%] left-[60%] w-4 h-4 text-rose-400/30 fill-rose-400/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx("div",{className:"absolute top-[8%] left-[45%] w-8 h-8 rounded-full bg-pink-300/10 blur-sm"}),e.jsx("div",{className:"absolute bottom-[25%] right-[30%] w-6 h-6 rounded-full bg-rose-300/10 blur-sm"})]}),xIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/5 via-slate-800/3 to-indigo-900/5"}),e.jsx("div",{className:"absolute top-[5%] right-[10%] opacity-15",children:e.jsxs("div",{className:"w-12 h-24 relative",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-10 h-3 bg-blue-600 rounded-full"}),e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-0 h-0 border-l-[20px] border-r-[20px] border-t-[60px] border-l-transparent border-r-transparent border-t-blue-500"})]})}),e.jsx(Nc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Jn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(Nc,{className:"absolute bottom-[20%] right-[8%] w-14 h-14 text-indigo-500/12"}),e.jsx("div",{className:"absolute top-[3%] left-[40%] opacity-12",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tr-none rotate-6"}),e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tl-none -rotate-6"})]})}),e.jsx(Jn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(Jn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),gIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-100/20 via-purple-100/15 to-sky-100/20"}),e.jsx("div",{className:"absolute top-[5%] left-[8%] w-12 h-16 rounded-full bg-gradient-to-b from-pink-300/25 to-pink-400/18 rotate-12"}),e.jsx("div",{className:"absolute top-[8%] right-[12%] w-10 h-14 rounded-full bg-gradient-to-b from-purple-300/25 to-purple-400/18 -rotate-6"}),e.jsx("div",{className:"absolute bottom-[18%] left-[15%] w-11 h-15 rounded-full bg-gradient-to-b from-sky-300/20 to-sky-400/12 rotate-6"}),e.jsx("div",{className:"absolute bottom-[22%] right-[10%] w-12 h-16 rounded-full bg-gradient-to-b from-yellow-300/20 to-yellow-400/12 -rotate-12"}),e.jsx("div",{className:"absolute top-[10%] left-[10%] w-6 h-1 bg-white/30 rounded-full rotate-12"}),e.jsx("div",{className:"absolute top-[12%] right-[15%] w-5 h-1 bg-white/25 rounded-full -rotate-6"}),e.jsx(Wg,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Wg,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(TM,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),yIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/12 via-purple-900/8 to-slate-900/12"}),e.jsx(tS,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(tS,{className:"absolute top-[10%] right-[12%] w-12 h-12 text-purple-400/20 animate-pulse"}),e.jsxs("div",{className:"absolute bottom-[18%] left-[8%]",children:[e.jsx("div",{className:"w-14 h-12 rounded-full bg-orange-500/20"}),e.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-4 bg-green-600/25 rounded-t-full"})]}),e.jsxs("div",{className:"absolute bottom-[22%] right-[12%]",children:[e.jsx("div",{className:"w-12 h-10 rounded-full bg-orange-400/15"}),e.jsx("div",{className:"absolute -top-1.5 left-1/2 -translate-x-1/2 w-1.5 h-3 bg-green-600/20 rounded-t-full"})]}),e.jsx("div",{className:"absolute top-[15%] left-[40%] opacity-20",children:e.jsx("svg",{viewBox:"0 0 24 12",className:"w-10 h-5 text-slate-800 fill-current",children:e.jsx("path",{d:"M12 6c-2-4-6-6-12-6 4 2 6 4 6 6s-2 4-6 6c6 0 10-2 12-6zm0 0c2-4 6-6 12-6-4 2-6 4-6 6s2 4 6 6c-6 0-10-2-12-6z"})})}),e.jsx(pn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(pn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),vIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-900/8 via-green-900/5 to-emerald-900/8"}),e.jsx(f1,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(f1,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(f1,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(a0,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(a0,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(a0,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(a0,{className:"absolute top-[8%] left-[70%] w-8 h-8 text-blue-200/20 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[12%] left-[10%] w-5 h-5 rounded-full bg-red-500/25"}),e.jsx("div",{className:"absolute top-[15%] right-[15%] w-4 h-4 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"absolute top-[20%] left-[55%] w-4 h-4 rounded-full bg-green-500/20"}),e.jsx(Jn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),bIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/10 via-amber-800/6 to-red-900/10"}),e.jsx("div",{className:"absolute top-[5%] left-[10%] w-10 h-8 rounded-full bg-orange-500/25 rotate-45"}),e.jsx("div",{className:"absolute top-[10%] right-[15%] w-8 h-6 rounded-full bg-red-500/20 -rotate-12"}),e.jsx("div",{className:"absolute top-[15%] left-[35%] w-7 h-5 rounded-full bg-amber-500/22 rotate-30"}),e.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-10 h-7 rounded-full bg-yellow-600/18 -rotate-45"}),e.jsx("div",{className:"absolute bottom-[22%] right-[10%] w-9 h-6 rounded-full bg-orange-600/15 rotate-12"}),e.jsxs("div",{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2",children:[e.jsx("div",{className:"w-16 h-14 rounded-full bg-orange-400/15"}),e.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-5 bg-green-600/18 rounded-t-full"})]}),e.jsx(ni,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(ni,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),_It=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-900/8 via-amber-900/4 to-purple-900/8"}),e.jsx(Jn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(Jn,{className:"absolute top-[8%] right-[12%] w-10 h-10 text-amber-400/30 fill-amber-400/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Jn,{className:"absolute top-[15%] left-[40%] w-7 h-7 text-yellow-300/25 fill-yellow-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Jn,{className:"absolute top-[12%] right-[35%] w-8 h-8 text-amber-300/28 fill-amber-300/18 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[20%] left-[25%] w-4 h-4 rounded-full bg-pink-400/30"}),e.jsx("div",{className:"absolute top-[18%] right-[30%] w-3 h-3 rounded-full bg-sky-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[60%] w-2.5 h-2.5 rounded-full bg-emerald-400/30"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-3 h-3 rounded-full bg-purple-400/30"}),e.jsx(pn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(ru,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(ru,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),wIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsxs("div",{className:"absolute bottom-[12%] left-1/2 -translate-x-1/2 flex items-end gap-3",children:[e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2.5 h-20 bg-blue-500/22 rounded-full"})," ",e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"})]}),e.jsx("div",{className:"absolute bottom-[38%] left-[calc(50%-42px)] w-3 h-4 bg-yellow-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[35%] left-[calc(50%-28px)] w-2.5 h-3 bg-yellow-300/25 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[40%] left-[calc(50%-14px)] w-3 h-4 bg-amber-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[45%] left-1/2 -translate-x-1/2 w-4 h-5 bg-yellow-400/35 rounded-full blur-sm"}),e.jsx(Jn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(pn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(pn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),jIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-green-900/12 via-emerald-900/6 to-teal-900/10"}),e.jsx(Yv,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(Yv,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(Yv,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(Yv,{className:"absolute bottom-[22%] right-[10%] w-11 h-11 text-emerald-400/18"}),e.jsx("div",{className:"absolute top-[15%] left-[35%] w-6 h-6 rounded-full bg-yellow-500/30 border-2 border-yellow-600/25"}),e.jsx("div",{className:"absolute top-[20%] right-[28%] w-5 h-5 rounded-full bg-amber-500/25 border-2 border-amber-600/20"}),e.jsx("div",{className:"absolute bottom-[28%] left-[45%] w-5 h-5 rounded-full bg-yellow-400/25 border-2 border-yellow-500/20"}),e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 opacity-12 rounded-bl-full overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-bl from-red-400/60 via-yellow-400/60 to-green-400/60"})}),e.jsxs("div",{className:"absolute bottom-[10%] right-[5%] opacity-15",children:[e.jsx("div",{className:"w-12 h-8 bg-slate-700 rounded-b-full"}),e.jsx("div",{className:"absolute -top-1 left-1/2 -translate-x-1/2 w-10 h-3 bg-slate-600 rounded-full"}),e.jsxs("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 flex gap-0.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-400"}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-400"}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-400"})]})]})]}),NIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsx("div",{className:"absolute top-[8%] left-[12%] w-16 h-16 rounded-full border-4 border-blue-500/18"}),e.jsx("div",{className:"absolute top-[10%] right-[10%] w-14 h-14 rounded-full border-4 border-indigo-500/15"}),e.jsx("div",{className:"absolute bottom-[18%] left-[18%] w-12 h-12 rounded-full border-3 border-sky-500/12"}),e.jsx(Jn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(Jn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(Nc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(Nc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(i1,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),kIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/6 via-rose-900/6 to-purple-900/6"}),e.jsx(Ch,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-amber-400/18"}),e.jsxs("div",{className:"absolute top-[5%] left-[15%]",children:[e.jsx("div",{className:"w-12 h-14 rounded-full bg-rose-400/25"}),e.jsx("div",{className:"w-0.5 h-10 bg-rose-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[3%] left-[25%]",children:[e.jsx("div",{className:"w-10 h-12 rounded-full bg-sky-400/25"}),e.jsx("div",{className:"w-0.5 h-12 bg-sky-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[8%] right-[18%]",children:[e.jsx("div",{className:"w-11 h-13 rounded-full bg-purple-400/25"}),e.jsx("div",{className:"w-0.5 h-9 bg-purple-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[10%]",children:[e.jsx("div",{className:"w-10 h-12 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"w-0.5 h-11 bg-amber-400/18 mx-auto"})]}),e.jsx("div",{className:"absolute top-[20%] left-[35%] w-3 h-3 bg-pink-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[18%] right-[40%] w-2.5 h-2.5 bg-emerald-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[25%] left-[55%] w-2 h-2 bg-amber-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[22%] right-[30%] w-2.5 h-2.5 bg-sky-400/35 rounded-full"}),e.jsx(ru,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(ko,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),SIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-rose-900/12 via-pink-900/8 to-red-900/12"}),e.jsx(ni,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(ni,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(ni,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(ni,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(ni,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(ni,{className:"absolute top-[20%] right-[35%] w-5 h-5 text-rose-300/35 fill-rose-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(ni,{className:"absolute top-[12%] left-[55%] w-5 h-5 text-red-300/30 fill-red-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(ni,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-400/30 fill-pink-400/15 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[18%] left-[45%] w-8 h-8 rounded-full bg-rose-300/18 blur-sm"}),e.jsx("div",{className:"absolute bottom-[25%] right-[40%] w-6 h-6 rounded-full bg-pink-300/15 blur-sm"})]}),CIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsxs("div",{className:"absolute top-[5%] right-[12%]",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-yellow-400/25 blur-sm"}),e.jsx(p1,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-14 h-14 text-amber-400/45"})]}),e.jsx("div",{className:"absolute bottom-[12%] left-[20%] w-20 h-10 bg-slate-800/12 rounded-full blur-md"}),e.jsx(p1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(pn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(p1,{className:"absolute bottom-[22%] right-[25%] w-8 h-8 text-orange-400/25"}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[15%] bg-gradient-to-t from-amber-900/10 to-transparent"})]}),MIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-cyan-900/6 to-emerald-900/10"}),e.jsx(bn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(bn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(Sp,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(Sp,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(ni,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(ni,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(pn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(ru,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),TIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-900/10 via-teal-900/6 to-cyan-900/10"}),e.jsx(ru,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(ru,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(Sp,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(bn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(pn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(pn,{className:"absolute top-[20%] right-[32%] w-7 h-7 text-cyan-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[55%] w-3 h-3 bg-amber-400/30 rounded-full"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-2.5 h-2.5 bg-teal-400/30 rounded-full"}),e.jsx("div",{className:"absolute top-[28%] left-[35%] w-2 h-2 bg-emerald-400/30 rounded-full"})]}),AIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsx(Sp,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(Sp,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(Sp,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(bn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(ru,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(pn,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(Jn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),EIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-emerald-900/6 to-green-900/10"}),e.jsx(bn,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-teal-500/22"}),e.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-12 h-10 bg-amber-400/18 rounded-sm"}),e.jsx("div",{className:"absolute bottom-[20%] left-[20%] w-10 h-8 bg-orange-400/15 rounded-sm"}),e.jsx("div",{className:"absolute bottom-[16%] right-[15%] w-11 h-9 bg-amber-300/18 rounded-sm"}),e.jsx(Sp,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(ni,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(pn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(n1,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),fIe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute top-4 left-[10%] w-3 h-3 bg-amber-400/60 rounded-full animate-pulse"}),e.jsx("div",{className:"absolute top-12 right-[15%] w-2 h-2 bg-rose-400/60 rounded-full animate-pulse delay-100"}),e.jsx("div",{className:"absolute top-8 left-[30%] w-2.5 h-2.5 bg-sky-400/60 rounded-full animate-pulse delay-200"}),e.jsx("div",{className:"absolute top-16 right-[25%] w-2 h-2 bg-emerald-400/60 rounded-full animate-pulse delay-300"})]}),PIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(ni,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(ni,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(ni,{className:"absolute top-4 left-[40%] w-2.5 h-2.5 text-rose-400/40 fill-rose-400/20 animate-pulse delay-300"}),e.jsx(ni,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),IIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(n1,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(pn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(bn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),LIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(J4,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(FM,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(J4,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),ZP=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(pn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(ru,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(pn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),xIe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(bn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(pn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(bn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),v1e=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(pn,{className:"h-5 w-5"}),category:"general",headerText:()=>"Video Message",subText:"A personal video just for you",gradientClasses:"from-background to-muted/30",accentColor:"primary"},{id:"thank_you",name:"Thank You",description:"Express your gratitude",icon:e.jsx(ni,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You, ${t}!`:"Thank You!",subText:"Your support means the world to me",gradientClasses:"from-rose-50/70 via-pink-50/50 to-red-50/40 dark:from-rose-950/30 dark:via-pink-950/20 dark:to-red-950/20",accentColor:"rose",decorativeElement:e.jsx(PIt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(XI,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thinking of You, ${t}`:"Thinking of You",subText:"Just wanted to reach out and say hello",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(ZP,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(J4,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Hey ${t}!`:"Hey There!",subText:"Just checking in to see how you're doing",gradientClasses:"from-amber-50/70 via-orange-50/50 to-yellow-50/40 dark:from-amber-950/30 dark:via-orange-950/20 dark:to-yellow-950/20",accentColor:"amber",decorativeElement:e.jsx(LIt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(No,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Market Update for ${t}`:"Market Update",subText:"The latest insights from your local market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue"},{id:"referral_thank_you",name:"Referral Thank You",description:"Thank someone for a referral",icon:e.jsx(pr,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You for the Referral, ${t}!`:"Thank You for the Referral!",subText:"Your trust in me means everything",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(ZP,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(Nc,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"So proud of your accomplishment",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(fIe,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(ma,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Welcome to the Neighborhood, ${t}!`:"Welcome to the Neighborhood!",subText:"So excited to have you as our new neighbor",gradientClasses:"from-teal-50/70 via-cyan-50/50 to-sky-50/40 dark:from-teal-950/30 dark:via-cyan-950/20 dark:to-sky-950/20",accentColor:"teal",decorativeElement:e.jsx(xIe,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(FM,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Hey ${t}!`:"Hey There!",subText:"No reason needed – just wanted to connect",gradientClasses:"from-sky-50/70 via-blue-50/50 to-indigo-50/40 dark:from-sky-950/30 dark:via-blue-950/20 dark:to-indigo-950/20",accentColor:"sky",decorativeElement:e.jsx(ZP,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Ch,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Birthday, ${t}!`:"Happy Birthday!",subText:"Wishing you an amazing year ahead",gradientClasses:"from-amber-50/80 via-rose-50/60 to-purple-50/40 dark:from-amber-950/30 dark:via-rose-950/20 dark:to-purple-950/20",accentColor:"amber",decorativeElement:e.jsx(kIt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(ni,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Valentine's Day, ${t}!`:"Happy Valentine's Day!",subText:"A heartfelt message from your real estate professional",gradientClasses:"from-rose-50/80 via-pink-50/60 to-red-50/40 dark:from-rose-950/30 dark:via-pink-950/20 dark:to-red-950/20",accentColor:"rose",decorativeElement:e.jsx(SIt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(p1,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Groundhog Day, ${t}!`:"Happy Groundhog Day!",subText:"Wishing you an early spring!",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(CIt,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(Jn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy New Year, ${t}!`:"Happy New Year!",subText:"Wishing you a year full of success and happiness",gradientClasses:"from-yellow-50/70 via-amber-50/50 to-orange-50/40 dark:from-yellow-950/30 dark:via-amber-950/20 dark:to-orange-950/20",accentColor:"yellow",decorativeElement:e.jsx(_It,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(TM,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Easter, ${t}!`:"Happy Easter!",subText:"Wishing you a joyful celebration",gradientClasses:"from-pink-50/70 via-purple-50/50 to-sky-50/40 dark:from-pink-950/30 dark:via-purple-950/20 dark:to-sky-950/20",accentColor:"pink",decorativeElement:e.jsx(gIt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Wg,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Mother's Day, ${t}!`:"Happy Mother's Day!",subText:"Celebrating the wonderful mothers in our lives",gradientClasses:"from-pink-50/70 via-rose-50/50 to-purple-50/40 dark:from-pink-950/30 dark:via-rose-950/20 dark:to-purple-950/20",accentColor:"pink",decorativeElement:e.jsx(fIt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(Nc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Father's Day, ${t}!`:"Happy Father's Day!",subText:"Celebrating the wonderful fathers in our lives",gradientClasses:"from-blue-50/70 via-sky-50/50 to-indigo-50/40 dark:from-blue-950/30 dark:via-sky-950/20 dark:to-indigo-950/20",accentColor:"blue",decorativeElement:e.jsx(xIt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(i1,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Memorial Day, ${t}`:"Happy Memorial Day",subText:"Honoring those who served our country",gradientClasses:"from-red-50/60 via-white to-blue-50/60 dark:from-red-950/30 dark:via-slate-950/20 dark:to-blue-950/30",accentColor:"blue",decorativeElement:e.jsx(mIt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(eh,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy 4th of July, ${t}!`:"Happy 4th of July!",subText:"Celebrating freedom and independence",gradientClasses:"from-red-50/70 via-white to-blue-50/70 dark:from-red-950/30 dark:via-slate-950/10 dark:to-blue-950/30",accentColor:"red",decorativeElement:e.jsx(pIt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(Nc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Labor Day, ${t}!`:"Happy Labor Day!",subText:"Celebrating the hard work that builds our communities",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(NIt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(tS,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Halloween, ${t}!`:"Happy Halloween!",subText:"Have a spooktacular day!",gradientClasses:"from-orange-50/70 via-amber-50/50 to-purple-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-purple-950/30",accentColor:"orange",decorativeElement:e.jsx(yIt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(ni,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Thanksgiving, ${t}!`:"Happy Thanksgiving!",subText:"Grateful for you and your friendship",gradientClasses:"from-orange-50/70 via-amber-50/50 to-red-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-red-950/20",accentColor:"orange",decorativeElement:e.jsx(bIt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(f1,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Merry Christmas, ${t}!`:"Merry Christmas!",subText:"Wishing you joy and peace this holiday season",gradientClasses:"from-red-50/70 via-green-50/40 to-emerald-50/40 dark:from-red-950/30 dark:via-green-950/20 dark:to-emerald-950/20",accentColor:"red",decorativeElement:e.jsx(vIt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(pn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Hanukkah, ${t}!`:"Happy Hanukkah!",subText:"Wishing you eight nights of light and joy",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(wIt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(Yv,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy St. Patrick's Day, ${t}!`:"Happy St. Patrick's Day!",subText:"Wishing you the luck of the Irish!",gradientClasses:"from-green-50/70 via-emerald-50/50 to-teal-50/40 dark:from-green-950/30 dark:via-emerald-950/20 dark:to-teal-950/20",accentColor:"green",decorativeElement:e.jsx(jIt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(bn,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Happy Home Anniversary, ${t}!`:"Happy Home Anniversary!",subText:"Celebrating another year in your beautiful home",gradientClasses:"from-teal-50/70 via-cyan-50/50 to-emerald-50/40 dark:from-teal-950/30 dark:via-cyan-950/20 dark:to-emerald-950/20",accentColor:"teal",decorativeElement:e.jsx(MIt,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(ru,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're under contract – exciting times ahead!",gradientClasses:"from-emerald-50/70 via-teal-50/50 to-cyan-50/40 dark:from-emerald-950/30 dark:via-teal-950/20 dark:to-cyan-950/20",accentColor:"emerald",decorativeElement:e.jsx(TIt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(hn,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Exciting News, ${t}!`:"Just Listed!",subText:"A new property is now on the market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-violet-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-violet-950/20",accentColor:"blue",decorativeElement:e.jsx(xIe,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(ac,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Just Sold!",subText:"Another successful transaction completed",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(ZP,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(fS,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Great News, ${t}!`:"Price Reduced!",subText:"This property just became more affordable",gradientClasses:"from-orange-50/70 via-amber-50/50 to-yellow-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-yellow-950/20",accentColor:"orange"},{id:"open_house",name:"Open House",description:"Invite to an open house event",icon:e.jsx(n1,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`You're Invited, ${t}!`:"You're Invited!",subText:"Join us for an exclusive open house",gradientClasses:"from-sky-50/70 via-blue-50/50 to-indigo-50/40 dark:from-sky-950/30 dark:via-blue-950/20 dark:to-indigo-950/20",accentColor:"sky",decorativeElement:e.jsx(IIt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(Sp,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"It's official – the keys are yours!",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(AIt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(bn,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Welcome Home, ${t}!`:"Welcome Home!",subText:"Wishing you all the best in your new home",gradientClasses:"from-teal-50/70 via-emerald-50/50 to-green-50/40 dark:from-teal-950/30 dark:via-emerald-950/20 dark:to-green-950/20",accentColor:"teal",decorativeElement:e.jsx(EIt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(sh,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Amazing News, ${t}!`:"Offer Accepted!",subText:"Your offer has been accepted – congratulations!",gradientClasses:"from-green-50/70 via-emerald-50/50 to-teal-50/40 dark:from-green-950/30 dark:via-emerald-950/20 dark:to-teal-950/20",accentColor:"green",decorativeElement:e.jsx(ZP,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(Nc,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're pre-approved and ready to find your dream home",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(fIe,{})}],DIt=[{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 OIt(t){return v1e.filter(s=>s.category===t)}function QM(t){return v1e.find(s=>s.id===t)||v1e[0]}function gIe(){const{shareToken:t,recipientToken:s}=yo(),[r,n]=k.useState(null),[a,o]=k.useState(null),[l,i]=k.useState(null),[c,u]=k.useState(!0),[p,f]=k.useState(null),[g,b]=k.useState(!0),_=k.useRef(null),j=k.useRef(0),w=k.useRef(0),N=(()=>{const Q=new URLSearchParams(window.location.search);return s||Q.get("rt")||null})(),S=k.useCallback((Q,ee=!1)=>{if(!N||Q<=0)return;const X=Math.max(1,Math.round(Q));if(X<=w.current)return;const re=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(N)}&e=watch&ws=${X}`;ee&&navigator.sendBeacon?navigator.sendBeacon(re):fetch(re,{method:"GET",keepalive:ee}).catch(()=>{}),w.current=Math.max(w.current,X)},[N]);k.useEffect(()=>{var ce;if(!g||!(r!=null&&r.playback_url)||!N)return;let Q=!1;const ee=()=>{j.current>0&&S(j.current,!0)},X=()=>{document.visibilityState==="hidden"&&ee()},ie=()=>{ee()},re=()=>{var ye;if(Q||!_.current||!((ye=window.playerjs)!=null&&ye.Player))return;const ge=new window.playerjs.Player(_.current);ge.on("timeupdate",ue=>{const pe=Math.floor(Number((ue==null?void 0:ue.seconds)??0));!Number.isFinite(pe)||pe<=0||(j.current=Math.max(j.current,pe))}),ge.on("pause",()=>{j.current>0&&S(j.current)}),ge.on("ended",()=>{j.current>0&&S(j.current,!0)})},oe=document.querySelector('script[data-bunny-playerjs="true"]');if((ce=window.playerjs)!=null&&ce.Player)re();else if(oe)oe.addEventListener("load",re,{once:!0});else{const ge=document.createElement("script");ge.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",ge.async=!0,ge.defer=!0,ge.dataset.bunnyPlayerjs="true",ge.onload=re,document.body.appendChild(ge)}return document.addEventListener("visibilitychange",X),window.addEventListener("beforeunload",ie),()=>{Q=!0,document.removeEventListener("visibilitychange",X),window.removeEventListener("beforeunload",ie),ee()}},[g,r==null?void 0:r.playback_url,N,S]),k.useEffect(()=>{j.current=0,w.current=0},[N,t]),k.useEffect(()=>{const Q=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="msgsndr"]',"[data-chat-widget]"].forEach(re=>{document.querySelectorAll(re).forEach(oe=>{oe.style.display="none"})})};Q();const ee=[setTimeout(Q,500),setTimeout(Q,1500),setTimeout(Q,3e3)],X=new MutationObserver(Q);return X.observe(document.body,{childList:!0,subtree:!0}),()=>{ee.forEach(clearTimeout),X.disconnect()}},[]),k.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:ee,error:X}=await H.from("agent_videos").select("id, title, playback_url, thumbnail_url, preview_url, duration_seconds, share_token, owner_user_id, contact_id, page_template, recipient_name").eq("share_token",t).eq("is_deleted",!1).single();if(X||!ee){f("Video not found or has been removed"),u(!1);return}n(ee);try{await H.rpc("log_video_view",{p_video_id:ee.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(ie){console.warn("Failed to log video view:",ie)}if(ee.owner_user_id){const{data:ie}=await H.from("profiles").select("id, name, email, phone").eq("id",ee.owner_user_id).single();if(ie){o(ie);try{const{data:re}=await H.storage.from("avatars").list(`${ee.owner_user_id}`);if(re&&re.length>0){const{data:oe}=H.storage.from("avatars").getPublicUrl(`${ee.owner_user_id}/${re[0].name}`);i(oe.publicUrl)}}catch{}}}u(!1)})()},[t]);const M=Q=>{if(!Q)return"0:00";const ee=Math.floor(Q/60),X=Q%60;return`${ee}:${X.toString().padStart(2,"0")}`},L=Q=>Q.includes("iframe.mediadelivery.net/play/")?Q.replace("/play/","/embed/")+"?autoplay=true&responsive=true":Q,I=Q=>{if(!Q)return"?";const ee=Q.split(" ");return ee.length>=2?`${ee[0][0]}${ee[1][0]}`.toUpperCase():Q.substring(0,2).toUpperCase()},O=QM((r==null?void 0:r.page_template)||"default"),q=(r==null?void 0:r.recipient_name)||null,U=O.headerText(q),V=`https://dashboard.relevelup.com/share/video/${t}`;if(c)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-primary"})});if(p||!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(Ee,{className:"max-w-md w-full",children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(An,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Video Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:p||"This video is no longer available."})]})})});const Y=O.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsx("title",{children:U}),e.jsx("meta",{name:"description",content:O.subText}),e.jsx("meta",{property:"og:title",content:U}),e.jsx("meta",{property:"og:description",content:O.subText}),e.jsx("meta",{property:"og:type",content:"video.other"}),e.jsx("meta",{property:"og:url",content:V}),r.preview_url&&e.jsx("meta",{property:"og:image",content:r.preview_url}),!r.preview_url&&r.thumbnail_url&&e.jsx("meta",{property:"og:image",content:r.thumbnail_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:r.playback_url}),e.jsx("meta",{property:"og:video:type",content:"text/html"}),e.jsx("meta",{property:"og:video:width",content:"1280"}),e.jsx("meta",{property:"og:video:height",content:"720"})]}),e.jsx("meta",{name:"twitter:card",content:"player"}),e.jsx("meta",{name:"twitter:title",content:U}),e.jsx("meta",{name:"twitter:description",content:O.subText}),r.preview_url&&e.jsx("meta",{name:"twitter:image",content:r.preview_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{name:"twitter:player",content:r.playback_url}),e.jsx("meta",{name:"twitter:player:width",content:"1280"}),e.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),e.jsxs("div",{className:It("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",O.gradientClasses),children:[Y&&O.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[Y&&e.jsxs("div",{className:"text-center py-4 animate-fade-in",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:It("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",O.accentColor==="primary"&&"bg-primary/10 text-primary",O.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",O.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",O.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",O.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",O.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",O.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",O.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",O.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",O.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",O.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",O.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",O.accentColor==="sky"&&"bg-sky-100 text-sky-600 dark:bg-sky-900/50 dark:text-sky-400"),children:e.jsx("div",{className:"scale-150",children:O.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:U}),e.jsx("p",{className:"text-muted-foreground",children:O.subText})]}),a&&e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card/90 backdrop-blur-sm rounded-lg border shadow-sm",children:[e.jsxs(Nn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx($a,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(kn,{className:"bg-primary/10 text-primary font-semibold",children:I(a.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:Y?"A special video from":"A personal video from"}),e.jsx("h2",{className:"text-lg font-semibold truncate",children:a.name||"Your Agent"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Real Estate Professional"})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[a.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`tel:${a.phone}`,"aria-label":"Call agent",children:e.jsx(Un,{className:"h-4 w-4"})})}),a.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`mailto:${a.email}`,"aria-label":"Email agent",children:e.jsx(cr,{className:"h-4 w-4"})})})]})]}),e.jsx(Ee,{className:"overflow-hidden shadow-lg",children:g&&r.playback_url?e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:e.jsx("iframe",{ref:_,src:L(r.playback_url),title:r.title||"Video message",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>b(!0),children:[r.preview_url||r.thumbnail_url?e.jsx("img",{src:r.preview_url||r.thumbnail_url||"",alt:r.title?`${r.title} video preview`:"Video message preview",className:"w-full h-full object-cover",onError:Q=>{var X;Q.currentTarget.style.display="none";const ee=(X=Q.currentTarget.parentElement)==null?void 0:X.querySelector(".video-fallback");ee&&(ee.style.display="flex")}}):null,e.jsx("div",{className:"video-fallback w-full h-full items-center justify-center bg-gradient-to-br from-primary/20 to-primary/5",style:{display:r.preview_url||r.thumbnail_url?"none":"flex"},children:e.jsx(An,{className:"h-16 w-16 text-primary/50"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 group-hover:bg-black/40 transition-colors",children:e.jsx("div",{className:"w-20 h-20 rounded-full bg-white/90 flex items-center justify-center shadow-lg transform group-hover:scale-105 transition-transform",children:e.jsx(nl,{className:"h-10 w-10 text-primary ml-1"})})}),r.duration_seconds&&e.jsx("div",{className:"absolute bottom-3 right-3 bg-black/70 text-white text-sm px-2 py-1 rounded",children:M(r.duration_seconds)})]})}),!Y&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.title||"Video Message"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:g?"Enjoy the video!":"Click to play the video"})]}),!g&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(K,{size:"lg",onClick:()=>b(!0),className:"gap-2",children:[e.jsx(nl,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(hIt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function RIt(){return k.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(c1t,{})}function FIt(){const{token:t}=yo();return k.useEffect(()=>{if(!t)return;const s=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/video-og-image?token=${t}`;window.location.replace(s)},[t]),e.jsx("main",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(ws,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const zIt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},BIt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},j5={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function $It(){var X,ie,re,oe;const{slugOrId:t}=yo(),[s]=Cc(),{data:r,isLoading:n}=eGe(t||""),a=tGe(),o=ekt(),l=s.get("ref"),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,S]=k.useState(!1),[M,L]=k.useState(null),[I,O]=k.useState(!1);k.useEffect(()=>{l&&o.mutate(l)},[l]);const q=ce=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ce),U=async ce=>{if(ce.preventDefault(),!(!i.trim()||!f.trim()||!r)){w(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:f.trim(),phone:b.trim(),shareToken:l}),S(!0),me.success("Thanks! The agent will be in touch soon.")}catch(ge){console.error("Lead submission error:",ge),me.error(`Failed to submit: ${ge.message||"Please try again"}`)}finally{w(!1)}}},B=(r==null?void 0:r.photos)||[],V=B.find(ce=>ce.is_primary)||B[0],Y=()=>{M!==null&&L(M===0?B.length-1:M-1)},Q=()=>{M!==null&&L(M===B.length-1?0:M+1)};if(n)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(ys,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ys,{className:"h-10 w-48 mb-6"}),e.jsx(ys,{className:"aspect-video mb-6"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-4",children:[e.jsx(ys,{className:"h-12 w-48"}),e.jsx(ys,{className:"h-6 w-full"}),e.jsx(ys,{className:"h-6 w-3/4"})]}),e.jsx(ys,{className:"h-64"})]})]})]});if(!r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(Pi,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:joe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(bn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx(Pi,{to:"/public/listings",children:"Browse All Listings"})})]})]});const ee=r.property_address?`${r.property_address} - ${r.city}, ${r.state}`:`${r.city}, ${r.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsxs("title",{children:[ee," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${q(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${j5[r.property_type]} in ${r.city}, ${r.state}. ${((X=r.description)==null?void 0:X.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:ee}),e.jsx("meta",{property:"og:description",content:`${q(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${j5[r.property_type]} in ${r.city}, ${r.state}. View photos, details, and contact the listing agent.`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:`https://listings.relevelup.com/${r.slug||r.id}`}),V&&e.jsx("meta",{property:"og:image",content:V.photo_url}),V&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${j5[r.property_type]} for sale`}),e.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),e.jsx("meta",{property:"og:locale",content:"en_US"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:ee}),e.jsx("meta",{name:"twitter:description",content:`${q(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),V&&e.jsx("meta",{name:"twitter:image",content:V.photo_url}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"geo.region",content:`US-${r.state}`}),e.jsx("meta",{name:"geo.placename",content:r.city}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateListing",name:r.property_address||`${r.city}, ${r.state} Home`,description:r.description||`${j5[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:B.map(ce=>ce.photo_url),address:{"@type":"PostalAddress",streetAddress:r.property_address||void 0,addressLocality:r.city,addressRegion:r.state,addressCountry:"US"},geo:r.neighborhood?{"@type":"GeoCoordinates",name:r.neighborhood}:void 0,offers:{"@type":"Offer",price:r.price,priceCurrency:"USD",availability:r.status==="sold"?"https://schema.org/SoldOut":r.status==="under_contract"?"https://schema.org/LimitedAvailability":"https://schema.org/InStock"},numberOfRooms:r.bedrooms||void 0,numberOfBathroomsTotal:r.bathrooms||void 0,floorSize:r.square_footage?{"@type":"QuantitativeValue",value:r.square_footage,unitCode:"FTK"}:void 0,yearBuilt:r.year_built||void 0,broker:r.agent?{"@type":"RealEstateAgent",name:r.agent.name,email:r.agent.email,worksFor:(ie=r.agent.brokerage)!=null&&ie.name?{"@type":"RealEstateAgent",name:r.agent.brokerage.name}:void 0}:void 0})})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(Pi,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:joe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(Pi,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),B.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>L(0),children:e.jsx("img",{src:V==null?void 0:V.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${j5[r.property_type]} main photo`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:B.slice(1,5).map((ce,ge)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>L(ge+1),children:[e.jsx("img",{src:ce.photo_url,alt:`${r.property_address||r.city} - Photo ${ge+2} of ${B.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),ge===3&&B.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",B.length-5," more"]})]},ce.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(st,{className:`${zIt[r.status]} text-white border-0`,children:BIt[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:q(r.price)}),r.property_address&&e.jsx("p",{className:"text-xl font-medium",children:r.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ma,{className:"h-4 w-4"}),r.city,", ",r.state,r.neighborhood&&` • ${r.neighborhood}`]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[r.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Im,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.bedrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Beds"})]}),r.bathrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Ju,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.bathrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Baths"})]}),r.square_footage&&e.jsxs("div",{className:"text-center",children:[e.jsx(b0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),r.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(st,{variant:"secondary",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),j5[r.property_type]]}),r.lot_size&&e.jsxs(st,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(st,{variant:"secondary",children:"HOA"})]}),r.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})]}),r.agent_notes&&r.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.agent_notes})]}),r.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[r.video&&r.video.playback_url&&e.jsx(Ee,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(Oe,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>O(!0),children:[r.video.thumbnail_url?e.jsx("img",{src:r.video.thumbnail_url,alt:"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gradient-to-br from-primary/20 to-primary/30",children:e.jsx(An,{className:"h-12 w-12 text-primary"})}),e.jsx("div",{className:"absolute inset-0 bg-black/30 group-hover:bg-black/40 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-white/90 group-hover:bg-white flex items-center justify-center transition-colors shadow-lg",children:e.jsx(nl,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(K,{onClick:()=>O(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(nl,{className:"h-4 w-4"}),"Watch Video Tour"]}),r.video.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center truncate",children:r.video.title})]})]})}),r.agent&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(to,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((re=r.agent.brokerage)==null?void 0:re.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:N?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(cr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:U,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"firstName",children:"First Name *"}),e.jsx(ze,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:ce=>c(ce.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ze,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:ce=>p(ce.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:ce=>g(ce.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:b,onChange:ce=>_(ce.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:j,children:j?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(fs,{open:M!==null,onOpenChange:()=>L(null),children:e.jsxs(ps,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(_s,{className:"sr-only",children:e.jsx(vs,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>L(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Rr,{className:"h-5 w-5"})}),M!==null&&B[M]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:B[M].photo_url,alt:`Photo ${M+1}`,className:"w-full max-h-[80vh] object-contain"}),B.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Y,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:Q,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(da,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[M+1," / ",B.length]})]})]})]})}),e.jsx(fs,{open:I,onOpenChange:O,children:e.jsxs(ps,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(_s,{className:"sr-only",children:e.jsx(vs,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>O(!1),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Rr,{className:"h-5 w-5"})}),((oe=r==null?void 0:r.video)==null?void 0:oe.playback_url)&&e.jsx("div",{className:"aspect-video w-full",children:e.jsx("iframe",{src:r.video.playback_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function qIt(){var o;const{slug:t}=yo(),{data:s,isLoading:r,error:n}=aGe(t);if(k.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),k.useEffect(()=>{s!=null&&s.id&&fo(s.id,"card_view")},[s==null?void 0:s.id]),r)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(ys,{className:"h-28 w-28 rounded-full"}),e.jsx(ys,{className:"h-6 w-48"}),e.jsx(ys,{className:"h-4 w-36"})]}),e.jsx(ys,{className:"h-12 w-full"}),e.jsx(ys,{className:"h-12 w-full"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Card Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This agent card doesn't exist or isn't published yet."})]})});const a=((o=s.profile)==null?void 0:o.name)||"Agent";return e.jsxs(e.Fragment,{children:[e.jsxs(Sc,{children:[e.jsxs("title",{children:[a," | Real Estate Agent"]}),e.jsx("meta",{name:"description",content:s.positioning_statement||`Connect with ${a}, your trusted real estate professional.`}),e.jsx("meta",{property:"og:title",content:`${a} | Real Estate Agent`}),e.jsx("meta",{property:"og:description",content:s.positioning_statement||`Connect with ${a}`}),s.avatar_url&&e.jsx("meta",{property:"og:image",content:s.avatar_url})]}),e.jsx(uje,{card:s})]})}function $Ye({slugOverride:t}={}){var Me;const{slug:s}=yo(),r=t||s,[n]=Cc(),a=n.get("t"),[o,l]=k.useState(!0),[i,c]=k.useState(null),[u,p]=k.useState(null),f=k.useRef(null),g=k.useRef(null),[b,_]=k.useState(null),[j,w]=k.useState(null),[N,S]=k.useState(!1),[M,L]=k.useState(!1),[I,O]=k.useState(0),[q,U]=k.useState(!1),[B,V]=k.useState(""),[Y,Q]=k.useState(""),[ee,X]=k.useState(""),[ie,re]=k.useState(""),[oe,ce]=k.useState(""),[ge,ye]=k.useState(""),[ue,pe]=k.useState(""),[_e,$e]=k.useState(""),[Ae,Ie]=k.useState(""),[Ce,xe]=k.useState(""),[we,Le]=k.useState(""),[tt,Te]=k.useState("");k.useEffect(()=>{pt()},[r,a]);const pt=async()=>{if(!r)return;l(!0);const{data:rt,error:He}=await H.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(He||!rt){U(!0),l(!1);return}p(rt),g.current=rt;const{data:ct}=await H.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",rt.user_id).single();if(ct){let Ue;if(ct.brokerage_id){const{data:We}=await H.from("brokerages").select("name").eq("id",ct.brokerage_id).single();Ue=(We==null?void 0:We.name)||void 0}let Ze=ct.avatar_url||null;if(!Ze){const{data:We}=H.storage.from("avatars").getPublicUrl(`${rt.user_id}/avatar.jpg`);We!=null&&We.publicUrl&&(Ze=`${We.publicUrl}?t=${Date.now()}`)}const Qe={...ct,avatar_url:Ze,brokerage_name:Ue};c(Qe),f.current=Qe}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",rt.id);const{data:Ue,error:Ze}=await H.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:rt.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:Ue,resolveErr:Ze}),!Ze&&(Ue!=null&&Ue.contact_id)){w(Ue.contact_id);const Qe=Ue.contact;Qe&&(_(Qe),V(Qe.first_name||""),Q(Qe.last_name||""),X(Qe.email||""),re(Qe.phone||""),ce(Qe.address||""),ye(Qe.city||""),pe(Qe.state||""),$e(Qe.zip||""),Ie(Qe.birthday||""),xe(Qe.home_anniversary||""))}}catch(Ue){console.error("Failed to resolve token:",Ue)}l(!1)},fe=async()=>{var rt,He;if(!B.trim()){me.error("Please enter your first name");return}if(!r){me.error("Invalid page. Please refresh.");return}L(!0);try{let ct=(rt=g.current)==null?void 0:rt.id,Ue=(He=g.current)==null?void 0:He.user_id;if(!ct||!Ue){const{data:Qe}=await H.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!Qe){me.error("This page is no longer active. Please contact the agent directly."),L(!1);return}ct=Qe.id,Ue=Qe.user_id}const{error:Ze}=await H.from("contact_intake_submissions").insert({intake_page_id:ct,agent_user_id:Ue,existing_contact_id:j,first_name:B.trim(),last_name:Y.trim()||null,email:ee.trim()||null,phone:ie.trim()||null,address:oe.trim()||null,city:ge.trim()||null,state:ue.trim()||null,zip:_e.trim()||null,birthday:Ae||null,home_anniversary:Ce||null,real_estate_interest:we||null,message:tt.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:Ze}),Ze)throw Ze;a&&await H.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const Qe=[B.trim(),Y.trim()].filter(Boolean).join(" ");await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/connect-page-notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentUserId:Ue,contactName:Qe,contactEmail:ee.trim()||null,contactPhone:ie.trim()||null,slug:r})})}catch(Qe){console.warn("Connect page notification failed (non-blocking):",Qe)}S(!0)}catch(ct){console.error(ct),me.error("Something went wrong. Please try again.")}finally{L(!1)}};if(o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-slate-400"})});if(q)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-700",children:"Page Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This connect page doesn't exist or is no longer active."})]})});if(N)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50 p-4",children:[e.jsx(Sc,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(Gs.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"max-w-md w-full text-center space-y-6 p-8",children:[e.jsx(Gs.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",delay:.2},className:"mx-auto w-20 h-20 rounded-full bg-emerald-100 flex items-center justify-center",children:e.jsx(sa,{className:"h-10 w-10 text-emerald-600"})}),e.jsx("h1",{className:"text-3xl font-bold text-slate-800",children:"Thank You!"}),e.jsxs("p",{className:"text-lg text-slate-600",children:[i==null?void 0:i.name," has received your info and will be in touch soon."]}),e.jsxs("div",{className:"flex items-center justify-center gap-1 text-sm text-slate-400 pt-4",children:[e.jsx(ni,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const qe=!!a&&!!b,at=3,et=[{title:qe?"Confirm Your Info":"Let's Get Connected",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"First Name *"}),e.jsx("input",{type:"text",value:B,onChange:rt=>V(rt.target.value),placeholder:"Jane",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Last Name"}),e.jsx("input",{type:"text",value:Y,onChange:rt=>Q(rt.target.value),placeholder:"Smith",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Email"}),e.jsx("input",{type:"email",value:ee,onChange:rt=>X(rt.target.value),placeholder:"jane@email.com",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Phone"}),e.jsx("input",{type:"tel",value:ie,onChange:rt=>re(rt.target.value),placeholder:"(555) 123-4567",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})},{title:"A Little More About You",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Street Address"}),e.jsx("input",{type:"text",value:oe,onChange:rt=>ce(rt.target.value),placeholder:"123 Main St",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"City"}),e.jsx("input",{type:"text",value:ge,onChange:rt=>ye(rt.target.value),placeholder:"Austin",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-1",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"State"}),e.jsx("input",{type:"text",value:ue,onChange:rt=>pe(rt.target.value),placeholder:"TX",maxLength:2,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Zip"}),e.jsx("input",{type:"text",value:_e,onChange:rt=>$e(rt.target.value),placeholder:"78701",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Birthday"}),e.jsx("input",{type:"date",value:Ae,onChange:rt=>Ie(rt.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Home Anniversary"}),e.jsx("input",{type:"date",value:Ce,onChange:rt=>xe(rt.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})]})},{title:"One Last Thing",fields:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-3",children:["Are you thinking about making a move anytime soon? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(totally optional)"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{value:"buying",label:"🏠 Buying",desc:"Looking for a home"},{value:"selling",label:"📋 Selling",desc:"Thinking of selling"},{value:"both",label:"🔄 Both",desc:"Buy & sell"},{value:"not_now",label:"😊 Not right now",desc:"Just staying connected"}].map(rt=>e.jsxs("button",{type:"button",onClick:()=>Le(we===rt.value?"":rt.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${we===rt.value?"border-blue-500 bg-blue-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300"}`,children:[e.jsx("span",{className:"block text-sm font-medium text-slate-800",children:rt.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:rt.desc})]},rt.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:["Anything else you'd like to share? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:tt,onChange:rt=>Te(rt.target.value),placeholder:"Feel free to drop a note...",rows:3,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all resize-none"})]})]})}];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50",children:[e.jsxs(Sc,{children:[e.jsxs("title",{children:["Connect with ",(i==null?void 0:i.name)||"Agent"]}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-8 sm:py-12",children:[e.jsxs(Gs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-center mb-8",children:[i!=null&&i.avatar_url?e.jsx("img",{src:i.avatar_url,alt:i.name,className:"w-24 h-24 rounded-full object-cover mx-auto mb-4 ring-4 ring-white shadow-lg"}):e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 mx-auto mb-4 flex items-center justify-center ring-4 ring-white shadow-lg",children:e.jsx("span",{className:"text-3xl font-bold text-white",children:((Me=i==null?void 0:i.name)==null?void 0:Me.charAt(0))||"?"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:i==null?void 0:i.name}),(i==null?void 0:i.title)&&e.jsx("p",{className:"text-slate-500 mt-0.5",children:i.title}),(i==null?void 0:i.brokerage_name)&&e.jsx("p",{className:"text-sm text-slate-400",children:i.brokerage_name}),((i==null?void 0:i.phone)||(i==null?void 0:i.email))&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[(i==null?void 0:i.phone)&&e.jsx("a",{href:`tel:${i.phone}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Call agent",children:e.jsx(Un,{className:"h-4.5 w-4.5"})}),(i==null?void 0:i.email)&&e.jsx("a",{href:`mailto:${i.email}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Email agent",children:e.jsx(cr,{className:"h-4.5 w-4.5"})})]})]}),e.jsx(Gs.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:"text-center text-slate-600 mb-8 px-4 leading-relaxed",children:(u==null?void 0:u.welcome_message)||"I'd love to stay connected! Fill in your info below."}),e.jsx("div",{className:"flex gap-2 mb-8 px-2",children:Array.from({length:at}).map((rt,He)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${He<=I?"bg-blue-500":"bg-slate-200"}`},He))}),e.jsxs(Gs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},className:"bg-white rounded-2xl shadow-lg shadow-slate-200/50 border border-slate-100 p-6 sm:p-8",children:[e.jsx(jZe,{mode:"wait",children:e.jsxs(Gs.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(pn,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:et[I].title})]}),et[I].fields]},I)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[I>0?e.jsx("button",{type:"button",onClick:()=>O(rt=>rt-1),className:"px-5 py-2.5 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors",children:"Back"}):e.jsx("div",{}),I{if(I===0&&!B.trim()){me.error("Please enter your first name");return}O(rt=>rt+1)},className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm",children:"Continue"}):e.jsx("button",{type:"button",onClick:()=>fe(),disabled:M,className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm disabled:opacity-50 flex items-center gap-2",children:M?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),I>0&&IO(rt=>rt+1),className:"text-xs text-slate-400 hover:text-slate-500 transition-colors",children:"Skip this step"})})]}),e.jsx("div",{className:"text-center mt-8",children:e.jsxs("div",{className:"flex items-center justify-center gap-1 text-xs text-slate-400",children:[e.jsx(ni,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}function YP({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=k.useState(0),[o,l]=k.useState(!1),i=k.useCallback(()=>{a(f=>(f+1)%t.length)},[t.length]),c=k.useCallback(()=>{a(f=>(f-1+t.length)%t.length)},[t.length]),u=k.useCallback(f=>{a(f)},[]);if(k.useEffect(()=>{if(t.length<=1||o)return;const f=setInterval(i,s);return()=>clearInterval(f)},[t.length,o,s,i]),!t||t.length===0)return null;const p=t[n];return e.jsxs("div",{className:It("relative w-full overflow-hidden rounded-xl",r),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsxs("div",{className:"relative aspect-[21/9] md:aspect-[3/1] w-full",children:[e.jsx("img",{src:p.image_url,alt:p.title,className:"w-full h-full object-cover rounded-t-xl"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:It("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:c,children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:It("absolute right-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:i,children:e.jsx(da,{className:"h-6 w-6"})})]}),t.length>1&&e.jsx("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex gap-2",children:t.map((f,g)=>e.jsx("button",{onClick:()=>u(g),className:It("w-2 h-2 rounded-full transition-all duration-300",g===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${g+1}`},g))})]}),e.jsxs("div",{className:"bg-foreground rounded-b-xl px-5 py-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm md:text-base font-semibold text-background truncate",children:p.title}),p.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:p.description})]}),p.link_url&&e.jsx("a",{href:p.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",children:e.jsx(K,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:p.link_text||"Learn More"})})]})]})}function UIt(t){return"EST"}function oD(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=UIt();return`${r} ${n}`}function JM(t){const s=new Date,r=new Date(t),n=iM(r,-15),a=iM(r,30);return s>a?"ended":Fg(s,{start:r,end:a})?"live":Fg(s,{start:n,end:r})?"starting_soon":"upcoming"}function vNe(t){const s=JM(t);return s==="starting_soon"||s==="live"}const yIe=vNe,VIt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=k.useState(new Date);k.useEffect(()=>{const b=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(b)},[]);const o=t.filter(b=>vNe(b.event_date));if(o.length===0)return null;const l=o[0],i=JM(l.event_date),c=s.find(b=>b.event_id===l.id),u=(c==null?void 0:c.zoom_join_url)||l.zoom_link,p=!!c,f=i==="live",g=f?{container:"from-red-500/10 via-red-500/5 to-primary/10 border-red-500/30",pulse:"from-red-500/5",indicator:"bg-red-500",text:"text-red-500",button:"bg-red-500 hover:bg-red-600",outlineButton:"border-red-500/50 text-red-500 hover:bg-red-500/10"}:{container:"from-amber-500/10 via-amber-500/5 to-primary/10 border-amber-500/30",pulse:"from-amber-500/5",indicator:"bg-amber-500",text:"text-amber-500",button:"bg-amber-500 hover:bg-amber-600",outlineButton:"border-amber-500/50 text-amber-500 hover:bg-amber-500/10"};return e.jsxs("div",{className:`relative mb-8 overflow-hidden rounded-xl bg-gradient-to-r ${g.container} border`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${g.pulse} to-transparent animate-pulse`}),e.jsx("div",{className:"relative p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex items-center justify-center",children:[e.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full ${g.indicator} opacity-75`}),e.jsx("span",{className:`relative flex h-3 w-3 rounded-full ${g.indicator}`})]}),e.jsx("div",{className:`flex items-center gap-2 ${g.text} font-bold text-sm uppercase tracking-wider`,children:f?e.jsxs(e.Fragment,{children:[e.jsx(h1,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"h-4 w-4"}),"Starting Soon"]})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg text-foreground line-clamp-1",children:l.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?`Started at ${oD(new Date(l.event_date))}`:`Starts at ${oD(new Date(l.event_date))}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:p?e.jsxs(K,{onClick:()=>window.open(u,"_blank"),className:`${g.button} text-white gap-2`,children:[e.jsx(tn,{className:"h-4 w-4"}),f?"Join Now":"Join When Live"]}):e.jsxs(K,{variant:"outline",onClick:r,className:`${g.outlineButton} gap-2`,children:[e.jsx(pr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var bNe="Progress",_Ne=100,[HIt]=ad(bNe),[WIt,GIt]=HIt(bNe),qYe=k.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=KIt,...l}=t;(a||a===0)&&!vIe(a)&&console.error(ZIt(`${a}`,"Progress"));const i=vIe(a)?a:_Ne;n!==null&&!bIe(n,i)&&console.error(YIt(`${n}`,"Progress"));const c=bIe(n,i)?n:null,u=Koe(c)?o(c,i):void 0;return e.jsx(WIt,{scope:r,value:c,max:i,children:e.jsx(nn.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":Koe(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":HYe(c,i),"data-value":c??void 0,"data-max":i,...l,ref:s})})});qYe.displayName=bNe;var UYe="ProgressIndicator",VYe=k.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=GIt(UYe,r);return e.jsx(nn.div,{"data-state":HYe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});VYe.displayName=UYe;function KIt(t,s){return`${Math.round(t/s*100)}%`}function HYe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function Koe(t){return typeof t=="number"}function vIe(t){return Koe(t)&&!isNaN(t)&&t>0}function bIe(t,s){return Koe(t)&&!isNaN(t)&&t<=s&&t>=0}function ZIt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${_Ne}\`.`}function YIt(t,s){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${s}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${_Ne} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var WYe=qYe,XIt=VYe;const Bi=k.forwardRef(({className:t,value:s,...r},n)=>e.jsx(WYe,{ref:n,className:It("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(XIt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));Bi.displayName=WYe.displayName;function QIt(){const{user:t,isBrokerageManager:s}=Ds(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState(!1),[c,u]=k.useState(!0),p=s?"brokerage_manager":"agent";k.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}f()},[t==null?void 0:t.id,p]);const f=async()=>{if(t!=null&&t.id)try{const{data:L,error:I}=await H.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(I)throw I;const{data:O,error:q}=await H.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if(q)throw q;const{data:U,error:B}=await H.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(B)throw B;n(L||[]),o(O||[]),i(!!U),L&&L.length>0&&await g(L,O||[])}catch(L){console.error("Error fetching checklist data:",L)}finally{u(!1)}},g=async(L,I)=>{var xe,we;if(!(t!=null&&t.id))return;const O=I.map(Le=>Le.item_id),q=L.filter(Le=>!O.includes(Le.id));if(q.length===0)return;const[U,B,V,Y,Q,ee,X,ie,re,oe,ce,ge,ye,ue,pe]=await Promise.all([H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),H.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),H.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),H.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),H.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),H.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),H.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),H.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),H.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),H.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),H.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),_e={},$e=(xe=U.data)==null?void 0:xe.brokerage_id;_e.share_resource=(B.count||0)>0,_e.post_community=(V.count||0)>0,_e.register_event=(Y.count||0)>0,_e.view_template=(Q.count||0)>0,_e.watch_academy=(ee.count||0)>0,_e.use_toolbox=(X.count||0)>0,_e.launch_app=(ie.count||0)>0,_e.add_contact=(re.count||0)>0,_e.create_video=(oe.count||0)>0,_e.complete_touch=(ce.count||0)>0,_e.add_transaction=(ge.count||0)>0,_e.add_listing=(ye.count||0)>0,_e.add_deal=(pe.count||0)>0;const Ae=((we=ue.data)==null?void 0:we.map(Le=>Le.id))||[],Ie=[];$e?Ie.push(H.from("profiles").select("id").eq("brokerage_id",$e).neq("id",t.id).then(Le=>{var tt;_e.add_agent=(((tt=Le.data)==null?void 0:tt.length)||0)>0})):_e.add_agent=!1,Ae.length>0?(Ie.push(H.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Ae).then(Le=>{_e.add_plan=(Le.count||0)>0})),Ie.push(H.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Ae).then(Le=>{_e.schedule_popby=(Le.count||0)>0}))):(_e.add_plan=!1,_e.schedule_popby=!1),await Promise.all(Ie);const Ce=q.filter(Le=>_e[Le.action_type]);if(Ce.length>0){const Le=Ce.map(Te=>({user_id:t.id,item_id:Te.id})),{error:tt}=await H.from("onboarding_checklist_progress").upsert(Le,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!tt){const Te=Ce.map(pt=>({item_id:pt.id,completed_at:new Date().toISOString()}));o(pt=>[...pt,...Te])}}},b=async L=>{if(t!=null&&t.id)try{const{error:I}=await H.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:L});if(I)throw I;o(O=>[...O,{item_id:L,completed_at:new Date().toISOString()}])}catch(I){console.error("Error marking item complete:",I)}},_=async()=>{if(t!=null&&t.id)try{const{error:L}=await H.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(L)throw L;i(!0)}catch(L){console.error("Error dismissing checklist:",L)}},j=a.length,w=r.length,N=w>0&&j>=w,S=w>0?j/w*100:0;return{items:r,progress:a,isDismissed:l,loading:c,completedCount:j,totalCount:w,isComplete:N,progressPercentage:S,isItemComplete:L=>a.some(I=>I.item_id===L),markComplete:b,dismiss:_,refetch:f}}const JIt={add_agent:e.jsx(pr,{className:"h-4 w-4"}),share_resource:e.jsx(wd,{className:"h-4 w-4"}),post_community:e.jsx(so,{className:"h-4 w-4"}),register_event:e.jsx(hn,{className:"h-4 w-4"}),view_template:e.jsx(zv,{className:"h-4 w-4"}),watch_academy:e.jsx(Kh,{className:"h-4 w-4"}),use_toolbox:e.jsx(ty,{className:"h-4 w-4"}),launch_app:e.jsx(HI,{className:"h-4 w-4"}),add_deal:e.jsx(m0,{className:"h-4 w-4"}),add_listing:e.jsx(bn,{className:"h-4 w-4"})},eLt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function tLt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:c,dismiss:u}=QIt(),p=fr(),[f,g]=k.useState(!0);return r||s||a===0||o?null:e.jsxs(Ee,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(x0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Get Started with LevelUp"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Complete these steps to make the most of your membership"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>g(!f),className:"h-8 w-8 p-0",children:f?e.jsx(ff,{className:"h-4 w-4"}):e.jsx(Eo,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(Rr,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Progress"}),e.jsxs("span",{className:"font-medium",children:[n," of ",a," complete"]})]}),e.jsx(Bi,{value:l,className:"h-2"})]})]}),f&&e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(b=>{const _=i(b.id);return e.jsxs("div",{className:It("flex items-start gap-3 p-3 rounded-lg transition-colors",_?"bg-muted/50":"bg-background hover:bg-muted/30 cursor-pointer"),onClick:()=>{if(_)return;const j=eLt[b.action_type];j?p(j):c(b.id)},children:[e.jsx("div",{className:"mt-0.5",children:_?e.jsx(sa,{className:"h-5 w-5 text-primary"}):e.jsx(_d,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:JIt[b.action_type]||e.jsx(_d,{className:"h-4 w-4"})}),e.jsx("span",{className:It("font-medium",_&&"line-through text-muted-foreground"),children:b.title})]}),b.description&&e.jsx("p",{className:It("text-sm text-muted-foreground mt-1",_&&"line-through"),children:b.description})]})]},b.id)})})})]})}const Vx=()=>mt({queryKey:["relationship-types"],queryFn:async()=>{const{data:t,error:s}=await H.from("relationship_types").select("*").order("sort_order");if(s)throw s;return t}}),Gm=t=>{const s=ci(),r=1e3,n=async a=>{const o=[];let l=0;for(;;){const{data:i,error:c}=await a.range(l,l+r-1);if(c)throw c;const u=i??[];if(o.push(...u),u.length{let a=H.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("owner_user_id",s).order("created_at",{ascending:!1}).order("first_name");return await n(a)},enabled:!!s})},sLt=t=>mt({queryKey:["innercircle-contact",t],queryFn:async()=>{const{data:s,error:r}=await H.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),GYe=()=>{const t=ci();return mt({queryKey:["innercircle-contact-counts",t],queryFn:async()=>{const{data:s,error:r}=await H.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(r)throw r;const n={};return s==null||s.forEach(a=>{var o;(o=a.tags)==null||o.forEach(l=>{n[l.relationship_type_id]=(n[l.relationship_type_id]||0)+1})}),n},enabled:!!t})},wue=()=>{const t=Qt(),s=ci();return Lt({mutationFn:async r=>{const{tagIds:n,...a}=r,o={...a,birthday:a.birthday||null,home_anniversary:a.home_anniversary||null,owner_user_id:s},{data:l,error:i}=await H.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:c}=await H.from("innercircle_contact_tags").insert(n.map(u=>({contact_id:l.id,relationship_type_id:u})));if(c)throw c}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),wn({title:"Contact created successfully"})},onError:r=>{wn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},wNe=()=>{const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{tagIds:n,tags:a,...o}=r,l={...o,birthday:o.birthday||null,home_anniversary:o.home_anniversary||null},{data:i,error:c}=await H.from("innercircle_contacts").update(l).eq("id",s).select().single();if(c)throw c;if(n!==void 0&&(await H.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:u}=await H.from("innercircle_contact_tags").insert(n.map(p=>({contact_id:s,relationship_type_id:p})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),wn({title:"Contact updated successfully"})},onError:s=>{wn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},KYe=()=>{const t=Qt();return Lt({mutationFn:async({contactId:s,spouseContactId:r})=>{if(r){const{error:n}=await H.from("innercircle_contacts").update({spouse_contact_id:r}).eq("id",s);if(n)throw n;const{error:a}=await H.from("innercircle_contacts").update({spouse_contact_id:s}).eq("id",r);if(a)throw a}else{const{data:n}=await H.from("innercircle_contacts").select("spouse_contact_id").eq("id",s).single(),a=n==null?void 0:n.spouse_contact_id,{error:o}=await H.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",s);if(o)throw o;if(a){const{error:l}=await H.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",a);if(l)throw l}}},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-spouse"]}),wn({title:"Spouse link updated"})},onError:s=>{wn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},jNe=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("innercircle_contacts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),wn({title:"Contact deleted successfully"})},onError:s=>{wn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},qO=()=>mt({queryKey:["action-types"],queryFn:async()=>{const{data:t,error:s}=await H.from("action_types").select("*").order("sort_order");if(s)throw s;return t}}),rLt=t=>mt({queryKey:["action-scripts",t],queryFn:async()=>{let s=H.from("action_scripts").select("*, action_type:action_types(*)");const{data:r,error:n}=await s;if(n)throw n;return r}}),nLt=()=>mt({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:t,error:s}=await H.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(s)throw s;return t}}),aLt=()=>{const t=Qt(),s=ci();return Lt({mutationFn:async({name:r,description:n})=>{const{data:a,error:o}=await H.from("touchpoint_plans").insert({name:r,description:n,owner_user_id:s,active:!0,is_template:!1}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan created successfully"})},onError:r=>{wn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},iLt=()=>{const t=Qt(),s=ci();return Lt({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await H.from("touchpoint_plans").select(` *, items:touchpoint_plan_items(*) `).eq("id",r).single();if(o)throw o;if(!a)throw new Error("Source plan not found");const{data:l,error:i}=await H.from("touchpoint_plans").insert({name:n,description:a.description,owner_user_id:s,active:!0,is_template:!1}).select().single();if(i)throw i;if(a.items&&a.items.length>0){const c=a.items.map(p=>({plan_id:l.id,month_number:p.month_number,action_type_id:p.action_type_id,default_script_id:p.default_script_id,notes:p.notes})),{error:u}=await H.from("touchpoint_plan_items").insert(c);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{wn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},oLt=()=>{const t=Qt();return Lt({mutationFn:async({id:s,name:r,description:n})=>{const{data:a,error:o}=await H.from("touchpoint_plans").update({name:r,description:n}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan updated successfully"})}})},lLt=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("touchpoint_plans").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan deleted successfully"})}})},cLt=()=>{const t=Qt();return Lt({mutationFn:async({planId:s,items:r})=>{if(await H.from("touchpoint_plan_items").delete().eq("plan_id",s),r.length>0){const{error:n}=await H.from("touchpoint_plan_items").insert(r.map(a=>({plan_id:s,month_number:a.month_number,action_type_id:a.action_type_id,default_script_id:a.default_script_id||null,notes:a.notes})));if(n)throw n}},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),wn({title:"Plan schedule updated"})}})},dLt=()=>{const t=Qt();return Lt({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await H.auth.getUser(),{data:i,error:c}=await H.from("action_scripts").insert({action_type_id:s,title:r,script_body:n,email_subject:a||null,tone:o||null,active:!0,user_id:l==null?void 0:l.id}).select().single();if(c)throw c;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["action-scripts"]}),wn({title:"Script created successfully"})},onError:s=>{wn({title:"Error creating script",description:s.message,variant:"destructive"})}})},uLt=()=>{const t=ci();return mt({queryKey:["user-plan-enrollments",t],queryFn:async()=>{const{data:s,error:r}=await H.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(r)throw r;return s},enabled:!!t})},hLt=()=>{const t=Qt(),s=ci();return Lt({mutationFn:async({planId:r,relationshipTypeId:n,active:a})=>{const{data:o}=await H.from("user_plan_enrollments").select("id").eq("plan_id",r).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await H.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await H.from("user_plan_enrollments").insert({owner_user_id:s,plan_id:r,relationship_type_id:n,active:!0,start_date:new Date().toISOString().split("T")[0]});if(l)throw l}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-plan-enrollments"]}),wn({title:"Plan enrollment updated"})}})},UO=(t=7)=>{const s=ci();return mt({queryKey:["contact-touch-logs",s,t],queryFn:async()=>{const r=new Date;r.setDate(r.getDate()-t);const{data:n,error:a}=await H.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).eq("owner_user_id",s).gte("completed_at",r.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!s})},ZYe=()=>{const t=ci();return mt({queryKey:["contacts-last-touch",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_touch_logs").select("contact_id, completed_at").eq("owner_user_id",t).order("completed_at",{ascending:!1});if(r)throw r;const n={};return s==null||s.forEach(a=>{n[a.contact_id]||(n[a.contact_id]=a.completed_at)}),n},enabled:!!t})},mLt=(t=90)=>{const{data:s}=Gm(),{data:r}=ZYe();if(!s||!r)return{contacts:[],count:0};const n=new Date;n.setDate(n.getDate()-t);const a=s.filter(o=>{const l=r[o.id];return l?new Date(l){const t=Qt(),s=ci();return Lt({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o,completedAt:l})=>{const{data:i,error:c}=await H.from("contact_touch_logs").insert({owner_user_id:s,contact_id:r,action_type_id:n,script_used_id:a,notes:o,completed_at:l||new Date().toISOString()}).select().single();if(c)throw c;return i},onSuccess:async(r,n)=>{var a,o;t.invalidateQueries({queryKey:["contact-touch-logs"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),t.invalidateQueries({queryKey:["today-actions"]}),wn({title:"Action completed!"});try{const[l,i]=await Promise.all([H.from("innercircle_contacts").select("email").eq("id",n.contactId).single(),H.from("action_types").select("name").eq("id",n.actionTypeId).single()]),c=(a=l.data)==null?void 0:a.email,u=((o=i.data)==null?void 0:o.name)||"Touch";c&&H.functions.invoke("boldtrail-sync",{body:{action:"push_touch",contact_email:c,touch_type:u,touch_notes:n.notes||null,touch_date:n.completedAt||r.completed_at}}).catch(()=>{})}catch{}}})},YYe="agentos_weekly_touch_goal",_Ie=20,Zoe=()=>{if(typeof window>"u")return _Ie;const t=localStorage.getItem(YYe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return _Ie},XYe=t=>{localStorage.setItem(YYe,t.toString())},kNe=()=>{const{data:t}=UO(7),s=new Date;s.setHours(0,0,0,0);const r=new Date(s);r.setDate(s.getDate()-s.getDay());const n=(t==null?void 0:t.filter(l=>new Date(l.completed_at)>=r).length)||0;let a=0;if(t&&t.length>0){const l=new Set(t.map(c=>new Date(c.completed_at).toDateString()));let i=new Date(s);for(;l.has(i.toDateString());)a++,i.setDate(i.getDate()-1)}const o=Zoe();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},pLt=()=>{const t=ci();return mt({queryKey:["contact-plan-cycles",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_plan_cycles").select(` *, contact:innercircle_contacts(*), plan:touchpoint_plans( *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) ) `);if(r)throw r;return s},enabled:!!t})},fLt=()=>{const t=Qt();return ci(),Lt({mutationFn:async()=>{const{data:s}=await H.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await H.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await H.from("contact_plan_cycles").select("contact_id, plan_id"),a=new Set((n==null?void 0:n.map(l=>`${l.contact_id}-${l.plan_id}`))||[]),o=[];for(const l of r)for(const i of l.tags||[]){const c=s.find(u=>u.relationship_type_id===i.relationship_type_id);c&&!a.has(`${l.id}-${c.plan_id}`)&&o.push({contact_id:l.id,plan_id:c.plan_id,relationship_type_id:i.relationship_type_id})}if(o.length>0){const{error:l}=await H.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&wn({title:`${s} contact(s) enrolled in plans`})}})},QYe=()=>{const t=ci(),{data:s}=pLt(),{data:r}=UO(30);return mt({queryKey:["today-actions",t,s==null?void 0:s.length,r==null?void 0:r.length],queryFn:async()=>{var _;if(!s||s.length===0)return[];const{data:n}=await H.from("contact_snoozes").select("contact_id").gte("snoozed_until",new Date().toISOString()),a=new Set((n==null?void 0:n.map(j=>j.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),c=new Set((r==null?void 0:r.filter(j=>new Date(j.completed_at)>=i).map(j=>`${j.contact_id}-${j.action_type_id}`))||[]);for(const j of s){if(!((_=j.plan)!=null&&_.items)||j.plan.items.length===0||!j.contact||a.has(j.contact_id))continue;const w=new Date(j.cycle_start_date),S=Math.floor((o.getTime()-w.getTime())/(30.44*24*60*60*1e3))%12+1,M=j.plan.items.find(L=>L.month_number===S);if(M&&M.action_type){const L=`${j.contact_id}-${M.action_type_id}`;if(!c.has(L)){const{data:I}=await H.from("relationship_types").select("name").eq("id",j.relationship_type_id).single();l.push({contact:j.contact,actionType:M.action_type,script:M.default_script||void 0,planName:j.plan.name,relationshipTypeName:(I==null?void 0:I.name)||"",monthNumber:S})}}}const u=5,p=o.getDate(),f=l.sort((j,w)=>j.contact.first_name.localeCompare(w.contact.first_name)),g=(p-1)%Math.max(1,f.length);return[...f.slice(g),...f.slice(0,g)].slice(0,u)},enabled:!!t&&!!s})};function xLt(){const t=fr(),{data:s,isLoading:r}=QYe(),{data:n}=Gm(),a=kNe(),[o,l]=k.useState(Zoe()),[i,c]=k.useState(""),[u,p]=k.useState(!1);k.useEffect(()=>{l(Zoe())},[]);const f=()=>{const O=parseInt(i,10);if(isNaN(O)||O<1){wn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(O),XYe(O),p(!1),wn({title:"Goal updated",description:`Weekly touch goal set to ${O}`})},g=()=>{c(o.toString()),p(!0)},b=$m(new Date),_=Pl(b,7),j=O=>{if(!O)return null;const q=O.split(/[-/T]/);if(q.length<3)return null;const U=parseInt(q[1],10)-1,B=parseInt(q[2],10);return isNaN(U)||isNaN(B)?null:new Date(b.getFullYear(),U,B)},w=(n==null?void 0:n.map(O=>{const q=j(O.birthday),U=j(O.home_anniversary),B=[];return q&&q>=b&&q<=_&&B.push({contact:O,type:"birthday",date:q,isToday:Cl(q,b)}),U&&U>=b&&U<=_&&B.push({contact:O,type:"anniversary",date:U,isToday:Cl(U,b)}),B}).flat().sort((O,q)=>O.date.getTime()-q.date.getTime()).slice(0,3))||[],N=(n==null?void 0:n.filter(O=>{const q=j(O.birthday),U=j(O.home_anniversary);return q&&Cl(q,b)||U&&Cl(U,b)}).length)||0,S=(s==null?void 0:s.length)||0,M=N+S,L=(a==null?void 0:a.actionsThisWeek)||0,I=(a==null?void 0:a.streak)||0;return r?e.jsx(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-primary/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-primary/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-primary/10 rounded w-1/2"})]})]})})}):e.jsxs(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(Pt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:I>0&&e.jsxs(st,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(eh,{className:"h-3 w-3"}),I," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[M>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[M," tasks"]})," for today"]}):"No tasks for today",L>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:L})," touches this week"]})]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(Tl,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control")},children:[e.jsx(Un,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:O=>{O.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(An,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(ma,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:O=>{O.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(m0,{className:"h-3.5 w-3.5"}),"Pipeline"]})]}),e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(qi,{asChild:!0,children:e.jsx("button",{onClick:g,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Xo,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(ps,{className:"sm:max-w-[360px]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Set Weekly Goal"}),e.jsx(Gr,{children:"How many touches do you want to complete each week?"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(ze,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:O=>c(O.target.value),placeholder:"20",onKeyDown:O=>{O.key==="Enter"&&f()}})]}),e.jsx(K,{onClick:f,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:L}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(Bi,{value:Math.min(L/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),L>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),L0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-L," more to hit your weekly goal"]})]}),w.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ch,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),e.jsx("div",{className:"space-y-2",children:w.map((O,q)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${O.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:U=>{U.stopPropagation(),t(`/mission-control/contacts/${O.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[O.type==="birthday"?e.jsx(Ch,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(bn,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[O.contact.first_name," ",O.contact.last_name]}),O.isToday&&e.jsx(st,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-pink-500/20 text-pink-600",children:"Today!"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:O.isToday?O.type==="birthday"?"🎂":"🏠":ms(O.date,"EEE, MMM d")}),e.jsx(da,{className:"h-3 w-3"})]})]},`${O.contact.id}-${O.type}-${q}`))})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full gap-1 text-muted-foreground hover:text-primary",onClick:()=>t("/mission-control"),children:["Open Agent OS",e.jsx(Qa,{className:"h-4 w-4"})]})]})]})}function gLt(t){return mt({queryKey:["brokerage-content-categories",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("brokerage_content_categories").select("*").eq("brokerage_id",t).order("sort_order");if(r)throw r;return s},enabled:!!t})}function yLt(t,s){return mt({queryKey:["brokerage-content",t,s],queryFn:async()=>{if(!t)return[];let r=H.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1});s&&(r=r.eq("category_id",s));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!t})}function vLt(t,s=4){return mt({queryKey:["brokerage-content-recent",t,s],queryFn:async()=>{if(!t)return[];const{data:r,error:n}=await H.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1}).limit(s);if(n)throw n;return r},enabled:!!t})}function bLt(t){const s=Qt();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("brokerage_content").insert(r).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content"]}),s.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function _Lt(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("brokerage_content").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content"]}),t.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function wLt(t){const s=Qt();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("brokerage_content_categories").insert({...r,brokerage_id:t}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function jLt(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("brokerage_content_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function NLt(t){const s=Qt();return Lt({mutationFn:async()=>{const r=[{name:"Events",icon:"📅",sort_order:0,is_default:!0,brokerage_id:t},{name:"Videos",icon:"🎥",sort_order:1,is_default:!0,brokerage_id:t},{name:"Documents",icon:"📄",sort_order:2,is_default:!0,brokerage_id:t},{name:"Resources",icon:"🔗",sort_order:3,is_default:!0,brokerage_id:t},{name:"Graphics",icon:"🎨",sort_order:4,is_default:!0,brokerage_id:t}],{error:n}=await H.from("brokerage_content_categories").upsert(r,{onConflict:"brokerage_id,name"});if(n)throw n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}const kLt={video:nl,pdf:Sn,link:dl,event:hn,graphic:ic},SLt={video:"bg-red-500/10 text-red-600 dark:text-red-400",pdf:"bg-blue-500/10 text-blue-600 dark:text-blue-400",link:"bg-green-500/10 text-green-600 dark:text-green-400",event:"bg-purple-500/10 text-purple-600 dark:text-purple-400",graphic:"bg-amber-500/10 text-amber-600 dark:text-amber-400"};function CLt(t){if(!t)return null;try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}function MLt(t){if(!t)return!1;try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function TLt({item:t}){const s=fr(),r=kLt[t.content_type]||dl,n=SLt[t.content_type]||"",[a,o]=k.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?CLt(t.url):null);k.useEffect(()=>{l||!t.url||t.content_type!=="video"||!MLt(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(c=>c.ok?c.json():null).then(c=>{c!=null&&c.thumbnail_url&&o(c.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,l]);const i=l||a;return e.jsxs(Ee,{className:"group cursor-pointer overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",onClick:()=>s(`/brokerage-content/${t.id}`),children:[i?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:i,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/20 flex items-center justify-center",children:e.jsx(r,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(st,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${n}`,children:[e.jsx(r,{className:"h-3 w-3 mr-0.5"}),t.content_type]})}),e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:t.title}),t.content_type==="event"&&t.event_date&&e.jsx("p",{className:"text-xs text-primary mt-1 font-medium",children:ms(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function ALt(){const{brokerageId:t}=Ds(),s=fr(),{data:r=[],isLoading:n}=vLt(t,4);return!t||n||r.length===0?null:e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Brokerage Content"})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/brokerage-content"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Qa,{className:"h-4 w-4"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:r.map(a=>e.jsx(TLt,{item:a},a.id))})]})}const JYe=()=>mt({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:t,error:s}=await H.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(s)throw s;return(t==null?void 0:t.enabled)??!1}}),eXe=t=>{const{user:s,brokerageId:r}=Ds();return mt({queryKey:["listings",t,r],queryFn:async()=>{let n=H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0);t!=null&&t.status&&(n=n.eq("status",t.status)),t!=null&&t.propertyType&&(n=n.eq("property_type",t.propertyType)),t!=null&&t.city&&(n=n.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(n=n.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(n=n.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(n=n.eq("open_to_referrals",!0));const{data:a,error:o}=await n;if(o)throw o;let l=a||[];if(r){const{data:i}=await H.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const c=i.map(f=>f.id);let u=H.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",c);t!=null&&t.status&&(u=u.eq("status",t.status)),t!=null&&t.propertyType&&(u=u.eq("property_type",t.propertyType)),t!=null&&t.city&&(u=u.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(u=u.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(u=u.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(u=u.eq("open_to_referrals",!0));const{data:p}=await u;if(p){const f=new Set(l.map(b=>b.id)),g=p.filter(b=>!f.has(b.id));l=[...l,...g]}}}switch(t==null?void 0:t.sortBy){case"updated":l.sort((i,c)=>new Date(c.updated_at).getTime()-new Date(i.updated_at).getTime());break;case"price_asc":l.sort((i,c)=>i.price-c.price);break;case"price_desc":l.sort((i,c)=>c.price-i.price);break;default:l.sort((i,c)=>new Date(c.created_at).getTime()-new Date(i.created_at).getTime())}return l}})},tXe=()=>{const{user:t}=Ds();return mt({queryKey:["my-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})},sXe=t=>{const{user:s}=Ds();return mt({queryKey:["listing",t],queryFn:async()=>{const{data:r,error:n}=await H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds) `).eq("id",t).single();if(n)throw n;return s&&await H.from("listing_views").insert({listing_id:t,viewer_id:s.id}),r},enabled:!!t})},ELt=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("listings").insert({...r,agent_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},PLt=()=>{const t=Qt();return Lt({mutationFn:async({agentId:s,...r})=>{const{data:n,error:a}=await H.from("listings").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["brokerage-listings"]})}})},ILt=()=>{const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("listings").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["listing",s.id]})}})},rXe=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("listings").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},LLt=()=>{const t=Qt();return Lt({mutationFn:async({listingId:s,photoUrl:r,isPrimary:n=!1})=>{const{data:a,error:o}=await H.from("listing_photos").insert({listing_id:s,photo_url:r,is_primary:n}).select().single();if(o)throw o;return a},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s.listing_id]}),t.invalidateQueries({queryKey:["my-listings"]})}})},DLt=()=>{const t=Qt();return Lt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await H.from("listing_photos").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},OLt=()=>{const t=Qt();return Lt({mutationFn:async({photos:s})=>{var o;const r=s.map(l=>H.from("listing_photos").update({sort_order:l.sort_order,is_primary:l.is_primary}).eq("id",l.id)),a=(o=(await Promise.all(r)).find(l=>l.error))==null?void 0:o.error;if(a)throw a;return s},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["listing"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},RLt=()=>{const t=Qt();return Lt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await H.from("listing_photos").update({is_primary:!1}).eq("listing_id",r);if(n)throw n;const{error:a}=await H.from("listing_photos").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},FLt=()=>{const{user:t}=Ds();return mt({queryKey:["saved-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("listing_saves").select(` *, listing:listings( *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id) ) `).eq("agent_id",t.id);if(r)throw r;return s},enabled:!!t})},nXe=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await H.from("listing_saves").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await H.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await H.from("listing_saves").insert({listing_id:r,agent_id:s.id}),{saved:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})},aXe=t=>{const{user:s}=Ds();return mt({queryKey:["listing-saved",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await H.from("listing_saves").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},zLt=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await H.from("listing_follows").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await H.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await H.from("listing_follows").insert({listing_id:r,agent_id:s.id}),{following:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["listing-following"]})}})},BLt=t=>{const{user:s}=Ds();return mt({queryKey:["listing-following",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await H.from("listing_follows").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},$Lt=()=>{const{user:t}=Ds();return Lt({mutationFn:async({listingId:s,shareType:r})=>{if(!t)throw new Error("Not authenticated");const{error:n}=await H.from("listing_shares").insert({listing_id:s,sharing_agent_id:t.id,share_type:r});if(n)throw n}})},qLt=()=>{const{user:t}=Ds();return mt({queryKey:["my-referrals",t==null?void 0:t.id],queryFn:async()=>{if(!t)return{sent:[],received:[]};const[s,r]=await Promise.all([H.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",t.id).order("created_at",{ascending:!1}),H.from("listing_referrals").select(` *, sender:profiles!listing_referrals_sender_agent_id_fkey(id, name, email), listing:listings(*,photos:listing_photos(*)) `).eq("listing_agent_id",t.id).order("created_at",{ascending:!1})]);return{sent:s.data||[],received:r.data||[]}},enabled:!!t})},ULt=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async({listingId:r,listingAgentId:n,buyerName:a,buyerType:o,notes:l})=>{if(!s)throw new Error("Not authenticated");const{data:i,error:c}=await H.from("listing_referrals").insert({listing_id:r,sender_agent_id:s.id,listing_agent_id:n,buyer_name:a,buyer_type:o,notes:l}).select().single();if(c)throw c;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["my-referrals"]})}})},VLt=()=>mt({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await H.from("listing_shares").select("sharing_agent_id, profiles!listing_shares_agent_id_fkey(name)").order("created_at",{ascending:!1}),s=new Map;t==null||t.forEach(l=>{var u;const i=l.sharing_agent_id;if(!i)return;const c=s.get(i);c?c.count++:s.set(i,{name:((u=l.profiles)==null?void 0:u.name)||"Unknown",count:1})});const r=Array.from(s.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10),{data:n}=await H.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 c;const i=a.get(l.agent_id);i?i.count++:a.set(l.agent_id,{name:((c=l.agent)==null?void 0:c.name)||"Unknown",count:1})});const o=Array.from(a.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10);return{topSharers:r,topListers:o}}}),HLt=()=>{const{user:t,brokerageId:s}=Ds();return mt({queryKey:["brokerage-listings",s],queryFn:async()=>{if(!t||!s)return[];const{data:r}=await H.from("profiles").select("id").eq("brokerage_id",s);if(!r||r.length===0)return[];const n=r.map(l=>l.id),{data:a,error:o}=await H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).in("agent_id",n).eq("is_approved",!0).order("created_at",{ascending:!1});if(o)throw o;return a},enabled:!!t&&!!s})},iXe=({className:t,variant:s="default"})=>e.jsx(st,{variant:"outline",className:It("text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0 h-4",s==="default"?"border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10":"border-muted-foreground/30 text-muted-foreground",t),children:"Beta"}),WLt={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"},GLt={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function KLt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function ZLt(){const t=fr(),{data:s,isLoading:r}=JYe(),{data:n,isLoading:a}=eXe({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),c=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(Ee,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-emerald-500/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-emerald-500/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-emerald-500/10 rounded w-1/2"})]})]})})}):e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Listing Exchange"}),e.jsx(iXe,{})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Qa,{className:"h-4 w-4"})]})]}),c.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(bn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(K,{variant:"link",size:"sm",onClick:()=>t("/mission-control/listings/new"),className:"mt-2",children:"Add the first listing"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:c.map(p=>{var g,b;const f=((g=p.photos)==null?void 0:g.find(_=>_.is_primary))||((b=p.photos)==null?void 0:b[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${p.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden relative",children:[f!=null&&f.photo_url?e.jsx("img",{src:f.photo_url,alt:`${p.city}, ${p.state}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(bn,{className:"h-8 w-8 text-muted-foreground/50"})}),p.is_featured&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(st,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(Jn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(st,{className:`text-[10px] px-1.5 py-0.5 ${WLt[p.status]}`,children:GLt[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:KLt(p.price)}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[p.city,", ",p.state]}),(p.bedrooms||p.bathrooms)&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[p.bedrooms&&`${p.bedrooms} bed`,p.bedrooms&&p.bathrooms&&" · ",p.bathrooms&&`${p.bathrooms} bath`]})]})]},p.id)})})]})}function oXe(t=10,s){return mt({queryKey:["event-leaderboard",t,s],queryFn:async()=>{const{data:r}=await H.from("user_roles").select("user_id").eq("role","admin"),n=new Set((r==null?void 0:r.map(g=>g.user_id))||[]);let a=null;if(s){const{data:g}=await H.from("profiles").select("id").eq("brokerage_id",s);a=new Set((g==null?void 0:g.map(b=>b.id))||[])}const{data:o,error:l}=await H.from("agent_attendance_stats").select("user_id, total_points, total_events_attended, current_streak").order("total_points",{ascending:!1}).limit(t+n.size+50);if(l)throw l;if(!o||o.length===0)return[];let i=o.filter(g=>!n.has(g.user_id));a&&(i=i.filter(g=>a.has(g.user_id)));const c=i.slice(0,t),u=c.map(g=>g.user_id),{data:p}=await H.from("profiles").select("id, name").in("id",u),f=new Map((p==null?void 0:p.map(g=>[g.id,{name:g.name}]))||[]);return c.map(g=>({user_id:g.user_id,total_points:g.total_points,total_events_attended:g.total_events_attended,current_streak:g.current_streak,profile:f.get(g.user_id)||null}))}})}function lXe(t){return mt({queryKey:["user-attendance-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("agent_attendance_stats").select("*").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return s},enabled:!!t})}function cXe(t){return mt({queryKey:["user-badges",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("agent_badges").select("*").eq("user_id",t).order("earned_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function dXe(t,s){return mt({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await H.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await H.from("user_roles").select("user_id").eq("role","admin"),a=new Set((n==null?void 0:n.map(c=>c.user_id))||[]),{data:o,error:l}=await H.from("agent_attendance_stats").select("user_id, total_points").gt("total_points",r.total_points);if(l)throw l;let i=(o==null?void 0:o.filter(c=>!a.has(c.user_id)))||[];if(s){const{data:c}=await H.from("profiles").select("id").eq("brokerage_id",s),u=new Set((c==null?void 0:c.map(p=>p.id))||[]);i=i.filter(p=>u.has(p.user_id))}return i.length+1},enabled:!!t})}function YLt(){const{user:t,brokerageId:s,isAdmin:r}=Ds();fr();const n=!!s,[a,o]=k.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:c}=oXe(5,l()),{data:u}=lXe(t==null?void 0:t.id),{data:p}=dXe(t==null?void 0:t.id,l()),{data:f}=cXe(t==null?void 0:t.id),g=r||n,b=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(c)return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4 text-yellow-500"}),b()]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...Array(g?5:3)].map((j,w)=>e.jsx(ys,{className:"h-10 w-full"},w))})})]});const _=j=>j===0?e.jsx(xo,{className:"h-4 w-4 text-yellow-500 mx-auto"}):j===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):j===2?e.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:j+1});if(g){const j=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-2",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4 text-yellow-500"}),b()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(K,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(K,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(Oe,{children:[!r&&u&&e.jsx("div",{className:"mb-3 p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Your Rank:"}),e.jsxs("span",{className:"font-bold text-primary",children:["#",p||"-"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:u.total_points})," pts"]}),e.jsxs("span",{children:[e.jsx("strong",{children:u.total_events_attended})," events"]})]})]})}),e.jsxs("div",{className:"space-y-2",children:[j.map((w,N)=>{var S,M,L;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${w.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":N===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:_(N)}),e.jsx(Nn,{className:"h-6 w-6",children:e.jsx(kn,{className:"text-xs",children:((M=(S=w.profile)==null?void 0:S.name)==null?void 0:M.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((L=w.profile)==null?void 0:L.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:w.total_points})]},w.user_id)}),j.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(Pi,{to:"/reward-store",className:"mt-3 flex items-center justify-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[e.jsx(ko,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(da,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Oe,{children:u?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:u.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Points"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:u.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events Attended"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(eh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Current Streak"})]}),e.jsxs("span",{className:"font-bold text-orange-500",children:[u.current_streak," 🔥"]})]}),f&&f.length>0&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx(Nc,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.slice(0,4).map(j=>e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-600 border border-yellow-500/20",children:j.badge_name},j.id)),f.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",f.length-4," more"]})]})]}),e.jsxs(Pi,{to:"/reward-store",className:"mt-3 flex items-center justify-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[e.jsx(ko,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(da,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(Jn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(Pi,{to:"/reward-store",className:"mt-3 inline-flex items-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[e.jsx(ko,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(da,{className:"h-4 w-4"})]})]})})]})}const nE=()=>mt({queryKey:["lead-sources"],queryFn:async()=>{const{data:t,error:s}=await H.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return t}}),SNe=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{const{data:n}=await H.from("lead_sources").select("id, name").eq("is_active",!0).ilike("name",r.trim()),a=(n||[]).find(i=>i.name.toLowerCase()===r.trim().toLowerCase()&&!0);if(a)throw new Error(`Lead source "${a.name}" already exists`);const{data:o,error:l}=await H.from("lead_sources").insert({name:r,owner_user_id:s==null?void 0:s.id,sort_order:100}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source added")},onError:r=>{me.error("Failed to add lead source"),console.error(r)}})},XLt=()=>{const t=Qt();return Lt({mutationFn:async({id:s,name:r})=>{const{error:n}=await H.from("lead_sources").update({name:r}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source updated")},onError:s=>{me.error(s.message||"Failed to update lead source")}})},QLt=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("lead_sources").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source removed")},onError:s=>{me.error(s.message||"Failed to remove lead source")}})},CNe=(t,s)=>{const{user:r,isAdmin:n}=Ds(),a=n&&s?s:r==null?void 0:r.id;return mt({queryKey:["scorecard-transactions",t,a],queryFn:async()=>{let o=H.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",a).order("close_date",{ascending:!1});t&&(o=o.gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`));const{data:l,error:i}=await o;if(i)throw i;return l},enabled:!!a})},MNe=t=>{const{user:s,isAdmin:r}=Ds(),n=r&&t?t:s==null?void 0:s.id;return mt({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await H.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})},jue=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("scorecard_transactions").insert({...r,owner_user_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction added")},onError:r=>{me.error("Failed to add transaction"),console.error(r)}})},JLt=()=>{const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("scorecard_transactions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction updated")},onError:s=>{me.error("Failed to update transaction"),console.error(s)}})},e8t=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("scorecard_transactions").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction deleted")},onError:s=>{me.error("Failed to delete transaction"),console.error(s)}})},uXe=(t,s)=>{const{user:r,isAdmin:n}=Ds(),a=n&&s?s:r==null?void 0:r.id;return mt({queryKey:["scorecard-goals",t,a],queryFn:async()=>{const{data:o,error:l}=await H.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",t).maybeSingle();if(l)throw l;return o},enabled:!!a})},t8t=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("scorecard_goals").upsert({...r,owner_user_id:s.id},{onConflict:"owner_user_id,year"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["scorecard-goals",n.year]}),me.success("Goals saved")},onError:r=>{me.error("Failed to save goals"),console.error(r)}})},Nue=()=>{const{user:t}=Ds();return mt({queryKey:["scorecard-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("scorecard_settings").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s},enabled:!!(t!=null&&t.id)})},s8t=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("scorecard_settings").upsert({...r,user_id:s.id},{onConflict:"user_id"}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-settings"]}),me.success("Settings saved")},onError:r=>{me.error("Failed to save settings"),console.error(r)}})},hXe=(t,s)=>{const{data:r,isLoading:n}=CNe(t,s),{data:a,isLoading:o}=MNe(s),{data:l}=Nue(),i=(l==null?void 0:l.show_commission)??!0,c=u=>{if(!u||u.length===0)return{totalTransactions:0,buyerCount:0,sellerCount:0,totalVolume:0,averagePrice:0,totalCommission:0,totalNetToAgent:0,topLeadSource:null,transactionsByMonth:[],leadSourceBreakdown:[]};const p=u.filter(I=>I.transaction_type==="buyer").length,f=u.filter(I=>I.transaction_type==="seller").length,g=u.reduce((I,O)=>I+Number(O.sale_price),0),b=u.reduce((I,O)=>I+(Number(O.commission_amount)||0),0),_=u.reduce((I,O)=>{const q=Number(O.commission_amount)||0;if(!q)return I;let U=q;return O.brokerage_split_pct&&(U-=q*(O.brokerage_split_pct/100)),O.team_split_pct&&(U-=q*(O.team_split_pct/100)),O.franchise_fee_pct&&(U-=q*(O.franchise_fee_pct/100)),O.referral_fee_pct&&(U-=q*(O.referral_fee_pct/100)),O.transaction_fee&&(U-=O.transaction_fee),I+Math.max(0,U)},0),j={};u.forEach(I=>{var q;const O=((q=I.lead_source)==null?void 0:q.name)||"Unknown";j[O]=(j[O]||0)+1});const w=Object.entries(j).map(([I,O])=>({name:I,count:O})).sort((I,O)=>O.count-I.count),N=w[0]||null,S={};u.forEach(I=>{const O=Ol(I.close_date).toLocaleString("default",{month:"short"});S[O]=(S[O]||0)+1});const L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(I=>({month:I,count:S[I]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:f,totalVolume:g,averagePrice:u.length>0?g/u.length:0,totalCommission:i?b:0,totalNetToAgent:i?_:0,topLeadSource:N,transactionsByMonth:L,leadSourceBreakdown:w}};return{yearStats:c(r),lifetimeStats:c(a),isLoading:n||o,showCommission:i}},r8t=()=>{const{isAdmin:t}=Ds();return mt({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:s,error:r}=await H.from("scorecard_transactions").select("owner_user_id").order("owner_user_id");if(r)throw r;const n=[...new Set(s.map(l=>l.owner_user_id))],{data:a,error:o}=await H.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:t})},Kb={recency:40,touchpoints:30,transactions:20},wIe={warm:70,cooling:40};function n8t(t){return t===null?0:t<=14?Kb.recency:t<=30?Kb.recency*.85:t<=60?Kb.recency*.65:t<=90?Kb.recency*.4:t<=180?Kb.recency*.2:Kb.recency*.05}function a8t(t){const s=Math.min(t/12,1);return Math.round(Kb.touchpoints*s)}function i8t(t){return t?Kb.transactions:0}function o8t(){return 0}function l8t(t){return t>=wIe.warm?"warm":t>=wIe.cooling?"cooling":"at-risk"}function kue(){const{data:t,isLoading:s}=Gm(),{data:r}=ZYe(),{data:n}=UO(365),{data:a}=MNe(),o=k.useMemo(()=>{if(!t)return[];const i=new Date,c=v4(i,12),u={};n==null||n.forEach(f=>{new Date(f.completed_at)>=c&&(u[f.contact_id]=(u[f.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(f=>f.contact_id).map(f=>f.contact_id))||[]);return t.map(f=>{const g=(r==null?void 0:r[f.id])||null,b=g?ly(i,new Date(g)):null,_=u[f.id]||0,j=p.has(f.id),w=n8t(b),N=a8t(_),S=i8t(j),M=o8t(),L=Math.round(w+N+S+M),I={score:L,status:l8t(L),breakdown:{recency:Math.round(w),touchpoints:Math.round(N),transactions:Math.round(S),referrals:Math.round(M)},lastTouchDate:g,daysSinceTouch:b,touchCountLast12Months:_,hasTransaction:j};return{...f,relationshipScore:I}})},[t,r,n,a]),l=k.useMemo(()=>{const i=o.filter(g=>g.relationshipScore.status==="warm").length,c=o.filter(g=>g.relationshipScore.status==="cooling").length,u=o.filter(g=>g.relationshipScore.status==="at-risk").length,p=o.length,f=p>0?Math.round(o.reduce((g,b)=>g+b.relationshipScore.score,0)/p):0;return{warm:i,cooling:c,atRisk:u,total:p,averageScore:f}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function mXe(){const t=fr(),{stats:s,contactsWithScores:r,isLoading:n}=kue();if(n)return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(ys,{className:"h-5 w-40"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(ys,{className:"h-20 w-full"}),e.jsx(ys,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>t("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(s.warm/s.total*100),o=Math.round(s.cooling/s.total*100),l=Math.round(s.atRisk/s.total*100),i=r.filter(c=>c.relationshipScore.status==="at-risk").sort((c,u)=>c.relationshipScore.score-u.relationshipScore.score).slice(0,3);return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ul,{className:"h-5 w-5 text-emerald-500"}),"Relationship Health"]}),e.jsx("span",{className:"text-2xl font-bold",children:s.averageScore})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Average score across ",s.total," contacts"]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-500"}),e.jsx("span",{children:"Warm"})]}),e.jsxs("span",{className:"font-medium",children:[s.warm," (",a,"%)"]})]}),e.jsx(Bi,{value:a,className:"h-2 bg-muted [&>div]:bg-emerald-500"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-amber-500"}),e.jsx("span",{children:"Cooling Off"})]}),e.jsxs("span",{className:"font-medium",children:[s.cooling," (",o,"%)"]})]}),e.jsx(Bi,{value:o,className:"h-2 bg-muted [&>div]:bg-amber-500"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-red-500"}),e.jsx("span",{children:"At Risk"})]}),e.jsxs("span",{className:"font-medium",children:[s.atRisk," (",l,"%)"]})]}),e.jsx(Bi,{value:l,className:"h-2 bg-muted [&>div]:bg-red-500"})]})]}),i.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(fS,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Needs Attention"})]}),e.jsx("div",{className:"space-y-2",children:i.map(c=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-red-500/5 hover:bg-red-500/10 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${c.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),e.jsxs("span",{className:"text-sm",children:[c.first_name," ",c.last_name]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:c.relationshipScore.daysSinceTouch===null?"Never":`${c.relationshipScore.daysSinceTouch}d`}),e.jsx(da,{className:"h-3 w-3"})]})]},c.id))})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(da,{className:"h-4 w-4 ml-1"})]})]})]})}const c8t=()=>{var re;const{user:t,isAdmin:s}=Ds(),r=fr(),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,c]=k.useState([]),[u,p]=k.useState([]),[f,g]=k.useState([]),[b,_]=k.useState([]),[j,w]=k.useState(new Set),[N,S]=k.useState([]),[M,L]=k.useState([]),[I,O]=k.useState([]),[q,U]=k.useState(null),[B,V]=k.useState(!0);k.useEffect(()=>{Y()},[t]);const Y=async()=>{var oe,ce,ge,ye,ue;try{const[pe,_e,$e,Ae,Ie,Ce,xe,we,Le,tt,Te]=await Promise.all([H.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),H.from("app_tiles").select("*").order("name"),H.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),H.from("events").select("*").order("event_date",{ascending:!0}),H.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),H.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),H.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),H.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),H.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),H.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),H.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(oe=Te.data)!=null&&oe.name&&U(Te.data.name);const pt=((ce=pe.data)==null?void 0:ce.map(rt=>rt.tag))||[],fe=new Set(((ge=$e.data)==null?void 0:ge.map(rt=>rt.app_id))||[]);w(fe);const at=(((ye=_e.data)==null?void 0:ye.filter(rt=>!rt.required_tags||rt.required_tags.length===0?!0:rt.required_tags.some(He=>pt.includes(He))))||[]).sort((rt,He)=>rt.name==="LevelUp Members Portal"?-1:He.name==="LevelUp Members Portal"?1:0);a(at.slice(0,6));const et=((ue=Ae.data)==null?void 0:ue.filter(rt=>JM(rt.event_date)!=="ended"))||[];l(et.slice(0,4)),S(Ie.data||[]),c(Ce.data||[]),p(xe.data||[]),g(we.data||[]),_(Le.data||[]);const Me=tt.data||[];L(Me.filter(rt=>rt.placement==="top")),O(Me.filter(rt=>rt.placement==="between"))}catch(pe){console.error("Error loading dashboard:",pe),me.error("Failed to load dashboard data")}finally{V(!1)}},Q=async oe=>{var ge;const ce=window.open("about:blank","_blank");try{await H.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:oe.app_id,app_name:oe.name,user_agent:navigator.userAgent});const{data:ye,error:ue}=await H.functions.invoke("sso-launch",{body:{app_id:oe.app_id}});if(ue)throw ue;ye!=null&&ye.redirect_url?ce&&!ce.closed?(ce.location.href=ye.redirect_url,(ge=ce.focus)==null||ge.call(ce)):window.location.assign(ye.redirect_url):(ce==null||ce.close(),me.error("Launch link unavailable"))}catch(ye){ce==null||ce.close(),console.error("Error launching app:",ye),me.error("Failed to launch app")}},ee=oe=>N==null?void 0:N.some(ce=>ce.event_id===oe),X=oe=>{const ce=N==null?void 0:N.find(ge=>ge.event_id===oe);return ce==null?void 0:ce.zoom_join_url};if(B)return e.jsx(Ms,{title:"Dashboard",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading your dashboard..."})]})})});const ie=oe=>I.filter(ce=>ce.section_after===oe);return e.jsxs(Ms,{title:"Dashboard",children:[e.jsx(VIt,{events:o,registrations:N,onNavigateToEvents:()=>r("/events")}),M.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(YP,{banners:M})}),e.jsx(tLt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",(q||((re=t==null?void 0:t.user_metadata)==null?void 0:re.name)||"there").split(" ")[0],"!"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Are you ready to LevelUp today?"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 mb-8",children:[e.jsx(xLt,{}),e.jsx(mXe,{}),e.jsx(YLt,{})]}),e.jsx(ALt,{}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Upcoming Events"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Qa,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]})})}):e.jsx("div",{className:"bg-card rounded-xl border border-border overflow-hidden divide-y divide-border max-w-full",children:o.map(oe=>{const ce=ee(oe.id),ge=X(oe.id)||oe.zoom_link;return e.jsxs("div",{className:`flex items-start gap-3 sm:gap-4 p-3 sm:p-4 hover:bg-muted/50 transition-colors cursor-pointer group ${yIe(oe.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[yIe(oe.event_date)?e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-red-500/10 flex flex-col items-center justify-center relative",children:[e.jsx("span",{className:"absolute inline-flex h-3 w-3 top-1 right-1 animate-ping rounded-full bg-red-500 opacity-75"}),e.jsx(h1,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"text-[10px] font-bold text-red-500 uppercase mt-0.5",children:"Live"})]}):e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-primary/10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-[10px] sm:text-xs font-medium text-primary uppercase",children:new Intl.DateTimeFormat("en-US",{month:"short",timeZone:"America/New_York"}).format(new Date(oe.event_date))}),e.jsx("span",{className:"text-lg sm:text-xl font-bold text-primary",children:new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:"America/New_York"}).format(new Date(oe.event_date))})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base text-foreground group-hover:text-primary transition-colors line-clamp-2 sm:truncate",children:oe.title}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground mt-0.5",children:[new Intl.DateTimeFormat("en-US",{weekday:"long",timeZone:"America/New_York"}).format(new Date(oe.event_date))," at ",oD(new Date(oe.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:ce?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:ye=>{ye.stopPropagation(),window.open(ge,"_blank")},children:[e.jsx(tn,{className:"h-3.5 w-3.5"}),"Join"]}):e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors",children:[e.jsx("span",{className:"text-sm",children:"Register"}),e.jsx(da,{className:"h-4 w-4"})]})})]},oe.id)})})]}),ie("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(YP,{banners:ie("events")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Academy Videos"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Qa,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pp,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No academy videos available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:f.map(oe=>e.jsxs("div",{onClick:()=>r(`/academy/${oe.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden relative",children:[oe.thumbnail_url?e.jsx("img",{src:oe.thumbnail_url,alt:oe.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(pp,{className:"h-8 w-8 text-muted-foreground/50"})}),oe.duration&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:oe.duration})]}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground line-clamp-2 group-hover:text-primary transition-colors",children:oe.title})})]},oe.id))})]}),ie("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(YP,{banners:ie("academy")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Resource Kits"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Qa,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Om,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No resource kits available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:u.map(oe=>e.jsxs("div",{onClick:()=>r(`/toolbox/${oe.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:oe.featured_image_url?e.jsx("img",{src:oe.featured_image_url,alt:oe.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Om,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:oe.name})})]},oe.id))})]}),ie("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(YP,{banners:ie("toolbox")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"New Templates"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Qa,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(z_,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No templates available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map(oe=>e.jsxs("div",{onClick:()=>r("/templates"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:oe.preview_image_url?e.jsx("img",{src:oe.preview_image_url,alt:oe.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(z_,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:oe.name})})]},oe.id))})]}),ie("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(YP,{banners:ie("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(ZLt,{})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Your Apps"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Qa,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(kx,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No apps available"})]})})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:n.map(oe=>{const ce=j.has(oe.id);return e.jsxs("div",{onClick:()=>Q(oe),className:"group flex items-start gap-4 p-5 bg-card rounded-xl border border-border cursor-pointer transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:oe.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:oe.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:oe.description})]}),ce&&e.jsx(kx,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},oe.id)})})]}),e.jsxs("section",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Additional Services"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Qa,{className:"h-4 w-4"})]})]}),b.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional services available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:b.map(oe=>e.jsxs("div",{onClick:()=>window.open(oe.signup_link_url,"_blank"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden",children:oe.preview_image_url?e.jsx("img",{src:oe.preview_image_url,alt:oe.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(pn,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsxs("div",{className:"p-3",children:[e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:oe.name}),oe.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:oe.description})]})]},oe.id))})]})]})};var pXe="AlertDialog",[d8t]=ad(pXe,[XHe]),$1=XHe(),fXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=$1(s);return e.jsx(Ude,{...n,...r,modal:!0})};fXe.displayName=pXe;var u8t="AlertDialogTrigger",xXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=$1(r);return e.jsx(lje,{...a,...n,ref:s})});xXe.displayName=u8t;var h8t="AlertDialogPortal",gXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=$1(s);return e.jsx(Vde,{...n,...r})};gXe.displayName=h8t;var m8t="AlertDialogOverlay",yXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=$1(r);return e.jsx(KA,{...a,...n,ref:s})});yXe.displayName=m8t;var eT="AlertDialogContent",[p8t,f8t]=d8t(eT),x8t=L$e("AlertDialogContent"),vXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=$1(r),l=k.useRef(null),i=qa(s,l),c=k.useRef(null);return e.jsx(hNt,{contentName:eT,titleName:bXe,docsSlug:"alert-dialog",children:e.jsx(p8t,{scope:r,cancelRef:c,children:e.jsxs(ZA,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Ir(a.onOpenAutoFocus,u=>{var p;u.preventDefault(),(p=c.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(x8t,{children:n}),e.jsx(y8t,{contentRef:l})]})})})});vXe.displayName=eT;var bXe="AlertDialogTitle",_Xe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=$1(r);return e.jsx(EO,{...a,...n,ref:s})});_Xe.displayName=bXe;var wXe="AlertDialogDescription",jXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=$1(r);return e.jsx(PO,{...a,...n,ref:s})});jXe.displayName=wXe;var g8t="AlertDialogAction",NXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=$1(r);return e.jsx(IO,{...a,...n,ref:s})});NXe.displayName=g8t;var kXe="AlertDialogCancel",SXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=f8t(kXe,r),o=$1(r),l=qa(s,a);return e.jsx(IO,{...o,...n,ref:l})});SXe.displayName=kXe;var y8t=({contentRef:t})=>{const s=`\`${eT}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${eT}\` by passing a \`${wXe}\` 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 \`${eT}\`. 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 k.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},v8t=fXe,b8t=xXe,_8t=gXe,CXe=yXe,MXe=vXe,TXe=NXe,AXe=SXe,EXe=_Xe,PXe=jXe;const kc=v8t,Cm=b8t,w8t=_8t,IXe=k.forwardRef(({className:t,...s},r)=>e.jsx(CXe,{className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));IXe.displayName=CXe.displayName;const Ql=k.forwardRef(({className:t,...s},r)=>e.jsxs(w8t,{children:[e.jsx(IXe,{}),e.jsx(MXe,{ref:r,className:It("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));Ql.displayName=MXe.displayName;const Jl=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-2 text-center sm:text-left",t),...s});Jl.displayName="AlertDialogHeader";const ec=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});ec.displayName="AlertDialogFooter";const tc=k.forwardRef(({className:t,...s},r)=>e.jsx(EXe,{ref:r,className:It("text-lg font-semibold",t),...s}));tc.displayName=EXe.displayName;const sc=k.forwardRef(({className:t,...s},r)=>e.jsx(PXe,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));sc.displayName=PXe.displayName;const Rl=k.forwardRef(({className:t,...s},r)=>e.jsx(TXe,{ref:r,className:It(X8(),t),...s}));Rl.displayName=TXe.displayName;const rc=k.forwardRef(({className:t,...s},r)=>e.jsx(AXe,{ref:r,className:It(X8({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));rc.displayName=AXe.displayName;const j8t=[{key:"contacts",label:"Contacts",icon:Un,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:nS,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Om,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:An,description:"View and upload videos"},{key:"listings",label:"Listings",icon:bn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:F_,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:ma,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:Mx,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:Sh,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:ey,description:"Create and manage smart presentations"}];function N8t(){var q;const{user:t}=Ds(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState(null),[f,g]=k.useState({email:"",name:"",password:""}),[b,_]=k.useState("create"),[j,w]=k.useState(!1),[N,S]=k.useState(null);k.useEffect(()=>{t&&M()},[t]);const M=async()=>{if(t){a(!0);try{const{data:U,error:B}=await H.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(B)throw B;if(U&&U.length>0){const V=U.map(ee=>ee.assistant_id),{data:Y}=await H.from("profiles").select("id, name, email").in("id",V),Q=U.map(ee=>{const X=Y==null?void 0:Y.find(ie=>ie.id===ee.assistant_id);return{...ee,permissions:ee.permissions,assistant_profile:X?{name:X.name||"",email:X.email||""}:void 0}});r(Q)}else r([])}catch(U){console.error("Error loading assistants:",U)}finally{a(!1)}}},L=async()=>{if(t){if(b==="link"){if(!f.email.trim()){me.error("Please enter the assistant's email");return}w(!0);try{const{data:{session:U}}=await H.auth.getSession();if(!U)throw new Error("Not authenticated");const{data:B,error:V}=await H.from("profiles").select("id, name, email").eq("email",f.email.trim().toLowerCase()).single();if(V||!B){me.error("No account found with that email. Try creating a new assistant instead.");return}const{data:Y}=await H.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",B.id);if(Y&&Y.length>0){me.error("This assistant is already assigned to you");return}const Q=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({userId:B.id,role:"assistant",action:"add",agentId:t.id})}),ee=await Q.json();if(!Q.ok)throw new Error(ee.error||"Failed to assign assistant role");const{error:X}=await H.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:B.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(X)throw X;me.success(`${B.name||B.email} linked as your assistant`),l(!1),g({email:"",name:"",password:""}),M()}catch(U){console.error("Error linking assistant:",U),me.error(U.message||"Failed to link assistant")}finally{w(!1)}return}if(!f.email.trim()||!f.name.trim()||!f.password.trim()){me.error("Please fill in all fields");return}if(f.password.length<6){me.error("Password must be at least 6 characters");return}w(!0);try{const{data:{session:U}}=await H.auth.getSession();if(!U)throw new Error("Not authenticated");const B=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({email:f.email.trim(),password:f.password,name:f.name.trim(),purpose:"assistant"})}),V=await B.json();if(!B.ok)throw new Error(V.error||"Failed to create assistant account");const Y=V.userId||V.id;if(!Y)throw new Error("No user ID returned");const Q=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({userId:Y,role:"assistant",action:"add",agentId:t.id})}),ee=await Q.json();if(!Q.ok)throw new Error(ee.error||"Failed to assign assistant role");const{error:X}=await H.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:Y,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(X)throw X;me.success(`Assistant account created for ${f.name.trim()}`),l(!1),g({email:"",name:"",password:""}),M()}catch(U){console.error("Error adding assistant:",U),me.error(U.message||"Failed to add assistant")}finally{w(!1)}}},I=async()=>{if(!(!u||!t))try{const{data:{session:U}}=await H.auth.getSession();if(!U)throw new Error("Not authenticated");const{error:B}=await H.from("agent_assistant_assignments").delete().eq("id",u.id);if(B)throw B;const{data:V}=await H.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!V||V.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),me.success("Assistant removed"),c(!1),p(null),M()}catch(U){console.error("Error removing assistant:",U),me.error(U.message||"Failed to remove assistant")}},O=async(U,B,V)=>{S(U);try{const Y=s.find(X=>X.id===U);if(!Y)return;const Q={...Y.permissions,[B]:V},{error:ee}=await H.from("agent_assistant_assignments").update({permissions:Q}).eq("id",U);if(ee)throw ee;r(X=>X.map(ie=>ie.id===U?{...ie,permissions:Q}:ie))}catch(Y){console.error("Error updating permissions:",Y),me.error("Failed to update permissions")}finally{S(null)}};return n?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(gr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(K,{size:"sm",onClick:()=>{_("create"),l(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No assistant assigned. Add one to help manage your contacts, deals, and more."}):e.jsx("div",{className:"space-y-4",children:s.map(U=>{var B,V,Y,Q;return e.jsxs("div",{className:"border rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Nn,{className:"h-10 w-10",children:e.jsx(kn,{children:((V=(B=U.assistant_profile)==null?void 0:B.name)==null?void 0:V.split(" ").map(ee=>ee[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Y=U.assistant_profile)==null?void 0:Y.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((Q=U.assistant_profile)==null?void 0:Q.email)||""})]}),e.jsxs(st,{variant:"secondary",className:"ml-2",children:[e.jsx(th,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(U),c(!0)},children:e.jsx(Nr,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Permissions"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:j8t.map(ee=>{const X=ee.icon;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:ee.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ee.description})]})]}),e.jsx(qr,{checked:U.permissions[ee.key]||!1,onCheckedChange:ie=>O(U.id,ee.key,ie),disabled:N===U.id})]},ee.key)})})]})]},U.id)})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add Assistant"}),e.jsx(Gr,{children:b==="create"?"Create a new account for your assistant.":"Link an existing assistant account by their email."})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsxs(K,{variant:b==="create"?"default":"outline",size:"sm",onClick:()=>_("create"),children:[e.jsx($s,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:b==="link"?"default":"outline",size:"sm",onClick:()=>_("link"),children:[e.jsx(Bo,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[b==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"assistant-name",children:"Name"}),e.jsx(ze,{id:"assistant-name",value:f.name,onChange:U=>g({...f,name:U.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"assistant-email",children:"Email"}),e.jsx(ze,{id:"assistant-email",type:"email",value:f.email,onChange:U=>g({...f,email:U.target.value}),placeholder:"assistant@email.com"})]}),b==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(ze,{id:"assistant-password",type:"password",value:f.password,onChange:U=>g({...f,password:U.target.value}),placeholder:"Min 6 characters"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your assistant can change this after their first login."})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:L,disabled:j,children:[j&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),b==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(kc,{open:i,onOpenChange:c,children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Remove Assistant?"}),e.jsxs(sc,{children:["This will remove ",(q=u==null?void 0:u.assistant_profile)==null?void 0:q.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:I,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function yh(t){this.content=t}yh.prototype={constructor:yh,find:function(t){for(var s=0;s>1}};yh.from=function(t){if(t instanceof yh)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new yh(s)};function LXe(t,s,r){for(let n=0;;n++){if(n==t.childCount||n==s.childCount)return t.childCount==s.childCount?null:r;let a=t.child(n),o=s.child(n);if(a==o){r+=a.nodeSize;continue}if(!a.sameMarkup(o))return r;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)r++;return r}if(a.content.size||o.content.size){let l=LXe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function DXe(t,s,r,n){for(let a=t.childCount,o=s.childCount;;){if(a==0||o==0)return a==o?null:{a:r,b:n};let l=t.child(--a),i=s.child(--o),c=l.nodeSize;if(l==i){r-=c,n-=c;continue}if(!l.sameMarkup(i))return{a:r,b:n};if(l.isText&&l.text!=i.text){let u=0,p=Math.min(l.text.length,i.text.length);for(;us&&n(c,a+i,o||null,l)!==!1&&c.content.size){let p=i+1;c.nodesBetween(Math.max(0,s-p),Math.min(c.content.size,r-p),n,a+p)}i=u}}descendants(s){this.nodesBetween(0,this.size,s)}textBetween(s,r,n,a){let o="",l=!0;return this.nodesBetween(s,r,(i,c)=>{let u=i.isText?i.text.slice(Math.max(s,c)-c,r-c):i.isLeaf?a?typeof a=="function"?a(i):a:i.type.spec.leafText?i.type.spec.leafText(i):"":"";i.isBlock&&(i.isLeaf&&u||i.isTextblock)&&n&&(l?l=!1:o+=n),o+=u},0),o}append(s){if(!s.size)return this;if(!this.size)return s;let r=this.lastChild,n=s.firstChild,a=this.content.slice(),o=0;for(r.isText&&r.sameMarkup(n)&&(a[a.length-1]=r.withText(r.text+n.text),o=1);os)for(let o=0,l=0;ls&&((lr)&&(i.isText?i=i.cut(Math.max(0,s-l),Math.min(i.text.length,r-l)):i=i.cut(Math.max(0,s-l-1),Math.min(i.content.size,r-l-1))),n.push(i),a+=i.nodeSize),l=c}return new Dr(n,a)}cutByIndex(s,r){return s==r?Dr.empty:s==0&&r==this.content.length?this:new Dr(this.content.slice(s,r))}replaceChild(s,r){let n=this.content[s];if(n==r)return this;let a=this.content.slice(),o=this.size+r.nodeSize-n.nodeSize;return a[s]=r,new Dr(a,o)}addToStart(s){return new Dr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Dr(this.content.concat(s),this.size+s.nodeSize)}eq(s){if(this.content.length!=s.content.length)return!1;for(let r=0;rthis.size||s<0)throw new RangeError(`Position ${s} outside of fragment (${this})`);for(let r=0,n=0;;r++){let a=this.child(r),o=n+a.nodeSize;if(o>=s)return o==s?cz(r+1,o):cz(r,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(s=>s.toJSON()):null}static fromJSON(s,r){if(!r)return Dr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Dr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Dr.empty;let r,n=0;for(let a=0;athis.type.rank&&(r||(r=s.slice(0,a)),r.push(this),n=!0),r&&r.push(o)}}return r||(r=s.slice()),n||r.push(this),r}removeFromSet(s){for(let r=0;rn.type.rank-a.type.rank),r}};Ll.none=[];class Xoe extends Error{}class jn{constructor(s,r,n){this.content=s,this.openStart=r,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(s,r){let n=RXe(this.content,s+this.openStart,r);return n&&new jn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new jn(OXe(this.content,s+this.openStart,r+this.openStart),this.openStart,this.openEnd)}eq(s){return this.content.eq(s.content)&&this.openStart==s.openStart&&this.openEnd==s.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let s={content:this.content.toJSON()};return this.openStart>0&&(s.openStart=this.openStart),this.openEnd>0&&(s.openEnd=this.openEnd),s}static fromJSON(s,r){if(!r)return jn.empty;let n=r.openStart||0,a=r.openEnd||0;if(typeof n!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new jn(Dr.fromJSON(s,r.content),n,a)}static maxOpen(s,r=!0){let n=0,a=0;for(let o=s.firstChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=s.lastChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.lastChild)a++;return new jn(s,n,a)}}jn.empty=new jn(Dr.empty,0,0);function OXe(t,s,r){let{index:n,offset:a}=t.findIndex(s),o=t.maybeChild(n),{index:l,offset:i}=t.findIndex(r);if(a==s||o.isText){if(i!=r&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,s).append(t.cut(r))}if(n!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(n,o.copy(OXe(o.content,s-a-1,r-a-1)))}function RXe(t,s,r,n){let{index:a,offset:o}=t.findIndex(s),l=t.maybeChild(a);if(o==s||l.isText)return n&&!n.canReplace(a,a,r)?null:t.cut(0,s).append(r).append(t.cut(s));let i=RXe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function k8t(t,s,r){if(r.openStart>t.depth)throw new Xoe("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new Xoe("Inconsistent open depths");return FXe(t,s,r,0)}function FXe(t,s,r,n){let a=t.index(n),o=t.node(n);if(a==s.index(n)&&n=0&&t.isText&&t.sameMarkup(s[r])?s[r]=t.withText(s[r].text+t.text):s.push(t)}function e8(t,s,r,n){let a=(s||t).node(r),o=0,l=s?s.index(r):a.childCount;t&&(o=t.index(r),t.depth>r?o++:t.textOffset&&(bS(t.nodeAfter,n),o++));for(let i=o;ia&&_1e(t,s,a+1),l=n.depth>a&&_1e(r,n,a+1),i=[];return e8(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(zXe(o,l),bS(_S(o,BXe(t,s,r,n,a+1)),i)):(o&&bS(_S(o,Qoe(t,s,a+1)),i),e8(s,r,a,i),l&&bS(_S(l,Qoe(r,n,a+1)),i)),e8(n,null,a,i),new Dr(i)}function Qoe(t,s,r){let n=[];if(e8(null,t,r,n),t.depth>r){let a=_1e(t,s,r+1);bS(_S(a,Qoe(t,s,r+1)),n)}return e8(s,null,r,n),new Dr(n)}function S8t(t,s){let r=s.depth-t.openStart,a=s.node(r).copy(t.content);for(let o=r-1;o>=0;o--)a=s.node(o).copy(Dr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class lD{constructor(s,r,n){this.pos=s,this.path=r,this.parentOffset=n,this.depth=r.length/3-1}resolveDepth(s){return s==null?this.depth:s<0?this.depth+s:s}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(s){return this.path[this.resolveDepth(s)*3]}index(s){return this.path[this.resolveDepth(s)*3+1]}indexAfter(s){return s=this.resolveDepth(s),this.index(s)+(s==this.depth&&!this.textOffset?0:1)}start(s){return s=this.resolveDepth(s),s==0?0:this.path[s*3-1]+1}end(s){return s=this.resolveDepth(s),this.start(s)+this.node(s).content.size}before(s){if(s=this.resolveDepth(s),!s)throw new RangeError("There is no position before the top-level node");return s==this.depth+1?this.pos:this.path[s*3-1]}after(s){if(s=this.resolveDepth(s),!s)throw new RangeError("There is no position after the top-level node");return s==this.depth+1?this.pos:this.path[s*3-1]+this.path[s*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let s=this.parent,r=this.index(this.depth);if(r==s.childCount)return null;let n=this.pos-this.path[this.path.length-1],a=s.child(r);return n?s.child(r).cut(n):a}get nodeBefore(){let s=this.index(this.depth),r=this.pos-this.path[this.path.length-1];return r?this.parent.child(s).cut(0,r):s==0?null:this.parent.child(s-1)}posAtIndex(s,r){r=this.resolveDepth(r);let n=this.path[r*3],a=r==0?0:this.path[r*3-1]+1;for(let o=0;o0;r--)if(this.start(r)<=s&&this.end(r)>=s)return r;return 0}blockRange(s=this,r){if(s.pos=0;n--)if(s.pos<=this.end(n)&&(!r||r(this.node(n))))return new Joe(this,s,n);return null}sameParent(s){return this.pos-this.parentOffset==s.pos-s.parentOffset}max(s){return s.pos>this.pos?s:this}min(s){return s.pos=0&&r<=s.content.size))throw new RangeError("Position "+r+" out of range");let n=[],a=0,o=r;for(let l=s;;){let{index:i,offset:c}=l.content.findIndex(o),u=o-c;if(n.push(l,i,a+c),!u||(l=l.child(i),l.isText))break;o=u-1,a+=c+1}return new lD(r,n,o)}static resolveCached(s,r){let n=jIe.get(s);if(n)for(let o=0;os&&this.nodesBetween(s,r,o=>(n.isInSet(o.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let s=this.type.name;return this.content.size&&(s+="("+this.content.toStringInner()+")"),$Xe(this.marks,s)}contentMatchAt(s){let r=this.type.contentMatch.matchFragment(this.content,0,s);if(!r)throw new Error("Called contentMatchAt on a node with invalid content");return r}canReplace(s,r,n=Dr.empty,a=0,o=n.childCount){let l=this.contentMatchAt(s).matchFragment(n,a,o),i=l&&l.matchFragment(this.content,r);if(!i||!i.validEnd)return!1;for(let c=a;cr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let s={type:this.type.name};for(let r in this.attrs){s.attrs=this.attrs;break}return this.content.size&&(s.content=this.content.toJSON()),this.marks.length&&(s.marks=this.marks.map(r=>r.toJSON())),s}static fromJSON(s,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(s.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return s.text(r.text,n)}let a=Dr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};J_.prototype.text=void 0;class ele extends J_{constructor(s,r,n,a){if(super(s,r,null,a),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$Xe(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(s,r){return this.text.slice(s,r)}get nodeSize(){return this.text.length}mark(s){return s==this.marks?this:new ele(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new ele(this.type,this.attrs,s,this.marks)}cut(s=0,r=this.text.length){return s==0&&r==this.text.length?this:this.withText(this.text.slice(s,r))}eq(s){return this.sameMarkup(s)&&this.text==s.text}toJSON(){let s=super.toJSON();return s.text=this.text,s}}function $Xe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class GS{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new A8t(s,r);if(n.next==null)return GS.empty;let a=qXe(n);n.next&&n.err("Unexpected trailing text");let o=R8t(O8t(a));return F8t(o,n),o}matchType(s){for(let r=0;ru.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${s}th edge in this content match`);return this.next[s]}toString(){let s=[];function r(n){s.push(n);for(let a=0;a{let o=a+(n.validEnd?"*":" ")+" ";for(let l=0;l"+s.indexOf(n.next[l].next);return o}).join(` `)}}GS.empty=new GS(!0);class A8t{constructor(s,r){this.string=s,this.nodeTypes=r,this.inline=null,this.pos=0,this.tokens=s.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(s){return this.next==s&&(this.pos++||!0)}err(s){throw new SyntaxError(s+" (in content expression '"+this.string+"')")}}function qXe(t){let s=[];do s.push(E8t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function E8t(t){let s=[];do s.push(P8t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function P8t(t){let s=D8t(t);for(;;)if(t.eat("+"))s={type:"plus",expr:s};else if(t.eat("*"))s={type:"star",expr:s};else if(t.eat("?"))s={type:"opt",expr:s};else if(t.eat("{"))s=I8t(t,s);else break;return s}function NIe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function I8t(t,s){let r=NIe(t),n=r;return t.eat(",")&&(t.next!="}"?n=NIe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function L8t(t,s){let r=t.nodeTypes,n=r[s];if(n)return[n];let a=[];for(let o in r){let l=r[o];l.isInGroup(s)&&a.push(l)}return a.length==0&&t.err("No node type or group '"+s+"' found"),a}function D8t(t){if(t.eat("(")){let s=qXe(t);return t.eat(")")||t.err("Missing closing paren"),s}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let s=L8t(t,t.next).map(r=>(t.inline==null?t.inline=r.isInline:t.inline!=r.isInline&&t.err("Mixing inline and block content"),{type:"name",value:r}));return t.pos++,s.length==1?s[0]:{type:"choice",exprs:s}}}function O8t(t){let s=[[]];return a(o(t,0),r()),s;function r(){return s.push([])-1}function n(l,i,c){let u={term:c,to:i};return s[l].push(u),u}function a(l,i){l.forEach(c=>c.to=i)}function o(l,i){if(l.type=="choice")return l.exprs.reduce((c,u)=>c.concat(o(u,i)),[]);if(l.type=="seq")for(let c=0;;c++){let u=o(l.exprs[c],i);if(c==l.exprs.length-1)return u;a(u,i=r())}else if(l.type=="star"){let c=r();return n(i,c),a(o(l.expr,c),c),[n(c)]}else if(l.type=="plus"){let c=r();return a(o(l.expr,i),c),a(o(l.expr,c),c),[n(c)]}else{if(l.type=="opt")return[n(i)].concat(o(l.expr,i));if(l.type=="range"){let c=i;for(let u=0;u{t[l].forEach(({term:i,to:c})=>{if(!i)return;let u;for(let p=0;p{u||a.push([i,u=[]]),u.indexOf(p)==-1&&u.push(p)})})});let o=s[n.join(",")]=new GS(n.indexOf(t.length-1)>-1);for(let l=0;l-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let s in this.attrs)if(this.attrs[s].isRequired)return!0;return!1}compatibleContent(s){return this==s||this.contentMatch.compatible(s.contentMatch)}computeAttrs(s){return!s&&this.defaultAttrs?this.defaultAttrs:HXe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new J_(this,this.computeAttrs(s),Dr.from(r),Ll.setFrom(n))}createChecked(s=null,r,n){return r=Dr.from(r),this.checkContent(r),new J_(this,this.computeAttrs(s),r,Ll.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Dr.from(r),r.size){let l=this.contentMatch.fillBefore(r);if(!l)return null;r=l.append(r)}let a=this.contentMatch.matchFragment(r),o=a&&a.fillBefore(Dr.empty,!0);return o?new J_(this,s,r.append(o),Ll.setFrom(n)):null}validContent(s){let r=this.contentMatch.matchFragment(s);if(!r||!r.validEnd)return!1;for(let n=0;n-1}allowsMarks(s){if(this.markSet==null)return!0;for(let r=0;rn[o]=new KXe(o,r,l));let a=r.spec.topNode||"doc";if(!n[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function z8t(t,s,r){let n=r.split("|");return a=>{let o=a===null?"null":typeof a;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${s} on type ${t}, got ${o}`)}}class B8t{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?z8t(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Sue{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=GXe(s,a.attrs),this.excluded=null;let o=VXe(this.attrs);this.instance=o?new Ll(this,o):null}create(s=null){return!s&&this.instance?this.instance:new Ll(this,HXe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new Sue(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class ZXe{constructor(s){this.linebreakReplacement=null,this.cached=Object.create(null);let r=this.spec={};for(let a in s)r[a]=s[a];r.nodes=yh.from(s.nodes),r.marks=yh.from(s.marks||{}),this.nodes=SIe.compile(this.spec.nodes,this),this.marks=Sue.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]=GS.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?CIe(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==""?[]:CIe(this,l.split(" "))}this.nodeFromJSON=a=>J_.fromJSON(this,a),this.markFromJSON=a=>Ll.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(s,r=null,n,a){if(typeof s=="string")s=this.nodeType(s);else if(s instanceof SIe){if(s.schema!=this)throw new RangeError("Node type from different schema used ("+s.name+")")}else throw new RangeError("Invalid node type: "+s);return s.createChecked(r,n,a)}text(s,r){let n=this.nodes.text;return new ele(n,n.defaultAttrs,s,Ll.setFrom(r))}mark(s,r){return typeof s=="string"&&(s=this.marks[s]),s.create(r)}nodeType(s){let r=this.nodes[s];if(!r)throw new RangeError("Unknown node type: "+s);return r}}function CIe(t,s){let r=[];for(let n=0;n-1)&&r.push(l=c)}if(!l)throw new SyntaxError("Unknown mark type: '"+s[n]+"'")}return r}function $8t(t){return t.tag!=null}function q8t(t){return t.style!=null}let t8=class j1e{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if($8t(a))this.tags.push(a);else if(q8t(a)){let o=/[^=]*/.exec(a.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let o=s.nodes[a.node];return o.contentMatch.matchType(o)})}parse(s,r={}){let n=new TIe(this,r,!1);return n.addAll(s,Ll.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new TIe(this,r,!0);return n.addAll(s,Ll.none,r.from,r.to),jn.maxOpen(n.finish())}matchTag(s,r,n){for(let a=n?this.tags.indexOf(n)+1:0;as.length&&(i.charCodeAt(s.length)!=61||i.slice(s.length+1)!=r))){if(l.getAttrs){let c=l.getAttrs(r);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(s){let r=[];function n(a){let o=a.priority==null?50:a.priority,l=0;for(;l{n(l=AIe(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in s.nodes){let o=s.nodes[a].spec.parseDOM;o&&o.forEach(l=>{n(l=AIe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new j1e(s,j1e.schemaRules(s)))}};const YXe={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},U8t={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},XXe={ol:!0,ul:!0},cD=1,N1e=2,s8=4;function MIe(t,s,r){return s!=null?(s?cD:0)|(s==="full"?N1e:0):t&&t.whitespace=="pre"?cD|N1e:r&~s8}class dz{constructor(s,r,n,a,o,l){this.type=s,this.attrs=r,this.marks=n,this.solid=a,this.options=l,this.content=[],this.activeMarks=Ll.none,this.match=o||(l&s8?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Dr.from(s));if(r)this.match=this.type.contentMatch.matchFragment(r);else{let n=this.type.contentMatch,a;return(a=n.findWrapping(s.type))?(this.match=n,a):null}}return this.match.findWrapping(s.type)}finish(s){if(!(this.options&cD)){let n=this.content[this.content.length-1],a;if(n&&n.isText&&(a=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let r=Dr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Dr.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}inlineContext(s){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:s.parentNode&&!YXe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class TIe{constructor(s,r,n){this.parser=s,this.options=r,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let a=r.topNode,o,l=MIe(null,r.preserveWhitespace,0)|(n?s8:0);a?o=new dz(a.type,a.attrs,Ll.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new dz(null,null,Ll.none,!0,null,l):o=new dz(s.schema.topNodeType,null,Ll.none,!0,null,l),this.nodes=[o],this.find=r.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(s,r){s.nodeType==3?this.addTextNode(s,r):s.nodeType==1&&this.addElement(s,r)}addTextNode(s,r){let n=s.nodeValue,a=this.top,o=a.options&N1e?"full":this.localPreserveWS||(a.options&cD)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(s)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,` `);else if(l.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(l.linebreakReplacement.create())){let i=n.split(/\r?\n|\r/);for(let c=0;c!c.clearMark(u)):r=r.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)i=c;else break}}return r}addElementByRule(s,r,n,a){let o,l;if(r.node)if(l=this.parser.schema.nodes[r.node],l.isLeaf)this.insertNode(l.create(r.attrs),n,s.nodeName=="BR")||this.leafFallback(s,n);else{let c=this.enter(l,r.attrs||null,n,r.preserveWhitespace);c&&(o=!0,n=c)}else{let c=this.parser.schema.marks[r.mark];n=n.concat(c.create(r.attrs))}let i=this.top;if(l&&l.isLeaf)this.findInside(s);else if(a)this.addElement(s,n,a);else if(r.getContent)this.findInside(s),r.getContent(s,this.parser.schema).forEach(c=>this.insertNode(c,n,!1));else{let c=s;typeof r.contentElement=="string"?c=s.querySelector(r.contentElement):typeof r.contentElement=="function"?c=r.contentElement(s):r.contentElement&&(c=r.contentElement),this.findAround(s,c,!0),this.addAll(c,n),this.findAround(s,c,!1)}o&&this.sync(i)&&this.open--}addAll(s,r,n,a){let o=n||0;for(let l=n?s.childNodes[n]:s.firstChild,i=a==null?null:s.childNodes[a];l!=i;l=l.nextSibling,++o)this.findAtPoint(s,o),this.addDOM(l,r);this.findAtPoint(s,o)}findPlace(s,r,n){let a,o;for(let l=this.open,i=0;l>=0;l--){let c=this.nodes[l],u=c.findWrapping(s);if(u&&(!a||a.length>u.length+i)&&(a=u,o=c,!u.length))break;if(c.solid){if(n)break;i+=2}}if(!a)return null;this.sync(o);for(let l=0;l(l.type?l.type.allowsMarkType(u.type):EIe(u.type,s))?(c=u.addToSet(c),!1):!0),this.nodes.push(new dz(s,r,c,a,null,i)),this.open++,n}closeExtra(s=!1){let r=this.nodes.length-1;if(r>this.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].finish(s));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(s){for(let r=this.open;r>=0;r--){if(this.nodes[r]==s)return this.open=r,!0;this.localPreserveWS&&(this.nodes[r].options|=cD)}return!1}get currentPos(){this.closeExtra();let s=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let a=n.length-1;a>=0;a--)s+=n[a].nodeSize;r&&s++}return s}findAtPoint(s,r){if(this.find)for(let n=0;n-1)return s.split(/\s*\|\s*/).some(this.matchesContext,this);let r=s.split("/"),n=this.options.context,a=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(a?0:1),l=(i,c)=>{for(;i>=0;i--){let u=r[i];if(u==""){if(i==r.length-1||i==0)continue;for(;c>=o;c--)if(l(i-1,c))return!0;return!1}else{let p=c>0||c==0&&a?this.nodes[c].type:n&&c>=o?n.node(c-o).type:null;if(!p||p.name!=u&&!p.isInGroup(u))return!1;c--}}return!0};return l(r.length-1,this.open)}textblockFromContext(){let s=this.options.context;if(s)for(let r=s.depth;r>=0;r--){let n=s.node(r).contentMatchAt(s.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}}function V8t(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&XXe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function H8t(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function AIe(t){let s={};for(let r in t)s[r]=t[r];return s}function EIe(t,s){let r=s.schema.nodes;for(let n in r){let a=r[n];if(!a.allowsMarkType(t))continue;let o=[],l=i=>{o.push(i);for(let c=0;c{if(o.length||l.marks.length){let i=0,c=0;for(;i=0;a--){let o=this.serializeMark(s.marks[a],s.isInline,r);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(s,r,n={}){let a=this.marks[s.type.name];return a&&Nie(Qxe(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Nie(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new bC(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=PIe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return PIe(s.marks)}}function PIe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function Qxe(t){return t.document||window.document}const IIe=new WeakMap;function W8t(t){let s=IIe.get(t);return s===void 0&&IIe.set(t,s=G8t(t)),s}function G8t(t){let s=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")s||(s=[]),s.push(n);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(r=a.slice(0,l),a=a.slice(l+1));let i,c=r?t.createElementNS(r,a):t.createElement(a),u=s[1],p=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){p=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=p;fp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:b,contentDOM:_}=Nie(t,g,r,n);if(c.appendChild(b),_){if(i)throw new RangeError("Multiple content holes");i=_}}}return{dom:c,contentDOM:i}}const QXe=65535,JXe=Math.pow(2,16);function K8t(t,s){return t+s*JXe}function LIe(t){return t&QXe}function Z8t(t){return(t-(t&QXe))/JXe}const eQe=1,tQe=2,kie=4,sQe=8;class k1e{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&sQe)>0}get deletedBefore(){return(this.delInfo&(eQe|kie))>0}get deletedAfter(){return(this.delInfo&(tQe|kie))>0}get deletedAcross(){return(this.delInfo&kie)>0}}class cf{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&cf.empty)return cf.empty}recover(s){let r=0,n=LIe(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],p=this.ranges[i+l],f=c+u;if(s<=f){let g=u?s==c?-1:s==f?1:r:r,b=c+a+(g<0?0:p);if(n)return b;let _=s==(r<0?c:f)?null:K8t(i/3,s-c),j=s==c?tQe:s==f?eQe:kie;return(r<0?s!=c:s!=f)&&(j|=sQe),new k1e(b,j,_)}a+=p-u}return n?s+a:new k1e(s+a,0,null)}touches(s,r){let n=0,a=LIe(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let u=this.ranges[i+o],p=c+u;if(s<=p&&i==a*3)return!0;n+=this.ranges[i+l]-u}return!1}forEach(s){let r=this.inverted?2:1,n=this.inverted?1:2;for(let a=0,o=0;a=0;r--){let a=s.getMirror(r);this.appendMap(s._maps[r].invert(),a!=null&&a>r?n-a-1:void 0)}}invert(){let s=new dD;return s.appendMappingInverted(this),s}map(s,r=1){if(this.mirror)return this._map(s,r,!0);for(let n=this.from;no&&c!l.isAtom||!i.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),r.openStart,r.openEnd);return eu.fromReplace(s,this.from,this.to,o)}invert(){return new l0(this.from,this.to,this.mark)}map(s){let r=s.mapResult(this.from,1),n=s.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new k_(r.pos,n.pos,this.mark)}merge(s){return s instanceof k_&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new k_(Math.min(this.from,s.from),Math.max(this.to,s.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new k_(r.from,r.to,s.markFromJSON(r.mark))}}em.jsonID("addMark",k_);class l0 extends em{constructor(s,r,n){super(),this.from=s,this.to=r,this.mark=n}apply(s){let r=s.slice(this.from,this.to),n=new jn(TNe(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return eu.fromReplace(s,this.from,this.to,n)}invert(){return new k_(this.from,this.to,this.mark)}map(s){let r=s.mapResult(this.from,1),n=s.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new l0(r.pos,n.pos,this.mark)}merge(s){return s instanceof l0&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new l0(Math.min(this.from,s.from),Math.max(this.to,s.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new l0(r.from,r.to,s.markFromJSON(r.mark))}}em.jsonID("removeMark",l0);class S_ extends em{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return eu.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return eu.fromReplace(s,this.pos,this.pos+1,new jn(Dr.from(n),0,r.isLeaf?0:1))}invert(s){let r=s.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let a=0;an.pos?null:new rh(r.pos,n.pos,a,o,this.slice,this.insert,this.structure)}toJSON(){let s={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(s.slice=this.slice.toJSON()),this.structure&&(s.structure=!0),s}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number"||typeof r.gapFrom!="number"||typeof r.gapTo!="number"||typeof r.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new rh(r.from,r.to,r.gapFrom,r.gapTo,jn.fromJSON(s,r.slice),r.insert,!!r.structure)}}em.jsonID("replaceAround",rh);function S1e(t,s,r){let n=t.resolve(s),a=r-s,o=n.depth;for(;a>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,a--;if(a>0){let l=n.node(o).maybeChild(n.indexAfter(o));for(;a>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,a--}}return!1}function Y8t(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(c,u,p)=>{if(!c.isInline)return;let f=c.marks;if(!n.isInSet(f)&&p.type.allowsMarkType(n.type)){let g=Math.max(u,s),b=Math.min(u+c.nodeSize,r),_=n.addToSet(f);for(let j=0;jt.step(c)),o.forEach(c=>t.step(c))}function X8t(t,s,r,n){let a=[],o=0;t.doc.nodesBetween(s,r,(l,i)=>{if(!l.isInline)return;o++;let c=null;if(n instanceof Sue){let u=l.marks,p;for(;p=n.isInSet(u);)(c||(c=[])).push(p),u=p.removeFromSet(u)}else n?n.isInSet(l.marks)&&(c=[n]):c=l.marks;if(c&&c.length){let u=Math.min(i+l.nodeSize,r);for(let p=0;pt.step(new l0(l.from,l.to,l.style)))}function ANe(t,s,r,n=r.contentMatch,a=!0){let o=t.doc.nodeAt(s),l=[],i=s+1;for(let c=0;c=0;c--)t.step(l[c])}function Q8t(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function aE(t){let r=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,a=0,o=0;;--n){let l=t.$from.node(n),i=t.$from.index(n)+a,c=t.$to.indexAfter(n)-o;if(nr;_--)j||n.index(_)>0?(j=!0,p=Dr.from(n.node(_).copy(p)),f++):c--;let g=Dr.empty,b=0;for(let _=o,j=!1;_>r;_--)j||a.after(_+1)=0;l--){if(n.size){let i=r[l].type.contentMatch.matchFragment(n);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=Dr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new rh(a,o,a,o,new jn(n,0,0),r.length,!0))}function rDt(t,s,r,n,a){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(s,r,(l,i)=>{let c=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(n,c)&&nDt(t.doc,t.mapping.slice(o).map(i),n)){let u=null;if(n.schema.linebreakReplacement){let b=n.whitespace=="pre",_=!!n.contentMatch.matchType(n.schema.linebreakReplacement);b&&!_?u=!1:!b&&_&&(u=!0)}u===!1&&nQe(t,l,i,o),ANe(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let p=t.mapping.slice(o),f=p.map(i,1),g=p.map(i+l.nodeSize,1);return t.step(new rh(f,g,f+1,g-1,new jn(Dr.from(n.create(c,null,l.marks)),0,0),1,!0)),u===!0&&rQe(t,l,i,o),!1}})}function rQe(t,s,r,n){s.forEach((a,o)=>{if(a.isText){let l,i=/\r?\n|\r/g;for(;l=i.exec(a.text);){let c=t.mapping.slice(n).map(r+1+o+l.index);t.replaceWith(c,c+1,s.type.schema.linebreakReplacement.create())}}})}function nQe(t,s,r,n){s.forEach((a,o)=>{if(a.type==a.type.schema.linebreakReplacement){let l=t.mapping.slice(n).map(r+1+o);t.replaceWith(l,l+1,s.type.schema.text(` `))}})}function nDt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function aDt(t,s,r,n,a){let o=t.doc.nodeAt(s);if(!o)throw new RangeError("No node at given position");r||(r=o.type);let l=r.create(n,null,a||o.marks);if(o.isLeaf)return t.replaceWith(s,s+o.nodeSize,l);if(!r.validContent(o.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new rh(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new jn(Dr.from(l),0,0),1,!0))}function x1(t,s,r=1,n){let a=t.resolve(s),o=a.depth-r,l=n&&n[n.length-1]||a.parent;if(o<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!l.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let u=a.depth-1,p=r-2;u>o;u--,p--){let f=a.node(u),g=a.index(u);if(f.type.spec.isolating)return!1;let b=f.content.cutByIndex(g,f.childCount),_=n&&n[p+1];_&&(b=b.replaceChild(0,_.type.create(_.attrs)));let j=n&&n[p]||f;if(!f.canReplace(g+1,f.childCount)||!j.type.validContent(b))return!1}let i=a.indexAfter(o),c=n&&n[0];return a.node(o).canReplaceWith(i,i,c?c.type:a.node(o+1).type)}function iDt(t,s,r=1,n){let a=t.doc.resolve(s),o=Dr.empty,l=Dr.empty;for(let i=a.depth,c=a.depth-r,u=r-1;i>c;i--,u--){o=Dr.from(a.node(i).copy(o));let p=n&&n[u];l=Dr.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new Zu(s,s,new jn(o.append(l),r,r),!0))}function Dw(t,s){let r=t.resolve(s),n=r.index();return aQe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function oDt(t,s){s.content.size||t.type.compatibleContent(s.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:n}=t.type.schema;for(let a=0;a0?(o=n.node(a+1),i++,l=n.node(a).maybeChild(i)):(o=n.node(a).maybeChild(i-1),l=n.node(a+1)),o&&!o.isTextblock&&aQe(o,l)&&n.node(a).canReplace(i,i+1))return s;if(a==0)break;s=r<0?n.before(a):n.after(a)}}function lDt(t,s,r){let n=null,{linebreakReplacement:a}=t.doc.type.schema,o=t.doc.resolve(s-r),l=o.node().type;if(a&&l.inlineContent){let p=l.whitespace=="pre",f=!!l.contentMatch.matchType(a);p&&!f?n=!1:!p&&f&&(n=!0)}let i=t.steps.length;if(n===!1){let p=t.doc.resolve(s+r);nQe(t,p.node(),p.before(),i)}l.inlineContent&&ANe(t,s+r-1,l,o.node().contentMatchAt(o.index()),n==null);let c=t.mapping.slice(i),u=c.map(s-r);if(t.step(new Zu(u,c.map(s+r,-1),jn.empty,!0)),n===!0){let p=t.doc.resolve(u);rQe(t,p.node(),p.before(),t.steps.length)}return t}function cDt(t,s,r){let n=t.resolve(s);if(n.parent.canReplaceWith(n.index(),n.index(),r))return s;if(n.parentOffset==0)for(let a=n.depth-1;a>=0;a--){let o=n.index(a);if(n.node(a).canReplaceWith(o,o,r))return n.before(a+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let a=n.depth-1;a>=0;a--){let o=n.indexAfter(a);if(n.node(a).canReplaceWith(o,o,r))return n.after(a+1);if(o=0;l--){let i=l==n.depth?0:n.pos<=(n.start(l+1)+n.end(l+1))/2?-1:1,c=n.index(l)+(i>0?1:0),u=n.node(l),p=!1;if(o==1)p=u.canReplace(c,c,a);else{let f=u.contentMatchAt(c).findWrapping(a.firstChild.type);p=f&&u.canReplaceWith(c,c,f[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function Mue(t,s,r=s,n=jn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return oQe(a,o,n)?new Zu(s,r,n):new dDt(a,o,n).fit()}function oQe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class dDt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Dr.empty;for(let a=0;a<=s.depth;a++){let o=s.node(a);this.frontier.push({type:o.type,match:o.contentMatchAt(s.indexAfter(a))})}for(let a=s.depth;a>0;a--)this.placed=Dr.from(s.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let s=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,a=this.close(s<0?this.$to:n.doc.resolve(s));if(!a)return null;let o=this.placed,l=n.depth,i=a.depth;for(;l&&i&&o.childCount==1;)o=o.firstChild.content,l--,i--;let c=new jn(o,l,i);return s>-1?new rh(n.pos,s,this.$to.pos,this.$to.end(),c,r):c.size||n.pos!=this.$to.pos?new Zu(n.pos,a.pos,c):null}findFittable(){let s=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,a=this.unplaced.openEnd;n1&&(a=0),o.type.spec.isolating&&a<=n){s=n;break}r=o.content}for(let r=1;r<=2;r++)for(let n=r==1?s:this.unplaced.openStart;n>=0;n--){let a,o=null;n?(o=ege(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:c,match:u}=this.frontier[i],p,f=null;if(r==1&&(l?u.matchType(l.type)||(f=u.fillBefore(Dr.from(l),!1)):o&&c.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:f};if(r==2&&l&&(p=u.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:p};if(o&&u.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=ege(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new jn(s,r+1,Math.max(n,a.size+r>=s.size-n?r+1:0)),!0)}dropNode(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=ege(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new jn(kI(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new jn(kI(s,r,1),r,n)}placeNodes({sliceDepth:s,frontierDepth:r,parent:n,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let j=0;j1||c==0||j.content.size)&&(f=w,p.push(lQe(j.mark(g.allowedMarks(j.marks)),u==1?c:0,u==i.childCount?b:-1)))}let _=u==i.childCount;_||(b=-1),this.placed=SI(this.placed,r,Dr.from(p)),this.frontier[r].match=f,_&&b<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,w=i;j1&&a==this.$to.end(--n);)++a;return a}findCloseLevel(s){e:for(let r=Math.min(this.depth,s.depth);r>=0;r--){let{match:n,type:a}=this.frontier[r],o=r=0;i--){let{match:c,type:u}=this.frontier[i],p=tge(s,i,u,c,!0);if(!p||p.childCount)continue e}return{depth:r,fit:l,move:o?s.doc.resolve(s.after(r+1)):s}}}}close(s){let r=this.findCloseLevel(s);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=SI(this.placed,r.depth,r.fit)),s=r.move;for(let n=r.depth+1;n<=s.depth;n++){let a=s.node(n),o=a.type.contentMatch.fillBefore(a.content,!0,s.index(n));this.openFrontierNode(a.type,a.attrs,o)}return s}openFrontierNode(s,r=null,n){let a=this.frontier[this.depth];a.match=a.match.matchType(s),this.placed=SI(this.placed,this.depth,Dr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Dr.empty,!0);r.childCount&&(this.placed=SI(this.placed,this.frontier.length,r))}}function kI(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(kI(t.firstChild.content,s-1,r)))}function SI(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(SI(t.lastChild.content,s-1,r)))}function ege(t,s){for(let r=0;r1&&(n=n.replaceChild(0,lQe(n.firstChild,s-1,n.childCount==1?r-1:0))),s>0&&(n=t.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(Dr.empty,!0)))),t.copy(n)}function tge(t,s,r,n,a){let o=t.node(s),l=a?t.indexAfter(s):t.index(s);if(l==o.childCount&&!r.compatibleContent(o.type))return null;let i=n.fillBefore(o.content,!0,l);return i&&!uDt(r,o.content,l)?i:null}function uDt(t,s,r){for(let n=r;n0;g--,b--){let _=a.node(g).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;l.indexOf(g)>-1?i=g:a.before(g)==b&&l.splice(1,0,-g)}let c=l.indexOf(i),u=[],p=n.openStart;for(let g=n.content,b=0;;b++){let _=g.firstChild;if(u.push(_),b==n.openStart)break;g=_.content}for(let g=p-1;g>=0;g--){let b=u[g],_=hDt(b.type);if(_&&!b.sameMarkup(a.node(Math.abs(i)-1)))p=g;else if(_||!b.type.isTextblock)break}for(let g=n.openStart;g>=0;g--){let b=(g+p+1)%(n.openStart+1),_=u[b];if(_)for(let j=0;j=0&&(t.replace(s,r,n),!(t.steps.length>f));g--){let b=l[g];b<0||(s=a.before(b),r=o.after(b))}}function cQe(t,s,r,n,a){if(sn){let o=a.contentMatchAt(0),l=o.fillBefore(t).append(t);t=l.append(o.matchFragment(l).fillBefore(Dr.empty,!0))}return t}function pDt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=cDt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new jn(Dr.from(n),0,0))}function fDt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=dQe(n,a);for(let l=0;l0&&(c||n.node(i-1).canReplace(n.index(i-1),a.indexAfter(i-1))))return t.delete(n.before(i),a.after(i))}for(let l=1;l<=n.depth&&l<=a.depth;l++)if(s-n.start(l)==n.depth-l&&r>n.end(l)&&a.end(l)-r!=a.depth-l&&n.start(l-1)==a.start(l-1)&&n.node(l-1).canReplace(n.index(l-1),a.index(l-1)))return t.delete(n.before(l),r);t.delete(s,r)}function dQe(t,s){let r=[],n=Math.min(t.depth,s.depth);for(let a=n;a>=0;a--){let o=t.start(a);if(os.pos+(s.depth-a)||t.node(a).type.spec.isolating||s.node(a).type.spec.isolating)break;(o==s.start(a)||a==t.depth&&a==s.depth&&t.parent.inlineContent&&s.parent.inlineContent&&a&&s.start(a-1)==o-1)&&r.push(a)}return r}class tT extends em{constructor(s,r,n){super(),this.pos=s,this.attr=r,this.value=n}apply(s){let r=s.nodeAt(this.pos);if(!r)return eu.fail("No node at attribute step's position");let n=Object.create(null);for(let o in r.attrs)n[o]=r.attrs[o];n[this.attr]=this.value;let a=r.type.create(n,null,r.marks);return eu.fromReplace(s,this.pos,this.pos+1,new jn(Dr.from(a),0,r.isLeaf?0:1))}getMap(){return cf.empty}invert(s){return new tT(this.pos,this.attr,s.nodeAt(this.pos).attrs[this.attr])}map(s){let r=s.mapResult(this.pos,1);return r.deletedAfter?null:new tT(r.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(s,r){if(typeof r.pos!="number"||typeof r.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new tT(r.pos,r.attr,r.value)}}em.jsonID("attr",tT);class uD extends em{constructor(s,r){super(),this.attr=s,this.value=r}apply(s){let r=Object.create(null);for(let a in s.attrs)r[a]=s.attrs[a];r[this.attr]=this.value;let n=s.type.create(r,s.content,s.marks);return eu.ok(n)}getMap(){return cf.empty}invert(s){return new uD(this.attr,s.attrs[this.attr])}map(s){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(s,r){if(typeof r.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new uD(r.attr,r.value)}}em.jsonID("docAttr",uD);let HT=class extends Error{};HT=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};HT.prototype=Object.create(Error.prototype);HT.prototype.constructor=HT;HT.prototype.name="TransformError";class PNe{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new dD}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new HT(r.failed);return this}maybeStep(s){let r=s.apply(this.doc);return r.failed||this.addStep(s,r.doc),r}get docChanged(){return this.steps.length>0}addStep(s,r){this.docs.push(this.doc),this.steps.push(s),this.mapping.appendMap(s.getMap()),this.doc=r}replace(s,r=s,n=jn.empty){let a=Mue(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new jn(Dr.from(n),0,0))}delete(s,r){return this.replace(s,r,jn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return mDt(this,s,r,n),this}replaceRangeWith(s,r,n){return pDt(this,s,r,n),this}deleteRange(s,r){return fDt(this,s,r),this}lift(s,r){return J8t(this,s,r),this}join(s,r=1){return lDt(this,s,r),this}wrap(s,r){return sDt(this,s,r),this}setBlockType(s,r=s,n,a=null){return rDt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return aDt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new tT(s,r,n)),this}setDocAttribute(s,r){return this.step(new uD(s,r)),this}addNodeMark(s,r){return this.step(new S_(s,r)),this}removeNodeMark(s,r){let n=this.doc.nodeAt(s);if(!n)throw new RangeError("No node at position "+s);if(r instanceof Ll)r.isInSet(n.marks)&&this.step(new KS(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new KS(s,o)),a=o.removeFromSet(a);for(let i=l.length-1;i>=0;i--)this.step(l[i])}return this}split(s,r=1,n){return iDt(this,s,r,n),this}addMark(s,r,n){return Y8t(this,s,r,n),this}removeMark(s,r,n){return X8t(this,s,r,n),this}clearIncompatible(s,r,n){return ANe(this,s,r,n),this}}const sge=Object.create(null);class fi{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new uQe(s.min(r),s.max(r))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let s=this.ranges;for(let r=0;r=0;o--){let l=r<0?U5(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):U5(s.node(0),s.node(o),s.after(o+1),s.index(o)+1,r,n);if(l)return l}return null}static near(s,r=1){return this.findFrom(s,r)||this.findFrom(s,-r)||new _f(s.node(0))}static atStart(s){return U5(s,s,0,0,1)||new _f(s)}static atEnd(s){return U5(s,s,s.content.size,s.childCount,-1)||new _f(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=sge[r.type];if(!n)throw new RangeError(`No selection type ${r.type} defined`);return n.fromJSON(s,r)}static jsonID(s,r){if(s in sge)throw new RangeError("Duplicate use of selection JSON ID "+s);return sge[s]=r,r.prototype.jsonID=s,r}getBookmark(){return ei.between(this.$anchor,this.$head).getBookmark()}}fi.prototype.visible=!0;class uQe{constructor(s,r){this.$from=s,this.$to=r}}let OIe=!1;function RIe(t){!OIe&&!t.parent.inlineContent&&(OIe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ei extends fi{constructor(s,r=s){RIe(s),RIe(r),super(s,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(s,r){let n=s.resolve(r.map(this.head));if(!n.parent.inlineContent)return fi.near(n);let a=s.resolve(r.map(this.anchor));return new ei(a.parent.inlineContent?a:n,n)}replace(s,r=jn.empty){if(super.replace(s,r),r==jn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof ei&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new Tue(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(s,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ei(s.resolve(r.anchor),s.resolve(r.head))}static create(s,r,n=r){let a=s.resolve(r);return new this(a,n==r?a:s.resolve(n))}static between(s,r,n){let a=s.pos-r.pos;if((!n||a)&&(n=a>=0?1:-1),!r.parent.inlineContent){let o=fi.findFrom(r,n,!0)||fi.findFrom(r,-n,!0);if(o)r=o.$head;else return fi.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(fi.findFrom(s,-n,!0)||fi.findFrom(s,n,!0)).$anchor,s.pos0?0:1);a>0?l=0;l+=a){let i=s.child(l);if(i.isAtom){if(!o&&Wa.isSelectable(i))return Wa.create(t,r-(a<0?i.nodeSize:0))}else{let c=U5(t,i,r+a,a<0?i.childCount:0,a,o);if(c)return c}r+=i.nodeSize*a}return null}function FIe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(fi.near(t.doc.resolve(l),r))}const zIe=1,uz=2,BIe=4;class gDt extends PNe{constructor(s){super(s.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=s.selection,this.storedMarks=s.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(s){return this.storedMarks=s,this.updated|=uz,this}ensureMarks(s){return Ll.sameSet(this.storedMarks||this.selection.$from.marks(),s)||this.setStoredMarks(s),this}addStoredMark(s){return this.ensureMarks(s.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(s){return this.ensureMarks(s.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&uz)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~uz,this.storedMarks=null}setTime(s){return this.time=s,this}replaceSelection(s){return this.selection.replace(this,s),this}replaceSelectionWith(s,r=!0){let n=this.selection;return r&&(s=s.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Ll.none))),n.replaceWith(this,s),this}deleteSelection(){return this.selection.replace(this),this}insertText(s,r,n){let a=this.doc.type.schema;if(r==null)return s?this.replaceSelectionWith(a.text(s),!0):this.deleteSelection();{if(n==null&&(n=r),!s)return this.deleteRange(r,n);let o=this.storedMarks;if(!o){let l=this.doc.resolve(r);o=n==r?l.marks():l.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(r,n,a.text(s,o)),!this.selection.empty&&this.selection.to==r+s.length&&this.setSelection(fi.near(this.selection.$to)),this}}setMeta(s,r){return this.meta[typeof s=="string"?s:s.key]=r,this}getMeta(s){return this.meta[typeof s=="string"?s:s.key]}get isGeneric(){for(let s in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=BIe,this}get scrolledIntoView(){return(this.updated&BIe)>0}}function $Ie(t,s){return!s||!t?t:t.bind(s)}class CI{constructor(s,r,n){this.name=s,this.init=$Ie(r.init,n),this.apply=$Ie(r.apply,n)}}const yDt=[new CI("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new CI("selection",{init(t,s){return t.selection||fi.atStart(s.doc)},apply(t){return t.selection}}),new CI("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new CI("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class rge{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=yDt.slice(),r&&r.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new CI(n.key,n.spec.state,n))})}}class dM{constructor(s){this.config=s}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(s){return this.applyTransaction(s).state}filterTransaction(s,r=-1){for(let n=0;nn.toJSON())),s&&typeof s=="object")for(let n in s){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=s[n],o=a.spec.state;o&&o.toJSON&&(r[n]=o.toJSON.call(a,this[a.key]))}return r}static fromJSON(s,r,n){if(!r)throw new RangeError("Invalid input for EditorState.fromJSON");if(!s.schema)throw new RangeError("Required config field 'schema' missing");let a=new rge(s.schema,s.plugins),o=new dM(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=J_.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=fi.fromJSON(o.doc,r.selection);else if(l.name=="storedMarks")r.storedMarks&&(o.storedMarks=r.storedMarks.map(s.schema.markFromJSON));else{if(n)for(let i in n){let c=n[i],u=c.spec.state;if(c.key==l.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(r,i)){o[l.name]=u.fromJSON.call(c,s,r[i],o);return}}o[l.name]=l.init(s,o)}}),o}}function hQe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=hQe(a,s,{})),r[n]=a}return r}class Iu{constructor(s){this.spec=s,this.props={},s.props&&hQe(s.props,this,this.props),this.key=s.key?s.key.key:mQe("plugin")}getState(s){return s[this.key]}}const nge=Object.create(null);function mQe(t){return t in nge?t+"$"+ ++nge[t]:(nge[t]=0,t+"$")}class tm{constructor(s="key"){this.key=mQe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const bh=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},WT=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let C1e=null;const Lv=function(t,s,r){let n=C1e||(C1e=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},vDt=function(){C1e=null},ZS=function(t,s,r,n){return r&&(qIe(t,s,r,n,-1)||qIe(t,s,r,n,1))},bDt=/^(img|br|input|textarea|hr)$/i;function qIe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:gx(t))){let l=t.parentNode;if(!l||l.nodeType!=1||VO(t)||bDt.test(t.nodeName)||t.contentEditable=="false")return!1;s=bh(t)+(a<0?0:1),t=l}else if(t.nodeType==1){let l=t.childNodes[s+(a<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((o=l.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)s+=a;else return!1;else t=l,s=a<0?gx(t):0}else return!1}}function gx(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function _Dt(t,s){for(;;){if(t.nodeType==3&&s)return t;if(t.nodeType==1&&s>0){if(t.contentEditable=="false")return null;t=t.childNodes[s-1],s=gx(t)}else if(t.parentNode&&!VO(t))s=bh(t),t=t.parentNode;else return null}}function wDt(t,s){for(;;){if(t.nodeType==3&&s2),dx=GT||(E0?/Mac/.test(E0.platform):!1),xQe=E0?/Win/.test(E0.platform):!1,Xv=/Android \d/.test(Ow),HO=!!UIe&&"webkitFontSmoothing"in UIe.documentElement.style,SDt=HO?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function CDt(t){let s=t.defaultView&&t.defaultView.visualViewport;return s?{left:0,right:s.width,top:0,bottom:s.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function jv(t,s){return typeof t=="number"?t:t[s]}function MDt(t){let s=t.getBoundingClientRect(),r=s.width/t.offsetWidth||1,n=s.height/t.offsetHeight||1;return{left:s.left,right:s.left+t.clientWidth*r,top:s.top,bottom:s.top+t.clientHeight*n}}function VIe(t,s,r){let n=t.someProp("scrollThreshold")||0,a=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let l=r||t.dom;l;){if(l.nodeType!=1){l=WT(l);continue}let i=l,c=i==o.body,u=c?CDt(o):MDt(i),p=0,f=0;if(s.topu.bottom-jv(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+jv(a,"top")-u.top:s.bottom-u.bottom+jv(a,"bottom")),s.leftu.right-jv(n,"right")&&(p=s.right-u.right+jv(a,"right")),p||f)if(c)o.defaultView.scrollBy(p,f);else{let b=i.scrollLeft,_=i.scrollTop;f&&(i.scrollTop+=f),p&&(i.scrollLeft+=p);let j=i.scrollLeft-b,w=i.scrollTop-_;s={left:s.left-j,top:s.top-w,right:s.right-j,bottom:s.bottom-w}}let g=c?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(g))break;l=g=="absolute"?l.offsetParent:WT(l)}}function TDt(t){let s=t.dom.getBoundingClientRect(),r=Math.max(0,s.top),n,a;for(let o=(s.left+s.right)/2,l=r+1;l=r-20){n=i,a=c.top;break}}return{refDOM:n,refTop:a,stack:gQe(t.dom)}}function gQe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=WT(n));return s}function ADt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;yQe(r,n==0?0:n-s)}function yQe(t,s){for(let r=0;r=i){l=Math.max(_.bottom,l),i=Math.min(_.top,i);let j=_.left>s.left?_.left-s.left:_.right=(_.left+_.right)/2?1:0));continue}}else _.top>s.top&&!c&&_.left<=s.left&&_.right>=s.left&&(c=p,u={left:Math.max(_.left,Math.min(_.right,s.left)),top:_.top});!r&&(s.left>=_.right&&s.top>=_.top||s.left>=_.left&&s.top>=_.bottom)&&(o=f+1)}}return!r&&c&&(r=c,a=u,n=0),r&&r.nodeType==3?PDt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:vQe(r,a)}function PDt(t,s){let r=t.nodeValue.length,n=document.createRange(),a;for(let o=0;o=(l.left+l.right)/2?1:0)};break}}return n.detach(),a||{node:t,offset:0}}function LNe(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function IDt(t,s){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&s.left(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(n,a,o)}function DDt(t,s,r,n){let a=-1;for(let o=s,l=!1;o!=t.dom;){let i=t.docView.nearestDesc(o,!0),c;if(!i)return null;if(i.dom.nodeType==1&&(i.node.isBlock&&i.parent||!i.contentDOM)&&((c=i.dom.getBoundingClientRect()).width||c.height)&&(i.node.isBlock&&i.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(i.dom.nodeName)&&(!l&&c.left>n.left||c.top>n.top?a=i.posBefore:(!l&&c.right-1?a:t.docView.posFromDOM(s,r,-1)}function bQe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;HO&&a&&n.nodeType==1&&(u=n.childNodes[a-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=s.top&&a--,n==t.dom&&a==n.childNodes.length-1&&n.lastChild.nodeType==1&&s.top>n.lastChild.getBoundingClientRect().bottom?i=t.state.doc.content.size:(a==0||n.nodeType!=1||n.childNodes[a-1].nodeName!="BR")&&(i=DDt(t,n,a,s))}i==null&&(i=LDt(t,l,s));let c=t.docView.nearestDesc(l,!0);return{pos:i,inside:c?c.posAtStart-c.border:-1}}function HIe(t){return t.top=0&&a==n.nodeValue.length?(c--,p=1):r<0?c--:u++,XP(Ub(Lv(n,c,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==gx(n))){let c=n.childNodes[a-1];if(c.nodeType==1)return age(c.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==gx(n))){let c=n.childNodes[a-1],u=c.nodeType==3?Lv(c,gx(c)-(l?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return XP(Ub(u,1),!1)}if(o==null&&a=0)}function XP(t,s){if(t.width==0)return t;let r=s?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function age(t,s){if(t.height==0)return t;let r=s?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function wQe(t,s,r){let n=t.state,a=t.root.activeElement;n!=s&&t.updateState(s),a!=t.dom&&t.focus();try{return r()}finally{n!=s&&t.updateState(n),a!=t.dom&&a&&a.focus()}}function FDt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return wQe(t,s,()=>{let{node:o}=t.docView.domFromPos(a.pos,r=="up"?-1:1);for(;;){let i=t.docView.nearestDesc(o,!0);if(!i)break;if(i.node.isBlock){o=i.contentDOM||i.dom;break}o=i.dom.parentNode}let l=_Qe(t,a.pos,1);for(let i=o.firstChild;i;i=i.nextSibling){let c;if(i.nodeType==1)c=i.getClientRects();else if(i.nodeType==3)c=Lv(i,0,i.nodeValue.length).getClientRects();else continue;for(let u=0;up.top+1&&(r=="up"?l.top-p.top>(p.bottom-l.top)*2:p.bottom-l.bottom>(l.bottom-p.top)*2))return!1}}return!0})}const zDt=/[\u0590-\u08ac]/;function BDt(t,s,r){let{$head:n}=s.selection;if(!n.parent.isTextblock)return!1;let a=n.parentOffset,o=!a,l=a==n.parent.content.size,i=t.domSelection();return i?!zDt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:wQe(t,s,()=>{let{focusNode:c,focusOffset:u,anchorNode:p,anchorOffset:f}=t.domSelectionRange(),g=i.caretBidiLevel;i.modify("move",r,"character");let b=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:_,focusOffset:j}=t.domSelectionRange(),w=_&&!b.contains(_.nodeType==1?_:_.parentNode)||c==_&&u==j;try{i.collapse(p,f),c&&(c!=p||u!=f)&&i.extend&&i.extend(c,u)}catch{}return g!=null&&(i.caretBidiLevel=g),w}):n.pos==n.start()||n.pos==n.end()}let WIe=null,GIe=null,KIe=!1;function $Dt(t,s,r){return WIe==s&&GIe==r?KIe:(WIe=s,GIe=r,KIe=r=="up"||r=="down"?FDt(t,s,r):BDt(t,s,r))}const Px=0,ZIe=1,j4=2,P0=3;class WO{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=Px,n.pmViewDesc=this}matchesWidget(s){return!1}matchesMark(s){return!1}matchesNode(s,r,n){return!1}matchesHack(s){return!1}parseRule(){return null}stopEvent(s){return!1}get size(){let s=0;for(let r=0;rbh(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=s.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(r==0)for(let o=s;;o=o.parentNode){if(o==this.dom){a=!1;break}if(o.previousSibling)break}if(a==null&&r==s.childNodes.length)for(let o=s;;o=o.parentNode){if(o==this.dom){a=!0;break}if(o.nextSibling)break}}return a??n>0?this.posAtEnd:this.posAtStart}nearestDesc(s,r=!1){for(let n=!0,a=s;a;a=a.parentNode){let o=this.getDesc(a),l;if(o&&(!r||o.node))if(n&&(l=o.nodeDOM)&&!(l.nodeType==1?l.contains(s.nodeType==1?s:s.parentNode):l==s))n=!1;else return o}}getDesc(s){let r=s.pmViewDesc;for(let n=r;n;n=n.parent)if(n==this)return r}posFromDOM(s,r,n){for(let a=s;a;a=a.parentNode){let o=this.getDesc(a);if(o)return o.localPosFromDOM(s,r,n)}return-1}descAt(s){for(let r=0,n=0;rs||l instanceof NQe){a=s-o;break}o=i}if(a)return this.children[n].domFromPos(a-this.children[n].border,r);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof jQe&&o.side>=0;n--);if(r<=0){let o,l=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,l=!1);return o&&r&&l&&!o.border&&!o.domAtom?o.domFromPos(o.size,r):{node:this.contentDOM,offset:o?bh(o.dom)+1:0}}else{let o,l=!0;for(;o=n=p&&r<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(s,r,p);s=l;for(let f=i;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){a=bh(g.dom)+1;break}s-=g.size}a==-1&&(a=0)}if(a>-1&&(u>r||i==this.children.length-1)){r=u;for(let p=i+1;p_&&lr){let _=i;i=c,c=_}let b=document.createRange();b.setEnd(c.node,c.offset),b.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(b)}}ignoreMutation(s){return!this.contentDOM&&s.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(s,r){for(let n=0,a=0;a=n:sn){let i=n+o.border,c=l-o.border;if(s>=i&&r<=c){this.dirty=s==n||r==l?j4:ZIe,s==i&&r==c&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=P0:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?j4:P0}n=l}this.dirty=j4}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?j4:ZIe;r.dirty{if(!o)return a;if(o.parent)return o.parent.posBeforeChild(o)})),!r.type.spec.raw){if(l.nodeType!=1){let i=document.createElement("span");i.appendChild(l),l=i}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(s,[],l,null),this.widget=r,this.widget=r,o=this}matchesWidget(s){return this.dirty==Px&&s.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(s){let r=this.widget.spec.stopEvent;return r?r(s):!1}ignoreMutation(s){return s.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class qDt extends WO{constructor(s,r,n,a){super(s,[],r,null),this.textDOM=n,this.text=a}get size(){return this.text.length}localPosFromDOM(s,r){return s!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(s){return{node:this.textDOM,offset:s}}ignoreMutation(s){return s.type==="characterData"&&s.target.nodeValue==s.oldValue}}class YS extends WO{constructor(s,r,n,a,o){super(s,[],n,a),this.mark=r,this.spec=o}static create(s,r,n,a){let o=a.nodeViews[r.type.name],l=o&&o(r,a,n);return(!l||!l.dom)&&(l=bC.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new YS(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&P0||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=P0&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=Px){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=P1e(o,0,s,n));for(let i=0;i{if(!c)return l;if(c.parent)return c.parent.posBeforeChild(c)},n,a),p=u&&u.dom,f=u&&u.contentDOM;if(r.isText){if(!p)p=document.createTextNode(r.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:f}=bC.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!f&&!r.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),r.type.spec.draggable&&(p.draggable=!0));let g=p;return p=CQe(p,n,r),u?c=new UDt(s,r,n,a,p,f||null,g,u,o,l+1):r.isText?new Eue(s,r,n,a,p,g,o):new tw(s,r,n,a,p,f||null,g,o,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let s={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(s.preserveWhitespace="full"),!this.contentDOM)s.getContent=()=>this.node.content;else if(!this.contentLost)s.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){s.contentElement=n.dom.parentNode;break}}s.contentElement||(s.getContent=()=>Dr.empty)}return s}matchesNode(s,r,n){return this.dirty==Px&&s.eq(this.node)&&tle(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(s,r){let n=this.node.inlineContent,a=r,o=s.composing?this.localCompositionInfo(s,r):null,l=o&&o.pos>-1?o:null,i=o&&o.pos<0,c=new HDt(this,l&&l.node,s);KDt(this.node,this.innerDeco,(u,p,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,n,s):u.type.side>=0&&!f&&c.syncToMarks(p==this.node.childCount?Ll.none:this.node.child(p).marks,n,s),c.placeWidget(u,s,a)},(u,p,f,g)=>{c.syncToMarks(u.marks,n,s);let b;c.findNodeMatch(u,p,f,g)||i&&s.state.selection.from>a&&s.state.selection.to-1&&c.updateNodeAt(u,p,f,b,s)||c.updateNextNode(u,p,f,s,g,a)||c.addNode(u,p,f,s,a),a+=u.nodeSize}),c.syncToMarks([],n,s),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==j4)&&(l&&this.protectLocalComposition(s,l),kQe(this.contentDOM,this.children,s),GT&&ZDt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof ei)||nr+this.node.content.size)return null;let o=s.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,i=YDt(this.node.content,l,n-r,a-r);return i<0?null:{node:o,pos:i,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(s,{node:r,pos:n,text:a}){if(this.getDesc(r))return;let o=r;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let l=new qDt(this,o,r,a);s.input.compositionNodes.push(l),this.children=P1e(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==P0||!s.sameMarkup(this.node)?!1:(this.updateInner(s,r,n,a),!0)}updateInner(s,r,n,a){this.updateOuterDeco(r),this.node=s,this.innerDeco=n,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=Px}updateOuterDeco(s){if(tle(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=SQe(this.dom,this.nodeDOM,E1e(this.outerDeco,this.node,r),E1e(s,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=s}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function YIe(t,s,r,n,a){CQe(n,s,t);let o=new tw(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class Eue extends tw{constructor(s,r,n,a,o,l,i){super(s,r,n,a,o,null,l,i,0)}parseRule(){let s=this.nodeDOM.parentNode;for(;s&&s!=this.dom&&!s.pmIsDeco;)s=s.parentNode;return{skip:s||!0}}update(s,r,n,a){return this.dirty==P0||this.dirty!=Px&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Px||s.text!=this.node.text)&&s.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=s.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=s,this.dirty=Px,!0)}inParent(){let s=this.parent.contentDOM;for(let r=this.nodeDOM;r;r=r.parentNode)if(r==s)return!0;return!1}domFromPos(s){return{node:this.nodeDOM,offset:s}}localPosFromDOM(s,r,n){return s==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):super.localPosFromDOM(s,r,n)}ignoreMutation(s){return s.type!="characterData"&&s.type!="selection"}slice(s,r,n){let a=this.node.cut(s,r),o=document.createTextNode(a.text);return new Eue(this.parent,a,this.outerDeco,this.innerDeco,o,o,n)}markDirty(s,r){super.markDirty(s,r),this.dom!=this.nodeDOM&&(s==0||r==this.nodeDOM.nodeValue.length)&&(this.dirty=P0)}get domAtom(){return!1}isText(s){return this.node.text==s}}class NQe extends WO{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==Px&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class UDt extends tw{constructor(s,r,n,a,o,l,i,c,u,p){super(s,r,n,a,o,l,i,u,p),this.spec=c}update(s,r,n,a){if(this.dirty==P0)return!1;if(this.spec.update&&(this.node.type==s.type||this.spec.multiType)){let o=this.spec.update(s,r,n);return o&&this.updateInner(s,r,n,a),o}else return!this.contentDOM&&!s.isLeaf?!1:super.update(s,r,n,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(s,r,n,a){this.spec.setSelection?this.spec.setSelection(s,r,n.root):super.setSelection(s,r,n,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(s){return this.spec.stopEvent?this.spec.stopEvent(s):!1}ignoreMutation(s){return this.spec.ignoreMutation?this.spec.ignoreMutation(s):super.ignoreMutation(s)}}function kQe(t,s,r){let n=t.firstChild,a=!1;for(let o=0;o>1,l=Math.min(o,s.length);for(;a-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let c=YS.create(this.top,s[o],r,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(s,r,n,a){let o=-1,l;if(a>=this.preMatch.index&&(l=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&l.matchesNode(s,r,n))o=this.top.children.indexOf(l,this.index);else for(let i=this.index,c=Math.min(this.top.children.length,i+5);i0;){let i;for(;;)if(n){let u=r.children[n-1];if(u instanceof YS)r=u,n=u.children.length;else{i=u,n--;break}}else{if(r==s)break e;n=r.parent.children.indexOf(r),r=r.parent}let c=i.node;if(c){if(c!=t.child(a-1))break;--a,o.set(i,a),l.push(i)}}return{index:a,matched:o,matches:l.reverse()}}function GDt(t,s){return t.type.side-s.type.side}function KDt(t,s,r,n){let a=s.locals(t),o=0;if(a.length==0){for(let u=0;uo;)i.push(a[l++]);let _=o+g.nodeSize;if(g.isText){let w=_;l!w.inline):i.slice();n(g,j,s.forChild(o,g),b),o=_}}function ZDt(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let s=t.style.cssText;t.style.cssText=s+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=s}}function YDt(t,s,r,n){for(let a=0,o=0;a=r){if(o>=n&&c.slice(n-s.length-i,n-i)==s)return n-s.length;let u=i=0&&u+s.length+i>=r)return i+u;if(r==n&&c.length>=n+s.length-i&&c.slice(n-i,n-i+s.length)==s)return n}}return-1}function P1e(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||p<=s?o.push(c):(ur&&o.push(c.slice(r-u,c.size,n)))}return o}function DNe(t,s=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let a=t.docView.nearestDesc(r.focusNode),o=a&&a.size==0,l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let i=n.resolve(l),c,u;if(Aue(r)){for(c=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&Wa.isSelectable(f)&&a.parent&&!(f.isInline&&jDt(r.focusNode,r.focusOffset,a.dom))){let g=a.posBefore;u=new Wa(l==g?i:n.resolve(g))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let f=l,g=l;for(let b=0;b{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!MQe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function QDt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,bh(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&Tp&&ew<=11&&(r.disabled=!0,r.disabled=!1)}function TQe(t,s){if(s instanceof Wa){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(tLe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else tLe(t)}function tLe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function ONe(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||ei.between(s,r,n)}function sLe(t){return t.editable&&!t.hasFocus()?!1:AQe(t)}function AQe(t){let s=t.domSelectionRange();if(!s.anchorNode)return!1;try{return t.dom.contains(s.anchorNode.nodeType==3?s.anchorNode.parentNode:s.anchorNode)&&(t.editable||t.dom.contains(s.focusNode.nodeType==3?s.focusNode.parentNode:s.focusNode))}catch{return!1}}function JDt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return ZS(s.node,s.offset,r.anchorNode,r.anchorOffset)}function I1e(t,s){let{$anchor:r,$head:n}=t.selection,a=s>0?r.max(n):r.min(n),o=a.parent.inlineContent?a.depth?t.doc.resolve(s>0?a.after():a.before()):null:a;return o&&fi.findFrom(o,s)}function Zb(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function rLe(t,s,r){let n=t.state.selection;if(n instanceof ei)if(r.indexOf("s")>-1){let{$head:a}=n,o=a.textOffset?null:s<0?a.nodeBefore:a.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let l=t.state.doc.resolve(a.pos+o.nodeSize*(s<0?-1:1));return Zb(t,new ei(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=I1e(t.state,s);return a&&a instanceof Wa?Zb(t,a):!1}else if(!(dx&&r.indexOf("m")>-1)){let a=n.$head,o=a.textOffset?null:s<0?a.nodeBefore:a.nodeAfter,l;if(!o||o.isText)return!1;let i=s<0?a.pos-o.nodeSize:a.pos;return o.isAtom||(l=t.docView.descAt(i))&&!l.contentDOM?Wa.isSelectable(o)?Zb(t,new Wa(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):HO?Zb(t,new ei(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Wa&&n.node.isInline)return Zb(t,new ei(s>0?n.$to:n.$from));{let a=I1e(t.state,s);return a?Zb(t,a):!1}}}function sle(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function n8(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function k5(t,s){return s<0?eOt(t):tOt(t)}function eOt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(Ex&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(n8(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(EQe(r))break;{let i=r.previousSibling;for(;i&&n8(i,-1);)a=r.parentNode,o=bh(i),i=i.previousSibling;if(i)r=i,n=sle(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?L1e(t,r,n):a&&L1e(t,a,o)}function tOt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=sle(r),o,l;for(;;)if(n{t.state==a&&g1(t)},50)}function nLe(t,s){let r=t.state.doc.resolve(s);if(!(Xu||xQe)&&r.parent.inlineContent){let a=t.coordsAtPos(s);if(s>r.start()){let o=t.coordsAtPos(s-1),l=(o.top+o.bottom)/2;if(l>a.top&&l1)return o.lefta.top&&l1)return o.left>a.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function aLe(t,s,r){let n=t.state.selection;if(n instanceof ei&&!n.empty||r.indexOf("s")>-1||dx&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=I1e(t.state,s);if(l&&l instanceof Wa)return Zb(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof _f?fi.near(l,s):fi.findFrom(l,s);return i?Zb(t,i):!1}return!1}function iLe(t,s){if(!(t.state.selection instanceof ei))return!0;let{$head:r,$anchor:n,empty:a}=t.state.selection;if(!r.sameParent(n))return!0;if(!a)return!1;if(t.endOfTextblock(s>0?"forward":"backward"))return!0;let o=!r.textOffset&&(s<0?r.nodeBefore:r.nodeAfter);if(o&&!o.isText){let l=t.state.tr;return s<0?l.delete(r.pos-o.nodeSize,r.pos):l.delete(r.pos,r.pos+o.nodeSize),t.dispatch(l),!0}return!1}function oLe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function nOt(t){if(!Qh||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:s,focusOffset:r}=t.domSelectionRange();if(s&&s.nodeType==1&&r==0&&s.firstChild&&s.firstChild.contentEditable=="false"){let n=s.firstChild;oLe(t,n,"true"),setTimeout(()=>oLe(t,n,"false"),20)}return!1}function aOt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function iOt(t,s){let r=s.keyCode,n=aOt(s);if(r==8||dx&&r==72&&n=="c")return iLe(t,-1)||k5(t,-1);if(r==46&&!s.shiftKey||dx&&r==68&&n=="c")return iLe(t,1)||k5(t,1);if(r==13||r==27)return!0;if(r==37||dx&&r==66&&n=="c"){let a=r==37?nLe(t,t.state.selection.from)=="ltr"?-1:1:-1;return rLe(t,a,n)||k5(t,a)}else if(r==39||dx&&r==70&&n=="c"){let a=r==39?nLe(t,t.state.selection.from)=="ltr"?1:-1:1;return rLe(t,a,n)||k5(t,a)}else{if(r==38||dx&&r==80&&n=="c")return aLe(t,-1,n)||k5(t,-1);if(r==40||dx&&r==78&&n=="c")return nOt(t)||aLe(t,1,n)||k5(t,1);if(n==(dx?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function RNe(t,s){t.someProp("transformCopied",b=>{s=b(s,t)});let r=[],{content:n,openStart:a,openEnd:o}=s;for(;a>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){a--,o--;let b=n.firstChild;r.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),n=b.content}let l=t.someProp("clipboardSerializer")||bC.fromSchema(t.state.schema),i=RQe(),c=i.createElement("div");c.appendChild(l.serializeFragment(n,{document:i}));let u=c.firstChild,p,f=0;for(;u&&u.nodeType==1&&(p=OQe[u.nodeName.toLowerCase()]);){for(let b=p.length-1;b>=0;b--){let _=i.createElement(p[b]);for(;c.firstChild;)_.appendChild(c.firstChild);c.appendChild(_),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${f?` -${f}`:""} ${JSON.stringify(r)}`);let g=t.someProp("clipboardTextSerializer",b=>b(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:c,text:g,slice:s}}function PQe(t,s,r,n,a){let o=a.parent.type.spec.code,l,i;if(!r&&!s)return null;let c=!!s&&(n||o||!r);if(c){if(t.someProp("transformPastedText",g=>{s=g(s,o||n,t)}),o)return i=new jn(Dr.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",g=>{i=g(i,t,!0)}),i;let f=t.someProp("clipboardTextParser",g=>g(s,a,n,t));if(f)i=f;else{let g=a.marks(),{schema:b}=t.state,_=bC.fromSchema(b);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(j=>{let w=l.appendChild(document.createElement("p"));j&&w.appendChild(_.serializeNode(b.text(j,g)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=dOt(r),HO&&uOt(l);let u=l&&l.querySelector("[data-pm-slice]"),p=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let f=+p[3];f>0;f--){let g=l.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;l=g}if(i||(i=(t.someProp("clipboardParser")||t.someProp("domParser")||t8.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(c||p),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!oOt.test(g.parentNode.nodeName)?{ignore:!0}:null}})),p)i=hOt(lLe(i,+p[1],+p[2]),p[4]);else if(i=jn.maxOpen(lOt(i.content,a),!0),i.openStart||i.openEnd){let f=0,g=0;for(let b=i.content.firstChild;f{i=f(i,t,c)}),i}const oOt=/^(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 lOt(t,s){if(t.childCount<2)return t;for(let r=s.depth;r>=0;r--){let a=s.node(r).contentMatchAt(s.index(r)),o,l=[];if(t.forEach(i=>{if(!l)return;let c=a.findWrapping(i.type),u;if(!c)return l=null;if(u=l.length&&o.length&&LQe(c,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=DQe(l[l.length-1],o.length));let p=IQe(i,c);l.push(p),a=a.matchType(p.type),o=c}}),l)return Dr.from(l)}return t}function IQe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Dr.from(t));return t}function LQe(t,s,r,n,a){if(a1&&(o=0),a=r&&(i=s<0?l.contentMatchAt(0).fillBefore(i,o<=a).append(i):i.append(l.contentMatchAt(l.childCount).fillBefore(Dr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function lLe(t,s,r){return sr})),oge.createHTML(t)):t}function dOt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=RQe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&OQe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=cOt(t),a)for(let o=0;o=0;i-=2){let c=r.nodes[n[i]];if(!c||c.hasRequiredAttrs())break;a=Dr.from(c.create(n[i+1],a)),o++,l++}return new jn(a,o,l)}const qm={},Um={},mOt={touchstart:!0,touchmove:!0};class pOt{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 fOt(t){for(let s in qm){let r=qm[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{gOt(t,n)&&!FNe(t,n)&&(t.editable||!(n.type in Um))&&r(t,n)},mOt[s]?{passive:!0}:void 0)}Qh&&t.dom.addEventListener("input",()=>null),O1e(t)}function C_(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function xOt(t){t.domObserver.stop();for(let s in t.input.eventHandlers)t.dom.removeEventListener(s,t.input.eventHandlers[s]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function O1e(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>FNe(t,n))})}function FNe(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function gOt(t,s){if(!s.bubbles)return!0;if(s.defaultPrevented)return!1;for(let r=s.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(s))return!1;return!0}function yOt(t,s){!FNe(t,s)&&qm[s.type]&&(t.editable||!(s.type in Um))&&qm[s.type](t,s)}Um.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!zQe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Xv&&Xu&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),GT&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let n=Date.now();t.input.lastIOSEnter=n,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==n&&(t.someProp("handleKeyDown",a=>a(t,u4(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||iOt(t,r)?r.preventDefault():C_(t,"key")};Um.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Um.keypress=(t,s)=>{let r=s;if(zQe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||dx&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof ei)||!n.$from.sameParent(n.$to)){let a=String.fromCharCode(r.charCode),o=()=>t.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!t.someProp("handleTextInput",l=>l(t,n.$from.pos,n.$to.pos,a,o))&&t.dispatch(o()),r.preventDefault()}};function Pue(t){return{left:t.clientX,top:t.clientY}}function vOt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function zNe(t,s,r,n,a){if(n==-1)return!1;let o=t.state.doc.resolve(n);for(let l=o.depth+1;l>0;l--)if(t.someProp(s,i=>l>o.depth?i(t,r,o.nodeAfter,o.before(l),a,!0):i(t,r,o.node(l),o.before(l),a,!1)))return!0;return!1}function sT(t,s,r){if(t.focused||t.focus(),t.state.selection.eq(s))return;let n=t.state.tr.setSelection(s);n.setMeta("pointer",!0),t.dispatch(n)}function bOt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Wa.isSelectable(n)?(sT(t,new Wa(r)),!0):!1}function _Ot(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Wa&&(n=r.node);let o=t.state.doc.resolve(s);for(let l=o.depth+1;l>0;l--){let i=l>o.depth?o.nodeAfter:o.node(l);if(Wa.isSelectable(i)){n&&r.$from.depth>0&&l>=r.$from.depth&&o.before(r.$from.depth+1)==r.$from.pos?a=o.before(r.$from.depth):a=o.before(l);break}}return a!=null?(sT(t,Wa.create(t.state.doc,a)),!0):!1}function wOt(t,s,r,n,a){return zNe(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?_Ot(t,r):bOt(t,r))}function jOt(t,s,r,n){return zNe(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function NOt(t,s,r,n){return zNe(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||kOt(t,r,n)}function kOt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(sT(t,ei.create(n,0,n.content.size)),!0):!1;let a=n.resolve(s);for(let o=a.depth+1;o>0;o--){let l=o>a.depth?a.nodeAfter:a.node(o),i=a.before(o);if(l.inlineContent)sT(t,ei.create(n,i+1,i+1+l.content.size));else if(Wa.isSelectable(l))sT(t,Wa.create(n,i));else continue;return!0}}function BNe(t){return rle(t)}const FQe=dx?"metaKey":"ctrlKey";qm.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=BNe(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&vOt(r,t.input.lastClick)&&!r[FQe]&&t.input.lastClick.button==r.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:a,x:r.clientX,y:r.clientY,type:o,button:r.button};let l=t.posAtCoords(Pue(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new SOt(t,l,r,!!n)):(o=="doubleClick"?jOt:NOt)(t,l.pos,l.inside,r)?r.preventDefault():C_(t,"pointer"))};class SOt{constructor(s,r,n,a){this.view=s,this.pos=r,this.event=n,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=s.state.doc,this.selectNode=!!n[FQe],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let p=s.state.doc.resolve(r.pos);o=p.parent,l=p.depth?p.before():0}const i=a?null:n.target,c=i?s.docView.nearestDesc(i,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=s.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof Wa&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ex&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),s.root.addEventListener("mouseup",this.up=this.up.bind(this)),s.root.addEventListener("mousemove",this.move=this.move.bind(this)),C_(s,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>g1(this.view)),this.view.input.mouseDown=null}up(s){if(this.done(),!this.view.dom.contains(s.target))return;let r=this.pos;this.view.state.doc!=this.startDoc&&(r=this.view.posAtCoords(Pue(s))),this.updateAllowDefault(s),this.allowDefault||!r?C_(this.view,"pointer"):wOt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||Qh&&this.mightDrag&&!this.mightDrag.node.isAtom||Xu&&!this.view.state.selection.visible&&Math.min(Math.abs(r.pos-this.view.state.selection.from),Math.abs(r.pos-this.view.state.selection.to))<=2)?(sT(this.view,fi.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):C_(this.view,"pointer")}move(s){this.updateAllowDefault(s),C_(this.view,"pointer"),s.buttons==0&&this.done()}updateAllowDefault(s){!this.allowDefault&&(Math.abs(this.event.x-s.clientX)>4||Math.abs(this.event.y-s.clientY)>4)&&(this.allowDefault=!0)}}qm.touchstart=t=>{t.input.lastTouch=Date.now(),BNe(t),C_(t,"pointer")};qm.touchmove=t=>{t.input.lastTouch=Date.now(),C_(t,"pointer")};qm.contextmenu=t=>BNe(t);function zQe(t,s){return t.composing?!0:Qh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const COt=Xv?5e3:-1;Um.compositionstart=Um.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof ei&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Xu&&xQe&&MOt(t)))t.markCursor=t.state.storedMarks||r.marks(),rle(t,!0),t.markCursor=null;else if(rle(t,!s.selection.empty),Ex&&s.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let n=t.domSelectionRange();for(let a=n.focusNode,o=n.focusOffset;a&&a.nodeType==1&&o!=0;){let l=o<0?a.lastChild:a.childNodes[o-1];if(!l)break;if(l.nodeType==3){let i=t.domSelection();i&&i.collapse(l,l.nodeValue.length);break}else a=l,o=-1}}t.input.composing=!0}BQe(t,COt)};function MOt(t){let{focusNode:s,focusOffset:r}=t.domSelectionRange();if(!s||s.nodeType!=1||r>=s.childNodes.length)return!1;let n=s.childNodes[r];return n.nodeType==1&&n.contentEditable=="false"}Um.compositionend=(t,s)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=s.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,BQe(t,20))};function BQe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>rle(t),s))}function $Qe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=AOt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function TOt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=_Dt(s.focusNode,s.focusOffset),n=wDt(s.focusNode,s.focusOffset);if(r&&n&&r!=n){let a=n.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(r==o||n==o)return o;if(!a||!a.isText(n.nodeValue))return n;if(t.input.compositionNode==n){let l=r.pmViewDesc;if(!(!l||!l.isText(r.nodeValue)))return n}}return r||n}function AOt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function rle(t,s=!1){if(!(Xv&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),$Qe(t),s||t.docView&&t.docView.dirty){let r=DNe(t),n=t.state.selection;return r&&!r.eq(n)?t.dispatch(t.state.tr.setSelection(r)):(t.markCursor||s)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function EOt(t,s){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(s),r.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),a=document.createRange();a.selectNodeContents(s),t.dom.blur(),n.removeAllRanges(),n.addRange(a),setTimeout(()=>{r.parentNode&&r.parentNode.removeChild(r),t.focus()},50)}const hD=Tp&&ew<15||GT&&SDt<604;qm.copy=Um.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=hD?null:r.clipboardData,l=n.content(),{dom:i,text:c}=RNe(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",c)):EOt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function POt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function IOt(t,s){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,n=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let a=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),n.parentNode&&n.parentNode.removeChild(n),r?mD(t,n.value,null,a,s):mD(t,n.textContent,n.innerHTML,a,s)},50)}function mD(t,s,r,n,a){let o=PQe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,a,o||jn.empty)))return!0;if(!o)return!1;let l=POt(o),i=l?t.state.tr.replaceSelectionWith(l,n):t.state.tr.replaceSelection(o);return t.dispatch(i.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function qQe(t){let s=t.getData("text/plain")||t.getData("Text");if(s)return s;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}Um.paste=(t,s)=>{let r=s;if(t.composing&&!Xv)return;let n=hD?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&mD(t,qQe(n),n.getData("text/html"),a,r)?r.preventDefault():IOt(t,r)};class UQe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const LOt=dx?"altKey":"ctrlKey";function VQe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[LOt]}qm.dragstart=(t,s)=>{let r=s,n=t.input.mouseDown;if(n&&n.done(),!r.dataTransfer)return;let a=t.state.selection,o=a.empty?null:t.posAtCoords(Pue(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Wa?a.to-1:a.to))){if(n&&n.mightDrag)l=Wa.create(t.state.doc,n.mightDrag.pos);else if(r.target&&r.target.nodeType==1){let f=t.docView.nearestDesc(r.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(l=Wa.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:c,text:u,slice:p}=RNe(t,i);(!r.dataTransfer.files.length||!Xu||fQe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(hD?"Text":"text/html",c.innerHTML),r.dataTransfer.effectAllowed="copyMove",hD||r.dataTransfer.setData("text/plain",u),t.dragging=new UQe(p,VQe(t,r),l)};qm.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Um.dragover=Um.dragenter=(t,s)=>s.preventDefault();Um.drop=(t,s)=>{try{DOt(t,s,t.dragging)}finally{t.dragging=null}};function DOt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(Pue(s));if(!n)return;let a=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",b=>{o=b(o,t,!1)}):o=PQe(t,qQe(s.dataTransfer),hD?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&VQe(t,s));if(t.someProp("handleDrop",b=>b(t,s,o||jn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?iQe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let c=t.state.tr;if(l){let{node:b}=r;b?b.replace(c):c.deleteSelection()}let u=c.mapping.map(i),p=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(p?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let g=c.doc.resolve(u);if(p&&Wa.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Wa(g));else{let b=c.mapping.map(i);c.mapping.maps[c.mapping.maps.length-1].forEach((_,j,w,N)=>b=N),c.setSelection(ONe(t,g,c.doc.resolve(b)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}qm.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&g1(t)},20))};qm.blur=(t,s)=>{let r=s;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),r.relatedTarget&&t.dom.contains(r.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};qm.beforeinput=(t,s)=>{if(Xu&&Xv&&s.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:n}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=n||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,u4(8,"Backspace")))))return;let{$cursor:a}=t.state.selection;a&&a.pos>0&&t.dispatch(t.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let t in Um)qm[t]=Um[t];function pD(t,s){if(t==s)return!0;for(let r in t)if(t[r]!==s[r])return!1;for(let r in s)if(!(r in t))return!1;return!0}class nle{constructor(s,r){this.toDOM=s,this.spec=r||wS,this.side=this.spec.side||0}map(s,r,n,a){let{pos:o,deleted:l}=s.mapResult(r.from+a,this.side<0?-1:1);return l?null:new Mm(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof nle&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&pD(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class sw{constructor(s,r){this.attrs=s,this.spec=r||wS}map(s,r,n,a){let o=s.map(r.from+a,this.spec.inclusiveStart?-1:1)-n,l=s.map(r.to+a,this.spec.inclusiveEnd?1:-1)-n;return o>=l?null:new Mm(o,l,this)}valid(s,r){return r.from=s&&(!o||o(i.spec))&&n.push(i.copy(i.from+a,i.to+a))}for(let l=0;ls){let i=this.children[l]+1;this.children[l+2].findInner(s-i,r-i,n,a+i,o)}}map(s,r,n){return this==Bh||s.maps.length==0?this:this.mapInner(s,r,0,0,n||wS)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=c+n,p;if(p=WQe(r,i,u)){for(a||(a=this.children.slice());oi&&f.to=s){this.children[i]==s&&(n=this.children[i+2]);break}let o=s+1,l=o+r.content.size;for(let i=0;io&&c.type instanceof sw){let u=Math.max(o,c.from)-o,p=Math.min(l,c.to)-o;ua.map(s,r,wS));return a_.from(n)}forChild(s,r){if(r.isLeaf)return xd.empty;let n=[];for(let a=0;ar instanceof xd)?s:s.reduce((r,n)=>r.concat(n instanceof xd?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let w=j-_-(b-g);for(let N=0;NS+p-f)continue;let M=i[N]+p-f;b>=M?i[N+1]=g<=M?-2:-1:g>=p&&w&&(i[N]+=w,i[N+1]+=w)}f+=w}),p=r.maps[u].map(p,-1)}let c=!1;for(let u=0;u=n.content.size){c=!0;continue}let g=r.map(t[u+1]+o,-1),b=g-a,{index:_,offset:j}=n.content.findIndex(f),w=n.maybeChild(_);if(w&&j==f&&j+w.nodeSize==b){let N=i[u+2].mapInner(r,w,p+1,t[u]+o+1,l);N!=Bh?(i[u]=f,i[u+1]=b,i[u+2]=N):(i[u+1]=-2,c=!0)}else c=!0}if(c){let u=ROt(i,t,s,r,a,o,l),p=ale(u,n,0,l);s=p.local;for(let f=0;fr&&l.to{let u=WQe(t,i,c+r);if(u){o=!0;let p=ale(u,i,r+c+1,n);p!=Bh&&a.push(c,c+i.nodeSize,p)}});let l=HQe(o?GQe(t):t,-r).sort(jS);for(let i=0;i0;)s++;t.splice(s,0,r)}function lge(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Bh&&s.push(n)}),t.cursorWrapper&&s.push(xd.create(t.state.doc,[t.cursorWrapper.deco])),a_.from(s)}const FOt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},zOt=Tp&&ew<=11;class BOt{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(s){this.anchorNode=s.anchorNode,this.anchorOffset=s.anchorOffset,this.focusNode=s.focusNode,this.focusOffset=s.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(s){return s.anchorNode==this.anchorNode&&s.anchorOffset==this.anchorOffset&&s.focusNode==this.focusNode&&s.focusOffset==this.focusOffset}}class $Ot{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new BOt,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()}),zOt&&(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,FOt)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let s=this.observer.takeRecords();if(s.length){for(let r=0;rthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(sLe(this.view)){if(this.suppressingSelectionUpdates)return g1(this.view);if(Tp&&ew<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&ZS(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(s){if(!s.focusNode)return!0;let r=new Set,n;for(let o=s.focusNode;o;o=WT(o))r.add(o);for(let o=s.anchorNode;o;o=WT(o))if(r.has(o)){n=o;break}let a=n&&this.view.docView.nearestDesc(n);if(a&&a.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let s of this.observer.takeRecords())this.queue.push(s);return this.queue}flush(){let{view:s}=this;if(!s.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]);let n=s.domSelectionRange(),a=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&sLe(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,c=[];if(s.editable)for(let p=0;pf.nodeName=="BR");if(p.length==2){let[f,g]=p;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of p){let b=g.parentNode;b&&b.nodeName=="LI"&&(!f||VOt(s,f)!=b)&&g.remove()}}}else if((Xu||Qh)&&c.some(p=>p.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let p of c)if(p.nodeName=="BR"&&p.parentNode){let f=p.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&p.parentNode.removeChild(p)}}let u=null;o<0&&a&&s.input.lastFocus>Date.now()-200&&Math.max(s.input.lastTouch,s.input.lastClick.time)-1||a)&&(o>-1&&(s.docView.markDirty(o,l),qOt(s)),this.handleDOMChange(o,l,i,c),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||g1(s),this.currentSelection.set(n))}registerMutation(s,r){if(r.indexOf(s.target)>-1)return null;let n=this.view.docView.nearestDesc(s.target);if(s.type=="attributes"&&(n==this.view.docView||s.attributeName=="contenteditable"||s.attributeName=="style"&&!s.oldValue&&!s.target.getAttribute("style"))||!n||n.ignoreMutation(s))return null;if(s.type=="childList"){for(let p=0;pa;w--){let N=n.childNodes[w-1],S=N.pmViewDesc;if(N.nodeName=="BR"&&!S){o=w;break}if(!S||S.size)break}let f=t.state.doc,g=t.someProp("domParser")||t8.fromSchema(t.state.schema),b=f.resolve(l),_=null,j=g.parse(n,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:a,to:o,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:WOt,context:b});if(u&&u[0].pos!=null){let w=u[0].pos,N=u[1]&&u[1].pos;N==null&&(N=w),_={anchor:w+l,head:N+l}}return{doc:j,sel:_,from:l,to:i}}function WOt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Qh&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||Qh&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const GOt=/^(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 KOt(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let q=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,U=DNe(t,q);if(U&&!t.state.selection.eq(U)){if(Xu&&Xv&&t.input.lastKeyCode===13&&Date.now()-100V(t,u4(13,"Enter"))))return;let B=t.state.tr.setSelection(U);q=="pointer"?B.setMeta("pointer",!0):q=="key"&&B.scrollIntoView(),o&&B.setMeta("composition",o),t.dispatch(B)}return}let l=t.state.doc.resolve(s),i=l.sharedDepth(r);s=l.before(i+1),r=t.state.doc.resolve(r).after(i+1);let c=t.state.selection,u=HOt(t,s,r),p=t.state.doc,f=p.slice(u.from,u.to),g,b;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Xv)&&a.some(q=>q.nodeType==1&&!GOt.test(q.nodeName))&&(!_||_.endA>=_.endB)&&t.someProp("handleKeyDown",q=>q(t,u4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!_)if(n&&c instanceof ei&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))_={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let q=pLe(t,t.state.doc,u.sel);if(q&&!q.eq(t.state.selection)){let U=t.state.tr.setSelection(q);o&&U.setMeta("composition",o),t.dispatch(U)}}return}t.state.selection.fromt.state.selection.from&&_.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?_.start=t.state.selection.from:_.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(_.endB+=t.state.selection.to-_.endA,_.endA=t.state.selection.to)),Tp&&ew<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>u.from&&u.doc.textBetween(_.start-u.from-1,_.start-u.from+1)=="  "&&(_.start--,_.endA--,_.endB--);let j=u.doc.resolveNoCache(_.start-u.from),w=u.doc.resolveNoCache(_.endB-u.from),N=p.resolve(_.start),S=j.sameParent(w)&&j.parent.inlineContent&&N.end()>=_.endA;if((GT&&t.input.lastIOSEnter>Date.now()-225&&(!S||a.some(q=>q.nodeName=="DIV"||q.nodeName=="P"))||!S&&j.posq(t,u4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>_.start&&YOt(p,_.start,_.endA,j,w)&&t.someProp("handleKeyDown",q=>q(t,u4(8,"Backspace")))){Xv&&Xu&&t.domObserver.suppressSelectionUpdates();return}Xu&&_.endB==_.start&&(t.input.lastChromeDelete=Date.now()),Xv&&!S&&j.start()!=w.start()&&w.parentOffset==0&&j.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==_.endA&&(_.endB-=2,w=u.doc.resolveNoCache(_.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(q){return q(t,u4(13,"Enter"))})},20));let M=_.start,L=_.endA,I=q=>{let U=q||t.state.tr.replace(M,L,u.doc.slice(_.start-u.from,_.endB-u.from));if(u.sel){let B=pLe(t,U.doc,u.sel);B&&!(Xu&&t.composing&&B.empty&&(_.start!=_.endB||t.input.lastChromeDeleteg1(t),20));let q=I(t.state.tr.delete(M,L)),U=p.resolve(_.start).marksAcross(p.resolve(_.endA));U&&q.ensureMarks(U),t.dispatch(q)}else if(_.endA==_.endB&&(O=ZOt(j.parent.content.cut(j.parentOffset,w.parentOffset),N.parent.content.cut(N.parentOffset,_.endA-N.start())))){let q=I(t.state.tr);O.type=="add"?q.addMark(M,L,O.mark):q.removeMark(M,L,O.mark),t.dispatch(q)}else if(j.parent.child(j.index()).isText&&j.index()==w.index()-(w.textOffset?0:1)){let q=j.parent.textBetween(j.parentOffset,w.parentOffset),U=()=>I(t.state.tr.insertText(q,M,L));t.someProp("handleTextInput",B=>B(t,M,L,q,U))||t.dispatch(U())}else t.dispatch(I());else t.dispatch(I())}function pLe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:ONe(t,s.resolve(r.anchor),s.resolve(r.head))}function ZOt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,c;for(let p=0;pp.mark(i.addToSet(p.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",c=p=>p.mark(i.removeFromSet(p.marks));else return null;let u=[];for(let p=0;pr||cge(l,!0,!1)0&&(s||t.indexAfter(n)==t.node(n).childCount);)n--,a++,s=!1;if(r){let o=t.node(n).maybeChild(t.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,a++}return a}function XOt(t,s,r,n,a){let o=t.findDiffStart(s,r);if(o==null)return null;let{a:l,b:i}=t.findDiffEnd(s,r+t.size,r+s.size);if(a=="end"){let c=Math.max(0,o-Math.min(l,i));n-=l+c-o}if(l=l?o-n:0;o-=c,o&&o=i?o-n:0;o-=c,o&&o=56320&&s<=57343&&r>=55296&&r<=56319}class KQe{constructor(s,r){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new pOt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(bLe),this.dispatch=this.dispatch.bind(this),this.dom=s&&s.mount||document.createElement("div"),s&&(s.appendChild?s.appendChild(this.dom):typeof s=="function"?s(this.dom):s.mount&&(this.mounted=!0)),this.editable=yLe(this),gLe(this),this.nodeViews=vLe(this),this.docView=YIe(this.state.doc,xLe(this),lge(this),this.dom,this),this.domObserver=new $Ot(this,(n,a,o,l)=>KOt(this,n,a,o,l)),this.domObserver.start(),fOt(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let s=this._props;this._props={};for(let r in s)this._props[r]=s[r];this._props.state=this.state}return this._props}update(s){s.handleDOMEvents!=this._props.handleDOMEvents&&O1e(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(bLe),this.directPlugins=s.plugins),this.updateStateInner(s.state,r)}setProps(s){let r={};for(let n in this._props)r[n]=this._props[n];r.state=this.state;for(let n in s)r[n]=s[n];this.update(r)}updateState(s){this.updateStateInner(s,this._props)}updateStateInner(s,r){var n;let a=this.state,o=!1,l=!1;s.storedMarks&&this.composing&&($Qe(this),l=!0),this.state=s;let i=a.plugins!=s.plugins||this._props.plugins!=r.plugins;if(i||this._props.plugins!=r.plugins||this._props.nodeViews!=r.nodeViews){let b=vLe(this);JOt(b,this.nodeViews)&&(this.nodeViews=b,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&O1e(this),this.editable=yLe(this),gLe(this);let c=lge(this),u=xLe(this),p=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(s.doc,u,c);(f||!s.selection.eq(a.selection))&&(l=!0);let g=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&TDt(this);if(l){this.domObserver.stop();let b=f&&(Tp||Xu)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&QOt(a.selection,s.selection);if(f){let _=Xu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=TOt(this)),(o||!this.docView.update(s.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=YIe(s.doc,u,c,this.dom,this)),_&&!this.trackWrites&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&JDt(this))?g1(this,b):(TQe(this,s.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((n=this.dragging)===null||n===void 0)&&n.node&&!a.doc.eq(s.doc)&&this.updateDraggedNode(this.dragging,a),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():g&&ADt(g)}scrollToSelection(){let s=this.domSelectionRange().focusNode;if(!(!s||!this.dom.contains(s.nodeType==1?s:s.parentNode))){if(!this.someProp("handleScrollToSelection",r=>r(this)))if(this.state.selection instanceof Wa){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&VIe(this,r.getBoundingClientRect(),s)}else VIe(this,this.coordsAtPos(this.state.selection.head,1),s)}}destroyPluginViews(){let s;for(;s=this.pluginViews.pop();)s.destroy&&s.destroy()}updatePluginViews(s){if(!s||s.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let r=0;r0&&this.state.doc.nodeAt(o))==n.node&&(a=o)}this.dragging=new UQe(s.slice,s.move,a<0?void 0:Wa.create(this.state.doc,a))}someProp(s,r){let n=this._props&&this._props[s],a;if(n!=null&&(a=r?r(n):n))return a;for(let l=0;lr.ownerDocument.getSelection()),this._root=r}return s||document}updateRoot(){this._root=null}posAtCoords(s){return ODt(this,s)}coordsAtPos(s,r=1){return _Qe(this,s,r)}domAtPos(s,r=0){return this.docView.domFromPos(s,r)}nodeDOM(s){let r=this.docView.descAt(s);return r?r.nodeDOM:null}posAtDOM(s,r,n=-1){let a=this.docView.posFromDOM(s,r,n);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(s,r){return $Dt(this,r||this.state,s)}pasteHTML(s,r){return mD(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return mD(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return RNe(this,s)}destroy(){this.docView&&(xOt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],lge(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,vDt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return yOt(this,s)}domSelectionRange(){let s=this.domSelection();return s?Qh&&this.root.nodeType===11&&NDt(this.dom.ownerDocument)==this.dom&&UOt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}KQe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function xLe(t){let s=Object.create(null);return s.class="ProseMirror",s.contenteditable=String(t.editable),t.someProp("attributes",r=>{if(typeof r=="function"&&(r=r(t.state)),r)for(let n in r)n=="class"?s.class+=" "+r[n]:n=="style"?s.style=(s.style?s.style+";":"")+r[n]:!s[n]&&n!="contenteditable"&&n!="nodeName"&&(s[n]=String(r[n]))}),s.translate||(s.translate="no"),[Mm.node(0,t.state.doc.content.size,s)]}function gLe(t){if(t.markCursor){let s=document.createElement("img");s.className="ProseMirror-separator",s.setAttribute("mark-placeholder","true"),s.setAttribute("alt",""),t.cursorWrapper={dom:s,deco:Mm.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function yLe(t){return!t.someProp("editable",s=>s(t.state)===!1)}function QOt(t,s){let r=Math.min(t.$anchor.sharedDepth(t.head),s.$anchor.sharedDepth(s.head));return t.$anchor.start(r)!=s.$anchor.start(r)}function vLe(t){let s=Object.create(null);function r(n){for(let a in n)Object.prototype.hasOwnProperty.call(s,a)||(s[a]=n[a])}return t.someProp("nodeViews",r),t.someProp("markViews",r),s}function JOt(t,s){let r=0,n=0;for(let a in t){if(t[a]!=s[a])return!0;r++}for(let a in s)n++;return r!=n}function bLe(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var yw={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:"'"},ile={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},eRt=typeof navigator<"u"&&/Mac/.test(navigator.platform),tRt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _h=0;_h<10;_h++)yw[48+_h]=yw[96+_h]=String(_h);for(var _h=1;_h<=24;_h++)yw[_h+111]="F"+_h;for(var _h=65;_h<=90;_h++)yw[_h]=String.fromCharCode(_h+32),ile[_h]=String.fromCharCode(_h);for(var dge in yw)ile.hasOwnProperty(dge)||(ile[dge]=yw[dge]);function sRt(t){var s=eRt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||tRt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?ile:yw)[t.keyCode]||t.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}const rRt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),nRt=typeof navigator<"u"&&/Win/.test(navigator.platform);function aRt(t){let s=t.split(/-(?!$)/),r=s[s.length-1];r=="Space"&&(r=" ");let n,a,o,l;for(let i=0;it.selection.empty?!1:(s&&s(t.tr.deleteSelection().scrollIntoView()),!0);function ZQe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const YQe=(t,s,r)=>{let n=ZQe(t,r);if(!n)return!1;let a=HNe(n);if(!a){let l=n.blockRange(),i=l&&aE(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(aJe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(KT(o,"end")||Wa.isSelectable(o)))for(let l=n.depth;;l--){let i=Mue(t.doc,n.before(l),n.after(l),jn.empty);if(i&&i.slice.size1)break}return o.isAtom&&a.depth==n.depth-1?(s&&s(t.tr.delete(a.pos-o.nodeSize,a.pos).scrollIntoView()),!0):!1},lRt=(t,s,r)=>{let n=ZQe(t,r);if(!n)return!1;let a=HNe(n);return a?XQe(t,a,s):!1},cRt=(t,s,r)=>{let n=JQe(t,r);if(!n)return!1;let a=WNe(n);return a?XQe(t,a,s):!1};function XQe(t,s,r){let n=s.nodeBefore,a=n,o=s.pos-1;for(;!a.isTextblock;o--){if(a.type.spec.isolating)return!1;let p=a.lastChild;if(!p)return!1;a=p}let l=s.nodeAfter,i=l,c=s.pos+1;for(;!i.isTextblock;c++){if(i.type.spec.isolating)return!1;let p=i.firstChild;if(!p)return!1;i=p}let u=Mue(t.doc,o,c,jn.empty);if(!u||u.from!=o||u instanceof Zu&&u.slice.size>=c-o)return!1;if(r){let p=t.tr.step(u);p.setSelection(ei.create(p.doc,o)),r(p.scrollIntoView())}return!0}function KT(t,s,r=!1){for(let n=t;n;n=s=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(r&&n.childCount!=1)return!1}return!1}const QQe=(t,s,r)=>{let{$head:n,empty:a}=t.selection,o=n;if(!a)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):n.parentOffset>0)return!1;o=HNe(n)}let l=o&&o.nodeBefore;return!l||!Wa.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Wa.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function HNe(t){if(!t.parent.type.spec.isolating)for(let s=t.depth-1;s>=0;s--){if(t.index(s)>0)return t.doc.resolve(t.before(s+1));if(t.node(s).type.spec.isolating)break}return null}function JQe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=JQe(t,r);if(!n)return!1;let a=WNe(n);if(!a)return!1;let o=a.nodeAfter;if(aJe(t,a,s,1))return!0;if(n.parent.content.size==0&&(KT(o,"start")||Wa.isSelectable(o))){let l=Mue(t.doc,n.before(),n.after(),jn.empty);if(l&&l.slice.size{let{$head:n,empty:a}=t.selection,o=n;if(!a)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):n.parentOffset=0;s--){let r=t.node(s);if(t.index(s)+1{let r=t.selection,n=r instanceof Wa,a;if(n){if(r.node.isTextblock||!Dw(t.doc,r.from))return!1;a=r.from}else if(a=Cue(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Wa.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},uRt=(t,s)=>{let r=t.selection,n;if(r instanceof Wa){if(r.node.isTextblock||!Dw(t.doc,r.to))return!1;n=r.to}else if(n=Cue(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},hRt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&aE(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},sJe=(t,s)=>{let{$head:r,$anchor:n}=t.selection;return!r.parent.type.spec.code||!r.sameParent(n)?!1:(s&&s(t.tr.insertText(` `).scrollIntoView()),!0)};function GNe(t){for(let s=0;s{let{$head:r,$anchor:n}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(n))return!1;let a=r.node(-1),o=r.indexAfter(-1),l=GNe(a.contentMatchAt(o));if(!l||!a.canReplaceWith(o,o,l))return!1;if(s){let i=r.after(),c=t.tr.replaceWith(i,i,l.createAndFill());c.setSelection(fi.near(c.doc.resolve(i),1)),s(c.scrollIntoView())}return!0},rJe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof _f||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=GNe(a.parent.contentMatchAt(a.indexAfter()));if(!o||!o.isTextblock)return!1;if(s){let l=(!n.parentOffset&&a.index(){let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){let o=r.before();if(x1(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&aE(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function pRt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Wa&&s.selection.node.isBlock)return!n.parentOffset||!x1(s.doc,n.pos)?!1:(r&&r(s.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],l,i,c=!1,u=!1;for(let b=n.depth;;b--)if(n.node(b).isBlock){c=n.end(b)==n.pos+(n.depth-b),u=n.start(b)==n.pos-(n.depth-b),i=GNe(n.node(b-1).contentMatchAt(n.indexAfter(b-1))),o.unshift(c&&i?{type:i}:null),l=b;break}else{if(b==1)return!1;o.unshift(null)}let p=s.tr;(s.selection instanceof ei||s.selection instanceof _f)&&p.deleteSelection();let f=p.mapping.map(n.pos),g=x1(p.doc,f,o.length,o);if(g||(o[0]=i?{type:i}:null,g=x1(p.doc,f,o.length,o)),!g)return!1;if(p.split(f,o.length,o),!c&&u&&n.node(l).type!=i){let b=p.mapping.map(n.before(l)),_=p.doc.resolve(b);i&&n.node(l-1).canReplaceWith(_.index(),_.index()+1,i)&&p.setNodeMarkup(p.mapping.map(n.before(l)),i)}return r&&r(p.scrollIntoView()),!0}}const fRt=pRt(),xRt=(t,s)=>{let{$from:r,to:n}=t.selection,a,o=r.sharedDepth(n);return o==0?!1:(a=r.before(o),s&&s(t.tr.setSelection(Wa.create(t.doc,a))),!0)};function gRt(t,s,r){let n=s.nodeBefore,a=s.nodeAfter,o=s.index();return!n||!a||!n.type.compatibleContent(a.type)?!1:!n.content.size&&s.parent.canReplace(o-1,o)?(r&&r(t.tr.delete(s.pos-n.nodeSize,s.pos).scrollIntoView()),!0):!s.parent.canReplace(o,o+1)||!(a.isTextblock||Dw(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function aJe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,c=a.type.spec.isolating||o.type.spec.isolating;if(!c&&gRt(t,s,r))return!0;let u=!c&&s.parent.canReplace(s.index(),s.index()+1);if(u&&(l=(i=a.contentMatchAt(a.childCount)).findWrapping(o.type))&&i.matchType(l[0]||o.type).validEnd){if(r){let b=s.pos+o.nodeSize,_=Dr.empty;for(let N=l.length-1;N>=0;N--)_=Dr.from(l[N].create(null,_));_=Dr.from(a.copy(_));let j=t.tr.step(new rh(s.pos-1,b,s.pos,b,new jn(_,1,0),l.length,!0)),w=j.doc.resolve(b+2*l.length);w.nodeAfter&&w.nodeAfter.type==a.type&&Dw(j.doc,w.pos)&&j.join(w.pos),r(j.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&c?null:fi.findFrom(s,1),f=p&&p.$from.blockRange(p.$to),g=f&&aE(f);if(g!=null&&g>=s.depth)return r&&r(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&KT(o,"start",!0)&&KT(a,"end")){let b=a,_=[];for(;_.push(b),!b.isTextblock;)b=b.lastChild;let j=o,w=1;for(;!j.isTextblock;j=j.firstChild)w++;if(b.canReplace(b.childCount,b.childCount,j.content)){if(r){let N=Dr.empty;for(let M=_.length-1;M>=0;M--)N=Dr.from(_[M].copy(N));let S=t.tr.step(new rh(s.pos-_.length,s.pos+o.nodeSize,s.pos+w,s.pos+o.nodeSize-w,new jn(N,_.length,0),0,!0));r(S.scrollIntoView())}return!0}}return!1}function iJe(t){return function(s,r){let n=s.selection,a=t<0?n.$from:n.$to,o=a.depth;for(;a.node(o).isInline;){if(!o)return!1;o--}return a.node(o).isTextblock?(r&&r(s.tr.setSelection(ei.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const yRt=iJe(-1),vRt=iJe(1);function bRt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&ENe(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function _Le(t,s=null){return function(r,n){let a=!1;for(let o=0;o{if(a)return!1;if(!(!c.isTextblock||c.hasMarkup(t,s)))if(c.type==t)a=!0;else{let p=r.doc.resolve(u),f=p.index();a=p.parent.canReplaceWith(f,f+1,t)}})}if(!a)return!1;if(n){let o=r.tr;for(let l=0;l=2&&s.$from.node(s.depth-1).type.compatibleContent(r)&&s.startIndex==0){if(s.$from.index(s.depth-1)==0)return!1;let c=l.resolve(s.start-2);o=new Joe(c,c,s.depth),s.endIndex=0;p--)o=Dr.from(r[p].type.create(r[p].attrs,o));t.step(new rh(s.start-(n?2:0),s.end,s.start,s.end,new jn(o,0,0),r.length,!0));let l=0;for(let p=0;pl.childCount>0&&l.firstChild.type==t);return o?r?n.node(o.depth-1).type==t?kRt(s,r,t,o):SRt(s,r,o):!0:!1}}function kRt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);oj;_--)b-=a.child(_).nodeSize,n.delete(b-1,b+1);let o=n.doc.resolve(r.start),l=o.nodeAfter;if(n.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let i=r.startIndex==0,c=r.endIndex==a.childCount,u=o.node(-1),p=o.index(-1);if(!u.canReplace(p+(i?0:1),p+1,l.content.append(c?Dr.empty:Dr.from(a))))return!1;let f=o.pos,g=f+l.nodeSize;return n.step(new rh(f-(i?1:0),g+(c?1:0),f+1,g-1,new jn((i?Dr.empty:Dr.from(a.copy(Dr.empty))).append(c?Dr.empty:Dr.from(a.copy(Dr.empty))),i?0:1,c?0:1),i?0:1)),s(n.scrollIntoView()),!0}function CRt(t){return function(s,r){let{$from:n,$to:a}=s.selection,o=n.blockRange(a,u=>u.childCount>0&&u.firstChild.type==t);if(!o)return!1;let l=o.startIndex;if(l==0)return!1;let i=o.parent,c=i.child(l-1);if(c.type!=t)return!1;if(r){let u=c.lastChild&&c.lastChild.type==i.type,p=Dr.from(u?t.create():null),f=new jn(Dr.from(t.create(null,Dr.from(i.type.create(null,p)))),u?3:1,0),g=o.start,b=o.end;r(s.tr.step(new rh(g-(u?3:1),b,g,b,f,1,!0)).scrollIntoView())}return!0}}function Iue(t){const{state:s,transaction:r}=t;let{selection:n}=r,{doc:a}=r,{storedMarks:o}=r;return{...s,apply:s.apply.bind(s),applyTransaction:s.applyTransaction.bind(s),plugins:s.plugins,schema:s.schema,reconfigure:s.reconfigure.bind(s),toJSON:s.toJSON.bind(s),get storedMarks(){return o},get selection(){return n},get doc(){return a},get tr(){return n=r.selection,a=r.doc,o=r.storedMarks,r}}}class Lue{constructor(s){this.editor=s.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=s.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:s,editor:r,state:n}=this,{view:a}=r,{tr:o}=n,l=this.buildProps(o);return Object.fromEntries(Object.entries(s).map(([i,c])=>[i,(...p)=>{const f=c(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i=[],c=!!s,u=s||o.tr,p=()=>(!c&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(u),i.every(g=>g===!0)),f={...Object.fromEntries(Object.entries(n).map(([g,b])=>[g,(...j)=>{const w=this.buildProps(u,r),N=b(...j)(w);return i.push(N),f}])),run:p};return f}createCan(s){const{rawCommands:r,state:n}=this,a=!1,o=s||n.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(r).map(([c,u])=>[c,(...p)=>u(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i={tr:s,editor:a,view:l,state:Iue({state:o,transaction:s}),dispatch:r?()=>{}:void 0,chain:()=>this.createChain(s,r),can:()=>this.createCan(s),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...p)=>u(...p)(i)]))}};return i}}let MRt=class{constructor(){this.callbacks={}}on(s,r){return this.callbacks[s]||(this.callbacks[s]=[]),this.callbacks[s].push(r),this}emit(s,...r){const n=this.callbacks[s];return n&&n.forEach(a=>a.apply(this,r)),this}off(s,r){const n=this.callbacks[s];return n&&(r?this.callbacks[s]=n.filter(a=>a!==r):delete this.callbacks[s]),this}once(s,r){const n=(...a)=>{this.off(s,n),r.apply(this,a)};return this.on(s,n)}removeAllListeners(){this.callbacks={}}};function oa(t,s,r){return t.config[s]===void 0&&t.parent?oa(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?oa(t.parent,s,r):null}):t.config[s]}function Due(t){const s=t.filter(a=>a.type==="extension"),r=t.filter(a=>a.type==="node"),n=t.filter(a=>a.type==="mark");return{baseExtensions:s,nodeExtensions:r,markExtensions:n}}function oJe(t){const s=[],{nodeExtensions:r,markExtensions:n}=Due(t),a=[...r,...n],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage,extensions:a},c=oa(l,"addGlobalAttributes",i);if(!c)return;c().forEach(p=>{p.types.forEach(f=>{Object.entries(p.attributes).forEach(([g,b])=>{s.push({type:f,name:g,attribute:{...o,...b}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},c=oa(l,"addAttributes",i);if(!c)return;const u=c();Object.entries(u).forEach(([p,f])=>{const g={...o,...f};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,s.push({type:l.name,name:p,attribute:g})})}),s}function ih(t,s){if(typeof t=="string"){if(!s.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return s.nodes[t]}return t}function Hc(...t){return t.filter(s=>!!s).reduce((s,r)=>{const n={...s};return Object.entries(r).forEach(([a,o])=>{if(!n[a]){n[a]=o;return}if(a==="class"){const i=o?String(o).split(" "):[],c=n[a]?n[a].split(" "):[],u=i.filter(p=>!c.includes(p));n[a]=[...c,...u].join(" ")}else if(a==="style"){const i=o?o.split(";").map(p=>p.trim()).filter(Boolean):[],c=n[a]?n[a].split(";").map(p=>p.trim()).filter(Boolean):[],u=new Map;c.forEach(p=>{const[f,g]=p.split(":").map(b=>b.trim());u.set(f,g)}),i.forEach(p=>{const[f,g]=p.split(":").map(b=>b.trim());u.set(f,g)}),n[a]=Array.from(u.entries()).map(([p,f])=>`${p}: ${f}`).join("; ")}else n[a]=o}),n},{})}function R1e(t,s){return s.filter(r=>r.type===t.type.name).filter(r=>r.attribute.rendered).map(r=>r.attribute.renderHTML?r.attribute.renderHTML(t.attrs)||{}:{[r.name]:t.attrs[r.name]}).reduce((r,n)=>Hc(r,n),{})}function lJe(t){return typeof t=="function"}function eo(t,s=void 0,...r){return lJe(t)?s?t.bind(s)(...r):t(...r):t}function TRt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ARt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function wLe(t,s){return"style"in t?t:{...t,getAttrs:r=>{const n=t.getAttrs?t.getAttrs(r):t.attrs;if(n===!1)return!1;const a=s.reduce((o,l)=>{const i=l.attribute.parseHTML?l.attribute.parseHTML(r):ARt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function jLe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&TRt(r)?!1:r!=null))}function ERt(t,s){var r;const n=oJe(t),{nodeExtensions:a,markExtensions:o}=Due(t),l=(r=a.find(u=>oa(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(N=>N.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},g=t.reduce((N,S)=>{const M=oa(S,"extendNodeSchema",f);return{...N,...M?M(u):{}}},{}),b=jLe({...g,content:eo(oa(u,"content",f)),marks:eo(oa(u,"marks",f)),group:eo(oa(u,"group",f)),inline:eo(oa(u,"inline",f)),atom:eo(oa(u,"atom",f)),selectable:eo(oa(u,"selectable",f)),draggable:eo(oa(u,"draggable",f)),code:eo(oa(u,"code",f)),whitespace:eo(oa(u,"whitespace",f)),linebreakReplacement:eo(oa(u,"linebreakReplacement",f)),defining:eo(oa(u,"defining",f)),isolating:eo(oa(u,"isolating",f)),attrs:Object.fromEntries(p.map(N=>{var S;return[N.name,{default:(S=N==null?void 0:N.attribute)===null||S===void 0?void 0:S.default}]}))}),_=eo(oa(u,"parseHTML",f));_&&(b.parseDOM=_.map(N=>wLe(N,p)));const j=oa(u,"renderHTML",f);j&&(b.toDOM=N=>j({node:N,HTMLAttributes:R1e(N,p)}));const w=oa(u,"renderText",f);return w&&(b.toText=w),[u.name,b]})),c=Object.fromEntries(o.map(u=>{const p=n.filter(w=>w.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},g=t.reduce((w,N)=>{const S=oa(N,"extendMarkSchema",f);return{...w,...S?S(u):{}}},{}),b=jLe({...g,inclusive:eo(oa(u,"inclusive",f)),excludes:eo(oa(u,"excludes",f)),group:eo(oa(u,"group",f)),spanning:eo(oa(u,"spanning",f)),code:eo(oa(u,"code",f)),attrs:Object.fromEntries(p.map(w=>{var N;return[w.name,{default:(N=w==null?void 0:w.attribute)===null||N===void 0?void 0:N.default}]}))}),_=eo(oa(u,"parseHTML",f));_&&(b.parseDOM=_.map(w=>wLe(w,p)));const j=oa(u,"renderHTML",f);return j&&(b.toDOM=w=>j({mark:w,HTMLAttributes:R1e(w,p)})),[u.name,b]}));return new ZXe({topNode:l,nodes:i,marks:c})}function hge(t,s){return s.nodes[t]||s.marks[t]||null}function NLe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function ZNe(t,s){const r=bC.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const PRt=(t,s=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-s),n,(a,o,l,i)=>{var c,u;const p=((u=(c=a.type.spec).toText)===null||u===void 0?void 0:u.call(c,{node:a,pos:o,parent:l,index:i}))||a.textContent||"%leaf%";r+=a.isAtom&&!a.isText?p:p.slice(0,Math.max(0,n-o))}),r};function YNe(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Oue{constructor(s){this.find=s.find,this.handler=s.handler}}const IRt=(t,s)=>{if(YNe(s))return s.exec(t);const r=s(t);if(!r)return null;const n=[r.text];return n.index=r.index,n.input=t,n.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(r.replaceWith)),n};function hz(t){var s;const{editor:r,from:n,to:a,text:o,rules:l,plugin:i}=t,{view:c}=r;if(c.composing)return!1;const u=c.state.doc.resolve(n);if(u.parent.type.spec.code||!((s=u.nodeBefore||u.nodeAfter)===null||s===void 0)&&s.marks.find(g=>g.type.spec.code))return!1;let p=!1;const f=PRt(u)+o;return l.forEach(g=>{if(p)return;const b=IRt(f,g.find);if(!b)return;const _=c.state.tr,j=Iue({state:c.state,transaction:_}),w={from:n-(b[0].length-o.length),to:a},{commands:N,chain:S,can:M}=new Lue({editor:r,state:j});g.handler({state:j,range:w,match:b,commands:N,chain:S,can:M})===null||!_.steps.length||(_.setMeta(i,{transform:_,from:n,to:a,text:o}),c.dispatch(_),p=!0)}),p}function LRt(t){const{editor:s,rules:r}=t,n=new Iu({state:{init(){return null},apply(a,o,l){const i=a.getMeta(n);if(i)return i;const c=a.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:p}=c;typeof p=="string"?p=p:p=ZNe(Dr.from(p),l.schema);const{from:f}=c,g=f+p.length;hz({editor:s,from:f,to:g,text:p,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return hz({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&hz({editor:s,from:o.pos,to:o.pos,text:"",rules:r,plugin:n})}),!1)},handleKeyDown(a,o){if(o.key!=="Enter")return!1;const{$cursor:l}=a.state.selection;return l?hz({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function DRt(t){return Object.prototype.toString.call(t).slice(8,-1)}function mz(t){return DRt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Rue(t,s){const r={...t};return mz(t)&&mz(s)&&Object.keys(s).forEach(n=>{mz(s[n])&&mz(t[n])?r[n]=Rue(t[n],s[n]):r[n]=s[n]}),r}class cy{constructor(s={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=eo(oa(this,"addOptions",{name:this.name}))),this.storage=eo(oa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new cy(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Rue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new cy(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=eo(oa(r,"addOptions",{name:r.name})),r.storage=eo(oa(r,"addStorage",{name:r.name,options:r.options})),r}static handleExit({editor:s,mark:r}){const{tr:n}=s.state,a=s.state.selection.$from;if(a.pos===a.end()){const l=a.marks();if(!!!l.find(u=>(u==null?void 0:u.type.name)===r.name))return!1;const c=l.find(u=>(u==null?void 0:u.type.name)===r.name);return c&&n.removeStoredMark(c),n.insertText(" ",a.pos),s.view.dispatch(n),!0}return!1}}function ORt(t){return typeof t=="number"}class RRt{constructor(s){this.find=s.find,this.handler=s.handler}}const FRt=(t,s,r)=>{if(YNe(s))return[...t.matchAll(s)];const n=s(t,r);return n?n.map(a=>{const o=[a.text];return o.index=a.index,o.input=t,o.data=a.data,a.replaceWith&&(a.text.includes(a.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(a.replaceWith)),o}):[]};function zRt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:c,chain:u,can:p}=new Lue({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(b,_)=>{if(!b.isTextblock||b.type.spec.code)return;const j=Math.max(n,_),w=Math.min(a,_+b.content.size),N=b.textBetween(j-_,w-_,void 0,"");FRt(N,o.find,l).forEach(M=>{if(M.index===void 0)return;const L=j+M.index+1,I=L+M[0].length,O={from:r.tr.mapping.map(L),to:r.tr.mapping.map(I)},q=o.handler({state:r,range:O,match:M,commands:c,chain:u,can:p,pasteEvent:l,dropEvent:i});f.push(q)})}),f.every(b=>b!==null)}let pz=null;const BRt=t=>{var s;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(s=r.clipboardData)===null||s===void 0||s.setData("text/html",t),r};function $Rt(t){const{editor:s,rules:r}=t;let n=null,a=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,i;try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}const c=({state:p,from:f,to:g,rule:b,pasteEvt:_})=>{const j=p.tr,w=Iue({state:p,transaction:j});if(!(!zRt({editor:s,state:w,from:Math.max(f-1,0),to:g.b-1,rule:b,pasteEvent:_,dropEvent:i})||!j.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,j}};return r.map(p=>new Iu({view(f){const g=_=>{var j;n=!((j=f.dom.parentElement)===null||j===void 0)&&j.contains(_.target)?f.dom.parentElement:null,n&&(pz=s)},b=()=>{pz&&(pz=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(o=n===f.dom.parentElement,i=g,!o){const b=pz;b!=null&&b.isEditable&&setTimeout(()=>{const _=b.state.selection;_&&b.commands.deleteRange({from:_.from,to:_.to})},10)}return!1},paste:(f,g)=>{var b;const _=(b=g.clipboardData)===null||b===void 0?void 0:b.getData("text/html");return l=g,a=!!(_!=null&&_.includes("data-pm-slice")),!1}}},appendTransaction:(f,g,b)=>{const _=f[0],j=_.getMeta("uiEvent")==="paste"&&!a,w=_.getMeta("uiEvent")==="drop"&&!o,N=_.getMeta("applyPasteRules"),S=!!N;if(!j&&!w&&!S)return;if(S){let{text:I}=N;typeof I=="string"?I=I:I=ZNe(Dr.from(I),b.schema);const{from:O}=N,q=O+I.length,U=BRt(I);return c({rule:p,state:b,from:O,to:{b:q},pasteEvt:U})}const M=g.doc.content.findDiffStart(b.doc.content),L=g.doc.content.findDiffEnd(b.doc.content);if(!(!ORt(M)||!L||M===L.b))return c({rule:p,state:b,from:M,to:L,pasteEvt:l})}}))}function qRt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class uM{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=uM.resolve(s),this.schema=ERt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=uM.sort(uM.flatten(s)),n=qRt(r.map(a=>a.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(a=>`'${a}'`).join(", ")}]. This can lead to issues.`),r}static flatten(s){return s.map(r=>{const n={name:r.name,options:r.options,storage:r.storage},a=oa(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=oa(n,"priority")||100,l=oa(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:hge(r.name,this.schema)},a=oa(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=uM.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:hge(l.name,this.schema)},c=[],u=oa(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&oa(l,"exitable",i)&&(p.ArrowRight=()=>cy.handleExit({editor:s,mark:l})),u){const j=Object.fromEntries(Object.entries(u()).map(([w,N])=>[w,()=>N({editor:s})]));p={...p,...j}}const f=oRt(p);c.push(f);const g=oa(l,"addInputRules",i);NLe(l,s.options.enableInputRules)&&g&&n.push(...g());const b=oa(l,"addPasteRules",i);NLe(l,s.options.enablePasteRules)&&b&&a.push(...b());const _=oa(l,"addProseMirrorPlugins",i);if(_){const j=_();c.push(...j)}return c}).flat();return[LRt({editor:s,rules:n}),...$Rt({editor:s,rules:a}),...o]}get attributes(){return oJe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=Due(this.extensions);return Object.fromEntries(r.filter(n=>!!oa(n,"addNodeView")).map(n=>{const a=this.attributes.filter(c=>c.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:s,type:ih(n.name,this.schema)},l=oa(n,"addNodeView",o);if(!l)return[];const i=(c,u,p,f,g)=>{const b=R1e(c,a);return l()({node:c,view:u,getPos:p,decorations:f,innerDecorations:g,editor:s,extension:n,HTMLAttributes:b})};return[n.name,i]}))}setupExtensions(){this.extensions.forEach(s=>{var r;this.editor.extensionStorage[s.name]=s.storage;const n={name:s.name,options:s.options,storage:s.storage,editor:this.editor,type:hge(s.name,this.schema)};s.type==="mark"&&(!((r=eo(oa(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=oa(s,"onBeforeCreate",n),o=oa(s,"onCreate",n),l=oa(s,"onUpdate",n),i=oa(s,"onSelectionUpdate",n),c=oa(s,"onTransaction",n),u=oa(s,"onFocus",n),p=oa(s,"onBlur",n),f=oa(s,"onDestroy",n);a&&this.editor.on("beforeCreate",a),o&&this.editor.on("create",o),l&&this.editor.on("update",l),i&&this.editor.on("selectionUpdate",i),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),p&&this.editor.on("blur",p),f&&this.editor.on("destroy",f)})}}class Ih{constructor(s={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=eo(oa(this,"addOptions",{name:this.name}))),this.storage=eo(oa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Ih(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Rue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Ih({...this.config,...s});return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=eo(oa(r,"addOptions",{name:r.name})),r.storage=eo(oa(r,"addStorage",{name:r.name,options:r.options})),r}}function cJe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(c,u,p,f)=>{var g;c.isBlock&&u>n&&(i+=o);const b=l==null?void 0:l[c.type.name];if(b)return p&&(i+=b({node:c,pos:u,parent:p,index:f,range:s})),!1;c.isText&&(i+=(g=c==null?void 0:c.text)===null||g===void 0?void 0:g.slice(Math.max(n,u)-u,a-u))}),i}function dJe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const URt=Ih.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Iu({key:new tm("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:s,schema:r}=t,{doc:n,selection:a}=s,{ranges:o}=a,l=Math.min(...o.map(p=>p.$from.pos)),i=Math.max(...o.map(p=>p.$to.pos)),c=dJe(r);return cJe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),VRt=()=>({editor:t,view:s})=>(requestAnimationFrame(()=>{var r;t.isDestroyed||(s.dom.blur(),(r=window==null?void 0:window.getSelection())===null||r===void 0||r.removeAllRanges())}),!0),HRt=(t=!1)=>({commands:s})=>s.setContent("",t),WRt=()=>({state:t,tr:s,dispatch:r})=>{const{selection:n}=s,{ranges:a}=n;return r&&a.forEach(({$from:o,$to:l})=>{t.doc.nodesBetween(o.pos,l.pos,(i,c)=>{if(i.type.isText)return;const{doc:u,mapping:p}=s,f=u.resolve(p.map(c)),g=u.resolve(p.map(c+i.nodeSize)),b=f.blockRange(g);if(!b)return;const _=aE(b);if(i.type.isTextblock){const{defaultType:j}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(b.start,j)}(_||_===0)&&s.lift(b,_)})}),!0},GRt=t=>s=>t(s),KRt=()=>({state:t,dispatch:s})=>rJe(t,s),ZRt=(t,s)=>({editor:r,tr:n})=>{const{state:a}=r,o=a.doc.slice(t.from,t.to);n.deleteRange(t.from,t.to);const l=n.mapping.map(s);return n.insert(l,o.content),n.setSelection(new ei(n.doc.resolve(Math.max(l-1,0)))),!0},YRt=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,n=r.$anchor.node();if(n.content.size>0)return!1;const a=t.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===n.type){if(s){const i=a.before(o),c=a.after(o);t.delete(i,c).scrollIntoView()}return!0}return!1},XRt=t=>({tr:s,state:r,dispatch:n})=>{const a=ih(t,r.schema),o=s.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===a){if(n){const c=o.before(l),u=o.after(l);s.delete(c,u).scrollIntoView()}return!0}return!1},QRt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},JRt=()=>({state:t,dispatch:s})=>VNe(t,s),eFt=()=>({commands:t})=>t.keyboardShortcut("Enter"),tFt=()=>({state:t,dispatch:s})=>mRt(t,s);function ole(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:YNe(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function uJe(t,s,r={}){return t.find(n=>n.type===s&&ole(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function kLe(t,s,r={}){return!!uJe(t,s,r)}function XNe(t,s,r){var n;if(!t||!s)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(p=>p.type===s))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(p=>p.type===s)||(r=r||((n=a.node.marks[0])===null||n===void 0?void 0:n.attrs),!uJe([...a.node.marks],s,r)))return;let l=a.index,i=t.start()+a.offset,c=l+1,u=i+a.node.nodeSize;for(;l>0&&kLe([...t.parent.child(l-1).marks],s,r);)l-=1,i-=t.parent.child(l).nodeSize;for(;c({tr:r,state:n,dispatch:a})=>{const o=Rw(t,n.schema),{doc:l,selection:i}=r,{$from:c,from:u,to:p}=i;if(a){const f=XNe(c,o,s);if(f&&f.from<=u&&f.to>=p){const g=ei.create(l,f.from,f.to);r.setSelection(g)}}return!0},rFt=t=>s=>{const r=typeof t=="function"?t(s):t;for(let n=0;n({editor:r,view:n,tr:a,dispatch:o})=>{s={scrollIntoView:!0,...s};const l=()=>{(QNe()||nFt())&&n.dom.focus(),requestAnimationFrame(()=>{r.isDestroyed||(n.focus(),s!=null&&s.scrollIntoView&&r.commands.scrollIntoView())})};if(n.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!hJe(r.state.selection))return l(),!0;const i=mJe(a.doc,t)||r.state.selection,c=r.state.selection.eq(i);return o&&(c||a.setSelection(i),c&&a.storedMarks&&a.setStoredMarks(a.storedMarks),l()),!0},iFt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),oFt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),pJe=t=>{const s=t.childNodes;for(let r=s.length-1;r>=0;r-=1){const n=s[r];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?t.removeChild(n):n.nodeType===1&&pJe(n)}return t};function fz(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return pJe(r)}function fD(t,s,r){if(t instanceof J_||t instanceof Dr)return t;r={slice:!0,parseOptions:{},...r};const n=typeof t=="object"&&t!==null,a=typeof t=="string";if(n)try{if(Array.isArray(t)&&t.length>0)return Dr.fromArray(t.map(i=>s.nodeFromJSON(i)));const l=s.nodeFromJSON(t);return r.errorOnInvalidContent&&l.check(),l}catch(o){if(r.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),fD("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const c=new ZXe({topNode:s.spec.topNode,marks:s.spec.marks,nodes:s.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(l=!0,i=typeof u=="string"?u:u.outerHTML,null)}]}})});if(r.slice?t8.fromSchema(c).parseSlice(fz(t),r.parseOptions):t8.fromSchema(c).parse(fz(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=t8.fromSchema(s);return r.slice?o.parseSlice(fz(t),r.parseOptions).content:o.parse(fz(t),r.parseOptions)}return fD("",s,r)}function lFt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(fi.near(t.doc.resolve(l),r))}const cFt=t=>!("type"in t),dFt=(t,s,r)=>({tr:n,dispatch:a,editor:o})=>{var l;if(a){r={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let i;const c=w=>{o.emit("contentError",{editor:o,error:w,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{fD(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(w){c(w)}try{i=fD(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(w){return c(w),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,b=!0;if((cFt(i)?i:[i]).forEach(w=>{w.check(),g=g?w.isText&&w.marks.length===0:!1,b=b?w.isBlock:!1}),p===f&&b){const{parent:w}=n.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,f+=1)}let j;if(g){if(Array.isArray(s))j=s.map(w=>w.text||"").join("");else if(s instanceof Dr){let w="";s.forEach(N=>{N.text&&(w+=N.text)}),j=w}else typeof s=="object"&&s&&s.text?j=s.text:j=s;n.insertText(j,p,f)}else j=i,n.replaceWith(p,f,j);r.updateSelection&&lFt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:j}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:j})}return!0},uFt=()=>({state:t,dispatch:s})=>dRt(t,s),hFt=()=>({state:t,dispatch:s})=>uRt(t,s),mFt=()=>({state:t,dispatch:s})=>YQe(t,s),pFt=()=>({state:t,dispatch:s})=>eJe(t,s),fFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Cue(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},xFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Cue(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},gFt=()=>({state:t,dispatch:s})=>lRt(t,s),yFt=()=>({state:t,dispatch:s})=>cRt(t,s);function fJe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function vFt(t){const s=t.split(/-(?!$)/);let r=s[s.length-1];r==="Space"&&(r=" ");let n,a,o,l;for(let i=0;i({editor:s,view:r,tr:n,dispatch:a})=>{const o=vFt(t).split(/-(?!$)/),l=o.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),i=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),c=s.captureTransaction(()=>{r.someProp("handleKeyDown",u=>u(r,i))});return c==null||c.steps.forEach(u=>{const p=u.map(n.mapping);p&&a&&n.maybeStep(p)}),!0};function xD(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?ih(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(f,g)=>{if(f.isText)return;const b=Math.max(n,g),_=Math.min(a,g+f.nodeSize);i.push({node:f,from:b,to:_})});const c=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>ole(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}const _Ft=(t,s={})=>({state:r,dispatch:n})=>{const a=ih(t,r.schema);return xD(r,a,s)?hRt(r,n):!1},wFt=()=>({state:t,dispatch:s})=>nJe(t,s),jFt=t=>({state:s,dispatch:r})=>{const n=ih(t,s.schema);return NRt(n)(s,r)},NFt=()=>({state:t,dispatch:s})=>sJe(t,s);function Fue(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function SLe(t,s){const r=typeof s=="string"?[s]:s;return Object.keys(t).reduce((n,a)=>(r.includes(a)||(n[a]=t[a]),n),{})}const kFt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Fue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=ih(t,n.schema)),i==="mark"&&(l=Rw(t,n.schema)),a&&r.selection.ranges.forEach(c=>{n.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,p)=>{o&&o===u.type&&r.setNodeMarkup(p,void 0,SLe(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create(SLe(f.attrs,s)))})})}),!0):!1},SFt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),CFt=()=>({tr:t,dispatch:s})=>{if(s){const r=new _f(t.doc);t.setSelection(r)}return!0},MFt=()=>({state:t,dispatch:s})=>QQe(t,s),TFt=()=>({state:t,dispatch:s})=>tJe(t,s),AFt=()=>({state:t,dispatch:s})=>xRt(t,s),EFt=()=>({state:t,dispatch:s})=>vRt(t,s),PFt=()=>({state:t,dispatch:s})=>yRt(t,s);function F1e(t,s,r={},n={}){return fD(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const IFt=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var c,u;const{doc:p}=o;if(r.preserveWhitespace!=="full"){const f=F1e(t,a.schema,r,{errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:a.options.enableContentCheck});return l&&o.replaceWith(0,p.content.size,f).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:p.content.size},t,{parseOptions:r,errorOnInvalidContent:(u=n.errorOnInvalidContent)!==null&&u!==void 0?u:a.options.enableContentCheck})};function xJe(t,s){const r=Rw(s,t.schema),{from:n,to:a,empty:o}=t.selection,l=[];o?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(n,a,c=>{l.push(...c.marks)});const i=l.find(c=>c.type.name===r.name);return i?{...i.attrs}:{}}function LFt(t,s){const r=new PNe(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function DFt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function gJe(t,s){for(let r=t.depth;r>0;r-=1){const n=t.node(r);if(s(n))return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:n}}}function JNe(t){return s=>gJe(s.$from,t)}function RFt(t,s){const r={from:0,to:t.content.size};return cJe(t,r,s)}function FFt(t,s){const r=ih(s,t.schema),{from:n,to:a}=t.selection,o=[];t.doc.nodesBetween(n,a,i=>{o.push(i)});const l=o.reverse().find(i=>i.type.name===r.name);return l?{...l.attrs}:{}}function yJe(t,s){const r=Fue(typeof s=="string"?s:s.name,t.schema);return r==="node"?FFt(t,s):r==="mark"?xJe(t,s):{}}function zFt(t,s=JSON.stringify){const r={};return t.filter(n=>{const a=s(n);return Object.prototype.hasOwnProperty.call(r,a)?!1:r[a]=!0})}function BFt(t){const s=zFt(t);return s.length===1?s:s.filter((r,n)=>!s.filter((o,l)=>l!==n).some(o=>r.oldRange.from>=o.oldRange.from&&r.oldRange.to<=o.oldRange.to&&r.newRange.from>=o.newRange.from&&r.newRange.to<=o.newRange.to))}function $Ft(t){const{mapping:s,steps:r}=t,n=[];return s.maps.forEach((a,o)=>{const l=[];if(a.ranges.length)a.forEach((i,c)=>{l.push({from:i,to:c})});else{const{from:i,to:c}=r[o];if(i===void 0||c===void 0)return;l.push({from:i,to:c})}l.forEach(({from:i,to:c})=>{const u=s.slice(o).map(i,-1),p=s.slice(o).map(c),f=s.invert().map(u,-1),g=s.invert().map(p);n.push({oldRange:{from:f,to:g},newRange:{from:u,to:p}})})}),BFt(n)}function eke(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=XNe(o,a.type);l&&n.push({mark:a,...l})}):r.nodesBetween(t,s,(a,o)=>{!a||(a==null?void 0:a.nodeSize)===void 0||n.push(...a.marks.map(l=>({from:o,to:o+a.nodeSize,mark:l})))}),n}function Sie(t,s,r){return Object.fromEntries(Object.entries(r).filter(([n])=>{const a=t.find(o=>o.type===s&&o.name===n);return a?a.attribute.keepOnSplit:!1}))}function z1e(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?Rw(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>ole(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:g})=>{const b=f.pos,_=g.pos;t.doc.nodesBetween(b,_,(j,w)=>{if(!j.isText&&!j.marks.length)return;const N=Math.max(b,w),S=Math.min(_,w+j.nodeSize),M=S-N;l+=M,i.push(...j.marks.map(L=>({mark:L,from:N,to:S})))})}),l===0)return!1;const c=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>ole(f.mark.attrs,r,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=i.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,g)=>f+g.to-g.from,0);return(c>0?c+u:c)>=l}function qFt(t,s,r={}){if(!s)return xD(t,null,r)||z1e(t,null,r);const n=Fue(s,t.schema);return n==="node"?xD(t,s,r):n==="mark"?z1e(t,s,r):!1}function CLe(t,s){const{nodeExtensions:r}=Due(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=eo(oa(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function tke(t,{checkChildren:s=!0,ignoreWhitespace:r=!1}={}){var n;if(r){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((n=t.text)!==null&&n!==void 0?n:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(s){let a=!0;return t.content.forEach(o=>{a!==!1&&(tke(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function UFt(t){return t instanceof Wa}function VFt(t,s,r){var n;const{selection:a}=s;let o=null;if(hJe(a)&&(o=a.$cursor),o){const i=(n=t.storedMarks)!==null&&n!==void 0?n:o.marks();return!!r.isInSet(i)||!i.some(c=>c.type.excludes(r))}const{ranges:l}=a;return l.some(({$from:i,$to:c})=>{let u=i.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(i.pos,c.pos,(p,f,g)=>{if(u)return!1;if(p.isInline){const b=!g||g.type.allowsMarkType(r),_=!!r.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(r));u=b&&_}return!u}),u})}const HFt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,c=Rw(t,n.schema);if(a)if(l){const u=xJe(n,c);r.addStoredMark(c.create({...u,...s}))}else i.forEach(u=>{const p=u.$from.pos,f=u.$to.pos;n.doc.nodesBetween(p,f,(g,b)=>{const _=Math.max(b,p),j=Math.min(b+g.nodeSize,f);g.marks.find(N=>N.type===c)?g.marks.forEach(N=>{c===N.type&&r.addMark(_,j,c.create({...N.attrs,...s}))}):r.addMark(_,j,c.create(s))})});return VFt(n,r,c)},WFt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),GFt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=ih(t,r.schema);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o.isTextblock?a().command(({commands:i})=>_Le(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>_Le(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},KFt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=k4(t,0,n.content.size),o=Wa.create(n,a);s.setSelection(o)}return!0},ZFt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=ei.atStart(n).from,i=ei.atEnd(n).to,c=k4(a,l,i),u=k4(o,l,i),p=ei.create(n,c,u);s.setSelection(p)}return!0},YFt=t=>({state:s,dispatch:r})=>{const n=ih(t,s.schema);return CRt(n)(s,r)};function MLe(t,s){const r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(r){const n=r.filter(a=>s==null?void 0:s.includes(a.type.name));t.tr.ensureMarks(n)}}const XFt=({keepMarks:t=!0}={})=>({tr:s,state:r,dispatch:n,editor:a})=>{const{selection:o,doc:l}=s,{$from:i,$to:c}=o,u=a.extensionManager.attributes,p=Sie(u,i.node().type.name,i.node().attrs);if(o instanceof Wa&&o.node.isBlock)return!i.parentOffset||!x1(l,i.pos)?!1:(n&&(t&&MLe(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,g=i.depth===0?void 0:DFt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let b=f&&g?[{type:g,attrs:p}]:void 0,_=x1(s.doc,s.mapping.map(i.pos),1,b);if(!b&&!_&&x1(s.doc,s.mapping.map(i.pos),1,g?[{type:g}]:void 0)&&(_=!0,b=g?[{type:g,attrs:p}]:void 0),n){if(_&&(o instanceof ei&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,b),g&&!f&&!i.parentOffset&&i.parent.type!==g)){const j=s.mapping.map(i.before()),w=s.doc.resolve(j);i.node(-1).canReplaceWith(w.index(),w.index()+1,g)&&s.setNodeMarkup(s.mapping.map(i.before()),g)}t&&MLe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return _},QFt=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=ih(t,n.schema),{$from:c,$to:u}=n.selection,p=n.selection.node;if(p&&p.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==i)return!1;const g=o.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==i||c.index(-2)!==c.node(-2).childCount-1)return!1;if(a){let N=Dr.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let U=c.depth-S;U>=c.depth-3;U-=1)N=Dr.from(c.node(U).copy(N));const M=c.indexAfter(-1){if(q>-1)return!1;U.isTextblock&&U.content.size===0&&(q=B+1)}),q>-1&&r.setSelection(ei.near(r.doc.resolve(q))),r.scrollIntoView()}return!0}const b=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,_={...Sie(g,f.type.name,f.attrs),...s},j={...Sie(g,c.node().type.name,c.node().attrs),...s};r.delete(c.pos,u.pos);const w=b?[{type:i,attrs:_},{type:b,attrs:j}]:[{type:i,attrs:_}];if(!x1(r.doc,c.pos,2))return!1;if(a){const{selection:N,storedMarks:S}=n,{splittableMarks:M}=o.extensionManager,L=S||N.$to.parentOffset&&N.$from.marks();if(r.split(c.pos,2,w).scrollIntoView(),!L||!a)return!0;const I=L.filter(O=>M.includes(O.type.name));r.ensureMarks(I)}return!0},mge=(t,s)=>{const r=JNe(l=>l.type===s)(t.selection);if(!r)return!0;const n=t.doc.resolve(Math.max(0,r.pos-1)).before(r.depth);if(n===void 0)return!0;const a=t.doc.nodeAt(n);return r.node.type===(a==null?void 0:a.type)&&Dw(t.doc,r.pos)&&t.join(r.pos),!0},pge=(t,s)=>{const r=JNe(l=>l.type===s)(t.selection);if(!r)return!0;const n=t.doc.resolve(r.start).after(r.depth);if(n===void 0)return!0;const a=t.doc.nodeAt(n);return r.node.type===(a==null?void 0:a.type)&&Dw(t.doc,n)&&t.join(n),!0},JFt=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:c,commands:u,can:p})=>{const{extensions:f,splittableMarks:g}=a.extensionManager,b=ih(t,l.schema),_=ih(s,l.schema),{selection:j,storedMarks:w}=l,{$from:N,$to:S}=j,M=N.blockRange(S),L=w||j.$to.parentOffset&&j.$from.marks();if(!M)return!1;const I=JNe(O=>CLe(O.type.name,f))(j);if(M.depth>=1&&I&&M.depth-I.depth<=1){if(I.node.type===b)return u.liftListItem(_);if(CLe(I.node.type.name,f)&&b.validContent(I.node.content)&&i)return c().command(()=>(o.setNodeMarkup(I.pos,b),!0)).command(()=>mge(o,b)).command(()=>pge(o,b)).run()}return!r||!L||!i?c().command(()=>p().wrapInList(b,n)?!0:u.clearNodes()).wrapInList(b,n).command(()=>mge(o,b)).command(()=>pge(o,b)).run():c().command(()=>{const O=p().wrapInList(b,n),q=L.filter(U=>g.includes(U.type.name));return o.ensureMarks(q),O?!0:u.clearNodes()}).wrapInList(b,n).command(()=>mge(o,b)).command(()=>pge(o,b)).run()},e7t=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=Rw(t,n.schema);return z1e(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},t7t=(t,s,r={})=>({state:n,commands:a})=>{const o=ih(t,n.schema),l=ih(s,n.schema),i=xD(n,o,r);let c;return n.selection.$anchor.sameParent(n.selection.$head)&&(c=n.selection.$anchor.parent.attrs),i?a.setNode(l,c):a.setNode(o,{...c,...r})},s7t=(t,s={})=>({state:r,commands:n})=>{const a=ih(t,r.schema);return xD(r,a,s)?n.lift(a):n.wrapIn(a,s)},r7t=()=>({state:t,dispatch:s})=>{const r=t.plugins;for(let n=0;n=0;c-=1)l.step(i.steps[c].invert(i.docs[c]));if(o.text){const c=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,c))}else l.delete(o.from,o.to)}return!0}}return!1},n7t=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,{empty:n,ranges:a}=r;return n||s&&a.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},a7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,c=Rw(t,n.schema),{$from:u,empty:p,ranges:f}=i;if(!a)return!0;if(p&&l){let{from:g,to:b}=i;const _=(o=u.marks().find(w=>w.type===c))===null||o===void 0?void 0:o.attrs,j=XNe(u,c,_);j&&(g=j.from,b=j.to),r.removeMark(g,b,c)}else f.forEach(g=>{r.removeMark(g.$from.pos,g.$to.pos,c)});return r.removeStoredMark(c),!0},i7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Fue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=ih(t,n.schema)),i==="mark"&&(l=Rw(t,n.schema)),a&&r.selection.ranges.forEach(c=>{const u=c.$from.pos,p=c.$to.pos;let f,g,b,_;r.selection.empty?n.doc.nodesBetween(u,p,(j,w)=>{o&&o===j.type&&(b=Math.max(w,u),_=Math.min(w+j.nodeSize,p),f=w,g=j)}):n.doc.nodesBetween(u,p,(j,w)=>{w=u&&w<=p&&(o&&o===j.type&&r.setNodeMarkup(w,void 0,{...j.attrs,...s}),l&&j.marks.length&&j.marks.forEach(N=>{if(l===N.type){const S=Math.max(w,u),M=Math.min(w+j.nodeSize,p);r.addMark(S,M,l.create({...N.attrs,...s}))}}))}),g&&(f!==void 0&&r.setNodeMarkup(f,void 0,{...g.attrs,...s}),l&&g.marks.length&&g.marks.forEach(j=>{l===j.type&&r.addMark(b,_,l.create({...j.attrs,...s}))}))}),!0):!1},o7t=(t,s={})=>({state:r,dispatch:n})=>{const a=ih(t,r.schema);return bRt(a,s)(r,n)},l7t=(t,s={})=>({state:r,dispatch:n})=>{const a=ih(t,r.schema);return _Rt(a,s)(r,n)};var c7t=Object.freeze({__proto__:null,blur:VRt,clearContent:HRt,clearNodes:WRt,command:GRt,createParagraphNear:KRt,cut:ZRt,deleteCurrentNode:YRt,deleteNode:XRt,deleteRange:QRt,deleteSelection:JRt,enter:eFt,exitCode:tFt,extendMarkRange:sFt,first:rFt,focus:aFt,forEach:iFt,insertContent:oFt,insertContentAt:dFt,joinBackward:mFt,joinDown:hFt,joinForward:pFt,joinItemBackward:fFt,joinItemForward:xFt,joinTextblockBackward:gFt,joinTextblockForward:yFt,joinUp:uFt,keyboardShortcut:bFt,lift:_Ft,liftEmptyBlock:wFt,liftListItem:jFt,newlineInCode:NFt,resetAttributes:kFt,scrollIntoView:SFt,selectAll:CFt,selectNodeBackward:MFt,selectNodeForward:TFt,selectParentNode:AFt,selectTextblockEnd:EFt,selectTextblockStart:PFt,setContent:IFt,setMark:HFt,setMeta:WFt,setNode:GFt,setNodeSelection:KFt,setTextSelection:ZFt,sinkListItem:YFt,splitBlock:XFt,splitListItem:QFt,toggleList:JFt,toggleMark:e7t,toggleNode:t7t,toggleWrap:s7t,undoInputRule:r7t,unsetAllMarks:n7t,unsetMark:a7t,updateAttributes:i7t,wrapIn:o7t,wrapInList:l7t});const d7t=Ih.create({name:"commands",addCommands(){return{...c7t}}}),u7t=Ih.create({name:"drop",addProseMirrorPlugins(){return[new Iu({key:new tm("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),h7t=Ih.create({name:"editable",addProseMirrorPlugins(){return[new Iu({key:new tm("editable"),props:{editable:()=>this.editor.options.editable}})]}}),m7t=new tm("focusEvents"),p7t=Ih.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Iu({key:m7t,props:{handleDOMEvents:{focus:(s,r)=>{t.isFocused=!0;const n=t.state.tr.setMeta("focus",{event:r}).setMeta("addToHistory",!1);return s.dispatch(n),!1},blur:(s,r)=>{t.isFocused=!1;const n=t.state.tr.setMeta("blur",{event:r}).setMeta("addToHistory",!1);return s.dispatch(n),!1}}}})]}}),f7t=Ih.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:i})=>{const{selection:c,doc:u}=i,{empty:p,$anchor:f}=c,{pos:g,parent:b}=f,_=f.parent.isTextblock&&g>0?i.doc.resolve(g-1):f,j=_.parent.type.spec.isolating,w=f.pos-f.parentOffset,N=j&&_.parent.childCount===1?w===f.pos:fi.atStart(u).from===g;return!p||!b.type.isTextblock||b.textContent.length||!N||N&&f.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),s=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:s,"Mod-Delete":s,"Mod-a":()=>this.editor.commands.selectAll()},a={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":s,"Ctrl-Alt-Backspace":s,"Alt-Delete":s,"Alt-d":s,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return QNe()||fJe()?o:a},addProseMirrorPlugins(){return[new Iu({key:new tm("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(j=>j.getMeta("composition")))return;const n=t.some(j=>j.docChanged)&&!s.doc.eq(r.doc),a=t.some(j=>j.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,c=fi.atStart(s.doc).from,u=fi.atEnd(s.doc).to;if(o||!(l===c&&i===u)||!tke(r.doc))return;const g=r.tr,b=Iue({state:r,transaction:g}),{commands:_}=new Lue({editor:this.editor,state:b});if(_.clearNodes(),!!g.steps.length)return g}})]}}),x7t=Ih.create({name:"paste",addProseMirrorPlugins(){return[new Iu({key:new tm("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),g7t=Ih.create({name:"tabindex",addProseMirrorPlugins(){return[new Iu({key:new tm("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class h4{get name(){return this.node.type.name}constructor(s,r,n=!1,a=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=s,this.editor=r,this.currentNode=a}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var s;return(s=this.actualDepth)!==null&&s!==void 0?s:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(s){let r=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}r=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:r,to:n},s)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const s=this.resolvedPos.start(this.resolvedPos.depth-1),r=this.resolvedPos.doc.resolve(s);return new h4(r,this.editor)}get before(){let s=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return s.depth!==this.depth&&(s=this.resolvedPos.doc.resolve(this.from-3)),new h4(s,this.editor)}get after(){let s=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return s.depth!==this.depth&&(s=this.resolvedPos.doc.resolve(this.to+3)),new h4(s,this.editor)}get children(){const s=[];return this.node.content.forEach((r,n)=>{const a=r.isBlock&&!r.isTextblock,o=r.isAtom&&!r.isText,l=this.pos+n+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const i=this.resolvedPos.doc.resolve(l);if(!a&&i.depth<=this.depth)return;const c=new h4(i,this.editor,a,a?r:null);a&&(c.actualDepth=this.depth+1),s.push(new h4(i,this.editor,a,a?r:null))}),s}get firstChild(){return this.children[0]||null}get lastChild(){const s=this.children;return s[s.length-1]||null}closest(s,r={}){let n=null,a=this.parent;for(;a&&!n;){if(a.node.type.name===s)if(Object.keys(r).length>0){const o=a.node.attrs,l=Object.keys(r);for(let i=0;i{n&&a.length>0||(l.node.type.name===s&&o.every(c=>r[c]===l.node.attrs[c])&&a.push(l),!(n&&a.length>0)&&(a=a.concat(l.querySelectorAll(s,r,n))))}),a}setAttribute(s){const{tr:r}=this.editor.state;r.setNodeMarkup(this.from,void 0,{...this.node.attrs,...s}),this.editor.view.dispatch(r)}}const y7t=`.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 v7t(t,s,r){const n=document.querySelector("style[data-tiptap-style]");if(n!==null)return n;const a=document.createElement("style");return s&&a.setAttribute("nonce",s),a.setAttribute("data-tiptap-style",""),a.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(a),a}class b7t extends MRt{constructor(s={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(s),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:n,moved:a})=>this.options.onDrop(r,n,a)),this.on("paste",({event:r,slice:n})=>this.options.onPaste(r,n)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=v7t(y7t,this.options.injectNonce))}setOptions(s={}){this.options={...this.options,...s},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(s,r=!0){this.setOptions({editable:s}),r&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(s,r){const n=lJe(r)?r(s,[...this.state.plugins]):[...this.state.plugins,s],a=this.state.reconfigure({plugins:n});return this.view.updateState(a),a}unregisterPlugin(s){if(this.isDestroyed)return;const r=this.state.plugins;let n=r;if([].concat(s).forEach(o=>{const l=typeof o=="string"?`${o}$`:o.key;n=n.filter(i=>!i.key.startsWith(l))}),r.length===n.length)return;const a=this.state.reconfigure({plugins:n});return this.view.updateState(a),a}createExtensionManager(){var s,r;const a=[...this.options.enableCoreExtensions?[h7t,URt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),d7t,p7t,f7t,g7t,u7t,x7t].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 uM(a,this)}createCommandManager(){this.commandManager=new Lue({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=F1e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(l){if(!(l instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(l.message))throw l;this.emit("contentError",{editor:this,error:l,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(i=>i.name!=="collaboration"),this.createExtensionManager()}}),r=F1e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=mJe(r,this.options.autofocus);this.view=new KQe(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(s=this.options.editorProps)===null||s===void 0?void 0:s.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:dM.create({doc:r,selection:n||void 0})});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(s){this.isCapturingTransaction=!0,s(),this.isCapturingTransaction=!1;const r=this.capturedTransaction;return this.capturedTransaction=null,r}dispatchTransaction(s){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=s;return}s.steps.forEach(l=>{var i;return(i=this.capturedTransaction)===null||i===void 0?void 0:i.step(l)});return}const r=this.state.apply(s),n=!this.state.selection.eq(r.selection);this.emit("beforeTransaction",{editor:this,transaction:s,nextState:r}),this.view.updateState(r),this.emit("transaction",{editor:this,transaction:s}),n&&this.emit("selectionUpdate",{editor:this,transaction:s});const a=s.getMeta("focus"),o=s.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:s}),o&&this.emit("blur",{editor:this,event:o.event,transaction:s}),!(!s.docChanged||s.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:s})}getAttributes(s){return yJe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return qFt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ZNe(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return RFt(this.state.doc,{blockSeparator:r,textSerializers:{...dJe(this.schema),...n}})}get isEmpty(){return tke(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const s=this.view.dom;s&&s.editor&&delete s.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var s;return!(!((s=this.view)===null||s===void 0)&&s.docView)}$node(s,r){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(s,r))||null}$nodes(s,r){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(s,r))||null}$pos(s){const r=this.state.doc.resolve(s);return new h4(r,this)}get $doc(){return this.$pos(0)}}function ZT(t){return new Oue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=eo(t.getAttributes,void 0,n);if(a===!1||a===null)return null;const{tr:o}=s,l=n[n.length-1],i=n[0];if(l){const c=i.search(/\S/),u=r.from+i.indexOf(l),p=u+l.length;if(eke(r.from,r.to,s.doc).filter(b=>b.mark.type.excluded.find(j=>j===t.type&&j!==b.mark.type)).filter(b=>b.to>u).length)return null;pr.from&&o.delete(r.from+c,u);const g=r.from+c+l.length;o.addMark(r.from+c,g,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function vJe(t){return new Oue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=eo(t.getAttributes,void 0,n)||{},{tr:o}=s,l=r.from;let i=r.to;const c=t.type.create(a);if(n[1]){const u=n[0].lastIndexOf(n[1]);let p=l+u;p>i?p=i:i=p+n[1].length;const f=n[0][n[0].length-1];o.insertText(f,l+n[0].length-1),o.replaceWith(p,i,c)}else if(n[0]){const u=t.type.isInline?l:l-1;o.insert(u,t.type.create(a)).delete(o.mapping.map(l),o.mapping.map(i))}o.scrollIntoView()}})}function B1e(t){return new Oue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=eo(t.getAttributes,void 0,n)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;s.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,o)}})}function gD(t){return new Oue({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=eo(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),c=l.doc.resolve(r.from).blockRange(),u=c&&ENe(c,t.type,o);if(!u)return null;if(l.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=s,{splittableMarks:b}=t.editor.extensionManager,_=g||f.$to.parentOffset&&f.$from.marks();if(_){const j=_.filter(w=>b.includes(w.type.name));l.ensureMarks(j)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(f,o).run()}const p=l.doc.resolve(r.from-1).nodeBefore;p&&p.type===t.type&&Dw(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let sm=class $1e{constructor(s={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=eo(oa(this,"addOptions",{name:this.name}))),this.storage=eo(oa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new $1e(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Rue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new $1e(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=eo(oa(r,"addOptions",{name:r.name})),r.storage=eo(oa(r,"addStorage",{name:r.name,options:r.options})),r}};function XS(t){return new RRt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=eo(t.getAttributes,void 0,n,a);if(o===!1||o===null)return null;const{tr:l}=s,i=n[n.length-1],c=n[0];let u=r.to;if(i){const p=c.search(/\S/),f=r.from+c.indexOf(i),g=f+i.length;if(eke(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(w=>w===t.type&&w!==_.mark.type)).filter(_=>_.to>f).length)return null;gr.from&&l.delete(r.from+p,f),u=r.from+p+i.length,l.addMark(r.from+p,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function _7t(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Wa){const o=n.index();return n.parent.canReplaceWith(o,o+1,s)}let a=n.depth;for(;a>=0;){const o=n.index(a);if(n.node(a).contentMatchAt(o).matchType(s))return!0;a-=1}return!1}function w7t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var bJe={exports:{}},fge={};/** * @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 TLe;function j7t(){if(TLe)return fge;TLe=1;var t=ht;function s(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var r=typeof Object.is=="function"?Object.is:s,n=t.useState,a=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function i(f,g){var b=g(),_=n({inst:{value:b,getSnapshot:g}}),j=_[0].inst,w=_[1];return o(function(){j.value=b,j.getSnapshot=g,c(j)&&w({inst:j})},[f,b,g]),a(function(){return c(j)&&w({inst:j}),f(function(){c(j)&&w({inst:j})})},[f]),l(b),b}function c(f){var g=f.getSnapshot;f=f.value;try{var b=g();return!r(f,b)}catch{return!0}}function u(f,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return fge.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,fge}bJe.exports=j7t();var ske=bJe.exports;const N7t=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},k7t=({contentComponent:t})=>{const s=ske.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ht.createElement(ht.Fragment,null,Object.values(s))};function S7t(){const t=new Set;let s={};return{subscribe(r){return t.add(r),()=>{t.delete(r)}},getSnapshot(){return s},getServerSnapshot(){return s},setRenderer(r,n){s={...s,[r]:u2e.createPortal(n.reactElement,n.element,r)},t.forEach(a=>a())},removeRenderer(r){const n={...s};delete n[r],s=n,t.forEach(a=>a())}}}class C7t extends ht.Component{constructor(s){var r;super(s),this.editorContentRef=ht.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((r=s.editor)===null||r===void 0)&&r.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const s=this.props.editor;if(s&&!s.isDestroyed&&s.options.element){if(s.contentComponent)return;const r=this.editorContentRef.current;r.append(...s.options.element.childNodes),s.setOptions({element:r}),s.contentComponent=S7t(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=s.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),s.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const s=this.props.editor;if(!s||(this.initialized=!1,s.isDestroyed||s.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),s.contentComponent=null,!s.options.element.firstChild))return;const r=document.createElement("div");r.append(...s.options.element.childNodes),s.setOptions({element:r})}render(){const{editor:s,innerRef:r,...n}=this.props;return ht.createElement(ht.Fragment,null,ht.createElement("div",{ref:N7t(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&ht.createElement(k7t,{contentComponent:s.contentComponent}))}}const M7t=k.forwardRef((t,s)=>{const r=ht.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ht.createElement(C7t,{key:r,innerRef:s,...t})}),rke=ht.memo(M7t);var T7t=function t(s,r){if(s===r)return!0;if(s&&r&&typeof s=="object"&&typeof r=="object"){if(s.constructor!==r.constructor)return!1;var n,a,o;if(Array.isArray(s)){if(n=s.length,n!=r.length)return!1;for(a=n;a--!==0;)if(!t(s[a],r[a]))return!1;return!0}if(s instanceof Map&&r instanceof Map){if(s.size!==r.size)return!1;for(a of s.entries())if(!r.has(a[0]))return!1;for(a of s.entries())if(!t(a[1],r.get(a[0])))return!1;return!0}if(s instanceof Set&&r instanceof Set){if(s.size!==r.size)return!1;for(a of s.entries())if(!r.has(a[0]))return!1;return!0}if(ArrayBuffer.isView(s)&&ArrayBuffer.isView(r)){if(n=s.length,n!=r.length)return!1;for(a=n;a--!==0;)if(s[a]!==r[a])return!1;return!0}if(s.constructor===RegExp)return s.source===r.source&&s.flags===r.flags;if(s.valueOf!==Object.prototype.valueOf)return s.valueOf()===r.valueOf();if(s.toString!==Object.prototype.toString)return s.toString()===r.toString();if(o=Object.keys(s),n=o.length,n!==Object.keys(r).length)return!1;for(a=n;a--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[a]))return!1;for(a=n;a--!==0;){var l=o[a];if(!(l==="_owner"&&s.$$typeof)&&!t(s[l],r[l]))return!1}return!0}return s!==s&&r!==r},A7t=w7t(T7t),_Je={exports:{}},xge={};/** * @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 ALe;function E7t(){if(ALe)return xge;ALe=1;var t=ht,s=ske;function r(u,p){return u===p&&(u!==0||1/u===1/p)||u!==u&&p!==p}var n=typeof Object.is=="function"?Object.is:r,a=s.useSyncExternalStore,o=t.useRef,l=t.useEffect,i=t.useMemo,c=t.useDebugValue;return xge.useSyncExternalStoreWithSelector=function(u,p,f,g,b){var _=o(null);if(_.current===null){var j={hasValue:!1,value:null};_.current=j}else j=_.current;_=i(function(){function N(O){if(!S){if(S=!0,M=O,O=g(O),b!==void 0&&j.hasValue){var q=j.value;if(b(q,O))return L=q}return L=O}if(q=L,n(M,O))return q;var U=g(O);return b!==void 0&&b(q,U)?q:(M=O,L=U)}var S=!1,M,L,I=f===void 0?null:f;return[function(){return N(p())},I===null?void 0:function(){return N(I())}]},[p,f,g,b]);var w=a(u,_[0],_[1]);return l(function(){j.hasValue=!0,j.value=w},[w]),c(w),w},xge}_Je.exports=E7t();var P7t=_Je.exports;const I7t=typeof window<"u"?k.useLayoutEffect:k.useEffect;class L7t{constructor(s){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=s,this.lastSnapshot={editor:s,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(s){return this.subscribers.add(s),()=>{this.subscribers.delete(s)}}watch(s){if(this.editor=s,this.editor){const r=()=>{this.transactionNumber+=1,this.subscribers.forEach(a=>a())},n=this.editor;return n.on("transaction",r),()=>{n.off("transaction",r)}}}}function D7t(t){var s;const[r]=k.useState(()=>new L7t(t.editor)),n=P7t.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:A7t);return I7t(()=>r.watch(t.editor),[t.editor,r]),k.useDebugValue(n),n}const O7t=!1,q1e=typeof window>"u",R7t=q1e||!!(typeof window<"u"&&window.next);class nke{constructor(s){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=s,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(s){this.editor=s,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(r=>r())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?q1e||R7t?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const s={...this.options.current,onBeforeCreate:(...n)=>{var a,o;return(o=(a=this.options.current).onBeforeCreate)===null||o===void 0?void 0:o.call(a,...n)},onBlur:(...n)=>{var a,o;return(o=(a=this.options.current).onBlur)===null||o===void 0?void 0:o.call(a,...n)},onCreate:(...n)=>{var a,o;return(o=(a=this.options.current).onCreate)===null||o===void 0?void 0:o.call(a,...n)},onDestroy:(...n)=>{var a,o;return(o=(a=this.options.current).onDestroy)===null||o===void 0?void 0:o.call(a,...n)},onFocus:(...n)=>{var a,o;return(o=(a=this.options.current).onFocus)===null||o===void 0?void 0:o.call(a,...n)},onSelectionUpdate:(...n)=>{var a,o;return(o=(a=this.options.current).onSelectionUpdate)===null||o===void 0?void 0:o.call(a,...n)},onTransaction:(...n)=>{var a,o;return(o=(a=this.options.current).onTransaction)===null||o===void 0?void 0:o.call(a,...n)},onUpdate:(...n)=>{var a,o;return(o=(a=this.options.current).onUpdate)===null||o===void 0?void 0:o.call(a,...n)},onContentError:(...n)=>{var a,o;return(o=(a=this.options.current).onContentError)===null||o===void 0?void 0:o.call(a,...n)},onDrop:(...n)=>{var a,o;return(o=(a=this.options.current).onDrop)===null||o===void 0?void 0:o.call(a,...n)},onPaste:(...n)=>{var a,o;return(o=(a=this.options.current).onPaste)===null||o===void 0?void 0:o.call(a,...n)}};return new b7t(s)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(s){return this.subscriptions.add(s),()=>{this.subscriptions.delete(s)}}static compareOptions(s,r){return Object.keys(s).every(n=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)?!0:n==="extensions"&&s.extensions&&r.extensions?s.extensions.length!==r.extensions.length?!1:s.extensions.every((a,o)=>{var l;return a===((l=r.extensions)===null||l===void 0?void 0:l[o])}):s[n]===r[n])}onRender(s){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&s.length===0?nke.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(s),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(s){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=s;return}if(this.previousDeps.length===s.length&&this.previousDeps.every((n,a)=>n===s[a]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=s}scheduleDestroy(){const s=this.instanceId,r=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===s){r&&r.setOptions(this.options.current);return}r&&!r.isDestroyed&&(r.destroy(),this.instanceId===s&&this.setEditor(null))},1)}}function ake(t={},s=[]){const r=k.useRef(t);r.current=t;const[n]=k.useState(()=>new nke(r)),a=ske.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return k.useDebugValue(a),k.useEffect(n.onRender(s)),D7t({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const F7t=k.createContext({editor:null});F7t.Consumer;const z7t=k.createContext({onDragStart:void 0}),B7t=()=>k.useContext(z7t);ht.forwardRef((t,s)=>{const{onDragStart:r}=B7t(),n=t.as||"div";return ht.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const $7t=/^\s*>\s$/,q7t=sm.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[gD({find:$7t,type:this.type})]}}),U7t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,V7t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,H7t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,W7t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,G7t=cy.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ZT({find:U7t,type:this.type}),ZT({find:H7t,type:this.type})]},addPasteRules(){return[XS({find:V7t,type:this.type}),XS({find:W7t,type:this.type})]}}),K7t="listItem",ELe="textStyle",PLe=/^\s*([-+*])\s$/,Z7t=sm.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:s})=>this.options.keepAttributes?s().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(K7t,this.editor.getAttributes(ELe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=gD({find:PLe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=gD({find:PLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ELe),editor:this.editor})),[t]}}),Y7t=/(^|[^`])`([^`]+)`(?!`)/,X7t=/(^|[^`])`([^`]+)`(?!`)/g,Q7t=cy.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ZT({find:Y7t,type:this.type})]},addPasteRules(){return[XS({find:X7t,type:this.type})]}}),J7t=/^```([a-z]+)?[\s\n]$/,ezt=/^~~~([a-z]+)?[\s\n]$/,tzt=sm.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var s;const{languageClassPrefix:r}=this.options,o=[...((s=t.firstElementChild)===null||s===void 0?void 0:s.classList)||[]].filter(l=>l.startsWith(r)).map(l=>l.replace(r,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:s}){return["pre",Hc(this.options.HTMLAttributes,s),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:s})=>s.setNode(this.name,t),toggleCodeBlock:t=>({commands:s})=>s.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:s}=this.editor.state.selection,r=s.pos===1;return!t||s.parent.type.name!==this.name?!1:r||!s.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:s}=t,{selection:r}=s,{$from:n,empty:a}=r;if(!a||n.parent.type!==this.type)return!1;const o=n.parentOffset===n.parent.nodeSize-2,l=n.parent.textContent.endsWith(` `);return!o||!l?!1:t.chain().command(({tr:i})=>(i.delete(n.pos-2,n.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:s}=t,{selection:r,doc:n}=s,{$from:a,empty:o}=r;if(!o||a.parent.type!==this.type||!(a.parentOffset===a.parent.nodeSize-2))return!1;const i=a.after();return i===void 0?!1:n.nodeAt(i)?t.commands.command(({tr:u})=>(u.setSelection(fi.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[B1e({find:J7t,type:this.type,getAttributes:t=>({language:t[1]})}),B1e({find:ezt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Iu({key:new tm("codeBlockVSCodeHandler"),props:{handlePaste:(t,s)=>{if(!s.clipboardData||this.editor.isActive(this.type.name))return!1;const r=s.clipboardData.getData("text/plain"),n=s.clipboardData.getData("vscode-editor-data"),a=n?JSON.parse(n):void 0,o=a==null?void 0:a.mode;if(!r||!o)return!1;const{tr:l,schema:i}=t.state,c=i.text(r.replace(/\r\n?/g,` `));return l.replaceSelectionWith(this.type.create({language:o},c)),l.selection.$from.parent.type!==this.type&&l.setSelection(ei.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),szt=sm.create({name:"doc",topNode:!0,content:"block+"});function rzt(t={}){return new Iu({view(s){return new nzt(s,t)}})}class nzt{constructor(s,r){var n;this.editorView=s,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=r.width)!==null&&n!==void 0?n:1,this.color=r.color===!1?void 0:r.color||"black",this.class=r.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let o=l=>{this[a](l)};return s.dom.addEventListener(a,o),{name:a,handler:o}})}destroy(){this.handlers.forEach(({name:s,handler:r})=>this.editorView.dom.removeEventListener(s,r))}update(s,r){this.cursorPos!=null&&r.doc!=s.state.doc&&(this.cursorPos>s.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(s){s!=this.cursorPos&&(this.cursorPos=s,s==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let s=this.editorView.state.doc.resolve(this.cursorPos),r=!s.parent.inlineContent,n,a=this.editorView.dom,o=a.getBoundingClientRect(),l=o.width/a.offsetWidth,i=o.height/a.offsetHeight;if(r){let f=s.nodeBefore,g=s.nodeAfter;if(f||g){let b=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(b){let _=b.getBoundingClientRect(),j=f?_.bottom:_.top;f&&g&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*i;n={left:_.left,right:_.right,top:j-w,bottom:j+w}}}}if(!n){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*l;n={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r);let u,p;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,p=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,b=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,p=f.top-c.scrollTop*b}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-p)/i+"px",this.element.style.width=(n.right-n.left)/l+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(s){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),s)}dragover(s){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:s.clientX,top:s.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),a=n&&n.type.spec.disableDropCursor,o=typeof a=="function"?a(this.editorView,r,s):a;if(r&&!o){let l=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=iQe(this.editorView.state.doc,l,this.editorView.dragging.slice);i!=null&&(l=i)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(s){this.editorView.dom.contains(s.relatedTarget)||this.setCursor(null)}}const azt=Ih.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[rzt(this.options)]}});class gd extends fi{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return gd.valid(n)?new gd(n):fi.near(n)}content(){return jn.empty}eq(s){return s instanceof gd&&s.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(s,r){if(typeof r.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new gd(s.resolve(r.pos))}getBookmark(){return new ike(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!izt(s)||!ozt(s))return!1;let n=r.type.spec.allowGapCursor;if(n!=null)return n;let a=r.contentMatchAt(s.index()).defaultType;return a&&a.isTextblock}static findGapCursorFrom(s,r,n=!1){e:for(;;){if(!n&&gd.valid(s))return s;let a=s.pos,o=null;for(let l=s.depth;;l--){let i=s.node(l);if(r>0?s.indexAfter(l)0){o=i.child(r>0?s.indexAfter(l):s.index(l)-1);break}else if(l==0)return null;a+=r;let c=s.doc.resolve(a);if(gd.valid(c))return c}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Wa.isSelectable(o)){s=s.doc.resolve(a+o.nodeSize*r),n=!1;continue e}break}o=l,a+=r;let i=s.doc.resolve(a);if(gd.valid(i))return i}return null}}}gd.prototype.visible=!1;gd.findFrom=gd.findGapCursorFrom;fi.jsonID("gapcursor",gd);class ike{constructor(s){this.pos=s}map(s){return new ike(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return gd.valid(r)?new gd(r):fi.near(r)}}function wJe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function izt(t){for(let s=t.depth;s>=0;s--){let r=t.index(s),n=t.node(s);if(r==0){if(n.type.spec.isolating)return!0;continue}for(let a=n.child(r-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||wJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function ozt(t){for(let s=t.depth;s>=0;s--){let r=t.indexAfter(s),n=t.node(s);if(r==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let a=n.child(r);;a=a.firstChild){if(a.childCount==0&&!a.inlineContent||wJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function lzt(){return new Iu({props:{decorations:hzt,createSelectionBetween(t,s,r){return s.pos==r.pos&&gd.valid(r)?new gd(r):null},handleClick:dzt,handleKeyDown:czt,handleDOMEvents:{beforeinput:uzt}}})}const czt=UNe({ArrowLeft:xz("horiz",-1),ArrowRight:xz("horiz",1),ArrowUp:xz("vert",-1),ArrowDown:xz("vert",1)});function xz(t,s){const r=t=="vert"?s>0?"down":"up":s>0?"right":"left";return function(n,a,o){let l=n.selection,i=s>0?l.$to:l.$from,c=l.empty;if(l instanceof ei){if(!o.endOfTextblock(r)||i.depth==0)return!1;c=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=gd.findGapCursorFrom(i,s,c);return u?(a&&a(n.tr.setSelection(new gd(u))),!0):!1}}function dzt(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!gd.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Wa.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new gd(n))),!0)}function uzt(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof gd))return!1;let{$from:r}=t.state.selection,n=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!n)return!1;let a=Dr.empty;for(let l=n.length-1;l>=0;l--)a=Dr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new jn(a,0,0));return o.setSelection(ei.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function hzt(t){if(!(t.selection instanceof gd))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",xd.create(t.doc,[Mm.widget(t.selection.head,s,{key:"gapcursor"})])}const mzt=Ih.create({name:"gapCursor",addProseMirrorPlugins(){return[lzt()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=eo(oa(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),pzt=sm.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Hc(this.options.HTMLAttributes,t)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:t,chain:s,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:o}=r;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:i}=n.extensionManager,c=o||a.$to.parentOffset&&a.$from.marks();return s().insertContent({type:this.name}).command(({tr:u,dispatch:p})=>{if(p&&c&&l){const f=c.filter(g=>i.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),fzt=sm.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:s}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Hc(this.options.HTMLAttributes,s),0]},addCommands(){return{setHeading:t=>({commands:s})=>this.options.levels.includes(t.level)?s.setNode(this.name,t):!1,toggleHeading:t=>({commands:s})=>this.options.levels.includes(t.level)?s.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,s)=>({...t,[`Mod-Alt-${s}`]:()=>this.editor.commands.toggleHeading({level:s})}),{})},addInputRules(){return this.options.levels.map(t=>B1e({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var lle=200,nh=function(){};nh.prototype.append=function(s){return s.length?(s=nh.from(s),!this.length&&s||s.length=r?nh.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};nh.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};nh.prototype.forEach=function(s,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length),r<=n?this.forEachInner(s,r,n,0):this.forEachInvertedInner(s,r,n,0)};nh.prototype.map=function(s,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length);var a=[];return this.forEach(function(o,l){return a.push(s(o,l))},r,n),a};nh.from=function(s){return s instanceof nh?s:s&&s.length?new jJe(s):nh.empty};var jJe=function(t){function s(n){t.call(this),this.values=n}t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s;var r={length:{configurable:!0},depth:{configurable:!0}};return s.prototype.flatten=function(){return this.values},s.prototype.sliceInner=function(a,o){return a==0&&o==this.length?this:new s(this.values.slice(a,o))},s.prototype.getInner=function(a){return this.values[a]},s.prototype.forEachInner=function(a,o,l,i){for(var c=o;c=l;c--)if(a(this.values[c],i+c)===!1)return!1},s.prototype.leafAppend=function(a){if(this.length+a.length<=lle)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=lle)return new s(a.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(s.prototype,r),s}(nh);nh.empty=new jJe([]);var xzt=function(t){function s(r,n){t.call(this),this.left=r,this.right=n,this.length=r.length+n.length,this.depth=Math.max(r.depth,n.depth)+1}return t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s,s.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},s.prototype.getInner=function(n){return ni&&this.right.forEachInner(n,Math.max(a-i,0),Math.min(this.length,o)-i,l+i)===!1)return!1},s.prototype.forEachInvertedInner=function(n,a,o,l){var i=this.left.length;if(a>i&&this.right.forEachInvertedInner(n,a-i,Math.max(o,i)-i,l+i)===!1||o=o?this.right.slice(n-o,a-o):this.left.slice(n,o).append(this.right.slice(0,a-o))},s.prototype.leafAppend=function(n){var a=this.right.leafAppend(n);if(a)return new s(this.left,a)},s.prototype.leafPrepend=function(n){var a=this.left.leafPrepend(n);if(a)return new s(a,this.right)},s.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new s(this.left,new s(this.right,n)):new s(this,n)},s}(nh);const gzt=500;class Vg{constructor(s,r){this.items=s,this.eventCount=r}popEvent(s,r){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let a,o;r&&(a=this.remapping(n,this.items.length),o=a.maps.length);let l=s.tr,i,c,u=[],p=[];return this.items.forEach((f,g)=>{if(!f.step){a||(a=this.remapping(n,g+1),o=a.maps.length),o--,p.push(f);return}if(a){p.push(new Gy(f.map));let b=f.step.map(a.slice(o)),_;b&&l.maybeStep(b).doc&&(_=l.mapping.maps[l.mapping.maps.length-1],u.push(new Gy(_,void 0,void 0,u.length+p.length))),o--,_&&a.appendMap(_,o)}else l.maybeStep(f.step);if(f.selection)return i=a?f.selection.map(a.slice(o)):f.selection,c=new Vg(this.items.slice(0,n).append(p.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:l,selection:i}}addTransform(s,r,n,a){let o=[],l=this.eventCount,i=this.items,c=!a&&i.length?i.get(i.length-1):null;for(let p=0;pvzt&&(i=yzt(i,u),l-=u),new Vg(i.append(o),l)}remapping(s,r){let n=new dD;return this.items.forEach((a,o)=>{let l=a.mirrorOffset!=null&&o-a.mirrorOffset>=s?n.maps.length-a.mirrorOffset:void 0;n.appendMap(a.map,l)},s,r),n}addMaps(s){return this.eventCount==0?this:new Vg(this.items.append(s.map(r=>new Gy(r))),this.eventCount)}rebased(s,r){if(!this.eventCount)return this;let n=[],a=Math.max(0,this.items.length-r),o=s.mapping,l=s.steps.length,i=this.eventCount;this.items.forEach(g=>{g.selection&&i--},a);let c=r;this.items.forEach(g=>{let b=o.getMirror(--c);if(b==null)return;l=Math.min(l,b);let _=o.maps[b];if(g.step){let j=s.steps[b].invert(s.docs[b]),w=g.selection&&g.selection.map(o.slice(c+1,b));w&&i++,n.push(new Gy(_,j,w))}else n.push(new Gy(_))},a);let u=[];for(let g=r;ggzt&&(f=f.compress(this.items.length-n.length)),f}emptyItemCount(){let s=0;return this.items.forEach(r=>{r.step||s++}),s}compress(s=this.items.length){let r=this.remapping(0,s),n=r.maps.length,a=[],o=0;return this.items.forEach((l,i)=>{if(i>=s)a.push(l),l.selection&&o++;else if(l.step){let c=l.step.map(r.slice(n)),u=c&&c.getMap();if(n--,u&&r.appendMap(u,n),c){let p=l.selection&&l.selection.map(r.slice(n));p&&o++;let f=new Gy(u.invert(),c,p),g,b=a.length-1;(g=a.length&&a[b].merge(f))?a[b]=g:a.push(f)}}else l.map&&n--},this.items.length,0),new Vg(nh.from(a.reverse()),o)}}Vg.empty=new Vg(nh.empty,0);function yzt(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class Gy{constructor(s,r,n,a){this.map=s,this.step=r,this.selection=n,this.mirrorOffset=a}merge(s){if(this.step&&s.step&&!s.selection){let r=s.step.merge(this.step);if(r)return new Gy(r.getMap().invert(),r,this.selection)}}}class Yb{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const vzt=20;function bzt(t,s,r,n){let a=r.getMeta(NS),o;if(a)return a.historyState;r.getMeta(jzt)&&(t=new Yb(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(NS))return l.getMeta(NS).redo?new Yb(t.done.addTransform(r,void 0,n,Cie(s)),t.undone,ILe(r.mapping.maps),t.prevTime,t.prevComposition):new Yb(t.done,t.undone.addTransform(r,void 0,n,Cie(s)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let i=r.getMeta("composition"),c=t.prevTime==0||!l&&t.prevComposition!=i&&(t.prevTime<(r.time||0)-n.newGroupDelay||!_zt(r,t.prevRanges)),u=l?gge(t.prevRanges,r.mapping):ILe(r.mapping.maps);return new Yb(t.done.addTransform(r,c?s.selection.getBookmark():void 0,n,Cie(s)),Vg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new Yb(t.done.rebased(r,o),t.undone.rebased(r,o),gge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new Yb(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),gge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function _zt(t,s){if(!s)return!1;if(!t.docChanged)return!0;let r=!1;return t.mapping.maps[0].forEach((n,a)=>{for(let o=0;o=s[o]&&(r=!0)}),r}function ILe(t){let s=[];for(let r=t.length-1;r>=0&&s.length==0;r--)t[r].forEach((n,a,o,l)=>s.push(o,l));return s}function gge(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=NS.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=wzt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const kJe=NJe(!1,!0),SJe=NJe(!0,!0),kzt=Ih.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>kJe(t,s),redo:()=>({state:t,dispatch:s})=>SJe(t,s)}},addProseMirrorPlugins(){return[Nzt(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()}}}),Szt=sm.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Hc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!_7t(s,s.schema.nodes[this.name]))return!1;const{selection:r}=s,{$from:n,$to:a}=r,o=t();return n.parentOffset===0?o.insertContentAt({from:Math.max(n.pos-1,0),to:a.pos},{type:this.name}):UFt(r)?o.insertContentAt(a.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:l,dispatch:i})=>{var c;if(i){const{$to:u}=l.selection,p=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(ei.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Wa.create(l.doc,u.pos)):l.setSelection(ei.create(l.doc,u.pos));else{const f=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();f&&(l.insert(p,f),l.setSelection(ei.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[vJe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Czt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Mzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Tzt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Azt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ezt=cy.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ZT({find:Czt,type:this.type}),ZT({find:Tzt,type:this.type})]},addPasteRules(){return[XS({find:Mzt,type:this.type}),XS({find:Azt,type:this.type})]}}),Pzt=sm.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Hc(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Izt="listItem",DLe="textStyle",OLe=/^(\d+)\.\s$/,Lzt=sm.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:s,...r}=t;return s===1?["ol",Hc(this.options.HTMLAttributes,r),0]:["ol",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:s})=>this.options.keepAttributes?s().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Izt,this.editor.getAttributes(DLe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=gD({find:OLe,type:this.type,getAttributes:s=>({start:+s[1]}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=gD({find:OLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(DLe)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),Dzt=sm.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Ozt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Rzt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Fzt=cy.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ZT({find:Ozt,type:this.type})]},addPasteRules(){return[XS({find:Rzt,type:this.type})]}}),zzt=sm.create({name:"text",group:"inline"}),oke=Ih.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(G7t.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(q7t.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(Z7t.configure(this.options.bulletList)),this.options.code!==!1&&t.push(Q7t.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(tzt.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(szt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(azt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(mzt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(pzt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(fzt.configure(this.options.heading)),this.options.history!==!1&&t.push(kzt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(Szt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Ezt.configure(this.options.italic)),this.options.listItem!==!1&&t.push(Pzt.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(Lzt.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(Dzt.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(Fzt.configure(this.options.strike)),this.options.text!==!1&&t.push(zzt.configure(this.options.text)),t}}),Bzt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",$zt="ελ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",U1e="numeric",V1e="ascii",H1e="alpha",a8="asciinumeric",MI="alphanumeric",W1e="domain",CJe="emoji",qzt="scheme",Uzt="slashscheme",vge="whitespace";function Vzt(t,s){return t in s||(s[t]=[]),s[t]}function S4(t,s,r){s[U1e]&&(s[a8]=!0,s[MI]=!0),s[V1e]&&(s[a8]=!0,s[H1e]=!0),s[a8]&&(s[MI]=!0),s[H1e]&&(s[MI]=!0),s[MI]&&(s[W1e]=!0),s[CJe]&&(s[W1e]=!0);for(const n in s){const a=Vzt(n,r);a.indexOf(t)<0&&a.push(t)}}function Hzt(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function xp(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}xp.groups={};xp.prototype={accepts(){return!!this.t},go(t){const s=this,r=s.j[t];if(r)return r;for(let n=0;nt.ta(s,r,n,a),ld=(t,s,r,n,a)=>t.tr(s,r,n,a),RLe=(t,s,r,n,a)=>t.ts(s,r,n,a),Xr=(t,s,r,n,a)=>t.tt(s,r,n,a),Av="WORD",G1e="UWORD",MJe="ASCIINUMERICAL",TJe="ALPHANUMERICAL",yD="LOCALHOST",K1e="TLD",Z1e="UTLD",Mie="SCHEME",H5="SLASH_SCHEME",lke="NUM",Y1e="WS",cke="NL",i8="OPENBRACE",o8="CLOSEBRACE",cle="OPENBRACKET",dle="CLOSEBRACKET",ule="OPENPAREN",hle="CLOSEPAREN",mle="OPENANGLEBRACKET",ple="CLOSEANGLEBRACKET",fle="FULLWIDTHLEFTPAREN",xle="FULLWIDTHRIGHTPAREN",gle="LEFTCORNERBRACKET",yle="RIGHTCORNERBRACKET",vle="LEFTWHITECORNERBRACKET",ble="RIGHTWHITECORNERBRACKET",_le="FULLWIDTHLESSTHAN",wle="FULLWIDTHGREATERTHAN",jle="AMPERSAND",Nle="APOSTROPHE",kle="ASTERISK",Xb="AT",Sle="BACKSLASH",Cle="BACKTICK",Mle="CARET",i_="COLON",dke="COMMA",Tle="DOLLAR",Ky="DOT",Ale="EQUALS",uke="EXCLAMATION",nx="HYPHEN",l8="PERCENT",Ele="PIPE",Ple="PLUS",Ile="POUND",c8="QUERY",hke="QUOTE",AJe="FULLWIDTHMIDDLEDOT",mke="SEMI",Zy="SLASH",d8="TILDE",Lle="UNDERSCORE",EJe="EMOJI",Dle="SYM";var PJe=Object.freeze({__proto__:null,ALPHANUMERICAL:TJe,AMPERSAND:jle,APOSTROPHE:Nle,ASCIINUMERICAL:MJe,ASTERISK:kle,AT:Xb,BACKSLASH:Sle,BACKTICK:Cle,CARET:Mle,CLOSEANGLEBRACKET:ple,CLOSEBRACE:o8,CLOSEBRACKET:dle,CLOSEPAREN:hle,COLON:i_,COMMA:dke,DOLLAR:Tle,DOT:Ky,EMOJI:EJe,EQUALS:Ale,EXCLAMATION:uke,FULLWIDTHGREATERTHAN:wle,FULLWIDTHLEFTPAREN:fle,FULLWIDTHLESSTHAN:_le,FULLWIDTHMIDDLEDOT:AJe,FULLWIDTHRIGHTPAREN:xle,HYPHEN:nx,LEFTCORNERBRACKET:gle,LEFTWHITECORNERBRACKET:vle,LOCALHOST:yD,NL:cke,NUM:lke,OPENANGLEBRACKET:mle,OPENBRACE:i8,OPENBRACKET:cle,OPENPAREN:ule,PERCENT:l8,PIPE:Ele,PLUS:Ple,POUND:Ile,QUERY:c8,QUOTE:hke,RIGHTCORNERBRACKET:yle,RIGHTWHITECORNERBRACKET:ble,SCHEME:Mie,SEMI:mke,SLASH:Zy,SLASH_SCHEME:H5,SYM:Dle,TILDE:d8,TLD:K1e,UNDERSCORE:Lle,UTLD:Z1e,UWORD:G1e,WORD:Av,WS:Y1e});const Nv=/[a-z]/,QP=new RegExp("\\p{L}","u"),bge=new RegExp("\\p{Emoji}","u"),kv=/\d/,_ge=/\s/,FLe="\r",wge=` `,Wzt="️",Gzt="‍",jge="";let gz=null,yz=null;function Kzt(t=[]){const s={};xp.groups=s;const r=new xp;gz==null&&(gz=zLe(Bzt)),yz==null&&(yz=zLe($zt)),Xr(r,"'",Nle),Xr(r,"{",i8),Xr(r,"}",o8),Xr(r,"[",cle),Xr(r,"]",dle),Xr(r,"(",ule),Xr(r,")",hle),Xr(r,"<",mle),Xr(r,">",ple),Xr(r,"(",fle),Xr(r,")",xle),Xr(r,"「",gle),Xr(r,"」",yle),Xr(r,"『",vle),Xr(r,"』",ble),Xr(r,"<",_le),Xr(r,">",wle),Xr(r,"&",jle),Xr(r,"*",kle),Xr(r,"@",Xb),Xr(r,"`",Cle),Xr(r,"^",Mle),Xr(r,":",i_),Xr(r,",",dke),Xr(r,"$",Tle),Xr(r,".",Ky),Xr(r,"=",Ale),Xr(r,"!",uke),Xr(r,"-",nx),Xr(r,"%",l8),Xr(r,"|",Ele),Xr(r,"+",Ple),Xr(r,"#",Ile),Xr(r,"?",c8),Xr(r,'"',hke),Xr(r,"/",Zy),Xr(r,";",mke),Xr(r,"~",d8),Xr(r,"_",Lle),Xr(r,"\\",Sle),Xr(r,"・",AJe);const n=ld(r,kv,lke,{[U1e]:!0});ld(n,kv,n);const a=ld(n,Nv,MJe,{[a8]:!0}),o=ld(n,QP,TJe,{[MI]:!0}),l=ld(r,Nv,Av,{[V1e]:!0});ld(l,kv,a),ld(l,Nv,l),ld(a,kv,a),ld(a,Nv,a);const i=ld(r,QP,G1e,{[H1e]:!0});ld(i,Nv),ld(i,kv,o),ld(i,QP,i),ld(o,kv,o),ld(o,Nv),ld(o,QP,o);const c=Xr(r,wge,cke,{[vge]:!0}),u=Xr(r,FLe,Y1e,{[vge]:!0}),p=ld(r,_ge,Y1e,{[vge]:!0});Xr(r,jge,p),Xr(u,wge,c),Xr(u,jge,p),ld(u,_ge,p),Xr(p,FLe),Xr(p,wge),ld(p,_ge,p),Xr(p,jge,p);const f=ld(r,bge,EJe,{[CJe]:!0});Xr(f,"#"),ld(f,bge,f),Xr(f,Wzt,f);const g=Xr(f,Gzt);Xr(g,"#"),ld(g,bge,f);const b=[[Nv,l],[kv,a]],_=[[Nv,null],[QP,i],[kv,o]];for(let j=0;jj[0]>w[0]?1:-1);for(let j=0;j=0?S[W1e]=!0:Nv.test(w)?kv.test(w)?S[a8]=!0:S[V1e]=!0:S[U1e]=!0,RLe(r,w,w,S)}return RLe(r,"localhost",yD,{ascii:!0}),r.jd=new xp(Dle),{start:r,tokens:Object.assign({groups:s},PJe)}}function IJe(t,s){const r=Zzt(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(f+=r[l].length,g++),u+=r[l].length,o+=r[l].length,l++;o-=f,l-=g,u-=f,a.push({t:p.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function Zzt(t){const s=[],r=t.length;let n=0;for(;n56319||n+1===r||(o=t.charCodeAt(n+1))<56320||o>57343?t[n]:t.slice(n,n+2);s.push(l),n+=l.length}return s}function Db(t,s,r,n,a){let o;const l=s.length;for(let i=0;i=0;)o++;if(o>0){s.push(r.join(""));for(let l=parseInt(t.substring(n,n+o),10);l>0;l--)r.pop();n+=o}else r.push(t[n]),n++}return s}const vD={defaultProtocol:"http",events:null,format:BLe,formatHref:BLe,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function pke(t,s=null){let r=Object.assign({},vD);t&&(r=Object.assign(r,t instanceof pke?t.o:t));const n=r.ignoreTags,a=[];for(let o=0;or?n.substring(0,r)+"…":n},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=vD.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const s=this,r=this.toHref(t.get("defaultProtocol")),n=t.get("formatHref",r,this),a=t.get("tagName",r,s),o=this.toFormattedString(t),l={},i=t.get("className",r,s),c=t.get("target",r,s),u=t.get("rel",r,s),p=t.getObj("attributes",r,s),f=t.getObj("events",r,s);return l.href=n,i&&(l.class=i),c&&(l.target=c),u&&(l.rel=u),p&&Object.assign(l,p),{tagName:a,attributes:l,content:o,eventListeners:f}}};function zue(t,s){class r extends LJe{constructor(a,o){super(a,o),this.t=t}}for(const n in s)r.prototype[n]=s[n];return r.t=t,r}const $Le=zue("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),qLe=zue("text"),Yzt=zue("nl"),vz=zue("url",{isLink:!0,toHref(t=vD.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==yD&&t[1].t===i_}}),Xf=t=>new xp(t);function Xzt({groups:t}){const s=t.domain.concat([jle,kle,Xb,Sle,Cle,Mle,Tle,Ale,nx,lke,l8,Ele,Ple,Ile,Zy,Dle,d8,Lle]),r=[Nle,i_,dke,Ky,uke,l8,c8,hke,mke,mle,ple,i8,o8,dle,cle,ule,hle,fle,xle,gle,yle,vle,ble,_le,wle],n=[jle,Nle,kle,Sle,Cle,Mle,Tle,Ale,nx,i8,o8,l8,Ele,Ple,Ile,c8,Zy,Dle,d8,Lle],a=Xf(),o=Xr(a,d8);Ji(o,n,o),Ji(o,t.domain,o);const l=Xf(),i=Xf(),c=Xf();Ji(a,t.domain,l),Ji(a,t.scheme,i),Ji(a,t.slashscheme,c),Ji(l,n,o),Ji(l,t.domain,l);const u=Xr(l,Xb);Xr(o,Xb,u),Xr(i,Xb,u),Xr(c,Xb,u);const p=Xr(o,Ky);Ji(p,n,o),Ji(p,t.domain,o);const f=Xf();Ji(u,t.domain,f),Ji(f,t.domain,f);const g=Xr(f,Ky);Ji(g,t.domain,f);const b=Xf($Le);Ji(g,t.tld,b),Ji(g,t.utld,b),Xr(u,yD,b);const _=Xr(f,nx);Xr(_,nx,_),Ji(_,t.domain,f),Ji(b,t.domain,f),Xr(b,Ky,g),Xr(b,nx,_);const j=Xr(b,i_);Ji(j,t.numeric,$Le);const w=Xr(l,nx),N=Xr(l,Ky);Xr(w,nx,w),Ji(w,t.domain,l),Ji(N,n,o),Ji(N,t.domain,l);const S=Xf(vz);Ji(N,t.tld,S),Ji(N,t.utld,S),Ji(S,t.domain,l),Ji(S,n,o),Xr(S,Ky,N),Xr(S,nx,w),Xr(S,Xb,u);const M=Xr(S,i_),L=Xf(vz);Ji(M,t.numeric,L);const I=Xf(vz),O=Xf();Ji(I,s,I),Ji(I,r,O),Ji(O,s,I),Ji(O,r,O),Xr(S,Zy,I),Xr(L,Zy,I);const q=Xr(i,i_),U=Xr(c,i_),B=Xr(U,Zy),V=Xr(B,Zy);Ji(i,t.domain,l),Xr(i,Ky,N),Xr(i,nx,w),Ji(c,t.domain,l),Xr(c,Ky,N),Xr(c,nx,w),Ji(q,t.domain,I),Xr(q,Zy,I),Xr(q,c8,I),Ji(V,t.domain,I),Ji(V,s,I),Xr(V,Zy,I);const Y=[[i8,o8],[cle,dle],[ule,hle],[mle,ple],[fle,xle],[gle,yle],[vle,ble],[_le,wle]];for(let Q=0;Q=0&&g++,a++,p++;if(g<0)a-=p,a0&&(o.push(Nge(qLe,s,l)),l=[]),a-=g,p-=g;const b=f.t,_=r.slice(a-p,a);o.push(Nge(b,s,_))}}return l.length>0&&o.push(Nge(qLe,s,l)),o}function Nge(t,s,r){const n=r[0].s,a=r[r.length-1].e,o=s.slice(n,a);return new t(o,r)}const Jzt=typeof console<"u"&&console&&console.warn||(()=>{}),e9t="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",xc={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function t9t(){return xp.groups={},xc.scanner=null,xc.parser=null,xc.tokenQueue=[],xc.pluginQueue=[],xc.customSchemes=[],xc.initialized=!1,xc}function ULe(t,s=!1){if(xc.initialized&&Jzt(`linkifyjs: already initialized - will not register custom scheme "${t}" ${e9t}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" 3. "-" cannot repeat`);xc.customSchemes.push([t,s])}function s9t(){xc.scanner=Kzt(xc.customSchemes);for(let t=0;t{const a=s.some(u=>u.docChanged)&&!r.doc.eq(n.doc),o=s.some(u=>u.getMeta("preventAutolink"));if(!a||o)return;const{tr:l}=n,i=LFt(r.doc,[...s]);if($Ft(i).forEach(({newRange:u})=>{const p=OFt(n.doc,u,b=>b.isTextblock);let f,g;if(p.length>1)f=p[0],g=n.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(p.length){const b=n.doc.textBetween(u.from,u.to," "," ");if(!n9t.test(b))return;f=p[0],g=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const b=g.split(r9t).filter(Boolean);if(b.length<=0)return!1;const _=b[b.length-1],j=f.pos+g.lastIndexOf(_);if(!_)return!1;const w=fke(_).map(N=>N.toObject(t.defaultProtocol));if(!i9t(w))return!1;w.filter(N=>N.isLink).map(N=>({...N,from:j+N.start+1,to:j+N.end+1})).filter(N=>n.schema.marks.code?!n.doc.rangeHasMark(N.from,N.to,n.schema.marks.code):!0).filter(N=>t.validate(N.value)).filter(N=>t.shouldAutoLink(N.value)).forEach(N=>{eke(N.from,N.to,n.doc).some(S=>S.mark.type===t.type)||l.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!l.steps.length)return l}})}function l9t(t){return new Iu({key:new tm("handleClickLink"),props:{handleClick:(s,r,n)=>{var a,o;if(n.button!==0||!s.editable)return!1;let l=n.target;const i=[];for(;l.nodeName!=="DIV";)i.push(l),l=l.parentNode;if(!i.find(g=>g.nodeName==="A"))return!1;const c=yJe(s.state,t.type.name),u=n.target,p=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:c.href,f=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:c.target;return u&&p?(window.open(p,f),!0):!1}}})}function c9t(t){return new Iu({key:new tm("handlePasteLink"),props:{handlePaste:(s,r,n)=>{const{state:a}=s,{selection:o}=a,{empty:l}=o;if(l)return!1;let i="";n.content.forEach(u=>{i+=u.textContent});const c=DJe(i,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===i);return!i||!c?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function B2(t,s){const r=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return s&&s.forEach(n=>{const a=typeof n=="string"?n:n.scheme;a&&r.push(a)}),!t||t.replace(a9t,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const gke=cy.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){ULe(t);return}ULe(t.scheme,t.optionalSlashes)})},onDestroy(){t9t()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,s)=>!!B2(t,s.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const s=t.getAttribute("href");return!s||!this.options.isAllowedUri(s,{defaultValidate:r=>!!B2(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:s=>!!B2(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Hc(this.options.HTMLAttributes,t),0]:["a",Hc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!B2(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?s().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!B2(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?s().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[XS({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=DJe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!B2(l,r),protocols:r,defaultProtocol:n}));a.length&&a.forEach(o=>s.push({text:o.value,data:{href:o.href},index:o.start}))}return s},type:this.type,getAttributes:t=>{var s;return{href:(s=t.data)===null||s===void 0?void 0:s.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:s,defaultProtocol:r}=this.options;return this.options.autolink&&t.push(o9t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!B2(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(l9t({type:this.type})),this.options.linkOnPaste&&t.push(c9t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),yke=Ih.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const s=t.style.textAlign;return this.options.alignments.includes(s)?s:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:s})=>this.options.alignments.includes(t)?this.options.types.map(r=>s.updateAttributes(r,{textAlign:t})).every(r=>r):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(s=>t.resetAttributes(s,"textAlign")).every(s=>s),toggleTextAlign:t=>({editor:s,commands:r})=>this.options.alignments.includes(t)?s.isActive({textAlign:t})?r.unsetTextAlign():r.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),d9t=t=>{if(!t.children.length)return;const s=t.querySelectorAll("span");s&&s.forEach(r=>{var n,a;const o=r.getAttribute("style"),l=(a=(n=r.parentElement)===null||n===void 0?void 0:n.closest("span"))===null||a===void 0?void 0:a.getAttribute("style");r.setAttribute("style",`${l};${o}`)})},vke=cy.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&d9t(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:s}=t;return t.doc.nodesBetween(s.from,s.to,(r,n)=>{if(r.isTextblock)return!0;r.marks.filter(a=>a.type===this.type).some(a=>Object.values(a.attrs).some(o=>!!o))||t.removeMark(n,n+r.nodeSize,this.type)}),!0}}}}),u9t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,h9t=sm.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Hc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[vJe({find:u9t,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let X1e,Q1e;if(typeof WeakMap<"u"){let t=new WeakMap;X1e=s=>t.get(s),Q1e=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;X1e=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var yd=class{constructor(t,s,r,n){this.width=t,this.height=s,this.map=r,this.problems=n}findCell(t){for(let s=0;s=r){(o||(o=[])).push({type:"overlong_rowspan",pos:p,n:N-M});break}const L=a+M*s;for(let I=0;In&&(o+=u.attrs.colspan)}}for(let l=0;l1&&(r=!0)}s==-1?s=o:s!=o&&(s=Math.max(s,o))}return s}function f9t(t,s,r){t.problems||(t.problems=[]);const n={};for(let a=0;a0;s--)if(t.node(s).type.spec.tableRole=="row")return t.node(0).resolve(t.before(s+1));return null}function g9t(t){for(let s=t.depth;s>0;s--){const r=t.node(s).type.spec.tableRole;if(r==="cell"||r==="header_cell")return t.node(s)}return null}function my(t){const s=t.selection.$head;for(let r=s.depth;r>0;r--)if(s.node(r).type.spec.tableRole=="row")return!0;return!1}function Bue(t){const s=t.selection;if("$anchorCell"in s&&s.$anchorCell)return s.$anchorCell.pos>s.$headCell.pos?s.$anchorCell:s.$headCell;if("node"in s&&s.node&&s.node.type.spec.tableRole=="cell")return s.$anchor;const r=iE(s.$head)||y9t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function y9t(t){for(let s=t.nodeAfter,r=t.pos;s;s=s.firstChild,r++){const n=s.type.spec.tableRole;if(n=="cell"||n=="header_cell")return t.doc.resolve(r)}for(let s=t.nodeBefore,r=t.pos;s;s=s.lastChild,r--){const n=s.type.spec.tableRole;if(n=="cell"||n=="header_cell")return t.doc.resolve(r-s.nodeSize)}}function J1e(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function v9t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function bke(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function OJe(t,s,r){const n=t.node(-1),a=yd.get(n),o=t.start(-1),l=a.nextCell(t.pos-o,s,r);return l==null?null:t.node(0).resolve(o+l)}function QS(t,s,r=1){const n={...t,colspan:t.colspan-r};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(s,r),n.colwidth.some(a=>a>0)||(n.colwidth=null)),n}function RJe(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;ap!=r.pos-o);c.unshift(r.pos-o);const u=c.map(p=>{const f=n.nodeAt(p);if(!f)throw new RangeError(`No cell with offset ${p} found`);const g=o+p+1;return new uQe(i.resolve(g),i.resolve(g+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=s,this.$headCell=r}map(s,r){const n=s.resolve(r.map(this.$anchorCell.pos)),a=s.resolve(r.map(this.$headCell.pos));if(J1e(n)&&J1e(a)&&bke(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Ev.rowSelection(n,a):o&&this.isColSelection()?Ev.colSelection(n,a):new Ev(n,a)}return ei.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=yd.get(s),n=this.$anchorCell.start(-1),a=r.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},l=[];for(let c=a.top;c0||w>0){let N=_.attrs;if(j>0&&(N=QS(N,0,j)),w>0&&(N=QS(N,N.colspan-w,w)),b.lefta.bottom){const N={..._.attrs,rowspan:Math.min(b.bottom,a.bottom)-Math.max(b.top,a.top)};b.top0)return!1;const n=s+this.$anchorCell.nodeAfter.attrs.rowspan,a=r+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,a)==this.$headCell.node(-1).childCount}static colSelection(s,r=s){const n=s.node(-1),a=yd.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),c=s.node(0);return l.top<=i.top?(l.top>0&&(s=c.resolve(o+a.map[l.left])),i.bottom0&&(r=c.resolve(o+a.map[i.left])),l.bottom0)return!1;const l=a+this.$anchorCell.nodeAfter.attrs.colspan,i=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,i)==r.width}eq(s){return s instanceof Ev&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=yd.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),c=s.node(0);return l.left<=i.left?(l.left>0&&(s=c.resolve(o+a.map[l.top*a.width])),i.right0&&(r=c.resolve(o+a.map[i.top*a.width])),l.right{s.push(Mm.node(n,n+r.nodeSize,{class:"selectedCell"}))}),xd.create(t.doc,s)}function j9t({$from:t,$to:s}){if(t.pos==s.pos||t.pos=0&&!(t.after(a+1)=0&&!(s.before(o+1)>s.start(o));o--,n--);return r==n&&/row|table/.test(t.node(a).type.spec.tableRole)}function N9t({$from:t,$to:s}){let r,n;for(let a=t.depth;a>0;a--){const o=t.node(a);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}for(let a=s.depth;a>0;a--){const o=s.node(a);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}return r!==n&&s.parentOffset===0}function k9t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Wa&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=oc.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=oc.rowSelection(i,i)}else if(!r){const i=yd.get(n.node),c=n.from+1,u=c+i.map[i.width*i.height-1];o=oc.create(a,c+1,u)}}else n instanceof ei&&j9t(n)?o=ei.create(a,n.from):n instanceof ei&&N9t(n)&&(o=ei.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const S9t=new tm("fix-tables");function zJe(t,s,r,n){const a=t.childCount,o=s.childCount;e:for(let l=0,i=0;l{a.type.spec.tableRole=="table"&&(r=C9t(t,a,o,r))};return s?s.doc!=t.doc&&zJe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function C9t(t,s,r,n){const a=yd.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let c=0;c0){let b="cell";p.firstChild&&(b=p.firstChild.type.spec.tableRole);const _=[];for(let w=0;w0?-1:0;b9t(s,n,a+o)&&(o=a==0||a==s.width?null:0);for(let l=0;l0&&a0&&s.map[i-1]==c||a0?-1:0;P9t(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,p=s.width*a;u0&&a0&&f==s.map[p-s.width]){const g=r.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(i).map(f+n),null,{...g,rowspan:g.rowspan-1}),u+=g.colspan-1}else if(a0&&r[o]==r[o-1]||n.right0&&r[a]==r[a-t]||n.bottom0){const p=c+1+u.content.size,f=VLe(u)?c+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new oc(o.doc.resolve(c+n.tableStart))),s(o)}return!0}function WLe(t,s){const r=Jh(t.schema);return F9t(({node:n})=>r[n.type.spec.tableRole])(t,s)}function F9t(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof oc){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=g9t(n.$from),!a)return!1;o=(l=iE(n.$from))===null||l===void 0?void 0:l.pos}if(a==null||o==null||a.attrs.colspan==1&&a.attrs.rowspan==1)return!1;if(r){let i=a.attrs;const c=[],u=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const p=$0(s),f=s.tr;for(let b=0;b{l.attrs[t]!==s&&o.setNodeMarkup(i,null,{...l.attrs,[t]:s})}):o.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:s}),n(o)}return!0}}function B9t(t){return function(s,r){if(!my(s))return!1;if(r){const n=Jh(s.schema),a=$0(s),o=s.tr,l=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),i=l.map(c=>a.table.nodeAt(c));for(let c=0;c{const b=g+o.tableStart,_=l.doc.nodeAt(b);_&&l.setNodeMarkup(b,f,_.attrs)}),n(l)}return!0}}bD("row",{useDeprecatedLogic:!0});bD("column",{useDeprecatedLogic:!0});const $9t=bD("cell",{useDeprecatedLogic:!0});function q9t(t,s){if(s<0){const r=t.nodeBefore;if(r)return t.pos-r.nodeSize;for(let n=t.index(-1)-1,a=t.before();n>=0;n--){const o=t.node(-1).child(n),l=o.lastChild;if(l)return a-1-l.nodeSize;a-=o.nodeSize}}else{if(t.index()0;n--)if(r.node(n).type.spec.tableRole=="table")return s&&s(t.tr.delete(r.before(n),r.after(n)).scrollIntoView()),!0;return!1}function bz(t,s){const r=t.selection;if(!(r instanceof oc))return!1;if(s){const n=t.tr,a=Jh(t.schema).cell.createAndFill().content;r.forEachCell((o,l)=>{o.content.eq(a)||n.replace(n.mapping.map(l+1),n.mapping.map(l+o.nodeSize-1),new jn(a,0,0))}),n.docChanged&&s(n)}return!0}function V9t(t){if(t.size===0)return null;let{content:s,openStart:r,openEnd:n}=t;for(;s.childCount==1&&(r>0&&n>0||s.child(0).type.spec.tableRole=="table");)r--,n--,s=s.child(0).content;const a=s.child(0),o=a.type.spec.tableRole,l=a.type.schema,i=[];if(o=="row")for(let c=0;c=0;l--){const{rowspan:i,colspan:c}=o.child(l).attrs;for(let u=a;u=s.length&&s.push(Dr.empty),r[a]n&&(g=g.type.createChecked(QS(g.attrs,g.attrs.colspan,p+g.attrs.colspan-n),g.content)),u.push(g),p+=g.attrs.colspan;for(let b=1;ba&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,a-f.attrs.rowspan)},f.content)),c.push(f)}o.push(Dr.from(c))}r=o,s=a}return{width:t,height:s,rows:r}}function G9t(t,s,r,n,a,o,l){const i=t.doc.type.schema,c=Jh(i);let u,p;if(a>s.width)for(let f=0,g=0;fs.height){const f=[];for(let _=0,j=(s.height-1)*s.width;_=s.width?!1:r.nodeAt(s.map[j+_]).type==c.header_cell;f.push(w?p||(p=c.header_cell.createAndFill()):u||(u=c.cell.createAndFill()))}const g=c.row.create(null,Dr.from(f)),b=[];for(let _=s.height;_{if(!a)return!1;const o=r.selection;if(o instanceof oc)return Tie(r,n,fi.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=UJe(a,t,s);if(l==null)return!1;if(t=="horiz")return Tie(r,n,fi.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),c=OJe(i,t,s);let u;return c?u=fi.near(c,1):s<0?u=fi.near(r.doc.resolve(i.before(-1)),-1):u=fi.near(r.doc.resolve(i.after(-1)),1),Tie(r,n,u)}}}function wz(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof oc)l=o;else{const c=UJe(a,t,s);if(c==null)return!1;l=new oc(r.doc.resolve(c))}const i=OJe(l.$headCell,t,s);return i?Tie(r,n,new oc(l.$anchorCell,i)):!1}}function Z9t(t,s){const r=t.state.doc,n=iE(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new oc(n))),!0):!1}function Y9t(t,s,r){if(!my(t.state))return!1;let n=V9t(r);const a=t.state.selection;if(a instanceof oc){n||(n={width:1,height:1,rows:[Dr.from(ebe(Jh(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=yd.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=W9t(n,i.right-i.left,i.bottom-i.top),XLe(t.state,t.dispatch,l,i,n),!0}else if(n){const o=Bue(t.state),l=o.start(-1);return XLe(t.state,t.dispatch,l,yd.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function X9t(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=QLe(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof oc)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=iE(t.state.selection.$anchor))!=null&&((r=kge(t,s))===null||r===void 0?void 0:r.pos)!=a.pos)o(a,s),s.preventDefault();else if(!n)return;function o(c,u){let p=kge(t,u);const f=o_.getState(t.state)==null;if(!p||!bke(c,p))if(f)p=c;else return;const g=new oc(c,p);if(f||!t.state.selection.eq(g)){const b=t.state.tr.setSelection(g);f&&b.setMeta(o_,c.pos),t.dispatch(b)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),o_.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(o_,-1))}function i(c){const u=c,p=o_.getState(t.state);let f;if(p!=null)f=t.state.doc.resolve(p);else if(QLe(t,u.target)!=n&&(f=kge(t,s),!f))return l();f&&o(f,u)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",i)}function UJe(t,s,r){if(!(t.state.selection instanceof ei))return null;const{$head:n}=t.state.selection;for(let a=n.depth-1;a>=0;a--){const o=n.node(a);if((r<0?n.index(a):n.indexAfter(a))!=(r<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=n.before(a),i=s=="vert"?r>0?"down":"up":r>0?"right":"left";return t.endOfTextblock(i)?l:null}}return null}function QLe(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function kge(t,s){const r=t.posAtCoords({left:s.clientX,top:s.clientY});if(!r)return null;const n=r.inside>=0?r.inside:r.pos;return iE(t.state.doc.resolve(n))}var Q9t=class{constructor(s,r){this.node=s,this.defaultCellMinWidth=r,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${r}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),tbe(s,this.colgroup,this.table,r),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(s){return s.type!=this.node.type?!1:(this.node=s,tbe(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function tbe(t,s,r,n,a,o){let l=0,i=!0,c=s.firstChild;const u=t.firstChild;if(u){for(let f=0,g=0;fnew n(f,r,g)),new eBt(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=df.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{tBt(l,i,t,a)},mouseleave:l=>{sBt(l)},mousedown:(l,i)=>{rBt(l,i,s,r)}},decorations:l=>{const i=df.getState(l);if(i&&i.activeHandle>-1)return lBt(l,i.activeHandle)},nodeViews:{}}});return o}var eBt=class Aie{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(df);if(n&&n.setHandle!=null)return new Aie(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new Aie(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return J1e(s.doc.resolve(a))||(a=-1),new Aie(a,r.dragging)}return r}};function tBt(t,s,r,n){if(!t.editable)return;const a=df.getState(t.state);if(a&&!a.dragging){const o=aBt(s.target);let l=-1;if(o){const{left:i,right:c}=o.getBoundingClientRect();s.clientX-i<=r?l=JLe(t,s,"left",r):c-s.clientX<=r&&(l=JLe(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),c=i.node(-1),u=yd.get(c),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}VJe(t,l)}}}function sBt(t){if(!t.editable)return;const s=df.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&VJe(t,-1)}function rBt(t,s,r,n){var a;if(!t.editable)return!1;const o=(a=t.dom.ownerDocument.defaultView)!==null&&a!==void 0?a:window,l=df.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),c=nBt(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(df,{setDragging:{startX:s.clientX,startWidth:c}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const g=df.getState(t.state);g!=null&&g.dragging&&(iBt(t,g.activeHandle,e8e(g.dragging,f,r)),t.dispatch(t.state.tr.setMeta(df,{setDragging:null})))}function p(f){if(!f.which)return u(f);const g=df.getState(t.state);if(g&&g.dragging){const b=e8e(g.dragging,f,r);t8e(t,g.activeHandle,b,n)}}return t8e(t,l.activeHandle,c,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function nBt(t,s,{colspan:r,colwidth:n}){const a=n&&n[n.length-1];if(a)return a;const o=t.domAtPos(s);let l=o.node.childNodes[o.offset].offsetWidth,i=r;if(n)for(let c=0;c{const n=t.nodes[r];n.spec.tableRole&&(s[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=s,s}function mBt(t,s,r,n,a){const o=hBt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!pBt(s))return!1;let r=0;const n=gJe(s.ranges[0].$from,o=>o.type.name==="table");return n==null||n.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(r+=1)}),r===s.ranges.length?(t.commands.deleteTable(),!0):!1},fBt=sm.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:dBt,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:s}){const{colgroup:r,tableWidth:n,tableMinWidth:a}=uBt(t,this.options.cellMinWidth),o=["table",Hc(this.options.HTMLAttributes,s,{style:n?`width: ${n}`:`min-width: ${a}`}),r,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:t=3,cols:s=3,withHeaderRow:r=!0}={})=>({tr:n,dispatch:a,editor:o})=>{const l=mBt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(ei.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>M9t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>T9t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>E9t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>I9t(t,s),addRowAfter:()=>({state:t,dispatch:s})=>L9t(t,s),deleteRow:()=>({state:t,dispatch:s})=>O9t(t,s),deleteTable:()=>({state:t,dispatch:s})=>U9t(t,s),mergeCells:()=>({state:t,dispatch:s})=>HLe(t,s),splitCell:()=>({state:t,dispatch:s})=>WLe(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>bD("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>bD("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>$9t(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>HLe(t,s)?!0:WLe(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>z9t(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>KLe(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>KLe(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&BJe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=oc.create(s.doc,t.anchorCell,t.headCell);s.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:jz,"Mod-Backspace":jz,Delete:jz,"Mod-Delete":jz}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[J9t({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],cBt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:eo(oa(t,"tableRole",s))}}}),xBt=sm.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Hc(this.options.HTMLAttributes,t),0]}}),gBt=sm.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const s=t.getAttribute("colwidth");return s?s.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Hc(this.options.HTMLAttributes,t),0]}}),yBt=sm.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const s=t.getAttribute("colwidth");return s?s.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Hc(this.options.HTMLAttributes,t),0]}});function py({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=k.useState(!1),[i,c]=k.useState(""),[u,p]=k.useState(!0),f=ake({extensions:[oke,gke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),yke.configure({types:["heading","paragraph"]}),vke,h9t.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),fBt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),xBt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null}}}}),gBt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),yBt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:j})=>{s(j.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(j,w)=>{var S;const N=(S=w.clipboardData)==null?void 0:S.items;if(!N)return!1;for(const M of Array.from(N))if(M.type.startsWith("image/")){w.preventDefault();const L=M.getAsFile();if(!L)continue;const I=new FileReader;return I.onload=O=>{var U;const q=(U=O.target)==null?void 0:U.result;j.dispatch(j.state.tr.replaceSelectionWith(j.state.schema.nodes.image.create({src:q})))},I.readAsDataURL(L),!0}return!1}}});k.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const g=()=>{if(!f)return;const j=f.getAttributes("link").href||"",w=f.getAttributes("link").target;c(j),p(w==="_blank"),l(!0)},b=()=>{f&&(i===""?f.chain().focus().extendMarkRange("link").unsetLink().run():f.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),c(""))},_=()=>{f&&f.chain().focus().extendMarkRange("link").unsetLink().run()};return f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),className:f.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(EM,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:2}).run(),className:f.isActive("heading",{level:2})?"bg-muted":"",title:"Heading 2",children:e.jsx(PM,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBold().run(),className:f.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(Y4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleItalic().run(),className:f.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(sS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBulletList().run(),className:f.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(Mh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleOrderedList().run(),className:f.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(p0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("left").run(),className:f.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:e.jsx(G4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("center").run(),className:f.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:e.jsx(W4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("right").run(),className:f.isActive({textAlign:"right"})?"bg-muted":"",title:"Align Right",children:e.jsx(K4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:g,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Bo,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:_,title:"Remove Link",children:e.jsx(Bo,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo",children:e.jsx(xS,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo",children:e.jsx(mS,{className:"h-4 w-4"})})]}),e.jsx(rke,{editor:f,className:"prose prose-sm max-w-none p-3 focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror_img]:max-w-none [&_.ProseMirror_table]:border-none [&_.ProseMirror_table]:border-collapse [&_.ProseMirror_td]:border-none [&_.ProseMirror_td]:p-0 [&_.ProseMirror_td]:align-top [&_.ProseMirror_th]:border-none [&_.ProseMirror_th]:p-0 [&_.ProseMirror_tr]:border-none",style:{minHeight:n}})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"link-url",children:"URL"}),e.jsx(ze,{id:"link-url",value:i,onChange:j=>c(j.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(be,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"button",onClick:b,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var vBt=Object.defineProperty,bBt=(t,s,r)=>s in t?vBt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,Ic=(t,s,r)=>bBt(t,typeof s!="symbol"?s+"":s,r);const Ole={x:0,y:0,width:0,height:0,unit:"px"},S5=(t,s,r)=>Math.min(Math.max(t,s),r),_Bt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),n8e=(t,s)=>t===s||t.width===s.width&&t.height===s.height&&t.x===s.x&&t.y===s.y&&t.unit===s.unit;function wBt(t,s,r,n){const a=Yy(t,r,n);return t.width&&(a.height=a.width/s),t.height&&(a.width=a.height*s),a.y+a.height>n&&(a.height=n-a.y,a.width=a.height*s),a.x+a.width>r&&(a.width=r-a.x,a.height=a.width/s),t.unit==="%"?Qb(a,r,n):a}function jBt(t,s,r){const n=Yy(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?Qb(n,s,r):n}function Qb(t,s,r){return t.unit==="%"?{...Ole,...t,unit:"%"}:{unit:"%",x:t.x?t.x/s*100:0,y:t.y?t.y/r*100:0,width:t.width?t.width/s*100:0,height:t.height?t.height/r*100:0}}function Yy(t,s,r){return t.unit?t.unit==="px"?{...Ole,...t,unit:"px"}:{unit:"px",x:t.x?t.x*s/100:0,y:t.y?t.y*r/100:0,width:t.width?t.width*s/100:0,height:t.height?t.height*r/100:0}:{...Ole,...t,unit:"px"}}function a8e(t,s,r,n,a,o=0,l=0,i=n,c=a){const u={...t};let p=Math.min(o,n),f=Math.min(l,a),g=Math.min(i,n),b=Math.min(c,a);s&&(s>1?(p=l?l*s:p,f=p/s,g=i*s):(f=o?o/s:f,p=f*s,b=c/s)),u.y<0&&(u.height=Math.max(u.height+u.y,f),u.y=0),u.x<0&&(u.width=Math.max(u.width+u.x,p),u.x=0);const _=n-(u.x+u.width);_<0&&(u.x=Math.min(u.x,n-p),u.width+=_);const j=a-(u.y+u.height);if(j<0&&(u.y=Math.min(u.y,a-f),u.height+=j),u.widthg&&((r==="sw"||r=="nw")&&(u.x-=g-u.width),u.width=g),u.height>b&&((r==="nw"||r=="ne")&&(u.y-=b-u.height),u.height=b),s){const w=u.width/u.height;if(ws){const N=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=N-u.width),u.width=N}}return u}function NBt(t,s,r,n){const a={...t};return s==="ArrowLeft"?n==="nw"?(a.x-=r,a.y-=r,a.width+=r,a.height+=r):n==="w"?(a.x-=r,a.width+=r):n==="sw"?(a.x-=r,a.width+=r,a.height+=r):n==="ne"?(a.y+=r,a.width-=r,a.height-=r):n==="e"?a.width-=r:n==="se"&&(a.width-=r,a.height-=r):s==="ArrowRight"&&(n==="nw"?(a.x+=r,a.y+=r,a.width-=r,a.height-=r):n==="w"?(a.x+=r,a.width-=r):n==="sw"?(a.x+=r,a.width-=r,a.height-=r):n==="ne"?(a.y-=r,a.width+=r,a.height+=r):n==="e"?a.width+=r:n==="se"&&(a.width+=r,a.height+=r)),s==="ArrowUp"?n==="nw"?(a.x-=r,a.y-=r,a.width+=r,a.height+=r):n==="n"?(a.y-=r,a.height+=r):n==="ne"?(a.y-=r,a.width+=r,a.height+=r):n==="sw"?(a.x+=r,a.width-=r,a.height-=r):n==="s"?a.height-=r:n==="se"&&(a.width-=r,a.height-=r):s==="ArrowDown"&&(n==="nw"?(a.x+=r,a.y+=r,a.width-=r,a.height-=r):n==="n"?(a.y+=r,a.height-=r):n==="ne"?(a.y+=r,a.width-=r,a.height-=r):n==="sw"?(a.x-=r,a.width+=r,a.height+=r):n==="s"?a.height+=r:n==="se"&&(a.width+=r,a.height+=r)),a}const C5={capture:!0,passive:!1};let kBt=0;const Vb=class Tg extends k.PureComponent{constructor(){super(...arguments),Ic(this,"docMoveBound",!1),Ic(this,"mouseDownOnCrop",!1),Ic(this,"dragStarted",!1),Ic(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),Ic(this,"componentRef",k.createRef()),Ic(this,"mediaRef",k.createRef()),Ic(this,"resizeObserver"),Ic(this,"initChangeCalled",!1),Ic(this,"instanceId",`rc-${kBt++}`),Ic(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),Ic(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Yy(r,a.width,a.height);if(n)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=s.target.dataset.ord,i=!!l;let c=s.clientX,u=s.clientY,p=o.x,f=o.y;if(l){const g=s.clientX-a.x,b=s.clientY-a.y;let _=0,j=0;l==="ne"||l=="e"?(_=g-(o.x+o.width),j=b-o.y,p=o.x,f=o.y+o.height):l==="se"||l==="s"?(_=g-(o.x+o.width),j=b-(o.y+o.height),p=o.x,f=o.y):l==="sw"||l=="w"?(_=g-o.x,j=b-(o.y+o.height),p=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(_=g-o.x,j=b-o.y,p=o.x+o.width,f=o.y+o.height),c=p+a.x+_,u=f+a.y+j}this.evData={startClientX:c,startClientY:u,startCropX:p,startCropY:f,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),Ic(this,"onComponentPointerDown",s=>{const{crop:r,disabled:n,locked:a,keepSelection:o,onChange:l}=this.props,i=this.getBox();if(n||a||o&&r)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const c=s.clientX-i.x,u=s.clientY-i.y,p={unit:"px",x:c,y:u,width:0,height:0};this.evData={startClientX:s.clientX,startClientY:s.clientY,startCropX:c,startCropY:u,clientX:s.clientX,clientY:s.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(Yy(p,i.width,i.height),Qb(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),Ic(this,"onDocPointerMove",s=>{const{crop:r,disabled:n,onChange:a,onDragStart:o}=this.props,l=this.getBox();if(n||!r||!this.mouseDownOnCrop)return;s.cancelable&&s.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(s));const{evData:i}=this;i.clientX=s.clientX,i.clientY=s.clientY;let c;i.isResize?c=this.resizeCrop():c=this.dragCrop(),n8e(r,c)||a(Yy(c,l.width,l.height),Qb(c,l.width,l.height))}),Ic(this,"onComponentKeyDown",s=>{const{crop:r,disabled:n,onChange:a,onComplete:o}=this.props;if(n)return;const l=s.key;let i=!1;if(!r)return;const c=this.getBox(),u=this.makePixelCrop(c),p=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?Tg.nudgeStepLarge:s.shiftKey?Tg.nudgeStepMedium:Tg.nudgeStep;if(l==="ArrowLeft"?(u.x-=p,i=!0):l==="ArrowRight"?(u.x+=p,i=!0):l==="ArrowUp"?(u.y-=p,i=!0):l==="ArrowDown"&&(u.y+=p,i=!0),i){s.cancelable&&s.preventDefault(),u.x=S5(u.x,0,c.width-u.width),u.y=S5(u.y,0,c.height-u.height);const f=Yy(u,c.width,c.height),g=Qb(u,c.width,c.height);a(f,g),o&&o(f,g)}}),Ic(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:c,maxHeight:u,onChange:p,onComplete:f}=this.props,g=this.getBox();if(o||!a)return;if(s.key==="ArrowUp"||s.key==="ArrowDown"||s.key==="ArrowLeft"||s.key==="ArrowRight")s.stopPropagation(),s.preventDefault();else return;const b=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?Tg.nudgeStepLarge:s.shiftKey?Tg.nudgeStepMedium:Tg.nudgeStep,_=Yy(a,g.width,g.height),j=NBt(_,s.key,b,r),w=a8e(j,n,r,g.width,g.height,l,i,c,u);if(!n8e(a,w)){const N=Qb(w,g.width,g.height);p(w,N),f&&f(w,N)}}),Ic(this,"onDocPointerDone",s=>{const{crop:r,disabled:n,onComplete:a,onDragEnd:o}=this.props,l=this.getBox();this.unbindDocMove(),!(n||!r)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,o&&o(s),a&&a(Yy(r,l.width,l.height),Qb(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),Ic(this,"onDragFocus",()=>{var s;(s=this.componentRef.current)==null||s.scrollTo(0,0)})}get document(){return document}getBox(){const s=this.mediaRef.current;if(!s)return{x:0,y:0,width:0,height:0};const{x:r,y:n,width:a,height:o}=s.getBoundingClientRect();return{x:r,y:n,width:a,height:o}}componentDidUpdate(s){const{crop:r,onComplete:n}=this.props;if(n&&!s.crop&&r){const{width:a,height:o}=this.getBox();a&&o&&n(Yy(r,a,o),Qb(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,C5),this.document.addEventListener("pointerup",this.onDocPointerDone,C5),this.document.addEventListener("pointercancel",this.onDocPointerDone,C5),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,C5),this.document.removeEventListener("pointerup",this.onDocPointerDone,C5),this.document.removeEventListener("pointercancel",this.onDocPointerDone,C5),this.docMoveBound=!1)}getCropStyle(){const{crop:s}=this.props;if(s)return{top:`${s.y}${s.unit}`,left:`${s.x}${s.unit}`,width:`${s.width}${s.unit}`,height:`${s.height}${s.unit}`}}dragCrop(){const{evData:s}=this,r=this.getBox(),n=this.makePixelCrop(r),a=s.clientX-s.startClientX,o=s.clientY-s.startClientY;return n.x=S5(s.startCropX+a,0,r.width-n.width),n.y=S5(s.startCropY+o,0,r.height-n.height),n}getPointRegion(s,r,n,a){const{evData:o}=this,l=o.clientX-s.x,i=o.clientY-s.y;let c;a&&r?c=r==="nw"||r==="n"||r==="ne":c=i1?o?[o,o/r]:[l*r,l]:l?[l*r,l]:[o,o/r]}resizeCrop(){const{evData:s}=this,{aspect:r=0,maxWidth:n,maxHeight:a}=this.props,o=this.getBox(),[l,i]=this.resolveMinDimensions(o,r,this.props.minWidth,this.props.minHeight);let c=this.makePixelCrop(o);const u=this.getPointRegion(o,s.ord,l,i),p=s.ord||u;let f=s.clientX-s.startClientX,g=s.clientY-s.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(f=Math.min(f,-l)),(i&&p==="nw"||p==="n"||p==="ne")&&(g=Math.min(g,-i));const b={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(b.x=s.startCropX,b.width=f,r?(b.height=b.width/r,b.y=s.startCropY-b.height):(b.height=Math.abs(g),b.y=s.startCropY-b.height)):u==="se"?(b.x=s.startCropX,b.y=s.startCropY,b.width=f,r?b.height=b.width/r:b.height=g):u==="sw"?(b.x=s.startCropX+f,b.y=s.startCropY,b.width=Math.abs(f),r?b.height=b.width/r:b.height=g):u==="nw"&&(b.x=s.startCropX+f,b.width=Math.abs(f),r?(b.height=b.width/r,b.y=s.startCropY-b.height):(b.height=Math.abs(g),b.y=s.startCropY+g));const _=a8e(b,r,u,o.width,o.height,l,i,n,a);return r||Tg.xyOrds.indexOf(p)>-1?c=_:Tg.xOrds.indexOf(p)>-1?(c.x=_.x,c.width=_.width):Tg.yOrds.indexOf(p)>-1&&(c.y=_.y,c.height=_.height),c.x=S5(c.x,0,o.width-c.width),c.y=S5(c.y,0,o.height-c.height),c}renderCropSelection(){const{ariaLabels:s=Tg.defaultProps.ariaLabels,disabled:r,locked:n,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,i=this.getCropStyle();if(l)return ht.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&&ht.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},ht.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":s.nwDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"nw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":s.nDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"n"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":s.neDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"ne"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":s.eDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"e"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":s.seDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"se"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":s.sDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"s"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":s.swDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"sw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":s.wDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"w"),role:"button"})),a&&ht.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:c=>c.stopPropagation()},a(this.state)),o&&ht.createElement(ht.Fragment,null,ht.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),ht.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...Ole,...this.props.crop||{}};return Yy(r,s.width,s.height)}render(){const{aspect:s,children:r,circularCrop:n,className:a,crop:o,disabled:l,locked:i,style:c,ruleOfThirds:u}=this.props,{cropIsActive:p,newCropIsBeingDrawn:f}=this.state,g=o?this.renderCropSelection():null,b=_Bt("ReactCrop",a,p&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",f&&"ReactCrop--new-crop",o&&s&&"ReactCrop--fixed-aspect",o&&n&&"ReactCrop--circular-crop",o&&u&&"ReactCrop--rule-of-thirds",!this.dragStarted&&o&&!o.width&&!o.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return ht.createElement("div",{ref:this.componentRef,className:b,style:c},ht.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?ht.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},ht.createElement("defs",null,ht.createElement("mask",{id:`hole-${this.instanceId}`},ht.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?ht.createElement("ellipse",{cx:`${o.x+o.width/2}${o.unit}`,cy:`${o.y+o.height/2}${o.unit}`,rx:`${o.width/2}${o.unit}`,ry:`${o.height/2}${o.unit}`,fill:"black"}):ht.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),ht.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,g)}};Ic(Vb,"xOrds",["e","w"]),Ic(Vb,"yOrds",["n","s"]),Ic(Vb,"xyOrds",["nw","ne","se","sw"]),Ic(Vb,"nudgeStep",1),Ic(Vb,"nudgeStepMedium",10),Ic(Vb,"nudgeStepLarge",100),Ic(Vb,"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 SBt=Vb;var HJe=["PageUp","PageDown"],WJe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],GJe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},oE="Slider",[rbe,CBt,MBt]=yO(oE),[KJe]=ad(oE,[MBt]),[TBt,$ue]=KJe(oE),ZJe=k.forwardRef((t,s)=>{const{name:r,min:n=0,max:a=100,step:o=1,orientation:l="horizontal",disabled:i=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[n],value:p,onValueChange:f=()=>{},onValueCommit:g=()=>{},inverted:b=!1,form:_,...j}=t,w=k.useRef(new Set),N=k.useRef(0),M=l==="horizontal"?ABt:EBt,[L=[],I]=ah({prop:p,defaultProp:u,onChange:Y=>{var ee;(ee=[...w.current][N.current])==null||ee.focus(),f(Y)}}),O=k.useRef(L);function q(Y){const Q=OBt(L,Y);V(Y,Q)}function U(Y){V(Y,N.current)}function B(){const Y=O.current[N.current];L[N.current]!==Y&&g(L)}function V(Y,Q,{commit:ee}={commit:!1}){const X=BBt(o),ie=$Bt(Math.round((Y-n)/o)*o+n,X),re=eD(ie,[n,a]);I((oe=[])=>{const ce=LBt(oe,re,Q);if(zBt(ce,c*o)){N.current=ce.indexOf(re);const ge=String(ce)!==String(oe);return ge&&ee&&g(ce),ge?ce:oe}else return oe})}return e.jsx(TBt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:N,thumbs:w.current,values:L,orientation:l,form:_,children:e.jsx(rbe.Provider,{scope:t.__scopeSlider,children:e.jsx(rbe.Slot,{scope:t.__scopeSlider,children:e.jsx(M,{"aria-disabled":i,"data-disabled":i?"":void 0,...j,ref:s,onPointerDown:Ir(j.onPointerDown,()=>{i||(O.current=L)}),min:n,max:a,inverted:b,onSlideStart:i?void 0:q,onSlideMove:i?void 0:U,onSlideEnd:i?void 0:B,onHomeKeyDown:()=>!i&&V(n,0,{commit:!0}),onEndKeyDown:()=>!i&&V(a,L.length-1,{commit:!0}),onStepKeyDown:({event:Y,direction:Q})=>{if(!i){const ie=HJe.includes(Y.key)||Y.shiftKey&&WJe.includes(Y.key)?10:1,re=N.current,oe=L[re],ce=o*ie*Q;V(oe+ce,re,{commit:!0})}}})})})})});ZJe.displayName=oE;var[YJe,XJe]=KJe(oE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),ABt=k.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:c,onStepKeyDown:u,...p}=t,[f,g]=k.useState(null),b=qa(s,M=>g(M)),_=k.useRef(void 0),j=Tw(a),w=j==="ltr",N=w&&!o||!w&&o;function S(M){const L=_.current||f.getBoundingClientRect(),I=[0,L.width],q=_ke(I,N?[r,n]:[n,r]);return _.current=L,q(M-L.left)}return e.jsx(YJe,{scope:t.__scopeSlider,startEdge:N?"left":"right",endEdge:N?"right":"left",direction:N?1:-1,size:"width",children:e.jsx(QJe,{dir:j,"data-orientation":"horizontal",...p,ref:b,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:M=>{const L=S(M.clientX);l==null||l(L)},onSlideMove:M=>{const L=S(M.clientX);i==null||i(L)},onSlideEnd:()=>{_.current=void 0,c==null||c()},onStepKeyDown:M=>{const I=GJe[N?"from-left":"from-right"].includes(M.key);u==null||u({event:M,direction:I?-1:1})}})})}),EBt=k.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:c,...u}=t,p=k.useRef(null),f=qa(s,p),g=k.useRef(void 0),b=!a;function _(j){const w=g.current||p.current.getBoundingClientRect(),N=[0,w.height],M=_ke(N,b?[n,r]:[r,n]);return g.current=w,M(j-w.top)}return e.jsx(YJe,{scope:t.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:e.jsx(QJe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const w=_(j.clientY);o==null||o(w)},onSlideMove:j=>{const w=_(j.clientY);l==null||l(w)},onSlideEnd:()=>{g.current=void 0,i==null||i()},onStepKeyDown:j=>{const N=GJe[b?"from-bottom":"from-top"].includes(j.key);c==null||c({event:j,direction:N?-1:1})}})})}),QJe=k.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:c,...u}=t,p=$ue(oE,r);return e.jsx(nn.span,{...u,ref:s,onKeyDown:Ir(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):HJe.concat(WJe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:Ir(t.onPointerDown,f=>{const g=f.target;g.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(g)?g.focus():n(f)}),onPointerMove:Ir(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Ir(t.onPointerUp,f=>{const g=f.target;g.hasPointerCapture(f.pointerId)&&(g.releasePointerCapture(f.pointerId),o(f))})})}),JJe="SliderTrack",eet=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=$ue(JJe,r);return e.jsx(nn.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});eet.displayName=JJe;var nbe="SliderRange",tet=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=$ue(nbe,r),o=XJe(nbe,r),l=k.useRef(null),i=qa(s,l),c=a.values.length,u=a.values.map(g=>net(g,a.min,a.max)),p=c>1?Math.min(...u):0,f=100-Math.max(...u);return e.jsx(nn.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:p+"%",[o.endEdge]:f+"%"}})});tet.displayName=nbe;var abe="SliderThumb",set=k.forwardRef((t,s)=>{const r=CBt(t.__scopeSlider),[n,a]=k.useState(null),o=qa(s,i=>a(i)),l=k.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(PBt,{...t,ref:o,index:l})}),PBt=k.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=$ue(abe,r),i=XJe(abe,r),[c,u]=k.useState(null),p=qa(s,S=>u(S)),f=c?l.form||!!c.closest("form"):!0,g=_O(c),b=l.values[n],_=b===void 0?0:net(b,l.min,l.max),j=DBt(n,l.values.length),w=g==null?void 0:g[i.size],N=w?RBt(w,_,i.direction):0;return k.useEffect(()=>{if(c)return l.thumbs.add(c),()=>{l.thumbs.delete(c)}},[c,l.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${_}% + ${N}px)`},children:[e.jsx(rbe.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(nn.span,{role:"slider","aria-label":t["aria-label"]||j,"aria-valuemin":l.min,"aria-valuenow":b,"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:b===void 0?{display:"none"}:t.style,onFocus:Ir(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(ret,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:b},n)]})});set.displayName=abe;var IBt="RadioBubbleInput",ret=k.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=k.useRef(null),o=qa(a,n),l=LO(s);return k.useEffect(()=>{const i=a.current;if(!i)return;const c=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(l!==s&&p){const f=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(nn.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});ret.displayName=IBt;function LBt(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function net(t,s,r){const o=100/(r-s)*(t-s);return eD(o,[0,100])}function DBt(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function OBt(t,s){if(t.length===1)return 0;const r=t.map(a=>Math.abs(a-s)),n=Math.min(...r);return r.indexOf(n)}function RBt(t,s,r){const n=t/2,o=_ke([0,50],[0,n]);return(n-o(s)*r)*r}function FBt(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function zBt(t,s){if(s>0){const r=FBt(t);return Math.min(...r)>=s}return!0}function _ke(t,s){return r=>{if(t[0]===t[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(t[1]-t[0]);return s[0]+n*(r-t[0])}}function BBt(t){return(String(t).split(".")[1]||"").length}function $Bt(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var aet=ZJe,qBt=eet,UBt=tet,VBt=set;const Kg=k.forwardRef(({className:t,...s},r)=>e.jsxs(aet,{ref:r,className:It("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(qBt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(UBt,{className:"absolute h-full bg-primary"})}),e.jsx(VBt,{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"})]}));Kg.displayName=aet.displayName;function HBt(t,s,r){return jBt(wBt({unit:"%",width:90},r,t,s),t,s)}const wke=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=k.useRef(null),[l,i]=k.useState(),[c,u]=k.useState(),[p,f]=k.useState(1),[g,b]=k.useState(0),_=k.useCallback(N=>{const{width:S,height:M}=N.currentTarget;i(HBt(S,M,a))},[a]),j=k.useCallback(async()=>{const N=o.current;if(!N||!c)return;const S=document.createElement("canvas"),M=S.getContext("2d");if(!M)return;const L=N.naturalWidth/N.width,I=N.naturalHeight/N.height,O=400;S.width=O,S.height=O,M.imageSmoothingQuality="high";const q=c.x*L,U=c.y*I,B=c.width*L,V=c.height*I,Y=g*Math.PI/180,Q=S.width/2,ee=S.height/2;return M.save(),M.translate(Q,ee),M.rotate(Y),M.scale(p,p),M.translate(-Q,-ee),M.drawImage(N,q,U,B,V,0,0,O,O),M.restore(),new Promise((X,ie)=>{S.toBlob(re=>{re?X(re):ie(new Error("Canvas is empty"))},"image/jpeg",.95)})},[c,p,g]),w=async()=>{try{const N=await j();N&&(n(N),s())}catch(N){console.error("Error cropping image:",N)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Crop Your Photo"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative max-h-[400px] overflow-hidden rounded-lg bg-muted flex items-center justify-center",children:e.jsx(SBt,{crop:l,onChange:(N,S)=>i(S),onComplete:N=>u(N),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${g}deg)`,maxHeight:"400px",width:"auto"},onLoad:_})})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(HM,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Kg,{value:[p],min:.5,max:3,step:.1,onValueChange:([N])=>f(N),className:"flex-1"}),e.jsx(K_,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(kL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Kg,{value:[g],min:-180,max:180,step:1,onValueChange:([N])=>b(N),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[g,"°"]})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:w,children:"Save Photo"})]})]})})},WBt=()=>{const{user:t}=Ds(),{toast:s}=Ua(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(null);k.useEffect(()=>{t&&c()},[t]);const c=async()=>{n(!0);try{const{data:f}=await H.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();f&&i({status:f.subscription_status||"none",productId:f.subscription_product_id,endDate:f.subscription_end_date,isGrandfathered:f.is_grandfathered||!1})}catch(f){console.error("Error loading subscription:",f)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:f}}=await H.auth.getSession();if(!f)throw new Error("Not authenticated");const{data:g,error:b}=await H.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${f.access_token}`}});if(b)throw b;g!=null&&g.url&&window.open(g.url,"_blank")}catch(f){console.error("Error opening customer portal:",f),s({title:"Error",description:f.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},p=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(st,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(st,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(st,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(st,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(st,{variant:"secondary",children:"Canceled"});default:return e.jsx(st,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Mx,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Mx,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(gr,{children:"Manage your subscription and billing"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:p()})]}),(l==null?void 0:l.endDate)&&l.status==="active"&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Next billing date"}),e.jsx("p",{className:"font-medium",children:new Date(l.endDate).toLocaleDateString()})]})]}),l!=null&&l.isGrandfathered?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your account was upgraded from LevelUp 1.0. To update/manage your subscription please reach out to support."}):(l==null?void 0:l.status)==="active"||(l==null?void 0:l.status)==="trialing"?e.jsxs(e.Fragment,{children:[(l==null?void 0:l.status)==="trialing"&&(l==null?void 0:l.endDate)&&e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Your trial ends on ",new Date(l.endDate).toLocaleDateString(),". After the trial, you'll be charged automatically."]}),e.jsxs(K,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(tn,{className:"mr-2 h-4 w-4"}),"Manage Billing"]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have an active subscription."})]})]})},GBt=()=>{const{user:t}=Ds(),s=fr(),{toast:r}=Ua(),[n]=Cc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:c,subscribe:u,unsubscribe:p}=FYe(),[f,g]=k.useState(!1),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,S]=k.useState(!1),[M,L]=k.useState(""),[I,O]=k.useState({name:"",email:"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[q,U]=k.useState(!1),[B,V]=k.useState(!1),[Y,Q]=k.useState({newPassword:"",confirmPassword:""});k.useEffect(()=>{t&&ee()},[t]),k.useEffect(()=>{o&&t&&setTimeout(()=>{var ce;(ce=document.getElementById("change-password-section"))==null||ce.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const ee=async()=>{var ce,ge,ye;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:ue,error:pe}=await H.from("profiles").select("name, email, phone, digest_opt_out, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url, email_signature, use_email_signature").eq("id",t.id).maybeSingle();if(pe)throw console.error("Profile query error:",pe),pe;ue?(console.log("Profile loaded successfully:",ue),O({name:ue.name||"",email:ue.email||"",phone:ue.phone||"",title:ue.title||"",bio:ue.bio||"",areas_served:ue.areas_served||"",years_experience:((ce=ue.years_experience)==null?void 0:ce.toString())||"",instagram_url:ue.instagram_url||"",facebook_url:ue.facebook_url||"",linkedin_url:ue.linkedin_url||"",email_signature:ue.email_signature||"",use_email_signature:ue.use_email_signature||!1}),U(ue.digest_opt_out||!1)):(console.warn("No profile found for user"),O({name:((ge=t.user_metadata)==null?void 0:ge.name)||((ye=t.email)==null?void 0:ye.split("@")[0])||"",email:t.email||"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}));const{data:_e}=await H.storage.from("avatars").list(`${t.id}`);if(_e&&_e.length>0){const{data:$e}=H.storage.from("avatars").getPublicUrl(`${t.id}/${_e[0].name}`);_($e.publicUrl)}}catch(ue){console.error("Error loading profile:",ue),r({title:"Error",description:ue.message||"Failed to load profile",variant:"destructive"})}},X=ce=>{var ue;const ge=(ue=ce.target.files)==null?void 0:ue[0];if(!ge)return;const ye=new FileReader;ye.onloadend=()=>{L(ye.result),S(!0)},ye.readAsDataURL(ge),ce.target.value=""},ie=async ce=>{if(t){w(!0);try{const{data:ge}=await H.storage.from("avatars").list(`${t.id}`);ge&&ge.length>0&&await H.storage.from("avatars").remove(ge.map(Ae=>`${t.id}/${Ae.name}`));const ue=`${t.id}/avatar.jpg`,{error:pe}=await H.storage.from("avatars").upload(ue,ce,{upsert:!0,contentType:"image/jpeg"});if(pe)throw pe;const{data:_e}=H.storage.from("avatars").getPublicUrl(ue),$e=_e.publicUrl;_(`${$e}?t=${Date.now()}`),await H.from("profiles").update({avatar_url:$e}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(ge){console.error("Error uploading avatar:",ge),r({title:"Error",description:ge.message||"Failed to upload photo",variant:"destructive"})}finally{w(!1)}}},re=async()=>{if(!I.name.trim()||!I.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}g(!0);try{const{error:ce}=await H.from("profiles").update({name:I.name.trim(),email:I.email.trim(),phone:I.phone.trim()||null,title:I.title.trim()||null,bio:I.bio.trim()||null,areas_served:I.areas_served.trim()||null,years_experience:I.years_experience?parseInt(I.years_experience):null,instagram_url:I.instagram_url.trim()||null,facebook_url:I.facebook_url.trim()||null,linkedin_url:I.linkedin_url.trim()||null,email_signature:I.email_signature||"",use_email_signature:I.use_email_signature}).eq("id",t==null?void 0:t.id);if(ce)throw ce;r({title:"Success",description:"Profile updated successfully"})}catch(ce){console.error("Error updating profile:",ce),r({title:"Error",description:ce.message||"Failed to update profile",variant:"destructive"})}finally{g(!1)}},oe=async()=>{if(!Y.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(Y.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(Y.newPassword!==Y.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}g(!0);try{const{error:ce}=await H.auth.updateUser({password:Y.newPassword});if(ce)throw ce;r({title:"Success",description:"Password updated successfully"}),Q({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(ce){console.error("Error updating password:",ce),r({title:"Error",description:ce.message||"Failed to update password",variant:"destructive"})}finally{g(!1)}};return e.jsx(Ms,{title:a?"Complete Your Profile":o?"Reset Your Password":"Profile Settings",description:a?"Welcome! Please complete your profile setup":o?"Please set a new password for your account":"Manage your account information and password",children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[!a&&!o&&e.jsx("div",{className:"mb-6",children:e.jsxs(K,{variant:"outline",onClick:()=>{var ce;(ce=document.getElementById("change-password-section"))==null||ce.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(rS,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Profile Photo"}),e.jsx(gr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Oe,{className:"flex items-center gap-6",children:[e.jsxs(Nn,{className:"h-24 w-24",children:[e.jsx($a,{src:b}),e.jsx(kn,{className:"text-2xl",children:I.name.split(" ").map(ce=>ce[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:X,disabled:j}),e.jsxs(K,{variant:"outline",onClick:()=>{var ce;return(ce=document.getElementById("avatar-upload"))==null?void 0:ce.click()},disabled:j,children:[e.jsx(li,{className:"mr-2 h-4 w-4"}),j?"Uploading...":"Upload Photo"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Upload an image and crop it to your liking."})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Personal Information"}),e.jsx(gr,{children:"Update your profile details"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:I.name,onChange:ce=>O({...I,name:ce.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:I.email,onChange:ce=>O({...I,email:ce.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"phone",children:"Phone Number"}),e.jsx(ze,{id:"phone",type:"tel",value:I.phone,onChange:ce=>O({...I,phone:ce.target.value}),placeholder:"e.g., +14155551234",maxLength:20}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for SMS lead notifications from your website — if you have a local authority site"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Job Title"}),e.jsx(ze,{id:"title",value:I.title,onChange:ce=>O({...I,title:ce.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"bio",children:"Bio"}),e.jsx(Er,{id:"bio",value:I.bio,onChange:ce=>O({...I,bio:ce.target.value}),placeholder:"A short description about yourself",maxLength:500,className:"min-h-[120px] resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(ze,{id:"areas_served",value:I.areas_served,onChange:ce=>O({...I,areas_served:ce.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(ze,{id:"years_experience",type:"number",min:"0",value:I.years_experience,onChange:ce=>O({...I,years_experience:ce.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(ze,{value:I.linkedin_url,onChange:ce=>O({...I,linkedin_url:ce.target.value}),placeholder:"LinkedIn URL"}),e.jsx(ze,{value:I.instagram_url,onChange:ce=>O({...I,instagram_url:ce.target.value}),placeholder:"Instagram URL"}),e.jsx(ze,{value:I.facebook_url,onChange:ce=>O({...I,facebook_url:ce.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:re,disabled:f,children:[e.jsx(qc,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Bv,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(gr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Use email signature in all emails"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:I.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx(qr,{checked:I.use_email_signature,onCheckedChange:ce=>O({...I,use_email_signature:ce})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Signature"}),e.jsx(py,{content:I.email_signature,onChange:ce=>O({...I,email_signature:ce}),placeholder:"Paste your Gmail signature here or create one...",minHeight:"120px",compact:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Copy your signature from Gmail Settings and paste it here — images and formatting will be preserved."})]}),e.jsxs(K,{onClick:re,disabled:f,children:[e.jsx(qc,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Ee,{id:"change-password-section",children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:a?"Set Your Password":"Change Password"}),e.jsx(gr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"newPassword",children:"New Password"}),e.jsx(ze,{id:"newPassword",type:"password",value:Y.newPassword,onChange:ce=>Q({...Y,newPassword:ce.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(ze,{id:"confirmPassword",type:"password",value:Y.confirmPassword,onChange:ce=>Q({...Y,confirmPassword:ce.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:oe,disabled:f,children:[e.jsx(qc,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(K,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[i?e.jsx(Lm,{className:"h-5 w-5"}):e.jsx(r1,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(gr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Oe,{children:l?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:i?"Notifications enabled":"Notifications disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"You'll receive notifications about new templates, videos, and events":"Enable to get notified about new content"})]}),e.jsx(qr,{checked:i,onCheckedChange:ce=>{ce?u():p()},disabled:c})]}):e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"Push notifications are not available in this browser."}),e.jsxs("p",{className:"text-xs space-y-1",children:[e.jsx("strong",{children:"Desktop:"})," Use Chrome, Firefox, or Edge.",e.jsx("br",{}),e.jsx("strong",{children:"Android:"})," Use Chrome or Firefox.",e.jsx("br",{}),e.jsx("strong",{children:"iPhone/iPad:"})," Push notifications on iOS ",e.jsx("em",{children:"only"})," work when this site is installed as an app from ",e.jsx("strong",{children:"Safari"}),". Open this site in Safari → tap the ",e.jsx("strong",{children:"Share"})," button → ",e.jsx("strong",{children:"Add to Home Screen"}),". Other browsers (Chrome, Firefox, etc.) on iOS do not support push notifications due to Apple restrictions."]})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[q?e.jsx(pL,{className:"h-5 w-5"}):e.jsx(cr,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(gr,{children:"Manage your email subscription settings"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx(qr,{checked:!q,onCheckedChange:async ce=>{V(!0);try{const{error:ge}=await H.from("profiles").update({digest_opt_out:!ce}).eq("id",t==null?void 0:t.id);if(ge)throw ge;U(!ce),r({title:ce?"Subscribed":"Unsubscribed",description:ce?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(ge){r({title:"Error",description:ge.message||"Failed to update preference",variant:"destructive"})}finally{V(!1)}},disabled:B})]})})]}),e.jsx(N8t,{}),e.jsx(WBt,{})]}),e.jsx(wke,{open:N,onClose:()=>S(!1),imageSrc:M,onCropComplete:ie,aspectRatio:1})]})})};var KBt="AspectRatio",iet=k.forwardRef((t,s)=>{const{ratio:r=1/1,style:n,...a}=t;return e.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/r}%`},"data-radix-aspect-ratio-wrapper":"",children:e.jsx(nn.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});iet.displayName=KBt;var ZBt=iet;const YBt=ZBt;function XBt(){const{user:t}=Ds(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),{data:l,isLoading:i}=mt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:_,error:j}=await H.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(j)throw j;return _},enabled:!!t&&a}),c=Lt({mutationFn:async()=>{const _=new Uint8Array(12);crypto.getRandomValues(_);const j=btoa(String.fromCharCode(..._)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:w}=await H.from("profiles").update({calendar_token:j}).eq("id",t==null?void 0:t.id);if(w)throw w;return j},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),me.success("Calendar subscription URL generated!")},onError:_=>{me.error("Failed to generate calendar URL: "+_.message)}}),u=l!=null&&l.calendar_token?`https://dashboard.relevelup.com/api/calendar/${l.calendar_token}.ics`:null,p=async()=>{u&&(await navigator.clipboard.writeText(u),n(!0),me.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},f=()=>{u&&(window.location.href=u.replace("https://","webcal://"))},g=()=>{if(u){const _=u.replace("https://","webcal://"),j=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(_)}`;window.open(j,"_blank")}},b=()=>{if(u){const _=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(u)}&name=Level%20Up%20Events`;window.open(_,"_blank")}};return e.jsxs(fs,{open:a,onOpenChange:o,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(Gr,{children:"Add all Level Up events to your personal calendar. Events will sync automatically and update when we add or change events."})]}),e.jsx("div",{className:"space-y-4 py-4",children:i?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Your Calendar URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(K,{variant:"outline",size:"icon",onClick:p,children:r?e.jsx(va,{className:"h-4 w-4 text-green-500"}):e.jsx(gi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Quick Add"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:f,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),"Add to Apple Calendar",e.jsx(tn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:g,children:[e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("path",{d:"M19.5 22h-15A2.5 2.5 0 0 1 2 19.5v-15A2.5 2.5 0 0 1 4.5 2H9v2H4.5a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h15a.5.5 0 0 0 .5-.5V15h2v4.5a2.5 2.5 0 0 1-2.5 2.5z"}),e.jsx("path",{d:"M12 2v8.5a1.5 1.5 0 0 0 1.5 1.5H22V2h-10z",fill:"#4285F4"}),e.jsx("path",{d:"M12 12V2H4.5A2.5 2.5 0 0 0 2 4.5V12h10z",fill:"#34A853"}),e.jsx("path",{d:"M2 12v7.5A2.5 2.5 0 0 0 4.5 22H12v-10H2z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 22h7.5a2.5 2.5 0 0 0 2.5-2.5V12h-10v10z",fill:"#EA4335"})]}),"Add to Google Calendar",e.jsx(tn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:b,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V12zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.81v-2.72zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z"})}),"Add to Outlook",e.jsx(tn,{className:"h-3 w-3 ml-auto opacity-50"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center pt-2",children:"Events sync automatically. If your membership expires, the calendar will show as empty."})]}):e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate your personal calendar subscription URL to get started."}),e.jsx(K,{onClick:()=>c.mutate(),disabled:c.isPending,className:"w-full",children:c.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var que="Tabs",[QBt]=ad(que,[Aw]),oet=Aw(),[JBt,jke]=QBt(que),cet=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:c="automatic",...u}=t,p=Tw(i),[f,g]=ah({prop:n,onChange:a,defaultProp:o??"",caller:que});return e.jsx(JBt,{scope:r,baseId:Tu(),value:f,onValueChange:g,orientation:l,dir:p,activationMode:c,children:e.jsx(nn.div,{dir:p,"data-orientation":l,...u,ref:s})})});cet.displayName=que;var det="TabsList",uet=k.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=jke(det,r),l=oet(r);return e.jsx(Dde,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(nn.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});uet.displayName=det;var het="TabsTrigger",met=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=jke(het,r),i=oet(r),c=xet(l.baseId,n),u=get(l.baseId,n),p=n===l.value;return e.jsx(Ode,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(nn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...o,ref:s,onMouseDown:Ir(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Ir(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Ir(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});met.displayName=het;var pet="TabsContent",fet=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=jke(pet,r),c=xet(i.baseId,n),u=get(i.baseId,n),p=n===i.value,f=k.useRef(p);return k.useEffect(()=>{const g=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(g)},[]),e.jsx(zd,{present:a||p,children:({present:g})=>e.jsx(nn.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":c,hidden:!g,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:f.current?"0s":void 0},children:g&&o})})});fet.displayName=pet;function xet(t,s){return`${t}-trigger-${s}`}function get(t,s){return`${t}-content-${s}`}var e$t=cet,yet=uet,vet=met,bet=fet;const ba=e$t,pa=k.forwardRef(({className:t,...s},r)=>e.jsx(yet,{ref:r,className:It("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));pa.displayName=yet.displayName;const ns=k.forwardRef(({className:t,...s},r)=>e.jsx(vet,{ref:r,className:It("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...s}));ns.displayName=vet.displayName;const bs=k.forwardRef(({className:t,...s},r)=>e.jsx(bet,{ref:r,className:It("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));bs.displayName=bet.displayName;const t$t={first_timer:Jn,regular:c1,dedicated:Nc,veteran:xo,streak_master:eh,century:xo},s$t={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 i8e(t){return t===1?e.jsx(xo,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(c1,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(Nc,{className:"h-5 w-5 text-amber-600"}):e.jsx("span",{className:"w-5 text-center text-sm font-medium text-muted-foreground",children:t})}function _et({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Ds(),{data:o,isLoading:l}=oXe(s?5:10,r),{data:i}=lXe(a==null?void 0:a.id),{data:c}=dXe(a==null?void 0:a.id),{data:u}=cXe(a==null?void 0:a.id);return l?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,f)=>e.jsx(ys,{className:"h-12 w-full"},f))})})]}):e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Oe,{children:[t&&i&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Your Stats"}),c&&e.jsxs(st,{variant:"secondary",className:"text-xs",children:["Rank #",c]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:i.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Points"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold",children:i.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(eh,{className:"h-4 w-4 text-orange-500"}),e.jsx("div",{className:"text-lg font-bold",children:i.current_streak}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Streak"})]})]}),u&&u.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1",children:[u.slice(0,4).map(p=>{const f=t$t[p.badge_type]||Jn;return e.jsxs(st,{variant:"outline",className:`text-xs ${s$t[p.badge_type]||""}`,title:p.badge_description||"",children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),p.badge_name]},p.id)}),u.length>4&&e.jsxs(st,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(ba,{defaultValue:"points",className:"w-full",children:[e.jsxs(pa,{className:"w-full mb-3",children:[e.jsx(ns,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(ns,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(bs,{value:"points",className:"mt-0",children:e.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((p,f)=>{var g,b,_;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:i8e(f+1)}),e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"text-xs",children:((b=(g=p.profile)==null?void 0:g.name)==null?void 0:b.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((_=p.profile)==null?void 0:_.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:p.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},p.user_id)}),(!o||o.length===0)&&e.jsx("div",{className:"text-center text-muted-foreground py-4 text-sm",children:"No attendance data yet. Attend an event to get on the leaderboard!"})]})}),e.jsx(bs,{value:"events",className:"mt-0",children:e.jsx("div",{className:"space-y-2",children:[...o||[]].sort((p,f)=>f.total_events_attended-p.total_events_attended).map((p,f)=>{var g,b,_;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:i8e(f+1)}),e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"text-xs",children:((b=(g=p.profile)==null?void 0:g.name)==null?void 0:b.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((_=p.profile)==null?void 0:_.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:p.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},p.user_id)})})})]})]})]})}function r$t(){const t=fr(),{user:s,isAdmin:r}=Ds(),n=Qt(),{data:a,isLoading:o}=mt({queryKey:["public-events"],queryFn:async()=>{const{data:j,error:w}=await H.from("events").select("*").order("event_date",{ascending:!0});if(w)throw w;return j}}),{data:l}=mt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:j,error:w}=await H.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(w)throw w;return j},enabled:!!s}),{data:i}=mt({queryKey:["event-registration-counts"],queryFn:async()=>{let j=[],w=0;const N=1e3;for(;;){const{data:M,error:L}=await H.from("event_registrations").select("event_id").range(w,w+N-1);if(L)throw L;if(!M||M.length===0||(j=j.concat(M),M.length{S[M.event_id]=(S[M.event_id]||0)+1}),S}}),c=Lt({mutationFn:async j=>{await H.auth.refreshSession();const{data:w,error:N}=await H.functions.invoke("zoom-register",{body:{event_id:j}});if(N)throw N;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:j=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),j!=null&&j.join_url?me.success("Successfully registered! You'll receive a Zoom confirmation email."):me.success("Successfully registered for the event!")},onError:j=>{me.error("Failed to register: "+j.message)}}),u=Lt({mutationFn:async j=>{const{data:w,error:N}=await H.functions.invoke("zoom-unregister",{body:{event_id:j}});if(N)throw N;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),me.success("Registration cancelled and removed from Zoom")},onError:j=>{me.error("Failed to cancel: "+j.message)}}),p=j=>l==null?void 0:l.some(w=>w.event_id===j),f=j=>{const w=l==null?void 0:l.find(N=>N.event_id===j);return w==null?void 0:w.zoom_join_url},g=j=>j.capacity?((i==null?void 0:i[j.id])||0)>=j.capacity:!1,b=(a==null?void 0:a.filter(j=>JM(j.event_date)!=="ended"))||[],_=(a==null?void 0:a.filter(j=>JM(j.event_date)==="ended"))||[];return e.jsx(Ms,{title:"Events",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Events"}),e.jsx("p",{className:"text-muted-foreground",children:"Browse and register for upcoming events"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(XBt,{}),r&&e.jsx(K,{variant:"outline",onClick:()=>t("/admin/events"),children:"Manage Events"})]})]}),e.jsxs("div",{className:`grid grid-cols-1 ${r?"lg:grid-cols-3":""} gap-6`,children:[e.jsxs("div",{className:r?"lg:col-span-2":"",children:[o?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading events..."}):b.length===0?e.jsx(Ee,{className:"text-center py-12",children:e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:b.map(j=>{const w=JM(j.event_date),N=vNe(j.event_date),S=w==="live",M=w==="starting_soon";return e.jsxs(Ee,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${S?"border-red-500 ring-2 ring-red-500/20":M?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${j.id}`),children:[N&&e.jsxs("div",{className:`${S?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),S?e.jsxs(e.Fragment,{children:[e.jsx(h1,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),j.image_url&&e.jsx(YBt,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:j.image_url,alt:j.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(Pt,{children:[e.jsx(Rt,{className:"line-clamp-2",children:j.title}),j.description&&e.jsx(gr,{className:"line-clamp-2",children:j.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Oe,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(j.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(un,{className:"h-4 w-4"}),oD(new Date(j.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(pr,{className:"h-4 w-4"}),(i==null?void 0:i[j.id])||0," registered",j.capacity&&` / ${j.capacity} spots`]})]}),e.jsx(VL,{className:"flex gap-2",onClick:L=>L.stopPropagation(),children:p(j.id)?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(j.id),disabled:u.isPending,children:[e.jsx(Rr,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(K,{className:"flex-1",onClick:()=>window.open(f(j.id)||j.zoom_link,"_blank"),children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{className:"w-full",onClick:()=>c.mutate(j.id),disabled:c.isPending||g(j),children:g(j)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(va,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},j.id)})}),_.length>0&&e.jsxs("div",{className:"mt-12",children:[e.jsx("h3",{className:"text-xl font-semibold mb-4 text-muted-foreground",children:"Past Events"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:_.map(j=>e.jsx(Ee,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${j.id}`),children:e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-base line-clamp-1",children:j.title}),e.jsx(gr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(j.event_date))})]})},j.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(_et,{showUserStats:!0})})]})]})})}const Sge=[{value:"all",label:"All Roles",icon:pr},{value:"newest",label:"Newest Members",icon:un},{value:"brokerage_manager",label:"Brokerage Managers",icon:RL},{value:"admin",label:"Admins",icon:th}];function n$t({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Le,tt;const{user:o,isAdmin:l,isBrokerageManager:i}=Ds(),[c,u]=k.useState([]),[p,f]=k.useState([]),[g,b]=k.useState([]),[_,j]=k.useState([]),[w,N]=k.useState(""),[S,M]=k.useState(""),[L,I]=k.useState(""),[O,q]=k.useState(!1),[U,B]=k.useState(!1),[V,Y]=k.useState("agents"),[Q,ee]=k.useState("all"),[X,ie]=k.useState({}),re=l||i;k.useEffect(()=>{t&&o&&(l?oe():ce())},[t,o,l]),k.useEffect(()=>{t||(b([]),j([]),N(""),M(""),I(""),Y("agents"),ee("all"))},[t]);const oe=async()=>{if(o){q(!0);try{const{data:Te,error:pt}=await H.from("brokerages").select("id, name").order("name");if(pt)throw pt;const fe=1e3,qe={};let at=0,et=!0;for(;et;){const{data:He,error:ct}=await H.from("profiles").select("brokerage_id").range(at*fe,(at+1)*fe-1);if(ct)throw ct;He==null||He.forEach(Ue=>{Ue.brokerage_id&&(qe[Ue.brokerage_id]=(qe[Ue.brokerage_id]||0)+1)}),et=(He==null?void 0:He.length)===fe,at++}f((Te==null?void 0:Te.map(He=>({...He,agent_count:qe[He.id]||0})))||[]);const Me=[];for(at=0,et=!0;et;){const{data:He,error:ct}=await H.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(at*fe,(at+1)*fe-1);if(ct)throw ct;He&&Me.push(...He),et=(He==null?void 0:He.length)===fe,at++}const rt={};for(at=0,et=!0;et;){const{data:He,error:ct}=await H.from("user_roles").select("user_id, role").range(at*fe,(at+1)*fe-1);if(ct)throw ct;He==null||He.forEach(Ue=>{rt[Ue.user_id]||(rt[Ue.user_id]=[]),rt[Ue.user_id].push(Ue.role)}),et=(He==null?void 0:He.length)===fe,at++}ie(rt),u(Me.map(He=>{var ct;return{id:He.id,name:He.name,email:He.email,brokerage_name:((ct=He.brokerages)==null?void 0:ct.name)||"No Brokerage",roles:rt[He.id]||[],created_at:He.created_at}}))}catch(Te){console.error("Error loading data:",Te),me.error("Failed to load agents and brokerages")}finally{q(!1)}}},ce=async()=>{if(o){q(!0);try{const{data:Te}=await H.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(Te!=null&&Te.brokerage_id)){me.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:pt,error:fe}=await H.from("profiles").select("id, name, email").eq("brokerage_id",Te.brokerage_id).neq("id",o.id).order("name");if(fe)throw fe;u(pt||[])}catch(Te){console.error("Error loading agents:",Te),me.error("Failed to load agents")}finally{q(!1)}}},ge=c.filter(Te=>{var fe;const pt=Te.name.toLowerCase().includes(w.toLowerCase())||Te.email.toLowerCase().includes(w.toLowerCase())||((fe=Te.brokerage_name)==null?void 0:fe.toLowerCase().includes(w.toLowerCase()));if(l&&Q!=="all"&&Q!=="newest"){const qe=X[Te.id]||[];return pt&&qe.includes(Q)}return pt}).sort((Te,pt)=>Q==="newest"?(pt.created_at||"").localeCompare(Te.created_at||""):0),ye=p.filter(Te=>Te.name.toLowerCase().includes(S.toLowerCase())),ue=()=>{g.length===ge.length?b([]):b(ge.map(Te=>Te.id))},pe=()=>{_.length===ye.length?j([]):j(ye.map(Te=>Te.id))},_e=Te=>{if(!re){b([Te]);return}b(pt=>pt.includes(Te)?pt.filter(fe=>fe!==Te):[...pt,Te])},$e=Te=>{j(pt=>pt.includes(Te)?pt.filter(fe=>fe!==Te):[...pt,Te])},Ae=async()=>{if(!(g.length>0||_.length>0)){me.error("Please select at least one agent or brokerage to share with");return}B(!0);try{const{data:pt,error:fe}=await H.functions.invoke("send-share-notification",{body:{recipientIds:g,brokerageIds:_,resourceType:r,resourceId:n,resourceTitle:a,message:L.trim()||void 0}});if(fe)throw fe;const qe=(pt==null?void 0:pt.sharesCreated)||g.length;me.success(`Shared with ${qe} agent${qe!==1?"s":""}`),s(!1)}catch(pt){console.error("Error sharing resource:",pt),me.error("Failed to share resource")}finally{B(!1)}},Ie=Te=>Te.split(" ").map(pt=>pt[0]).join("").toUpperCase().slice(0,2),Ce=Te=>{const pt=X[Te]||[];return pt.includes("admin")?e.jsx(st,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):pt.includes("brokerage_manager")?e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},xe=g.length+_.length,we=Q!=="all"&&Q!=="newest"?ge.length:null;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{className:"flex-shrink-0",children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Bn,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(Gr,{className:"line-clamp-2",children:['Share "',a,'" with ',l?"agents or brokerages":"agents in your brokerage"]})]}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[l?e.jsxs(ba,{value:V,onValueChange:Y,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(ns,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),g.length>0&&e.jsx(st,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:g.length})]}),e.jsxs(ns,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),_.length>0&&e.jsx(st,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:_.length})]})]}),e.jsxs(bs,{value:"agents",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or brokerage...",value:w,onChange:Te=>N(Te.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:Q,onValueChange:ee,children:[e.jsxs(Hs,{className:"w-[180px]",children:[e.jsx(Qg,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Ys,{placeholder:"Filter by role"})]}),e.jsx(Ws,{children:Sge.map(Te=>e.jsx(Mt,{value:Te.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Te.icon,{className:"h-4 w-4"}),e.jsx("span",{children:Te.label})]})},Te.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ue,className:"text-xs h-8",disabled:ge.length===0,children:[e.jsx(pr,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===ge.length&&ge.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[we!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[we," ",(Le=Sge.find(Te=>Te.value===Q))==null?void 0:Le.label]}),e.jsxs("span",{className:"font-medium",children:[g.length," selected"]})]})]}),e.jsx(Gi,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ge.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(pr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:Q!=="all"?`No ${(tt=Sge.find(Te=>Te.value===Q))==null?void 0:tt.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:ge.map(Te=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${g.includes(Te.id)?"bg-accent":""}`,onClick:()=>_e(Te.id),children:[e.jsx(Oo,{checked:g.includes(Te.id),onCheckedChange:()=>_e(Te.id),className:"flex-shrink-0"}),e.jsx(Nn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(kn,{className:"text-xs bg-primary/10 text-primary",children:Ie(Te.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Te.name}),Ce(Te.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[Te.email,Te.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",Te.brokerage_name]})]})]})]},Te.id))})})]}),e.jsxs(bs,{value:"brokerages",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search brokerages...",value:S,onChange:Te=>M(Te.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:pe,className:"text-xs h-8",disabled:ye.length===0,children:[e.jsx(ka,{className:"h-3.5 w-3.5 mr-1.5"}),_.length===ye.length&&ye.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[_.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground px-1 flex-shrink-0",children:"Selecting a brokerage will send to all agents in that brokerage."}),e.jsx(Gi,{className:"h-[250px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ye.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(ka,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No brokerages found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:ye.map(Te=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${_.includes(Te.id)?"bg-accent":""}`,onClick:()=>$e(Te.id),children:[e.jsx(Oo,{checked:_.includes(Te.id),onCheckedChange:()=>$e(Te.id),className:"flex-shrink-0"}),e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(ka,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Te.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Te.agent_count," agent",Te.agent_count!==1?"s":""]})]})]},Te.id))})})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:w,onChange:Te=>N(Te.target.value),className:"pl-9"})]}),re&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ue,className:"text-xs h-8",disabled:ge.length===0,children:[e.jsx(pr,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===ge.length&&ge.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[g.length," selected"]})]}),e.jsx(Gi,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ge.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(pr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:ge.map(Te=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${g.includes(Te.id)?"bg-accent":""}`,onClick:()=>_e(Te.id),children:[e.jsx(Oo,{checked:g.includes(Te.id),onCheckedChange:()=>_e(Te.id),className:"flex-shrink-0"}),e.jsx(Nn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(kn,{className:"text-xs bg-primary/10 text-primary",children:Ie(Te.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Te.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Te.email})]})]},Te.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(be,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(Er,{id:"message",placeholder:"I thought you might find this useful...",value:L,onChange:Te=>I(Te.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:Ae,disabled:xe===0||U,children:U?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function lE({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=k.useState(!1),{user:c}=Ds();return c?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(wd,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(n$t,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function a$t(){const{eventId:t}=yo(),s=fr(),{user:r}=Ds(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(0),[u,p]=k.useState(!0),[f,g]=k.useState(!1);k.useEffect(()=>{t&&b()},[t,r]);const b=async()=>{try{const{data:M,error:L}=await H.from("events").select("*").eq("id",t).single();if(L)throw L;a(M);const{count:I}=await H.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(c(I||0),r){const{data:O}=await H.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(O)}}catch(M){console.error("Error loading event:",M),me.error("Failed to load event"),s("/events")}finally{p(!1)}},_=async()=>{if(!(!r||!n)){g(!0);try{const{error:M}=await H.auth.refreshSession();if(M){console.error("Session refresh failed:",M),me.error("Your session has expired. Please log in again.");return}if(o){const{error:L}=await H.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(L)throw L;me.success("Successfully cancelled registration"),l(null),c(I=>I-1)}else{const{data:L,error:I}=await H.functions.invoke("zoom-register",{body:{event_id:n.id}});if(I)throw I;me.success("Successfully registered for event!"),l({id:L.registration_id,zoom_join_url:L.zoom_join_url}),c(O=>O+1)}}catch(M){console.error("Registration error:",M),me.error(o?"Failed to cancel registration":"Failed to register for event")}finally{g(!1)}}},j=M=>{var L,I,O;if(M.includes("iframe.mediadelivery.net")||M.includes("video.bunnycdn.com")){const q=M.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(q)return`https://iframe.mediadelivery.net/embed/${q[1]}/${q[2]}?autoplay=false&preload=true`}if(M.includes("youtube.com")||M.includes("youtu.be")){const q=M.includes("youtu.be")?(L=M.split("youtu.be/")[1])==null?void 0:L.split("?")[0]:(I=M.split("v=")[1])==null?void 0:I.split("&")[0];if(q)return`https://www.youtube.com/embed/${q}`}if(M.includes("vimeo.com")){const q=(O=M.split("vimeo.com/")[1])==null?void 0:O.split("?")[0];if(q)return`https://player.vimeo.com/video/${q}`}return M};if(u)return e.jsx(Ms,{title:"Event",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading event..."})]})})});if(!n)return e.jsx(Ms,{title:"Event Not Found",children:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-muted-foreground",children:"Event not found"}),e.jsx(K,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const w=w0(new Date(n.event_date)),N=n.capacity&&i>=n.capacity,S=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Ms,{title:n.title,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(K,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),w&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(st,{variant:"secondary",className:"text-lg px-4 py-2",children:"Event Ended"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:n.title}),e.jsx(lE,{resourceType:"event",resourceId:n.id,resourceTitle:n.title})]}),n.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground dark:prose-invert",dangerouslySetInnerHTML:{__html:n.description}})]}),n.video_url&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(pp,{className:"h-5 w-5"}),"Event Preview"]}),e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:e.jsx("iframe",{src:j(n.video_url),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Event Preview Video"})})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hn,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(n.event_date))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:oD(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(pr,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[i," / ",n.capacity]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Registered"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 rounded-lg",children:[e.jsx(xi,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!w&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(S,"_blank"),children:[e.jsx(tn,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:_,disabled:f,children:[f?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:_,disabled:f||(N??!1),children:f?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):N?"Event Full":"Register Now"})}),w&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(tn,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const i$t=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(An,{className:"h-6 w-6"}),path:"/mission-control/video/record",category:"Marketing",color:"bg-rose-500/15 text-rose-600"},{id:"smart-card",name:"Smart Card",description:"Your digital business card — share your info with a single link",icon:e.jsx(Mx,{className:"h-6 w-6"}),path:"/mission-control/my-card",category:"Marketing",color:"bg-sky-500/15 text-sky-600"},{id:"smart-presentations",name:"Smart Presentations",description:"Create beautiful listing and buyer presentations",icon:e.jsx(ey,{className:"h-6 w-6"}),path:"/mission-control/presentations",category:"Marketing",color:"bg-amber-500/15 text-amber-600"},{id:"landing-pages",name:"Landing Pages",description:"Build custom landing pages to capture leads",icon:e.jsx(Sn,{className:"h-6 w-6"}),path:"/mission-control/landing-pages",category:"Marketing",color:"bg-emerald-500/15 text-emerald-600"},{id:"guest-book",name:"Guest Book",description:"Digital open house sign-in to capture visitor info",icon:e.jsx(Sh,{className:"h-6 w-6"}),path:"/mission-control/guest-book",category:"Open House",color:"bg-orange-500/15 text-orange-600"},{id:"card-studio",name:"Card Studio",description:"Send beautiful animated digital cards for birthdays, anniversaries & milestones",icon:e.jsx(pn,{className:"h-6 w-6"}),path:"/mission-control/card-studio",category:"Marketing",color:"bg-pink-500/15 text-pink-600"},{id:"direct-mail",name:"Direct Mail",description:"Send professional postcards to your contacts via direct mail",icon:e.jsx(cr,{className:"h-6 w-6"}),path:"/mission-control/direct-mail",category:"Marketing",adminOnly:!0,beta:!0,color:"bg-indigo-500/15 text-indigo-600"},{id:"reelflow",name:"ReelFlow",description:"Turn property photos into cinematic video clips and reels — powered by AI",icon:e.jsx(gu,{className:"h-6 w-6"}),path:"/admin/beta/homereel",category:"Marketing",beta:!0,isNew:!0,color:"bg-violet-500/15 text-violet-600"},{id:"mass-emails",name:"Mass Emails",description:"Create and send bulk email campaigns to your contacts",icon:e.jsx(Bn,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0,color:"bg-teal-500/15 text-teal-600"}],o$t=()=>{const{user:t,isAdmin:s}=Ds(),r=fr(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,c]=k.useState(""),[u,p]=k.useState("all"),[f,g]=k.useState(new Set),[b,_]=k.useState(new Set);k.useEffect(()=>{j()},[t]);const j=async()=>{try{const{data:B}=await H.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),V=(B==null?void 0:B.map(ge=>ge.tag))||[],{data:Y,error:Q}=await H.from("app_tiles").select("*").order("name");if(Q)throw Q;const[{data:ee},{data:X}]=await Promise.all([H.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),H.from("user_tool_favorites").select("tool_id").eq("user_id",t==null?void 0:t.id)]),ie=new Set((ee==null?void 0:ee.map(ge=>ge.app_id))||[]);g(ie);const re=new Set((X||[]).map(ge=>ge.tool_id));_(re);const ce=((Y==null?void 0:Y.filter(ge=>!ge.required_tags||ge.required_tags.length===0?!0:ge.required_tags.some(ye=>V.includes(ye))))||[]).sort((ge,ye)=>ge.name==="LevelUp Members Portal"?-1:ye.name==="LevelUp Members Portal"?1:0);a(ce)}catch(B){console.error("Error loading apps:",B),me.error("Failed to load apps")}finally{l(!1)}},w=async B=>{var Y;const V=window.open("about:blank","_blank");try{const{data:Q,error:ee}=await H.auth.getSession();if(ee||!Q.session){V==null||V.close(),me.error("Session expired. Please refresh the page and try again.");return}const X=Q.session.access_token;await H.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:B.app_id,app_name:B.name,user_agent:navigator.userAgent});const{data:ie,error:re}=await H.functions.invoke("sso-launch",{body:{app_id:B.app_id},headers:{Authorization:`Bearer ${X}`}});if(re)throw re;ie!=null&&ie.redirect_url?V&&!V.closed?(V.location.href=ie.redirect_url,(Y=V.focus)==null||Y.call(V)):window.location.assign(ie.redirect_url):(V==null||V.close(),me.error("Launch link unavailable"))}catch(Q){V==null||V.close(),console.error("Error launching app:",Q),me.error("Failed to launch app. Please try again.")}},N=async(B,V)=>{B.stopPropagation();const Y=f.has(V);try{if(Y){const{error:Q}=await H.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",V);if(Q)throw Q;g(ee=>{const X=new Set(ee);return X.delete(V),X}),me.success("Removed from favorites")}else{const{error:Q}=await H.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:V});if(Q)throw Q;g(ee=>new Set(ee).add(V)),me.success("Added to favorites")}}catch(Q){console.error("Error toggling favorite:",Q),me.error("Failed to update favorites")}},S=async(B,V)=>{B.stopPropagation();const Y=b.has(V);try{if(Y){const{error:Q}=await H.from("user_tool_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("tool_id",V);if(Q)throw Q;_(ee=>{const X=new Set(ee);return X.delete(V),X}),me.success("Removed from favorites")}else{const{error:Q}=await H.from("user_tool_favorites").insert({user_id:t==null?void 0:t.id,tool_id:V});if(Q)throw Q;_(ee=>new Set(ee).add(V)),me.success("Added to favorites")}}catch(Q){console.error("Error toggling tool favorite:",Q),me.error("Failed to update favorites")}},M=n.filter(B=>{var Y;const V=B.name.toLowerCase().includes(i.toLowerCase())||((Y=B.description)==null?void 0:Y.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?V&&f.has(B.id):V}),L=i$t.filter(B=>{if(B.adminOnly&&!s)return!1;const V=B.name.toLowerCase().includes(i.toLowerCase())||B.description.toLowerCase().includes(i.toLowerCase());return u==="favorites"?V&&b.has(B.id):V}),I=L.reduce((B,V)=>(B[V.category]||(B[V.category]=[]),B[V.category].push(V),B),{}),O=[{id:"all",label:"All"},{id:"tools",label:"Built-in Tools"},{id:"apps",label:"Connected Apps"},{id:"favorites",label:"Favorites"}];if(o)return e.jsx(Ms,{title:"Apps & Tools",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading apps & tools..."})]})})});const q=u==="all"||u==="tools"||u==="favorites",U=u==="all"||u==="apps"||u==="favorites";return e.jsxs(Ms,{title:"Apps & Tools",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Apps & Tools"}),e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search apps & tools...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:B=>c(B.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:O.map(B=>e.jsxs("button",{onClick:()=>p(B.id),className:It("pb-3 text-sm font-medium transition-colors relative",u===B.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[B.label,u===B.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},B.id))}),q&&Object.keys(I).length>0&&e.jsxs("div",{className:"mb-10",children:[u==="all"&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(ty,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(I).map(([B,V])=>e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground bg-muted px-2.5 py-1 rounded-full",children:B})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:V.map(Y=>{const Q=b.has(Y.id);return e.jsxs("div",{onClick:()=>r(Y.path),className:It("group flex items-start gap-4 p-5 bg-card rounded-xl border transition-all duration-200 hover:shadow-lg cursor-pointer relative overflow-hidden",Y.isNew?"border-primary/40 ring-1 ring-primary/20 hover:border-primary/60":"border-border hover:border-primary/30"),children:[Y.isNew&&e.jsx("div",{className:"absolute top-0 right-0 bg-gradient-to-r from-violet-500 to-indigo-500 text-white text-[10px] font-bold uppercase px-3 py-0.5 rounded-bl-lg tracking-wider shadow-sm",children:"✨ New"}),e.jsx("div",{className:It("flex-shrink-0 w-14 h-14 rounded-xl flex items-center justify-center transition-transform group-hover:scale-105",Y.color||"bg-primary/10 text-primary"),children:Y.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate flex items-center gap-2",children:[Y.name,Y.beta&&e.jsx("span",{className:"text-[10px] font-semibold bg-amber-100 text-amber-700 px-1.5 py-0.5 rounded-full border border-amber-200",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:Y.description})]}),e.jsx("button",{className:It("flex-shrink-0 p-1 transition-colors",Q?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:ee=>S(ee,Y.id),children:e.jsx(kx,{className:It("h-5 w-5",Q&&"fill-current")})})]},Y.id)})})]},B))]}),U&&e.jsxs("div",{children:[u==="all"&&M.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(tn,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Connected Apps"})]}),M.length===0&&u!=="all"&&!(u==="favorites"&&L.length>0)?e.jsx("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:u==="favorites"?e.jsxs(e.Fragment,{children:[e.jsx(kx,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No favorites yet"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Click the bookmark icon on any app or tool to add it to your favorites"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Th,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No apps available"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:s?"Get started by adding apps in the admin panel":"Contact your administrator to get access to apps"}),s&&e.jsx(K,{className:"mt-4",onClick:()=>r("/admin/apps"),children:"Add Apps"})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:M.map(B=>{const V=f.has(B.id),Y=B.name.toLowerCase().includes("agent review")||B.app_id==="agent_review";return e.jsxs("div",{className:"group flex flex-col p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"flex items-start gap-4 cursor-pointer",onClick:()=>w(B),children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:B.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:B.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:B.description})]}),e.jsx("button",{className:It("flex-shrink-0 p-1 transition-colors",V?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:Q=>N(Q,B.id),children:e.jsx(kx,{className:It("h-5 w-5",V&&"fill-current")})})]}),Y&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:Q=>Q.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},B.id)})})]}),q&&U&&M.length===0&&L.length===0&&i&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:[e.jsx(cn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No results found"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Try a different search term"})]})]})},l$t=()=>{const t=fr(),[s,r]=k.useState(""),[n,a]=k.useState("all"),[o,l]=k.useState("all"),[i,c]=k.useState("grid"),{data:u=[]}=mt({queryKey:["template-categories"],queryFn:async()=>{const{data:N,error:S}=await H.from("template_categories").select("*").order("name");if(S)throw S;return N}}),{data:p=[]}=mt({queryKey:["template-types"],queryFn:async()=>{const{data:N,error:S}=await H.from("template_types").select("*").order("name");if(S)throw S;return N}}),{data:f=[],isLoading:g}=mt({queryKey:["canva-templates"],queryFn:async()=>{const{data:N,error:S}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(S)throw S;const{data:M,error:L}=await H.from("template_links").select("*").order("sort_order");if(L)throw L;const{data:I}=await H.from("template_likes").select("template_id"),{data:O}=await H.from("template_comments").select("template_id"),q=new Map;I==null||I.forEach(V=>{q.set(V.template_id,(q.get(V.template_id)||0)+1)});const U=new Map;return O==null||O.forEach(V=>{U.set(V.template_id,(U.get(V.template_id)||0)+1)}),(N||[]).map(V=>({...V,links:(M||[]).filter(Y=>Y.template_id===V.id)||[],likesCount:q.get(V.id)||0,commentsCount:U.get(V.id)||0}))}}),b=f.filter(N=>{var I;const S=N.name.toLowerCase().includes(s.toLowerCase())||((I=N.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase())),M=n==="all"||N.category_id===n,L=o==="all"||N.type_id===o;return S&&M&&L}),_=()=>{r(""),a("all"),l("all")},j=s||n!=="all"||o!=="all",w=N=>{t(`/templates/${N}`)};return e.jsx(Ms,{title:"Canva Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Canva Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse and use our collection of professionally designed templates"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search templates...",value:s,onChange:N=>r(N.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:n,onValueChange:a,children:[e.jsx(Hs,{className:"w-full sm:w-48",children:e.jsx(Ys,{placeholder:"All Categories"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Categories"}),u.map(N=>e.jsx(Mt,{value:N.id,children:N.name},N.id))]})]}),e.jsxs(Ks,{value:o,onValueChange:l,children:[e.jsx(Hs,{className:"w-full sm:w-48",children:e.jsx(Ys,{placeholder:"All Types"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),p.map(N=>e.jsx(Mt,{value:N.id,children:N.name},N.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[j&&e.jsx(K,{variant:"outline",size:"sm",onClick:_,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>c("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>c("list"),className:"rounded-full",children:e.jsx(Mh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[b.length," template",b.length!==1?"s":""," found"]}),g&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((N,S)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ys,{className:"h-5 w-16"}),e.jsx(ys,{className:"h-5 w-20"})]})]})},S))}),!g&&b.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:j?"No templates match your filters":"No templates available yet"}),j&&e.jsx(K,{variant:"outline",onClick:_,children:"Clear Filters"})]}),!g&&b.length>0&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:b.map(N=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>w(N.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[N.preview_image_url?e.jsx("img",{src:N.preview_image_url,alt:N.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),N.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(st,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Bo,{className:"h-3 w-3"}),N.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${i==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:N.name}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:jde(N.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[N.category&&e.jsx(st,{variant:"secondary",className:"text-xs",children:N.category.name}),N.type&&e.jsx(st,{variant:"outline",className:"text-xs",children:N.type.name})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3.5 w-3.5"}),N.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3.5 w-3.5"}),N.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:S=>{S.stopPropagation(),w(N.id)},children:[e.jsx(tn,{className:"h-4 w-4"}),"View Template"]})]})]},N.id))})]})})};var c$t="Separator",o8e="horizontal",d$t=["horizontal","vertical"],wet=k.forwardRef((t,s)=>{const{decorative:r,orientation:n=o8e,...a}=t,o=u$t(n)?n:o8e,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(nn.div,{"data-orientation":o,...i,...a,ref:s})});wet.displayName=c$t;function u$t(t){return d$t.includes(t)}var jet=wet;const rl=k.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(jet,{ref:a,decorative:r,orientation:s,className:It("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));rl.displayName=jet.displayName;const GO=()=>({trackEngagement:k.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await H.auth.getUser();if(!o)return;await H.from("content_engagement_logs").insert({user_id:o.id,resource_type:s,resource_id:r,resource_title:n,action_type:a})}catch(o){console.error("Error tracking engagement:",o)}},[])}),h$t=()=>{const{templateId:t}=yo(),s=fr(),{user:r,isAdmin:n}=Ds(),{toast:a}=Ua(),o=Qt(),{trackEngagement:l}=GO(),[i,c]=k.useState(""),{data:u,isLoading:p}=mt({queryKey:["template-detail",t],queryFn:async()=>{const{data:L,error:I}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(I)throw I;const{data:O}=await H.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:q}=await H.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...L,links:O||[],guides:q||[]}},enabled:!!t}),{data:f=[]}=mt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:L,error:I}=await H.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(I)throw I;return(L||[]).map(O=>O.resource_kits).filter(Boolean)},enabled:!!t});k.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:g=[]}=mt({queryKey:["template-likes",t],queryFn:async()=>{const{data:L,error:I}=await H.from("template_likes").select("*").eq("template_id",t);if(I)throw I;return L},enabled:!!t}),{data:b=[]}=mt({queryKey:["template-comments",t],queryFn:async()=>{const{data:L,error:I}=await H.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(I)throw I;const O=[...new Set(L.map(B=>B.user_id))],{data:q}=await H.from("profiles").select("id, name").in("id",O),U=new Map((q==null?void 0:q.map(B=>[B.id,B.name]))||[]);return L.map(B=>({...B,user_name:U.get(B.user_id)||"Unknown User"}))},enabled:!!t}),_=Lt({mutationFn:async L=>{const{error:I}=await H.from("template_comments").insert({template_id:t,user_id:r.id,content:L});if(I)throw I},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),c(""),a({title:"Comment added!"})},onError:L=>{a({title:"Error adding comment",description:L.message,variant:"destructive"})}}),j=Lt({mutationFn:async L=>{const{error:I}=await H.from("template_comments").delete().eq("id",L);if(I)throw I},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),w=Lt({mutationFn:async()=>{const L=g.find(I=>I.user_id===(r==null?void 0:r.id));if(L){const{error:I}=await H.from("template_likes").delete().eq("id",L.id);if(I)throw I}else{const{error:I}=await H.from("template_likes").insert({template_id:t,user_id:r.id});if(I)throw I}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),N=g.some(L=>L.user_id===(r==null?void 0:r.id)),S=L=>L.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),M=L=>{L.preventDefault(),!(!i.trim()||!r)&&_.mutate(i.trim())};return p?e.jsx(Ms,{title:"Templates",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):u?e.jsx(Ms,{title:u.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Pi,{to:"/templates",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Templates"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:u.name}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.category&&e.jsx(st,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(st,{variant:"outline",children:u.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(Pi,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(lE,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:N?"default":"outline",className:"gap-2 rounded-full",onClick:()=>w.mutate(),disabled:!r||w.isPending,children:[e.jsx(sh,{className:`h-4 w-4 ${N?"fill-current":""}`}),g.length," ",g.length===1?"Like":"Likes"]})]})]}),u.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&>p]:mb-4 [&>p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:u.description}})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Bo,{className:"h-4 w-4"}),u.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:u.links.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_canva"),window.open(L.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(tn,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]})}),u.video_url&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("div",{className:"aspect-video w-full rounded-lg overflow-hidden",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})}),u.guides&&u.guides.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Sn,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_pdf"),window.open(L.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:L.name}),L.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(L.file_size/1024).toFixed(0)," KB)"]})]}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]})}),f.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Ml,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:f.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${L.id}`),children:[L.featured_image_url?e.jsx("img",{src:L.featured_image_url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(Ml,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:L.name})]},L.id))})]})}),e.jsx(rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx($c,{className:"h-5 w-5"}),"Comments (",b.length,")"]}),r?e.jsxs("form",{onSubmit:M,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:i,onChange:L=>c(L.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||_.isPending,children:e.jsx(Bn,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:b.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):b.map(L=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:S(L.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:L.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Uc(new Date(L.created_at),{addSuffix:!0})}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>j.mutate(L.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:L.content})]})]})})},L.id))})]})]})}):e.jsx(Ms,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Bo,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Template not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This template may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(Pi,{to:"/templates",children:"Back to Templates"})})]})})},m$t=()=>{const{user:t}=Ds(),[s,r]=k.useState(""),[n,a]=k.useState("all"),{data:o=[]}=mt({queryKey:["academy-categories"],queryFn:async()=>{const{data:g,error:b}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(b)throw b;return g}}),{data:l=[],isLoading:i}=mt({queryKey:["academy-videos"],queryFn:async()=>{const{data:g,error:b}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(b)throw b;const{data:_,error:j}=await H.from("academy_resources").select("*").order("sort_order");if(j)throw j;return g.map(N=>({...N,resources:(_==null?void 0:_.filter(S=>S.video_id===N.id))||[]}))}}),{data:c=[]}=mt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:g,error:b}=await H.from("academy_video_likes").select("video_id, user_id");if(b)throw b;return g}}),u=l.filter(g=>{var j;const b=s===""||g.title.toLowerCase().includes(s.toLowerCase())||((j=g.description)==null?void 0:j.toLowerCase().includes(s.toLowerCase())),_=n==="all"||g.category_id===n;return b&&_}),p=g=>c.filter(b=>b.video_id===g).length,f=g=>c.some(b=>b.video_id===g&&b.user_id===(t==null?void 0:t.id));return e.jsx(Ms,{title:"Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Academy"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"On-demand training videos and resources"})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-4",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos...",value:s,onChange:g=>r(g.target.value),className:"pl-10"})]})}),e.jsx(ba,{value:n,onValueChange:a,children:e.jsxs(pa,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(ns,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(g=>e.jsx(ns,{value:g.id,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:g.name},g.id))]})}),i?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(An,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No videos found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s?"Try adjusting your search terms":"Check back soon for new content"})]})}):e.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:u.map(g=>e.jsx(Pi,{to:`/academy/${g.id}`,children:e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow group h-full",children:[e.jsxs("div",{className:"relative aspect-video bg-muted",children:[g.thumbnail_url?e.jsx("img",{src:g.thumbnail_url,alt:g.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(An,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/90 flex items-center justify-center",children:e.jsx(nl,{className:"h-8 w-8 text-primary-foreground ml-1"})})}),g.duration&&e.jsxs("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-2 py-1 rounded flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),g.duration]})]}),e.jsxs(Pt,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Rt,{className:"text-lg line-clamp-2",children:g.title})}),g.category&&e.jsx(st,{variant:"secondary",className:"w-fit",children:g.category.name})]}),e.jsxs(Oe,{className:"pt-0",children:[g.description&&e.jsx(gr,{className:"line-clamp-2",children:g.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:`h-4 w-4 ${f(g.id)?"fill-primary text-primary":""}`}),p(g.id)]}),g.resources&&g.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4"}),g.resources.length]})]})]})]})},g.id))})]})})};function Net({resourceType:t,resourceId:s}){const{data:r=[]}=mt({queryKey:["linked-templates",t,s],queryFn:async()=>{if(t==="academy_video"){const{data:n,error:a}=await H.from("academy_video_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("video_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}else{const{data:n,error:a}=await H.from("resource_kit_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("kit_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}},enabled:!!s});return r.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(ic,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(Pi,{to:`/templates/${n.id}`,children:e.jsxs(st,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 transition-colors gap-1.5 px-3 py-1.5 text-xs font-medium rounded-full",children:[e.jsx(ic,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const p$t=(t,s)=>{if(s==="bunny_stream"){let r=t.replace("iframe.mediadelivery.net","player.mediadelivery.net");return r.includes("?")||(r+="?autoplay=false&loop=false&muted=false&preload=true&responsive=true"),r}if(s==="youtube"){const r=/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=t.match(r);if(n)return`https://www.youtube.com/embed/${n[1]}`}if(s==="vimeo"){const r=/vimeo\.com\/(?:video\/)?(\d+)/,n=t.match(r);if(n)return`https://player.vimeo.com/video/${n[1]}`}if(s==="loom"){const r=/loom\.com\/share\/([a-zA-Z0-9]+)/,n=t.match(r);if(n)return`https://www.loom.com/embed/${n[1]}`}return t},f$t=()=>{const{videoId:t}=yo();fr();const{user:s,isAdmin:r}=Ds(),{toast:n}=Ua(),a=Qt(),{trackEngagement:o}=GO(),[l,i]=k.useState(""),{data:c,isLoading:u}=mt({queryKey:["academy-video",t],queryFn:async()=>{const{data:M,error:L}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(L)throw L;const{data:I}=await H.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...M,resources:I||[]}},enabled:!!t});k.useEffect(()=>{c&&o("academy_video",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:p=[]}=mt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:M,error:L}=await H.from("academy_video_likes").select("*").eq("video_id",t);if(L)throw L;return M},enabled:!!t}),{data:f=[]}=mt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:M,error:L}=await H.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(L)throw L;const I=[...new Set(M.map(U=>U.user_id))],{data:O}=await H.from("profiles").select("id, name").in("id",I),q=new Map((O==null?void 0:O.map(U=>[U.id,U.name]))||[]);return M.map(U=>({...U,user_name:q.get(U.user_id)||"Unknown User"}))},enabled:!!t}),g=Lt({mutationFn:async M=>{const{error:L}=await H.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:M});if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:M=>{n({title:"Error adding comment",description:M.message,variant:"destructive"})}}),b=Lt({mutationFn:async M=>{const{error:L}=await H.from("academy_video_comments").delete().eq("id",M);if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),_=Lt({mutationFn:async()=>{const M=p.find(L=>L.user_id===(s==null?void 0:s.id));if(M){const{error:L}=await H.from("academy_video_likes").delete().eq("id",M.id);if(L)throw L}else{const{error:L}=await H.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(L)throw L}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),j=p.some(M=>M.user_id===(s==null?void 0:s.id)),w=M=>{switch(M==null?void 0:M.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},N=M=>M.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),S=M=>{M.preventDefault(),!(!l.trim()||!s)&&g.mutate(l.trim())};return u?e.jsx(Ms,{title:"Academy",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):c?e.jsx(Ms,{title:c.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Pi,{to:"/academy",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Academy"]})}),e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-black",style:{paddingTop:"56.25%"},children:["youtube","vimeo","loom","bunny_stream"].includes(c.video_type)?e.jsx("iframe",{src:p$t(c.video_url,c.video_type),loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,height:"100%",width:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-white gap-4",children:[e.jsx(An,{className:"h-16 w-16 opacity-50"}),e.jsx(K,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:c.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(tn,{className:"h-4 w-4"}),"Open Video"]})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:c.title}),c.category&&e.jsx(st,{variant:"secondary",children:c.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(Pi,{to:`/admin/academy?edit=${c.id}`,children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(lE,{resourceType:"academy_video",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(sh,{className:`h-4 w-4 ${j?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),c.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:c.description}})]}),c.resources&&c.resources.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Sn,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:c.resources.map(M=>e.jsxs("a",{href:M.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted transition-colors",children:[e.jsx("span",{className:"text-2xl",children:w(M.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:M.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:M.file_type})]}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]},M.id))})]})}),e.jsx(Net,{resourceType:"academy_video",resourceId:c.id}),e.jsx(rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx($c,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:l,onChange:M=>i(M.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||g.isPending,children:e.jsx(Bn,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(M=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:N(M.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:M.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Uc(new Date(M.created_at),{addSuffix:!0})}),M.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>b.mutate(M.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:M.content})]})]})})},M.id))})]})]})}):e.jsx(Ms,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(An,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Video not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This video may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(Pi,{to:"/academy",children:"Back to Academy"})})]})})};function x$t(){const t=fr(),[s,r]=k.useState(""),{data:n,isLoading:a}=mt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;return b}}),{data:o}=mt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(_)throw _;return b}}),{data:l}=mt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kit_likes").select("kit_id");if(_)throw _;return b}}),{data:i}=mt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kit_comments").select("kit_id");if(_)throw _;return b}}),c=n==null?void 0:n.filter(b=>{var _;return b.name.toLowerCase().includes(s.toLowerCase())||((_=b.description)==null?void 0:_.toLowerCase().includes(s.toLowerCase()))}),u=b=>(o==null?void 0:o.filter(_=>_.kit_id===b))||[],p=b=>(l==null?void 0:l.filter(_=>_.kit_id===b).length)||0,f=b=>(i==null?void 0:i.filter(_=>_.kit_id===b).length)||0,g=b=>{t(`/toolbox/${b}`)};return e.jsx(Ms,{title:"Toolbox",description:"Download resource kits and tools to help grow your business",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Toolbox"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Download resource kits and tools to help grow your business"})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search resource kits...",value:s,onChange:b=>r(b.target.value),className:"pl-10"})]}),!a&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(c==null?void 0:c.length)||0," resource kit",(c==null?void 0:c.length)!==1?"s":""," available"]}),a?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((b,_)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"}),e.jsx(ys,{className:"h-4 w-2/3"})]})},_))}):(c==null?void 0:c.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(Ml,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resource kits found"}),e.jsx("p",{className:"text-muted-foreground",children:s?"Try adjusting your search terms":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:c==null?void 0:c.map(b=>{const _=u(b.id).length,j=p(b.id),w=f(b.id);return e.jsxs(Ee,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>g(b.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:b.featured_image_url?e.jsx("img",{src:b.featured_image_url,alt:b.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Ml,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:b.name}),b.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:jde(b.description)}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4"}),_," file",_!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3.5 w-3.5"}),j]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3.5 w-3.5"}),w]})]})]})]})]},b.id)})})]})})}const g$t=()=>{const{kitId:t}=yo(),{user:s,isAdmin:r}=Ds(),{toast:n}=Ua(),a=Qt(),{trackEngagement:o}=GO(),[l,i]=k.useState(""),{data:c,isLoading:u}=mt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:M,error:L}=await H.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(L)throw L;const{data:I}=await H.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:O}=await H.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...M,files:I||[],links:O||[]}},enabled:!!t});k.useEffect(()=>{c&&o("toolbox",c.id,c.name,"view")},[c==null?void 0:c.id]);const{data:p=[]}=mt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:M,error:L}=await H.from("resource_kit_likes").select("*").eq("kit_id",t);if(L)throw L;return M},enabled:!!t}),{data:f=[]}=mt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:M,error:L}=await H.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(L)throw L;const I=[...new Set(M.map(U=>U.user_id))],{data:O}=await H.from("profiles").select("id, name").in("id",I),q=new Map((O==null?void 0:O.map(U=>[U.id,U.name]))||[]);return M.map(U=>({...U,user_name:q.get(U.user_id)||"Unknown User"}))},enabled:!!t}),g=Lt({mutationFn:async M=>{const{error:L}=await H.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:M});if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:M=>{n({title:"Error adding comment",description:M.message,variant:"destructive"})}}),b=Lt({mutationFn:async M=>{const{error:L}=await H.from("resource_kit_comments").delete().eq("id",M);if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),_=Lt({mutationFn:async()=>{const M=p.find(L=>L.user_id===(s==null?void 0:s.id));if(M){const{error:L}=await H.from("resource_kit_likes").delete().eq("id",M.id);if(L)throw L}else{const{error:L}=await H.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(L)throw L}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),j=p.some(M=>M.user_id===(s==null?void 0:s.id)),w=M=>M.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),N=M=>M?M<1024?M+" B":M<1024*1024?(M/1024).toFixed(1)+" KB":(M/(1024*1024)).toFixed(1)+" MB":"",S=M=>{M.preventDefault(),!(!l.trim()||!s)&&g.mutate(l.trim())};return u?e.jsx(Ms,{title:"Toolbox",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):c?e.jsx(Ms,{title:c.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Pi,{to:"/toolbox",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Toolbox"]})}),c.featured_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:c.featured_image_url,alt:c.name,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:c.name})}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(Pi,{to:`/admin/toolbox?edit=${c.id}`,children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(lE,{resourceType:"resource_kit",resourceId:c.id,resourceTitle:c.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 rounded-full",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(sh,{className:`h-4 w-4 ${j?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),c.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:c.description}})]}),c.files&&c.files.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Sn,{className:"h-4 w-4"}),"Included Resources (",c.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:c.files.map(M=>e.jsxs("a",{href:M.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",c.id,c.name,"click_pdf"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(Sn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:M.name}),M.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:N(M.file_size)})]})]}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},M.id))})]})}),c.links&&c.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(tn,{className:"h-4 w-4"}),"Canva Templates (",c.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:c.links.map(M=>e.jsxs("a",{href:M.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",c.id,c.name,"click_canva"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-purple-500/10",children:e.jsx(tn,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:M.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},M.id))})]})}),e.jsx(Net,{resourceType:"resource_kit",resourceId:c.id}),e.jsx(rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx($c,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:l,onChange:M=>i(M.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||g.isPending,children:e.jsx(Bn,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(M=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:w(M.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:M.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Uc(new Date(M.created_at),{addSuffix:!0})}),M.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>b.mutate(M.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:M.content})]})]})})},M.id))})]})]})}):e.jsx(Ms,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ml,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Resource kit not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource kit may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(Pi,{to:"/toolbox",children:"Back to Toolbox"})})]})})},y$t=()=>{const t=fr(),[s,r]=k.useState(""),[n,a]=k.useState("grid"),{data:o=[],isLoading:l}=mt({queryKey:["social-swag"],queryFn:async()=>{const{data:u,error:p}=await H.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(p)throw p;const{data:f,error:g}=await H.from("social_swag_links").select("*").order("sort_order");if(g)throw g;const{data:b}=await H.from("social_swag_likes").select("swag_id"),{data:_}=await H.from("social_swag_comments").select("swag_id"),j=new Map;b==null||b.forEach(S=>{j.set(S.swag_id,(j.get(S.swag_id)||0)+1)});const w=new Map;return _==null||_.forEach(S=>{w.set(S.swag_id,(w.get(S.swag_id)||0)+1)}),(u||[]).map(S=>({...S,links:(f||[]).filter(M=>M.swag_id===S.id)||[],likesCount:j.get(S.id)||0,commentsCount:w.get(S.id)||0}))}}),i=o.filter(u=>{var f;return u.title.toLowerCase().includes(s.toLowerCase())||((f=u.description)==null?void 0:f.toLowerCase().includes(s.toLowerCase()))}),c=u=>{t(`/social-swag/${u}`)};return e.jsx(Ms,{title:"Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Social Swag"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse our collection of social media content and graphics"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search social swag...",value:s,onChange:u=>r(u.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Mh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," item",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((u,p)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"})]})},p))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No items match your search":"No social swag available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(u=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${n==="list"?"flex flex-row":""}`,onClick:()=>c(u.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${n==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[u.preview_image_url?e.jsx("img",{src:u.preview_image_url,alt:u.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),u.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(st,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Bo,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${n==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:u.title}),u.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:u.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:p=>{p.stopPropagation(),c(u.id)},children:[e.jsx(tn,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var Ni=function(){return Ni=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(c||!u),f=s>1&&(u||!c),g=function(){n&&o(n)},b=function(){a&&o(a)};return e.jsx(X$t,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:g,onNextClick:b})}function Q$t(t){var s,r=lc(),n=r.classNames,a=r.disableNavigation,o=r.styles,l=r.captionLayout,i=r.components,c=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:Met,u;return a?u=e.jsx(c,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(l8e,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(l8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(c8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):u=e.jsxs(e.Fragment,{children:[e.jsx(c,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(c8e,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function J$t(t){var s=lc(),r=s.footer,n=s.styles,a=s.classNames.tfoot;return r?e.jsx("tfoot",{className:a,style:n.tfoot,children:e.jsx("tr",{children:e.jsx("td",{colSpan:8,children:r})})}):e.jsx(e.Fragment,{})}function eqt(t,s,r){for(var n=r?A1(new Date):Xh(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=Pl(n,o);a.push(l)}return a}function tqt(){var t=lc(),s=t.classNames,r=t.styles,n=t.showWeekNumber,a=t.locale,o=t.weekStartsOn,l=t.ISOWeek,i=t.formatters.formatWeekdayName,c=t.labels.labelWeekday,u=eqt(a,o,l);return e.jsxs("tr",{style:r.head_row,className:s.head_row,children:[n&&e.jsx("td",{style:r.head_cell,className:s.head_cell}),u.map(function(p,f){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":c(p,{locale:a}),children:i(p,{locale:a})},f)})]})}function sqt(){var t,s=lc(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:tqt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function rqt(t){var s=lc(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var Nke=k.createContext(void 0);function nqt(t){if(!KO(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(Nke.Provider,{value:s,children:t.children})}return e.jsx(aqt,{initialProps:t.initialProps,children:t.children})}function aqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,f){var g,b;(g=s.onDayClick)===null||g===void 0||g.call(s,u,p,f);var _=!!(p.selected&&a&&(n==null?void 0:n.length)===a);if(!_){var j=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!j){var w=n?ket([],n):[];if(p.selected){var N=w.findIndex(function(S){return Cl(u,S)});w.splice(N,1)}else w.push(u);(b=s.onSelect)===null||b===void 0||b.call(s,w,u,p,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,f=n.some(function(g){return Cl(g,u)});return!!(p&&!f)});var c={selected:n,onDayClick:l,modifiers:i};return e.jsx(Nke.Provider,{value:c,children:r})}function kke(){var t=k.useContext(Nke);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function iqt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?Cl(a,t)&&Cl(n,t)?void 0:Cl(a,t)?{from:a,to:void 0}:Cl(n,t)?void 0:US(n,t)?{from:t,to:a}:{from:n,to:t}:a?US(t,a)?{from:a,to:t}:{from:t,to:a}:n?VS(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var Ske=k.createContext(void 0);function oqt(t){if(!ZO(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(Ske.Provider,{value:s,children:t.children})}return e.jsx(lqt,{initialProps:t.initialProps,children:t.children})}function lqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=n||{},o=a.from,l=a.to,i=s.min,c=s.max,u=function(b,_,j){var w,N;(w=s.onDayClick)===null||w===void 0||w.call(s,b,_,j);var S=iqt(b,n);(N=s.onSelect)===null||N===void 0||N.call(s,S,b,_,j)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],Cl(o,l)||(p.range_middle=[{after:o,before:l}])):p.range_end=[o]):l&&(p.range_start=[l],p.range_end=[l]),i&&(o&&!l&&p.disabled.push({after:mie(o,i-1),before:Pl(o,i-1)}),o&&l&&p.disabled.push({after:o,before:Pl(o,i-1)}),!o&&l&&p.disabled.push({after:mie(l,i-1),before:Pl(l,i-1)})),c){if(o&&!l&&(p.disabled.push({before:Pl(o,-c+1)}),p.disabled.push({after:Pl(o,c-1)})),o&&l){var f=mf(l,o)+1,g=c-f;p.disabled.push({before:mie(o,g)}),p.disabled.push({after:Pl(l,g)})}!o&&l&&(p.disabled.push({before:Pl(l,-c+1)}),p.disabled.push({after:Pl(l,c-1)}))}return e.jsx(Ske.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function Cke(){var t=k.useContext(Ske);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Eie(t){return Array.isArray(t)?ket([],t):t!==void 0?[t]:[]}function cqt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=Eie(a)}),s}var dy;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(dy||(dy={}));var dqt=dy.Selected,Sv=dy.Disabled,uqt=dy.Hidden,hqt=dy.Today,Cge=dy.RangeEnd,Mge=dy.RangeMiddle,Tge=dy.RangeStart,mqt=dy.Outside;function pqt(t,s,r){var n,a=(n={},n[dqt]=Eie(t.selected),n[Sv]=Eie(t.disabled),n[uqt]=Eie(t.hidden),n[hqt]=[t.today],n[Cge]=[],n[Mge]=[],n[Tge]=[],n[mqt]=[],n);return t.fromDate&&a[Sv].push({before:t.fromDate}),t.toDate&&a[Sv].push({after:t.toDate}),KO(t)?a[Sv]=a[Sv].concat(s.modifiers[Sv]):ZO(t)&&(a[Sv]=a[Sv].concat(r.modifiers[Sv]),a[Tge]=r.modifiers[Tge],a[Mge]=r.modifiers[Mge],a[Cge]=r.modifiers[Cge]),a}var Eet=k.createContext(void 0);function fqt(t){var s=lc(),r=kke(),n=Cke(),a=pqt(s,r,n),o=cqt(s.modifiers),l=Ni(Ni({},a),o);return e.jsx(Eet.Provider,{value:l,children:t.children})}function Pet(){var t=k.useContext(Eet);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function xqt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function gqt(t){return!!(t&&typeof t=="object"&&"from"in t)}function yqt(t){return!!(t&&typeof t=="object"&&"after"in t)}function vqt(t){return!!(t&&typeof t=="object"&&"before"in t)}function bqt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function _qt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=mf(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=mf(t,n)>=0&&mf(a,t)>=0;return l}return a?Cl(a,t):n?Cl(n,t):!1}function wqt(t){return pje(t)}function jqt(t){return Array.isArray(t)&&t.every(pje)}function Nqt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(wqt(r))return Cl(t,r);if(jqt(r))return r.includes(t);if(gqt(r))return _qt(t,r);if(bqt(r))return r.dayOfWeek.includes(t.getDay());if(xqt(r)){var n=mf(r.before,t),a=mf(r.after,t),o=n>0,l=a<0,i=US(r.before,r.after);return i?l&&o:o||l}return yqt(r)?mf(t,r.after)>0:vqt(r)?mf(r.before,t)>0:typeof r=="function"?r(t):!1})}function Mke(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return Nqt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!sue(t,r)&&(a.outside=!0),a}function kqt(t,s){for(var r=Fc(t[0]),n=cx(t[t.length-1]),a,o,l=r;l<=n;){var i=Mke(l,s),c=!i.disabled&&!i.hidden;if(!c){l=Pl(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=Pl(l,1)}return o||a}var Sqt=365;function Iet(t,s){var r=s.moveBy,n=s.direction,a=s.context,o=s.modifiers,l=s.retry,i=l===void 0?{count:0,lastFocused:t}:l,c=a.weekStartsOn,u=a.fromDate,p=a.toDate,f=a.locale,g={day:Pl,week:y4,month:Bm,year:d4t,startOfWeek:function(w){return a.ISOWeek?A1(w):Xh(w,{locale:f,weekStartsOn:c})},endOfWeek:function(w){return a.ISOWeek?jGe(w):eue(w,{locale:f,weekStartsOn:c})}},b=g[r](t,n==="after"?1:-1);n==="before"&&u?b=u4t([u,b]):n==="after"&&p&&(b=h4t([p,b]));var _=!0;if(o){var j=Mke(b,o);_=!j.disabled&&!j.hidden}return _?b:i.count>Sqt?i.lastFocused:Iet(b,{moveBy:r,direction:n,context:a,modifiers:o,retry:Ni(Ni({},i),{count:i.count+1})})}var Let=k.createContext(void 0);function Cqt(t){var s=YO(),r=Pet(),n=k.useState(),a=n[0],o=n[1],l=k.useState(),i=l[0],c=l[1],u=kqt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){c(a),o(void 0)},g=function(w){o(w)},b=lc(),_=function(w,N){if(a){var S=Iet(a,{moveBy:w,direction:N,context:b,modifiers:r});Cl(a,S)||(s.goToDate(S,a),g(S))}},j={focusedDay:a,focusTarget:p,blur:f,focus:g,focusDayAfter:function(){return _("day","after")},focusDayBefore:function(){return _("day","before")},focusWeekAfter:function(){return _("week","after")},focusWeekBefore:function(){return _("week","before")},focusMonthBefore:function(){return _("month","before")},focusMonthAfter:function(){return _("month","after")},focusYearBefore:function(){return _("year","before")},focusYearAfter:function(){return _("year","after")},focusStartOfWeek:function(){return _("startOfWeek","before")},focusEndOfWeek:function(){return _("endOfWeek","after")}};return e.jsx(Let.Provider,{value:j,children:t.children})}function Tke(){var t=k.useContext(Let);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function Mqt(t,s){var r=Pet(),n=Mke(t,r,s);return n}var Ake=k.createContext(void 0);function Tqt(t){if(!Uue(t.initialProps)){var s={selected:void 0};return e.jsx(Ake.Provider,{value:s,children:t.children})}return e.jsx(Aqt,{initialProps:t.initialProps,children:t.children})}function Aqt(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var c,u,p;if((c=s.onDayClick)===null||c===void 0||c.call(s,o,l,i),l.selected&&!s.required){(u=s.onSelect)===null||u===void 0||u.call(s,void 0,o,l,i);return}(p=s.onSelect)===null||p===void 0||p.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(Ake.Provider,{value:a,children:r})}function Det(){var t=k.useContext(Ake);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function Eqt(t,s){var r=lc(),n=Det(),a=kke(),o=Cke(),l=Tke(),i=l.focusDayAfter,c=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,f=l.blur,g=l.focus,b=l.focusMonthBefore,_=l.focusMonthAfter,j=l.focusYearBefore,w=l.focusYearAfter,N=l.focusStartOfWeek,S=l.focusEndOfWeek,M=function(oe){var ce,ge,ye,ue;Uue(r)?(ce=n.onDayClick)===null||ce===void 0||ce.call(n,t,s,oe):KO(r)?(ge=a.onDayClick)===null||ge===void 0||ge.call(a,t,s,oe):ZO(r)?(ye=o.onDayClick)===null||ye===void 0||ye.call(o,t,s,oe):(ue=r.onDayClick)===null||ue===void 0||ue.call(r,t,s,oe)},L=function(oe){var ce;g(t),(ce=r.onDayFocus)===null||ce===void 0||ce.call(r,t,s,oe)},I=function(oe){var ce;f(),(ce=r.onDayBlur)===null||ce===void 0||ce.call(r,t,s,oe)},O=function(oe){var ce;(ce=r.onDayMouseEnter)===null||ce===void 0||ce.call(r,t,s,oe)},q=function(oe){var ce;(ce=r.onDayMouseLeave)===null||ce===void 0||ce.call(r,t,s,oe)},U=function(oe){var ce;(ce=r.onDayPointerEnter)===null||ce===void 0||ce.call(r,t,s,oe)},B=function(oe){var ce;(ce=r.onDayPointerLeave)===null||ce===void 0||ce.call(r,t,s,oe)},V=function(oe){var ce;(ce=r.onDayTouchCancel)===null||ce===void 0||ce.call(r,t,s,oe)},Y=function(oe){var ce;(ce=r.onDayTouchEnd)===null||ce===void 0||ce.call(r,t,s,oe)},Q=function(oe){var ce;(ce=r.onDayTouchMove)===null||ce===void 0||ce.call(r,t,s,oe)},ee=function(oe){var ce;(ce=r.onDayTouchStart)===null||ce===void 0||ce.call(r,t,s,oe)},X=function(oe){var ce;(ce=r.onDayKeyUp)===null||ce===void 0||ce.call(r,t,s,oe)},ie=function(oe){var ce;switch(oe.key){case"ArrowLeft":oe.preventDefault(),oe.stopPropagation(),r.dir==="rtl"?i():c();break;case"ArrowRight":oe.preventDefault(),oe.stopPropagation(),r.dir==="rtl"?c():i();break;case"ArrowDown":oe.preventDefault(),oe.stopPropagation(),u();break;case"ArrowUp":oe.preventDefault(),oe.stopPropagation(),p();break;case"PageUp":oe.preventDefault(),oe.stopPropagation(),oe.shiftKey?j():b();break;case"PageDown":oe.preventDefault(),oe.stopPropagation(),oe.shiftKey?w():_();break;case"Home":oe.preventDefault(),oe.stopPropagation(),N();break;case"End":oe.preventDefault(),oe.stopPropagation(),S();break}(ce=r.onDayKeyDown)===null||ce===void 0||ce.call(r,t,s,oe)},re={onClick:M,onFocus:L,onBlur:I,onKeyDown:ie,onKeyUp:X,onMouseEnter:O,onMouseLeave:q,onPointerEnter:U,onPointerLeave:B,onTouchCancel:V,onTouchEnd:Y,onTouchMove:Q,onTouchStart:ee};return re}function Pqt(){var t=lc(),s=Det(),r=kke(),n=Cke(),a=Uue(t)?s.selected:KO(t)?r.selected:ZO(t)?n.selected:void 0;return a}function Iqt(t){return Object.values(dy).includes(t)}function Lqt(t,s){var r=[t.classNames.day];return Object.keys(s).forEach(function(n){var a=t.modifiersClassNames[n];if(a)r.push(a);else if(Iqt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function Dqt(t,s){var r=Ni({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=Ni(Ni({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function Oqt(t,s,r){var n,a,o,l=lc(),i=Tke(),c=Mqt(t,s),u=Eqt(t,c),p=Pqt(),f=!!(l.onDayClick||l.mode!=="default");k.useEffect(function(){var O;c.outside||i.focusedDay&&f&&Cl(i.focusedDay,t)&&((O=r.current)===null||O===void 0||O.focus())},[i.focusedDay,t,r,f,c.outside]);var g=Lqt(l,c).join(" "),b=Dqt(l,c),_=!!(c.outside&&!l.showOutsideDays||c.hidden),j=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:rqt,w=e.jsx(j,{date:t,displayMonth:s,activeModifiers:c}),N={style:b,className:g,children:w,role:"gridcell"},S=i.focusTarget&&Cl(i.focusTarget,t)&&!c.outside,M=i.focusedDay&&Cl(i.focusedDay,t),L=Ni(Ni(Ni({},N),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=M||S?0:-1,n)),u),I={isButton:f,isHidden:_,activeModifiers:c,selectedDays:p,buttonProps:L,divProps:N};return I}function Rqt(t){var s=k.useRef(null),r=Oqt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(Rle,Ni({name:"day",ref:s},r.buttonProps)):e.jsx("div",Ni({},r.divProps))}function Fqt(t){var s=t.number,r=t.dates,n=lc(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,c=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,p=u(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:p});var f=c(Number(s),{locale:i}),g=function(b){a(s,r,b)};return e.jsx(Rle,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:g,children:p})}function zqt(t){var s,r,n=lc(),a=n.styles,o=n.classNames,l=n.showWeekNumber,i=n.components,c=(s=i==null?void 0:i.Day)!==null&&s!==void 0?s:Rqt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:Fqt,p;return l&&(p=e.jsx("td",{className:o.cell,style:a.cell,children:e.jsx(u,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:o.row,style:a.row,children:[p,t.dates.map(function(f){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(c,{displayMonth:t.displayMonth,date:f})},fSt(f))})]})}function d8e(t,s,r){for(var n=r!=null&&r.ISOWeek?jGe(s):eue(s,r),a=r!=null&&r.ISOWeek?A1(t):Xh(t,r),o=mf(n,a),l=[],i=0;i<=o;i++)l.push(Pl(a,i));var c=l.reduce(function(u,p){var f=r!=null&&r.ISOWeek?fje(p):gje(p,r),g=u.find(function(b){return b.weekNumber===f});return g?(g.dates.push(p),u):(u.push({weekNumber:f,dates:[p]}),u)},[]);return c}function Bqt(t,s){var r=d8e(Fc(t),cx(t),s);if(s!=null&&s.useFixedWeeks){var n=gSt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=y4(o,6-n),i=d8e(y4(o,1),l,s);r.push.apply(r,i)}}return r}function $qt(t){var s,r,n,a=lc(),o=a.locale,l=a.classNames,i=a.styles,c=a.hideHead,u=a.fixedWeeks,p=a.components,f=a.weekStartsOn,g=a.firstWeekContainsDate,b=a.ISOWeek,_=Bqt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:b,locale:o,weekStartsOn:f,firstWeekContainsDate:g}),j=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:sqt,w=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:zqt,N=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:J$t;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!c&&e.jsx(j,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:_.map(function(S){return e.jsx(w,{displayMonth:t.displayMonth,dates:S.dates,weekNumber:S.weekNumber},S.weekNumber)})}),e.jsx(N,{displayMonth:t.displayMonth})]})}function qqt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Uqt=qqt()?k.useLayoutEffect:k.useEffect,Age=!1,Vqt=0;function u8e(){return"react-day-picker-".concat(++Vqt)}function Hqt(t){var s,r=t??(Age?u8e():null),n=k.useState(r),a=n[0],o=n[1];return Uqt(function(){a===null&&o(u8e())},[]),k.useEffect(function(){Age===!1&&(Age=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function Wqt(t){var s,r,n=lc(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,c=YO().displayMonths,u=Hqt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),p=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,f=[o.month],g=l.month,b=t.displayIndex===0,_=t.displayIndex===c.length-1,j=!b&&!_;a==="rtl"&&(s=[b,_],_=s[0],b=s[1]),b&&(f.push(o.caption_start),g=Ni(Ni({},g),l.caption_start)),_&&(f.push(o.caption_end),g=Ni(Ni({},g),l.caption_end)),j&&(f.push(o.caption_between),g=Ni(Ni({},g),l.caption_between));var w=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:Q$t;return e.jsxs("div",{className:f.join(" "),style:g,children:[e.jsx(w,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx($qt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function Gqt(t){var s=lc(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function Kqt(t){var s,r,n=t.initialProps,a=lc(),o=Tke(),l=YO(),i=k.useState(!1),c=i[0],u=i[1];k.useEffect(function(){a.initialFocus&&o.focusTarget&&(c||(o.focus(o.focusTarget),u(!0)))},[a.initialFocus,c,o.focus,o.focusTarget,o]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var f=Ni(Ni({},a.styles.root),a.style),g=Object.keys(n).filter(function(_){return _.startsWith("data-")}).reduce(function(_,j){var w;return Ni(Ni({},_),(w={},w[j]=n[j],w))},{}),b=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:Gqt;return e.jsx("div",Ni({className:p.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},g,{children:e.jsx(b,{children:l.displayMonths.map(function(_,j){return e.jsx(Wqt,{displayIndex:j,displayMonth:_},j)})})}))}function Zqt(t){var s=t.children,r=v$t(t,["children"]);return e.jsx(F$t,{initialProps:r,children:e.jsx(K$t,{children:e.jsx(Tqt,{initialProps:r,children:e.jsx(nqt,{initialProps:r,children:e.jsx(oqt,{initialProps:r,children:e.jsx(fqt,{children:e.jsx(Cqt,{children:s})})})})})})})}function Yqt(t){return e.jsx(Zqt,Ni({},t,{children:e.jsx(Kqt,{initialProps:t})}))}function wf({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(Yqt,{showOutsideDays:r,className:It("p-3",t),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:It(X8({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:It(X8({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({...a})=>e.jsx(cl,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(da,{className:"h-4 w-4"})},...n})}wf.displayName="Calendar";var Vue="Popover",[Oet]=ad(Vue,[F0]),XO=F0(),[Xqt,Fw]=Oet(Vue),Ret=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=XO(s),c=k.useRef(null),[u,p]=k.useState(!1),[f,g]=ah({prop:n,defaultProp:a??!1,onChange:o,caller:Vue});return e.jsx(wO,{...i,children:e.jsx(Xqt,{scope:s,contentId:Tu(),triggerRef:c,open:f,onOpenChange:g,onOpenToggle:k.useCallback(()=>g(b=>!b),[g]),hasCustomAnchor:u,onCustomAnchorAdd:k.useCallback(()=>p(!0),[]),onCustomAnchorRemove:k.useCallback(()=>p(!1),[]),modal:l,children:r})})};Ret.displayName=Vue;var Fet="PopoverAnchor",Qqt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Fw(Fet,r),o=XO(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return k.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(qA,{...o,...n,ref:s})});Qqt.displayName=Fet;var zet="PopoverTrigger",Bet=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Fw(zet,r),o=XO(r),l=qa(s,a.triggerRef),i=e.jsx(nn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Het(a.open),...n,ref:l,onClick:Ir(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(qA,{asChild:!0,...o,children:i})});Bet.displayName=zet;var Eke="PopoverPortal",[Jqt,eUt]=Oet(Eke,{forceMount:void 0}),$et=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=Fw(Eke,s);return e.jsx(Jqt,{scope:s,forceMount:r,children:e.jsx(zd,{present:r||o.open,children:e.jsx(FA,{asChild:!0,container:a,children:n})})})};$et.displayName=Eke;var YT="PopoverContent",qet=k.forwardRef((t,s)=>{const r=eUt(YT,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=Fw(YT,t.__scopePopover);return e.jsx(zd,{present:n||o.open,children:o.modal?e.jsx(sUt,{...a,ref:s}):e.jsx(rUt,{...a,ref:s})})});qet.displayName=YT;var tUt=lw("PopoverContent.RemoveScroll"),sUt=k.forwardRef((t,s)=>{const r=Fw(YT,t.__scopePopover),n=k.useRef(null),a=qa(s,n),o=k.useRef(!1);return k.useEffect(()=>{const l=n.current;if(l)return Rde(l)},[]),e.jsx(MO,{as:tUt,allowPinchZoom:!0,children:e.jsx(Uet,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ir(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Ir(t.onPointerDownOutside,l=>{const i=l.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0,u=i.button===2||c;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Ir(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),rUt=k.forwardRef((t,s)=>{const r=Fw(YT,t.__scopePopover),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(Uet,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var c,u;(c=t.onInteractOutside)==null||c.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),Uet=k.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:p,...f}=t,g=Fw(YT,r),b=XO(r);return Lde(),e.jsx(SO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(kw,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>g.onOpenChange(!1),children:e.jsx(jO,{"data-state":Het(g.open),role:"dialog",id:g.contentId,...b,...f,ref:s,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Vet="PopoverClose",nUt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Fw(Vet,r);return e.jsx(nn.button,{type:"button",...n,ref:s,onClick:Ir(t.onClick,()=>a.onOpenChange(!1))})});nUt.displayName=Vet;var aUt="PopoverArrow",iUt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=XO(r);return e.jsx(NO,{...a,...n,ref:s})});iUt.displayName=aUt;function Het(t){return t?"open":"closed"}var oUt=Ret,lUt=Bet,cUt=$et,Wet=qet;const $o=oUt,qo=lUt,Ro=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(cUt,{children:e.jsx(Wet,{ref:a,align:s,sideOffset:r,className:It("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));Ro.displayName=Wet.displayName;const dUt=pC("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"}}),Pke=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:It(dUt({variant:s}),t),...r}));Pke.displayName="Alert";const uUt=k.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:It("mb-1 font-medium leading-none tracking-tight",t),...s}));uUt.displayName="AlertTitle";const Ike=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("text-sm [&_p]:leading-relaxed",t),...s}));Ike.displayName="AlertDescription";function hUt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=Qt(),[c,u]=k.useState(a),[p,f]=k.useState([]),[g,b]=k.useState(null),[_,j]=k.useState("now"),[w,N]=k.useState(o6e(m6e(new Date),1)),[S,M]=k.useState("12"),[L,I]=k.useState("00"),[O,q]=k.useState("PM");k.useEffect(()=>{if(t){u(a),j("now"),f([]);const _e=o6e(m6e(new Date),1);N(_e);const $e=_e.getHours();M(String($e>12?$e-12:$e===0?12:$e)),I("00"),q($e>=12?"PM":"AM")}},[t,a]);const U=()=>{if(!w)return null;let _e=parseInt(S);const $e=parseInt(L);return O==="PM"&&_e!==12&&(_e+=12),O==="AM"&&_e===12&&(_e=0),WL(HL(w,_e),$e)},{data:B,isLoading:V}=mt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:_e}}=await H.auth.getUser();if(!_e)return[];const{data:$e,error:Ae}=await H.from("social_accounts").select("*").eq("user_id",_e.id).eq("is_active",!0).order("platform",{ascending:!0});if(Ae)throw Ae;return console.log("Fetched social accounts for posting:",$e),$e},enabled:t,staleTime:0}),Y=Lt({mutationFn:async({accountId:_e,platform:$e})=>{b(_e);const{data:Ae,error:Ie}=await H.functions.invoke("social-post",{body:{platform:$e,accountId:_e,imageUrl:r,caption:c}});if(Ie)throw Ie;if(Ae!=null&&Ae.error)throw new Error(Ae.error);return Ae},onSuccess:_e=>{const $e=_e.platform==="facebook"?"Facebook":_e.platform==="instagram"?"Instagram":_e.platform==="linkedin"?"LinkedIn":"Google Business";me.success(`Posted to ${$e}!`)},onError:_e=>{me.error(`Failed to post: ${_e.message}`)},onSettled:()=>{b(null)}}),Q=Lt({mutationFn:async({accountId:_e,platform:$e,scheduledFor:Ae})=>{const{data:{user:Ie}}=await H.auth.getUser();if(!Ie)throw new Error("Not authenticated");const{error:Ce}=await H.from("scheduled_posts").insert({user_id:Ie.id,social_account_id:_e,platform:$e,image_url:r,caption:c,swag_item_id:o||null,reel_id:l||null,scheduled_for:Ae.toISOString(),status:"scheduled"});if(Ce)throw Ce;return{platform:$e}},onSuccess:_e=>{const $e=_e.platform==="facebook"?"Facebook":_e.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Post scheduled for ${$e}!`)},onError:_e=>{me.error(`Failed to schedule: ${_e.message}`)}}),ee=async()=>{if(p.length===0){me.error("Please select at least one account");return}if(_==="schedule"){const _e=U();if(!_e||_e<=new Date){me.error("Please select a future date and time");return}for(const $e of p){const Ae=B==null?void 0:B.find(Ie=>Ie.id===$e);Ae&&await Q.mutateAsync({accountId:$e,platform:Ae.platform,scheduledFor:_e})}i.invalidateQueries({queryKey:["scheduled-posts"]}),me.success(`${p.length} post(s) scheduled for ${ms(_e,"PPp")}`)}else for(const _e of p){const $e=B==null?void 0:B.find(Ae=>Ae.id===_e);$e&&await Y.mutateAsync({accountId:_e,platform:$e.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},X=_e=>{f($e=>$e.includes(_e)?$e.filter(Ae=>Ae!==_e):[...$e,_e])},ie=(B==null?void 0:B.filter(_e=>_e.platform==="facebook"))||[],re=(B==null?void 0:B.filter(_e=>_e.platform==="instagram"))||[],oe=(B==null?void 0:B.filter(_e=>_e.platform==="linkedin"))||[],ce=(B==null?void 0:B.filter(_e=>_e.platform==="google_business"))||[],ge=((B==null?void 0:B.length)||0)>0,ye=Y.isPending||Q.isPending,ue=Array.from({length:12},(_e,$e)=>String($e+1)),pe=["00","15","30","45"];return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create Social Post"}),e.jsx(Gr,{children:"Share this image to your connected social accounts"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"aspect-square w-full max-w-[200px] mx-auto overflow-hidden rounded-lg border",children:e.jsx("img",{src:r,alt:"Post preview",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"caption",children:"Caption"}),e.jsx(Er,{id:"caption",placeholder:"Write a caption for your post...",value:c,onChange:_e=>u(_e.target.value),rows:3}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.length,"/2200 characters"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Publish Time"}),e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsx("button",{type:"button",onClick:()=>j("now"),className:It("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",_==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>j("schedule"),className:It("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",_==="schedule"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Schedule"})]})]}),_==="schedule"&&e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(un,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("justify-start text-left font-normal flex-1",!w&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),w?ms(w,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:w,onSelect:N,disabled:_e=>_ee.jsx(Mt,{value:_e,children:_e},_e))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Ks,{value:L,onValueChange:I,children:[e.jsx(Hs,{className:"w-[70px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:pe.map(_e=>e.jsx(Mt,{value:_e,children:_e},_e))})]}),e.jsxs(Ks,{value:O,onValueChange:_e=>q(_e),children:[e.jsx(Hs,{className:"w-[70px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"AM",children:"AM"}),e.jsx(Mt,{value:"PM",children:"PM"})]})]})]})]}),w&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ms(U()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Post to"}),V&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-6 w-6 animate-spin"})}),!V&&!ge&&e.jsxs(Pke,{children:[e.jsx(kl,{className:"h-4 w-4"}),e.jsxs(Ike,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(Pi,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(Xo,{className:"h-3.5 w-3.5"}),"Connect your Facebook, Instagram & LinkedIn"]})]})]}),ie.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Su,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),ie.map(_e=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(_e.id),onCheckedChange:()=>X(_e.id),disabled:g===_e.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:_e.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Su,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:_e.page_name||_e.platform_username}),g===_e.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},_e.id))]}),re.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Mu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),re.map(_e=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(_e.id),onCheckedChange:()=>X(_e.id),disabled:g===_e.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:_e.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",_e.platform_username]}),g===_e.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},_e.id))]}),oe.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Mp,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),oe.map(_e=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(_e.id),onCheckedChange:()=>X(_e.id),disabled:g===_e.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:_e.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mp,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:_e.platform_username}),g===_e.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},_e.id))]}),ce.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(ma,{className:"h-4 w-4 text-red-600"})," Google Business"]}),ce.map(_e=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(_e.id),onCheckedChange:()=>X(_e.id),disabled:g===_e.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:_e.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(ma,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:_e.page_name||_e.platform_username}),g===_e.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},_e.id))]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:ee,disabled:p.length===0||ye,className:"gap-2",children:[ye?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):_==="schedule"?e.jsx(hn,{className:"h-4 w-4"}):e.jsx(Bn,{className:"h-4 w-4"}),_==="schedule"?`Schedule ${p.length} post${p.length!==1?"s":""}`:`Post to ${p.length} account${p.length!==1?"s":""}`]})]})]})})}function mUt(){const t=Qt(),[s,r]=k.useState(void 0),[n,a]=k.useState("all"),[o,l]=k.useState(null),[i,c]=k.useState(""),[u,p]=k.useState(void 0),[f,g]=k.useState("12"),[b,_]=k.useState("00"),[j,w]=k.useState("PM"),{data:N=[],isLoading:S}=mt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:ce,error:ge}=await H.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(ge)throw ge;return ce}}),M=N.filter(ce=>{if(n!=="all"&&ce.status!==n)return!1;if(s&&ce.scheduled_for){const ge=new Date(ce.scheduled_for);if(!Cl(ge,s))return!1}return!0}),L=N.filter(ce=>ce.scheduled_for).map(ce=>$m(new Date(ce.scheduled_for))),I=Lt({mutationFn:async ce=>{const{error:ge}=await H.from("scheduled_posts").update({caption:ce.caption,scheduled_for:ce.scheduled_for}).eq("id",ce.id);if(ge)throw ge},onSuccess:()=>{me.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:ce=>{me.error(`Failed to update: ${ce.message}`)}}),O=Lt({mutationFn:async ce=>{const{error:ge}=await H.from("scheduled_posts").update({status:"cancelled"}).eq("id",ce);if(ge)throw ge},onSuccess:()=>{me.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{me.error(`Failed to cancel: ${ce.message}`)}}),q=Lt({mutationFn:async ce=>{const{error:ge}=await H.from("scheduled_posts").delete().eq("id",ce);if(ge)throw ge},onSuccess:()=>{me.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{me.error(`Failed to delete: ${ce.message}`)}}),U=Lt({mutationFn:async ce=>{const{data:ge,error:ye}=await H.functions.invoke("social-post",{body:{platform:ce.platform,accountId:ce.social_account_id,imageUrl:ce.image_url,caption:ce.caption}});if(ye)throw ye;if(ge!=null&&ge.error)throw new Error(ge.error);return await H.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";me.success(`Posted to ${ge}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{me.error(`Failed to post: ${ce.message}`)}}),B=ce=>{if(l(ce),c(ce.caption||""),ce.scheduled_for){const ge=new Date(ce.scheduled_for);p(ge);const ye=ge.getHours();g(String(ye>12?ye-12:ye===0?12:ye)),_(String(ge.getMinutes()).padStart(2,"0")),w(ye>=12?"PM":"AM")}},V=()=>{if(!o||!u)return;let ce=parseInt(f);const ge=parseInt(b);j==="PM"&&ce!==12&&(ce+=12),j==="AM"&&ce===12&&(ce=0);const ye=WL(HL(u,ce),ge);I.mutate({id:o.id,caption:i,scheduled_for:ye.toISOString()})},Y=ce=>{switch(ce){case"facebook":return e.jsx(Su,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(Mu,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(Mp,{className:"h-4 w-4 text-blue-700"});default:return null}},Q=ce=>{switch(ce){case"scheduled":return e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(st,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(xi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(st,{variant:"destructive",className:"gap-1",children:[e.jsx(vc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(st,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(kl,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(st,{variant:"outline",children:ce})}},ee=Array.from({length:12},(ce,ge)=>String(ge+1)),X=["00","15","30","45"],ie=N.filter(ce=>ce.status==="scheduled").length,re=N.filter(ce=>ce.status==="posted").length,oe=N.filter(ce=>ce.status==="scheduled"&&ce.scheduled_for&&ySt(new Date(ce.scheduled_for))).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ie}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Scheduled"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:oe}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:re}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:N.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total"})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Od,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(wf,{mode:"single",selected:s,onSelect:r,className:It("pointer-events-auto"),modifiers:{hasPost:L},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(void 0),className:"w-full mt-2",children:"Clear date filter"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qg,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(ce=>e.jsx(K,{variant:n===ce?"default":"outline",size:"sm",onClick:()=>a(ce),className:"capitalize",children:ce},ce))})]}),S&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!S&&M.length===0&&e.jsxs(Ee,{className:"p-8 text-center",children:[e.jsx(hn,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium mb-2",children:"No posts found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?`No posts scheduled for ${ms(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:M.map(ce=>{var ge,ye;return e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[e.jsx("div",{className:"sm:w-32 h-32 sm:h-auto bg-muted flex-shrink-0",children:e.jsx("img",{src:ce.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(Oe,{className:"flex-1 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Y(ce.platform),e.jsx("span",{className:"font-medium",children:((ge=ce.social_accounts)==null?void 0:ge.page_name)||((ye=ce.social_accounts)==null?void 0:ye.platform_username)||"Unknown"}),Q(ce.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[ce.status==="scheduled"&&e.jsxs(B1,{children:[e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>B(ce),children:e.jsx(Ra,{className:"h-4 w-4"})})}),e.jsx(Xl,{children:"Edit post"})]}),e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U.mutate(ce),disabled:U.isPending,children:U.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"})})}),e.jsx(Xl,{children:"Post now"})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Cancel this scheduled post?"}),e.jsx(sc,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Keep"}),e.jsx(Rl,{onClick:()=>O.mutate(ce.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(Rl,{onClick:()=>q.mutate(ce.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(ce.status==="posted"||ce.status==="cancelled"||ce.status==="failed")&&e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete this post?"}),e.jsx(sc,{children:"This will permanently remove this post from your history."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>q.mutate(ce.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),ce.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:ce.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ce.status==="posted"&&ce.posted_at?`Posted ${ms(new Date(ce.posted_at),"PPp")}`:ce.scheduled_for?`Scheduled for ${ms(new Date(ce.scheduled_for),"PPp")}`:"Not scheduled"]}),ce.status==="failed"&&ce.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",ce.error_message]})]})]})},ce.id)})})]})]}),e.jsx(fs,{open:!!o,onOpenChange:ce=>!ce&&l(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Scheduled Post"}),e.jsx(Gr,{children:"Update the caption or reschedule this post"})]}),o&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"aspect-square w-32 mx-auto overflow-hidden rounded-lg border",children:e.jsx("img",{src:o.image_url,alt:"Post preview",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Caption"}),e.jsx(Er,{value:i,onChange:ce=>c(ce.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(be,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),u?ms(u,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:u,onSelect:p,disabled:ce=>cee.jsx(Mt,{value:ce,children:ce},ce))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Ks,{value:b,onValueChange:_,children:[e.jsx(Hs,{className:"w-[70px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:X.map(ce=>e.jsx(Mt,{value:ce,children:ce},ce))})]}),e.jsxs(Ks,{value:j,onValueChange:ce=>w(ce),children:[e.jsx(Hs,{className:"w-[70px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"AM",children:"AM"}),e.jsx(Mt,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:V,disabled:I.isPending,children:[I.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function Nz(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Get={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(t,s){(function(r){t.exports=r()})(function(){return function r(n,a,o){function l(u,p){if(!a[u]){if(!n[u]){var f=typeof Nz=="function"&&Nz;if(!p&&f)return f(u,!0);if(i)return i(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var b=a[u]={exports:{}};n[u][0].call(b.exports,function(_){var j=n[u][1][_];return l(j||_)},b,b.exports,r,n,a,o)}return a[u].exports}for(var i=typeof Nz=="function"&&Nz,c=0;c>2,b=(3&u)<<4|p>>4,_=1>6:64,j=2>4,p=(15&g)<<4|(b=i.indexOf(c.charAt(j++)))>>2,f=(3&b)<<6|(_=i.indexOf(c.charAt(j++))),S[w++]=u,b!==64&&(S[w++]=p),_!==64&&(S[w++]=f);return S}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),c=r("./stream/DataLengthProbe");function u(p,f,g,b,_){this.compressedSize=p,this.uncompressedSize=f,this.crc32=g,this.compression=b,this.compressedContent=_}u.prototype={getContentWorker:function(){var p=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return p.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),p},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(p,f,g){return p.pipe(new i).pipe(new c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},n.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,a){var o=r("./stream/GenericWorker");a.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},a.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,a){var o=r("./utils"),l=function(){for(var i,c=[],u=0;u<256;u++){i=u;for(var p=0;p<8;p++)i=1&i?3988292384^i>>>1:i>>>1;c[u]=i}return c}();n.exports=function(i,c){return i!==void 0&&i.length?o.getTypeOf(i)!=="string"?function(u,p,f,g){var b=l,_=g+f;u^=-1;for(var j=g;j<_;j++)u=u>>>8^b[255&(u^p[j])];return-1^u}(0|c,i,i.length,0):function(u,p,f,g){var b=l,_=g+f;u^=-1;for(var j=g;j<_;j++)u=u>>>8^b[255&(u^p.charCodeAt(j))];return-1^u}(0|c,i,i.length,0):0}},{"./utils":32}],5:[function(r,n,a){a.base64=!1,a.binary=!1,a.dir=!1,a.createFolders=!0,a.date=null,a.compression=null,a.compressionOptions=null,a.comment=null,a.unixPermissions=null,a.dosPermissions=null},{}],6:[function(r,n,a){var o=null;o=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:o}},{lie:37}],7:[function(r,n,a){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=r("pako"),i=r("./utils"),c=r("./stream/GenericWorker"),u=o?"uint8array":"array";function p(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}a.magic="\b\0",i.inherits(p,c),p.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,f.data),!1)},p.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},p.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},p.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},a.compressWorker=function(f){return new p("Deflate",f)},a.uncompressWorker=function(){return new p("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(b,_){var j,w="";for(j=0;j<_;j++)w+=String.fromCharCode(255&b),b>>>=8;return w}function l(b,_,j,w,N,S){var M,L,I=b.file,O=b.compression,q=S!==u.utf8encode,U=i.transformTo("string",S(I.name)),B=i.transformTo("string",u.utf8encode(I.name)),V=I.comment,Y=i.transformTo("string",S(V)),Q=i.transformTo("string",u.utf8encode(V)),ee=B.length!==I.name.length,X=Q.length!==V.length,ie="",re="",oe="",ce=I.dir,ge=I.date,ye={crc32:0,compressedSize:0,uncompressedSize:0};_&&!j||(ye.crc32=b.crc32,ye.compressedSize=b.compressedSize,ye.uncompressedSize=b.uncompressedSize);var ue=0;_&&(ue|=8),q||!ee&&!X||(ue|=2048);var pe=0,_e=0;ce&&(pe|=16),N==="UNIX"?(_e=798,pe|=function(Ae,Ie){var Ce=Ae;return Ae||(Ce=Ie?16893:33204),(65535&Ce)<<16}(I.unixPermissions,ce)):(_e=20,pe|=function(Ae){return 63&(Ae||0)}(I.dosPermissions)),M=ge.getUTCHours(),M<<=6,M|=ge.getUTCMinutes(),M<<=5,M|=ge.getUTCSeconds()/2,L=ge.getUTCFullYear()-1980,L<<=4,L|=ge.getUTCMonth()+1,L<<=5,L|=ge.getUTCDate(),ee&&(re=o(1,1)+o(p(U),4)+B,ie+="up"+o(re.length,2)+re),X&&(oe=o(1,1)+o(p(Y),4)+Q,ie+="uc"+o(oe.length,2)+oe);var $e="";return $e+=` \0`,$e+=o(ue,2),$e+=O.magic,$e+=o(M,2),$e+=o(L,2),$e+=o(ye.crc32,4),$e+=o(ye.compressedSize,4),$e+=o(ye.uncompressedSize,4),$e+=o(U.length,2),$e+=o(ie.length,2),{fileRecord:f.LOCAL_FILE_HEADER+$e+U+ie,dirRecord:f.CENTRAL_FILE_HEADER+o(_e,2)+$e+o(Y.length,2)+"\0\0\0\0"+o(pe,4)+o(w,4)+U+ie+Y}}var i=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),f=r("../signature");function g(b,_,j,w){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=j,this.encodeFileName=w,this.streamFiles=b,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(g,c),g.prototype.push=function(b){var _=b.meta.percent||0,j=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(b):(this.bytesWritten+=b.data.length,c.prototype.push.call(this,{data:b.data,meta:{currentFile:this.currentFile,percent:j?(_+100*(j-w-1))/j:100}}))},g.prototype.openedSource=function(b){this.currentSourceOffset=this.bytesWritten,this.currentFile=b.file.name;var _=this.streamFiles&&!b.file.dir;if(_){var j=l(b,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:j.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(b){this.accumulate=!1;var _=this.streamFiles&&!b.file.dir,j=l(b,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(j.dirRecord),_)this.push({data:function(w){return f.DATA_DESCRIPTOR+o(w.crc32,4)+o(w.compressedSize,4)+o(w.uncompressedSize,4)}(b),meta:{percent:100}});else for(this.push({data:j.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var b=this.bytesWritten,_=0;_=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=i,u},readString:function(i){return o.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},n.exports=l},{"../utils":32}],19:[function(r,n,a){var o=r("./Uint8ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){this.checkOffset(i);var c=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,c},n.exports=l},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,a){var o=r("./DataReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},l.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},l.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},l.prototype.readData=function(i){this.checkOffset(i);var c=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,c},n.exports=l},{"../utils":32,"./DataReader":18}],21:[function(r,n,a){var o=r("./ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,c},n.exports=l},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,a){var o=r("../utils"),l=r("../support"),i=r("./ArrayReader"),c=r("./StringReader"),u=r("./NodeBufferReader"),p=r("./Uint8ArrayReader");n.exports=function(f){var g=o.getTypeOf(f);return o.checkSupport(g),g!=="string"||l.uint8array?g==="nodebuffer"?new u(f):l.uint8array?new p(o.transformTo("uint8array",f)):new i(o.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,a){a.LOCAL_FILE_HEADER="PK",a.CENTRAL_FILE_HEADER="PK",a.CENTRAL_DIRECTORY_END="PK",a.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",a.ZIP64_CENTRAL_DIRECTORY_END="PK",a.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,a){var o=r("./GenericWorker"),l=r("../utils");function i(c){o.call(this,"ConvertWorker to "+c),this.destType=c}l.inherits(i,o),i.prototype.processChunk=function(c){this.push({data:l.transformTo(this.destType,c.data),meta:c.meta})},n.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,a){var o=r("./GenericWorker"),l=r("../crc32");function i(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(i,o),i.prototype.processChunk=function(c){this.streamInfo.crc32=l(c.data,this.streamInfo.crc32||0),this.push(c)},n.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(c){l.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}o.inherits(i,l),i.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}l.prototype.processChunk.call(this,c)},n.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(c){l.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(p){u.dataIsReady=!0,u.data=p,u.max=p&&p.length||0,u.type=o.getTypeOf(p),u.isPaused||u._tickAndRepeat()},function(p){u.error(p)})}o.inherits(i,l),i.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,a){function o(l){this.name=l||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(l){this.emit("data",l)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(l){this.emit("error",l)}return!0},error:function(l){return!this.isFinished&&(this.isPaused?this.generatedError=l:(this.isFinished=!0,this.emit("error",l),this.previous&&this.previous.error(l),this.cleanUp()),!0)},on:function(l,i){return this._listeners[l].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(l,i){if(this._listeners[l])for(var c=0;c "+l:l}},n.exports=o},{}],29:[function(r,n,a){var o=r("../utils"),l=r("./ConvertWorker"),i=r("./GenericWorker"),c=r("../base64"),u=r("../support"),p=r("../external"),f=null;if(u.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(_,j){return new p.Promise(function(w,N){var S=[],M=_._internalType,L=_._outputType,I=_._mimeType;_.on("data",function(O,q){S.push(O),j&&j(q)}).on("error",function(O){S=[],N(O)}).on("end",function(){try{var O=function(q,U,B){switch(q){case"blob":return o.newBlob(o.transformTo("arraybuffer",U),B);case"base64":return c.encode(U);default:return o.transformTo(q,U)}}(L,function(q,U){var B,V=0,Y=null,Q=0;for(B=0;B"u")a.blob=!1;else{var o=new ArrayBuffer(0);try{a.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);l.append(o),a.blob=l.getBlob("application/zip").size===0}catch{a.blob=!1}}}try{a.nodestream=!!r("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,a){for(var o=r("./utils"),l=r("./support"),i=r("./nodejsUtils"),c=r("./stream/GenericWorker"),u=new Array(256),p=0;p<256;p++)u[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}a.utf8encode=function(b){return l.nodebuffer?i.newBufferFrom(b,"utf-8"):function(_){var j,w,N,S,M,L=_.length,I=0;for(S=0;S>>6:(w<65536?j[M++]=224|w>>>12:(j[M++]=240|w>>>18,j[M++]=128|w>>>12&63),j[M++]=128|w>>>6&63),j[M++]=128|63&w);return j}(b)},a.utf8decode=function(b){return l.nodebuffer?o.transformTo("nodebuffer",b).toString("utf-8"):function(_){var j,w,N,S,M=_.length,L=new Array(2*M);for(j=w=0;j>10&1023,L[w++]=56320|1023&N)}return L.length!==w&&(L.subarray?L=L.subarray(0,w):L.length=w),o.applyFromCharCode(L)}(b=o.transformTo(l.uint8array?"uint8array":"array",b))},o.inherits(f,c),f.prototype.processChunk=function(b){var _=o.transformTo(l.uint8array?"uint8array":"array",b.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var j=_;(_=new Uint8Array(j.length+this.leftOver.length)).set(this.leftOver,0),_.set(j,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var w=function(S,M){var L;for((M=M||S.length)>S.length&&(M=S.length),L=M-1;0<=L&&(192&S[L])==128;)L--;return L<0||L===0?M:L+u[S[L]]>M?L:M}(_),N=_;w!==_.length&&(l.uint8array?(N=_.subarray(0,w),this.leftOver=_.subarray(w,_.length)):(N=_.slice(0,w),this.leftOver=_.slice(w,_.length))),this.push({data:a.utf8decode(N),meta:b.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=f,o.inherits(g,c),g.prototype.processChunk=function(b){this.push({data:a.utf8encode(b.data),meta:b.meta})},a.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,a){var o=r("./support"),l=r("./base64"),i=r("./nodejsUtils"),c=r("./external");function u(j){return j}function p(j,w){for(var N=0;N>8;this.dir=!!(16&this.externalFileAttributes),b==0&&(this.dosPermissions=63&this.externalFileAttributes),b==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var b=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=b.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=b.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=b.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=b.readInt(4))}},readExtraFields:function(b){var _,j,w,N=b.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});b.index+4>>6:(b<65536?g[w++]=224|b>>>12:(g[w++]=240|b>>>18,g[w++]=128|b>>>12&63),g[w++]=128|b>>>6&63),g[w++]=128|63&b);return g},a.buf2binstring=function(f){return p(f,f.length)},a.binstring2buf=function(f){for(var g=new o.Buf8(f.length),b=0,_=g.length;b<_;b++)g[b]=f.charCodeAt(b);return g},a.buf2string=function(f,g){var b,_,j,w,N=g||f.length,S=new Array(2*N);for(b=_=0;b>10&1023,S[_++]=56320|1023&j)}return p(S,_)},a.utf8border=function(f,g){var b;for((g=g||f.length)>f.length&&(g=f.length),b=g-1;0<=b&&(192&f[b])==128;)b--;return b<0||b===0?g:b+c[f[b]]>g?b:g}},{"./common":41}],43:[function(r,n,a){n.exports=function(o,l,i,c){for(var u=65535&o|0,p=o>>>16&65535|0,f=0;i!==0;){for(i-=f=2e3>>1:l>>>1;i[c]=l}return i}();n.exports=function(l,i,c,u){var p=o,f=u+c;l^=-1;for(var g=u;g>>8^p[255&(l^i[g])];return-1^l}},{}],46:[function(r,n,a){var o,l=r("../utils/common"),i=r("./trees"),c=r("./adler32"),u=r("./crc32"),p=r("./messages"),f=0,g=4,b=0,_=-2,j=-1,w=4,N=2,S=8,M=9,L=286,I=30,O=19,q=2*L+1,U=15,B=3,V=258,Y=V+B+1,Q=42,ee=113,X=1,ie=2,re=3,oe=4;function ce(fe,qe){return fe.msg=p[qe],qe}function ge(fe){return(fe<<1)-(4fe.avail_out&&(at=fe.avail_out),at!==0&&(l.arraySet(fe.output,qe.pending_buf,qe.pending_out,at,fe.next_out),fe.next_out+=at,qe.pending_out+=at,fe.total_out+=at,fe.avail_out-=at,qe.pending-=at,qe.pending===0&&(qe.pending_out=0))}function pe(fe,qe){i._tr_flush_block(fe,0<=fe.block_start?fe.block_start:-1,fe.strstart-fe.block_start,qe),fe.block_start=fe.strstart,ue(fe.strm)}function _e(fe,qe){fe.pending_buf[fe.pending++]=qe}function $e(fe,qe){fe.pending_buf[fe.pending++]=qe>>>8&255,fe.pending_buf[fe.pending++]=255&qe}function Ae(fe,qe){var at,et,Me=fe.max_chain_length,rt=fe.strstart,He=fe.prev_length,ct=fe.nice_match,Ue=fe.strstart>fe.w_size-Y?fe.strstart-(fe.w_size-Y):0,Ze=fe.window,Qe=fe.w_mask,We=fe.prev,Je=fe.strstart+V,it=Ze[rt+He-1],Dt=Ze[rt+He];fe.prev_length>=fe.good_match&&(Me>>=2),ct>fe.lookahead&&(ct=fe.lookahead);do if(Ze[(at=qe)+He]===Dt&&Ze[at+He-1]===it&&Ze[at]===Ze[rt]&&Ze[++at]===Ze[rt+1]){rt+=2,at++;do;while(Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&rtUe&&--Me!=0);return He<=fe.lookahead?He:fe.lookahead}function Ie(fe){var qe,at,et,Me,rt,He,ct,Ue,Ze,Qe,We=fe.w_size;do{if(Me=fe.window_size-fe.lookahead-fe.strstart,fe.strstart>=We+(We-Y)){for(l.arraySet(fe.window,fe.window,We,We,0),fe.match_start-=We,fe.strstart-=We,fe.block_start-=We,qe=at=fe.hash_size;et=fe.head[--qe],fe.head[qe]=We<=et?et-We:0,--at;);for(qe=at=We;et=fe.prev[--qe],fe.prev[qe]=We<=et?et-We:0,--at;);Me+=We}if(fe.strm.avail_in===0)break;if(He=fe.strm,ct=fe.window,Ue=fe.strstart+fe.lookahead,Ze=Me,Qe=void 0,Qe=He.avail_in,Ze=B)for(rt=fe.strstart-fe.insert,fe.ins_h=fe.window[rt],fe.ins_h=(fe.ins_h<=B&&(fe.ins_h=(fe.ins_h<=B)if(et=i._tr_tally(fe,fe.strstart-fe.match_start,fe.match_length-B),fe.lookahead-=fe.match_length,fe.match_length<=fe.max_lazy_match&&fe.lookahead>=B){for(fe.match_length--;fe.strstart++,fe.ins_h=(fe.ins_h<=B&&(fe.ins_h=(fe.ins_h<=B&&fe.match_length<=fe.prev_length){for(Me=fe.strstart+fe.lookahead-B,et=i._tr_tally(fe,fe.strstart-1-fe.prev_match,fe.prev_length-B),fe.lookahead-=fe.prev_length-1,fe.prev_length-=2;++fe.strstart<=Me&&(fe.ins_h=(fe.ins_h<fe.pending_buf_size-5&&(at=fe.pending_buf_size-5);;){if(fe.lookahead<=1){if(Ie(fe),fe.lookahead===0&&qe===f)return X;if(fe.lookahead===0)break}fe.strstart+=fe.lookahead,fe.lookahead=0;var et=fe.block_start+at;if((fe.strstart===0||fe.strstart>=et)&&(fe.lookahead=fe.strstart-et,fe.strstart=et,pe(fe,!1),fe.strm.avail_out===0)||fe.strstart-fe.block_start>=fe.w_size-Y&&(pe(fe,!1),fe.strm.avail_out===0))return X}return fe.insert=0,qe===g?(pe(fe,!0),fe.strm.avail_out===0?re:oe):(fe.strstart>fe.block_start&&(pe(fe,!1),fe.strm.avail_out),X)}),new we(4,4,8,4,Ce),new we(4,5,16,8,Ce),new we(4,6,32,32,Ce),new we(4,4,16,16,xe),new we(8,16,32,32,xe),new we(8,16,128,128,xe),new we(8,32,128,256,xe),new we(32,128,258,1024,xe),new we(32,258,258,4096,xe)],a.deflateInit=function(fe,qe){return pt(fe,qe,S,15,8,0)},a.deflateInit2=pt,a.deflateReset=Te,a.deflateResetKeep=tt,a.deflateSetHeader=function(fe,qe){return fe&&fe.state?fe.state.wrap!==2?_:(fe.state.gzhead=qe,b):_},a.deflate=function(fe,qe){var at,et,Me,rt;if(!fe||!fe.state||5>8&255),_e(et,et.gzhead.time>>16&255),_e(et,et.gzhead.time>>24&255),_e(et,et.level===9?2:2<=et.strategy||et.level<2?4:0),_e(et,255&et.gzhead.os),et.gzhead.extra&&et.gzhead.extra.length&&(_e(et,255&et.gzhead.extra.length),_e(et,et.gzhead.extra.length>>8&255)),et.gzhead.hcrc&&(fe.adler=u(fe.adler,et.pending_buf,et.pending,0)),et.gzindex=0,et.status=69):(_e(et,0),_e(et,0),_e(et,0),_e(et,0),_e(et,0),_e(et,et.level===9?2:2<=et.strategy||et.level<2?4:0),_e(et,3),et.status=ee);else{var He=S+(et.w_bits-8<<4)<<8;He|=(2<=et.strategy||et.level<2?0:et.level<6?1:et.level===6?2:3)<<6,et.strstart!==0&&(He|=32),He+=31-He%31,et.status=ee,$e(et,He),et.strstart!==0&&($e(et,fe.adler>>>16),$e(et,65535&fe.adler)),fe.adler=1}if(et.status===69)if(et.gzhead.extra){for(Me=et.pending;et.gzindex<(65535&et.gzhead.extra.length)&&(et.pending!==et.pending_buf_size||(et.gzhead.hcrc&&et.pending>Me&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Me,Me)),ue(fe),Me=et.pending,et.pending!==et.pending_buf_size));)_e(et,255&et.gzhead.extra[et.gzindex]),et.gzindex++;et.gzhead.hcrc&&et.pending>Me&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Me,Me)),et.gzindex===et.gzhead.extra.length&&(et.gzindex=0,et.status=73)}else et.status=73;if(et.status===73)if(et.gzhead.name){Me=et.pending;do{if(et.pending===et.pending_buf_size&&(et.gzhead.hcrc&&et.pending>Me&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Me,Me)),ue(fe),Me=et.pending,et.pending===et.pending_buf_size)){rt=1;break}rt=et.gzindexMe&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Me,Me)),rt===0&&(et.gzindex=0,et.status=91)}else et.status=91;if(et.status===91)if(et.gzhead.comment){Me=et.pending;do{if(et.pending===et.pending_buf_size&&(et.gzhead.hcrc&&et.pending>Me&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Me,Me)),ue(fe),Me=et.pending,et.pending===et.pending_buf_size)){rt=1;break}rt=et.gzindexMe&&(fe.adler=u(fe.adler,et.pending_buf,et.pending-Me,Me)),rt===0&&(et.status=103)}else et.status=103;if(et.status===103&&(et.gzhead.hcrc?(et.pending+2>et.pending_buf_size&&ue(fe),et.pending+2<=et.pending_buf_size&&(_e(et,255&fe.adler),_e(et,fe.adler>>8&255),fe.adler=0,et.status=ee)):et.status=ee),et.pending!==0){if(ue(fe),fe.avail_out===0)return et.last_flush=-1,b}else if(fe.avail_in===0&&ge(qe)<=ge(at)&&qe!==g)return ce(fe,-5);if(et.status===666&&fe.avail_in!==0)return ce(fe,-5);if(fe.avail_in!==0||et.lookahead!==0||qe!==f&&et.status!==666){var ct=et.strategy===2?function(Ue,Ze){for(var Qe;;){if(Ue.lookahead===0&&(Ie(Ue),Ue.lookahead===0)){if(Ze===f)return X;break}if(Ue.match_length=0,Qe=i._tr_tally(Ue,0,Ue.window[Ue.strstart]),Ue.lookahead--,Ue.strstart++,Qe&&(pe(Ue,!1),Ue.strm.avail_out===0))return X}return Ue.insert=0,Ze===g?(pe(Ue,!0),Ue.strm.avail_out===0?re:oe):Ue.last_lit&&(pe(Ue,!1),Ue.strm.avail_out===0)?X:ie}(et,qe):et.strategy===3?function(Ue,Ze){for(var Qe,We,Je,it,Dt=Ue.window;;){if(Ue.lookahead<=V){if(Ie(Ue),Ue.lookahead<=V&&Ze===f)return X;if(Ue.lookahead===0)break}if(Ue.match_length=0,Ue.lookahead>=B&&0Ue.lookahead&&(Ue.match_length=Ue.lookahead)}if(Ue.match_length>=B?(Qe=i._tr_tally(Ue,1,Ue.match_length-B),Ue.lookahead-=Ue.match_length,Ue.strstart+=Ue.match_length,Ue.match_length=0):(Qe=i._tr_tally(Ue,0,Ue.window[Ue.strstart]),Ue.lookahead--,Ue.strstart++),Qe&&(pe(Ue,!1),Ue.strm.avail_out===0))return X}return Ue.insert=0,Ze===g?(pe(Ue,!0),Ue.strm.avail_out===0?re:oe):Ue.last_lit&&(pe(Ue,!1),Ue.strm.avail_out===0)?X:ie}(et,qe):o[et.level].func(et,qe);if(ct!==re&&ct!==oe||(et.status=666),ct===X||ct===re)return fe.avail_out===0&&(et.last_flush=-1),b;if(ct===ie&&(qe===1?i._tr_align(et):qe!==5&&(i._tr_stored_block(et,0,0,!1),qe===3&&(ye(et.head),et.lookahead===0&&(et.strstart=0,et.block_start=0,et.insert=0))),ue(fe),fe.avail_out===0))return et.last_flush=-1,b}return qe!==g?b:et.wrap<=0?1:(et.wrap===2?(_e(et,255&fe.adler),_e(et,fe.adler>>8&255),_e(et,fe.adler>>16&255),_e(et,fe.adler>>24&255),_e(et,255&fe.total_in),_e(et,fe.total_in>>8&255),_e(et,fe.total_in>>16&255),_e(et,fe.total_in>>24&255)):($e(et,fe.adler>>>16),$e(et,65535&fe.adler)),ue(fe),0=at.w_size&&(rt===0&&(ye(at.head),at.strstart=0,at.block_start=0,at.insert=0),Ze=new l.Buf8(at.w_size),l.arraySet(Ze,qe,Qe-at.w_size,at.w_size,0),qe=Ze,Qe=at.w_size),He=fe.avail_in,ct=fe.next_in,Ue=fe.input,fe.avail_in=Qe,fe.next_in=0,fe.input=qe,Ie(at);at.lookahead>=B;){for(et=at.strstart,Me=at.lookahead-(B-1);at.ins_h=(at.ins_h<>>=B=U>>>24,M-=B,(B=U>>>16&255)===0)ie[p++]=65535&U;else{if(!(16&B)){if(!(64&B)){U=L[(65535&U)+(S&(1<>>=B,M-=B),M<15&&(S+=X[c++]<>>=B=U>>>24,M-=B,!(16&(B=U>>>16&255))){if(!(64&B)){U=I[(65535&U)+(S&(1<>>=B,M-=B,(B=p-f)>3,S&=(1<<(M-=V<<3))-1,o.next_in=c,o.next_out=p,o.avail_in=c>>24&255)+(Q>>>8&65280)+((65280&Q)<<8)+((255&Q)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function M(Q){var ee;return Q&&Q.state?(ee=Q.state,Q.total_in=Q.total_out=ee.total=0,Q.msg="",ee.wrap&&(Q.adler=1&ee.wrap),ee.mode=_,ee.last=0,ee.havedict=0,ee.dmax=32768,ee.head=null,ee.hold=0,ee.bits=0,ee.lencode=ee.lendyn=new o.Buf32(j),ee.distcode=ee.distdyn=new o.Buf32(w),ee.sane=1,ee.back=-1,g):b}function L(Q){var ee;return Q&&Q.state?((ee=Q.state).wsize=0,ee.whave=0,ee.wnext=0,M(Q)):b}function I(Q,ee){var X,ie;return Q&&Q.state?(ie=Q.state,ee<0?(X=0,ee=-ee):(X=1+(ee>>4),ee<48&&(ee&=15)),ee&&(ee<8||15=oe.wsize?(o.arraySet(oe.window,ee,X-oe.wsize,oe.wsize,0),oe.wnext=0,oe.whave=oe.wsize):(ie<(re=oe.wsize-oe.wnext)&&(re=ie),o.arraySet(oe.window,ee,X-ie,re,oe.wnext),(ie-=re)?(o.arraySet(oe.window,ee,X-ie,ie,0),oe.wnext=ie,oe.whave=oe.wsize):(oe.wnext+=re,oe.wnext===oe.wsize&&(oe.wnext=0),oe.whave>>8&255,X.check=i(X.check,rt,2,0),pe=ue=0,X.mode=2;break}if(X.flags=0,X.head&&(X.head.done=!1),!(1&X.wrap)||(((255&ue)<<8)+(ue>>8))%31){Q.msg="incorrect header check",X.mode=30;break}if((15&ue)!=8){Q.msg="unknown compression method",X.mode=30;break}if(pe-=4,fe=8+(15&(ue>>>=4)),X.wbits===0)X.wbits=fe;else if(fe>X.wbits){Q.msg="invalid window size",X.mode=30;break}X.dmax=1<>8&1),512&X.flags&&(rt[0]=255&ue,rt[1]=ue>>>8&255,X.check=i(X.check,rt,2,0)),pe=ue=0,X.mode=3;case 3:for(;pe<32;){if(ge===0)break e;ge--,ue+=ie[oe++]<>>8&255,rt[2]=ue>>>16&255,rt[3]=ue>>>24&255,X.check=i(X.check,rt,4,0)),pe=ue=0,X.mode=4;case 4:for(;pe<16;){if(ge===0)break e;ge--,ue+=ie[oe++]<>8),512&X.flags&&(rt[0]=255&ue,rt[1]=ue>>>8&255,X.check=i(X.check,rt,2,0)),pe=ue=0,X.mode=5;case 5:if(1024&X.flags){for(;pe<16;){if(ge===0)break e;ge--,ue+=ie[oe++]<>>8&255,X.check=i(X.check,rt,2,0)),pe=ue=0}else X.head&&(X.head.extra=null);X.mode=6;case 6:if(1024&X.flags&&(ge<(Ae=X.length)&&(Ae=ge),Ae&&(X.head&&(fe=X.head.extra_len-X.length,X.head.extra||(X.head.extra=new Array(X.head.extra_len)),o.arraySet(X.head.extra,ie,oe,Ae,fe)),512&X.flags&&(X.check=i(X.check,ie,Ae,oe)),ge-=Ae,oe+=Ae,X.length-=Ae),X.length))break e;X.length=0,X.mode=7;case 7:if(2048&X.flags){if(ge===0)break e;for(Ae=0;fe=ie[oe+Ae++],X.head&&fe&&X.length<65536&&(X.head.name+=String.fromCharCode(fe)),fe&&Ae>9&1,X.head.done=!0),Q.adler=X.check=0,X.mode=12;break;case 10:for(;pe<32;){if(ge===0)break e;ge--,ue+=ie[oe++]<>>=7&pe,pe-=7&pe,X.mode=27;break}for(;pe<3;){if(ge===0)break e;ge--,ue+=ie[oe++]<>>=1)){case 0:X.mode=14;break;case 1:if(V(X),X.mode=20,ee!==6)break;ue>>>=2,pe-=2;break e;case 2:X.mode=17;break;case 3:Q.msg="invalid block type",X.mode=30}ue>>>=2,pe-=2;break;case 14:for(ue>>>=7&pe,pe-=7&pe;pe<32;){if(ge===0)break e;ge--,ue+=ie[oe++]<>>16^65535)){Q.msg="invalid stored block lengths",X.mode=30;break}if(X.length=65535&ue,pe=ue=0,X.mode=15,ee===6)break e;case 15:X.mode=16;case 16:if(Ae=X.length){if(ge>>=5,pe-=5,X.ndist=1+(31&ue),ue>>>=5,pe-=5,X.ncode=4+(15&ue),ue>>>=4,pe-=4,286>>=3,pe-=3}for(;X.have<19;)X.lens[He[X.have++]]=0;if(X.lencode=X.lendyn,X.lenbits=7,at={bits:X.lenbits},qe=u(0,X.lens,0,19,X.lencode,0,X.work,at),X.lenbits=at.bits,qe){Q.msg="invalid code lengths set",X.mode=30;break}X.have=0,X.mode=19;case 19:for(;X.have>>16&255,Le=65535&Me,!((xe=Me>>>24)<=pe);){if(ge===0)break e;ge--,ue+=ie[oe++]<>>=xe,pe-=xe,X.lens[X.have++]=Le;else{if(Le===16){for(et=xe+2;pe>>=xe,pe-=xe,X.have===0){Q.msg="invalid bit length repeat",X.mode=30;break}fe=X.lens[X.have-1],Ae=3+(3&ue),ue>>>=2,pe-=2}else if(Le===17){for(et=xe+3;pe>>=xe)),ue>>>=3,pe-=3}else{for(et=xe+7;pe>>=xe)),ue>>>=7,pe-=7}if(X.have+Ae>X.nlen+X.ndist){Q.msg="invalid bit length repeat",X.mode=30;break}for(;Ae--;)X.lens[X.have++]=fe}}if(X.mode===30)break;if(X.lens[256]===0){Q.msg="invalid code -- missing end-of-block",X.mode=30;break}if(X.lenbits=9,at={bits:X.lenbits},qe=u(p,X.lens,0,X.nlen,X.lencode,0,X.work,at),X.lenbits=at.bits,qe){Q.msg="invalid literal/lengths set",X.mode=30;break}if(X.distbits=6,X.distcode=X.distdyn,at={bits:X.distbits},qe=u(f,X.lens,X.nlen,X.ndist,X.distcode,0,X.work,at),X.distbits=at.bits,qe){Q.msg="invalid distances set",X.mode=30;break}if(X.mode=20,ee===6)break e;case 20:X.mode=21;case 21:if(6<=ge&&258<=ye){Q.next_out=ce,Q.avail_out=ye,Q.next_in=oe,Q.avail_in=ge,X.hold=ue,X.bits=pe,c(Q,$e),ce=Q.next_out,re=Q.output,ye=Q.avail_out,oe=Q.next_in,ie=Q.input,ge=Q.avail_in,ue=X.hold,pe=X.bits,X.mode===12&&(X.back=-1);break}for(X.back=0;we=(Me=X.lencode[ue&(1<>>16&255,Le=65535&Me,!((xe=Me>>>24)<=pe);){if(ge===0)break e;ge--,ue+=ie[oe++]<>tt)])>>>16&255,Le=65535&Me,!(tt+(xe=Me>>>24)<=pe);){if(ge===0)break e;ge--,ue+=ie[oe++]<>>=tt,pe-=tt,X.back+=tt}if(ue>>>=xe,pe-=xe,X.back+=xe,X.length=Le,we===0){X.mode=26;break}if(32&we){X.back=-1,X.mode=12;break}if(64&we){Q.msg="invalid literal/length code",X.mode=30;break}X.extra=15&we,X.mode=22;case 22:if(X.extra){for(et=X.extra;pe>>=X.extra,pe-=X.extra,X.back+=X.extra}X.was=X.length,X.mode=23;case 23:for(;we=(Me=X.distcode[ue&(1<>>16&255,Le=65535&Me,!((xe=Me>>>24)<=pe);){if(ge===0)break e;ge--,ue+=ie[oe++]<>tt)])>>>16&255,Le=65535&Me,!(tt+(xe=Me>>>24)<=pe);){if(ge===0)break e;ge--,ue+=ie[oe++]<>>=tt,pe-=tt,X.back+=tt}if(ue>>>=xe,pe-=xe,X.back+=xe,64&we){Q.msg="invalid distance code",X.mode=30;break}X.offset=Le,X.extra=15&we,X.mode=24;case 24:if(X.extra){for(et=X.extra;pe>>=X.extra,pe-=X.extra,X.back+=X.extra}if(X.offset>X.dmax){Q.msg="invalid distance too far back",X.mode=30;break}X.mode=25;case 25:if(ye===0)break e;if(Ae=$e-ye,X.offset>Ae){if((Ae=X.offset-Ae)>X.whave&&X.sane){Q.msg="invalid distance too far back",X.mode=30;break}Ie=Ae>X.wnext?(Ae-=X.wnext,X.wsize-Ae):X.wnext-Ae,Ae>X.length&&(Ae=X.length),Ce=X.window}else Ce=re,Ie=ce-X.offset,Ae=X.length;for(yeq?(B=Ie[Ce+w[ee]],pe[_e+w[ee]]):(B=96,0),S=1<>ce)+(M-=S)]=U<<24|B<<16|V|0,M!==0;);for(S=1<>=1;if(S!==0?(ue&=S-1,ue+=S):ue=0,ee++,--$e[Q]==0){if(Q===ie)break;Q=f[g+w[ee]]}if(re>>7)]}function _e(Me,rt){Me.pending_buf[Me.pending++]=255&rt,Me.pending_buf[Me.pending++]=rt>>>8&255}function $e(Me,rt,He){Me.bi_valid>N-He?(Me.bi_buf|=rt<>N-Me.bi_valid,Me.bi_valid+=He-N):(Me.bi_buf|=rt<>>=1,He<<=1,0<--rt;);return He>>>1}function Ce(Me,rt,He){var ct,Ue,Ze=new Array(w+1),Qe=0;for(ct=1;ct<=w;ct++)Ze[ct]=Qe=Qe+He[ct-1]<<1;for(Ue=0;Ue<=rt;Ue++){var We=Me[2*Ue+1];We!==0&&(Me[2*Ue]=Ie(Ze[We]++,We))}}function xe(Me){var rt;for(rt=0;rt>1;1<=He;He--)tt(Me,Ze,He);for(Ue=Je;He=Me.heap[1],Me.heap[1]=Me.heap[Me.heap_len--],tt(Me,Ze,1),ct=Me.heap[1],Me.heap[--Me.heap_max]=He,Me.heap[--Me.heap_max]=ct,Ze[2*Ue]=Ze[2*He]+Ze[2*ct],Me.depth[Ue]=(Me.depth[He]>=Me.depth[ct]?Me.depth[He]:Me.depth[ct])+1,Ze[2*He+1]=Ze[2*ct+1]=Ue,Me.heap[1]=Ue++,tt(Me,Ze,1),2<=Me.heap_len;);Me.heap[--Me.heap_max]=Me.heap[1],function(Dt,Vt){var hs,Ts,Cs,cs,er,xt,Es=Vt.dyn_tree,ur=Vt.max_code,Mr=Vt.stat_desc.static_tree,Lr=Vt.stat_desc.has_stree,fn=Vt.stat_desc.extra_bits,ki=Vt.stat_desc.extra_base,Ea=Vt.stat_desc.max_length,dr=0;for(cs=0;cs<=w;cs++)Dt.bl_count[cs]=0;for(Es[2*Dt.heap[Dt.heap_max]+1]=0,hs=Dt.heap_max+1;hs>=7;Ue>>=1)if(1&it&&We.dyn_ltree[2*Je]!==0)return l;if(We.dyn_ltree[18]!==0||We.dyn_ltree[20]!==0||We.dyn_ltree[26]!==0)return i;for(Je=32;Je>>3,(Ze=Me.static_len+3+7>>>3)<=Ue&&(Ue=Ze)):Ue=Ze=He+5,He+4<=Ue&&rt!==-1?et(Me,rt,He,ct):Me.strategy===4||Ze===Ue?($e(Me,2+(ct?1:0),3),Te(Me,Y,Q)):($e(Me,4+(ct?1:0),3),function(We,Je,it,Dt){var Vt;for($e(We,Je-257,5),$e(We,it-1,5),$e(We,Dt-4,4),Vt=0;Vt>>8&255,Me.pending_buf[Me.d_buf+2*Me.last_lit+1]=255&rt,Me.pending_buf[Me.l_buf+Me.last_lit]=255&He,Me.last_lit++,rt===0?Me.dyn_ltree[2*He]++:(Me.matches++,rt--,Me.dyn_ltree[2*(X[He]+f+1)]++,Me.dyn_dtree[2*pe(rt)]++),Me.last_lit===Me.lit_bufsize-1},a._tr_align=function(Me){$e(Me,2,3),Ae(Me,M,Y),function(rt){rt.bi_valid===16?(_e(rt,rt.bi_buf),rt.bi_buf=0,rt.bi_valid=0):8<=rt.bi_valid&&(rt.pending_buf[rt.pending++]=255&rt.bi_buf,rt.bi_buf>>=8,rt.bi_valid-=8)}(Me)}},{"../utils/common":41}],53:[function(r,n,a){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,a){(function(o){(function(l,i){if(!l.setImmediate){var c,u,p,f,g=1,b={},_=!1,j=l.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(l);w=w&&w.setTimeout?w:l,c={}.toString.call(l.process)==="[object process]"?function(L){process.nextTick(function(){S(L)})}:function(){if(l.postMessage&&!l.importScripts){var L=!0,I=l.onmessage;return l.onmessage=function(){L=!1},l.postMessage("","*"),l.onmessage=I,L}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",M,!1):l.attachEvent("onmessage",M),function(L){l.postMessage(f+L,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(L){S(L.data)},function(L){p.port2.postMessage(L)}):j&&"onreadystatechange"in j.createElement("script")?(u=j.documentElement,function(L){var I=j.createElement("script");I.onreadystatechange=function(){S(L),I.onreadystatechange=null,u.removeChild(I),I=null},u.appendChild(I)}):function(L){setTimeout(S,0,L)},w.setImmediate=function(L){typeof L!="function"&&(L=new Function(""+L));for(var I=new Array(arguments.length-1),O=0;O"u"?o===void 0?this:o:self)}).call(this,typeof Gv<"u"?Gv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Get);var pUt=Get.exports;const fUt=Po(pUt);function Ege(t,s=400,r=75){return t&&`${t.replace("/storage/v1/object/public/","/storage/v1/render/image/public/")}?width=${s}&quality=${r}&resize=contain`}const xUt=()=>{const{isAdmin:t}=Ds(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState("all"),[i,c]=k.useState(new Set),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState("images"),[j,w]=k.useState(null),{data:N=[],isLoading:S}=mt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:ge,error:ye}=await H.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ye)throw ye;return ge}}),{data:M=[]}=mt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:ge,error:ye}=await H.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ye)throw ye;return ge}}),{data:L=[]}=mt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:ge,error:ye}=await H.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ye)throw ye;return ge}}),{data:I=[]}=mt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:ge,error:ye}=await H.from("social_accounts").select("id, platform").eq("is_active",!0);if(ye)throw ye;return ge||[]}}),O=I.length>0,q=k.useMemo(()=>o==="all"?null:L.find(ge=>ge.month===o)||null,[o,L]),U=k.useMemo(()=>[...new Set(N.map(ye=>ye.month))].sort((ye,ue)=>ue.localeCompare(ye)),[N]);k.useEffect(()=>{U.length>0&&o==="all"&&l(U[0])},[U,o]);const B=ge=>{try{const ye=bje(ge,"yyyy-MM",new Date);return ms(ye,"MMMM yyyy")}catch{return ge}},V=k.useMemo(()=>o==="all"?N:N.filter(ge=>ge.month===o),[o,N]),Y=k.useMemo(()=>{var ge;return o==="all"?null:((ge=M.find(ye=>ye.month===o))==null?void 0:ge.canva_link)||null},[o,M]),Q=async ge=>{try{await navigator.clipboard.writeText(ge),me.success("Caption copied to clipboard!")}catch{me.error("Failed to copy caption")}},ee=async(ge,ye)=>{try{const pe=await(await fetch(ge)).blob(),_e=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),$e=navigator.canShare&&navigator.canShare({files:[new File([pe],"test.jpg",{type:"image/jpeg"})]});if(_e&&$e){const Ae=new File([pe],`social-swag-${ye}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Ae],title:"Social Swag Image"}),me.success("Image ready to save!")}else{const Ae=window.URL.createObjectURL(pe),Ie=document.createElement("a");Ie.href=Ae,Ie.download=`social-swag-${ye}.jpg`,document.body.appendChild(Ie),Ie.click(),document.body.removeChild(Ie),window.URL.revokeObjectURL(Ae),me.success("Image downloaded!")}}catch(ue){ue.name!=="AbortError"&&me.error("Failed to download image")}},X=ge=>{c(ye=>{const ue=new Set(ye);return ue.has(ge)?ue.delete(ge):ue.add(ge),ue})},ie=()=>{c(new Set(V.map(ge=>ge.id)))},re=()=>{c(new Set),p(!1)},oe=async()=>{const ge=V.filter(ye=>i.has(ye.id));if(ge.length===0){me.error("No images selected");return}g(!0),me.info(`Preparing ${ge.length} images for download...`);try{const ye=new fUt,ue=[...ge].sort((Ie,Ce)=>Ie.sort_order-Ce.sort_order);for(let Ie=0;Ie{u?X(ge.id):r(ge)};return e.jsx(Ms,{title:"Social Swag 2.0",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary via-primary/80 to-info p-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsxs(st,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(pn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(st,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(gl,{className:"h-3 w-3 mr-1"}),N.length," images"]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3",children:"Social Swag 📸"}),e.jsx("p",{className:"text-lg text-primary-foreground/90 max-w-2xl",children:"Ready-to-post social media images delivered to you monthly. Just download, copy the caption, and share with your audience!"})]})]}),t?e.jsxs(ba,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(pa,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(ns,{value:"gallery",className:"gap-2",children:[e.jsx(gl,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(ns,{value:"scheduled",className:"gap-2",children:[e.jsx(Od,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(bs,{value:"gallery",className:"space-y-6",children:[t?O?e.jsx(Ee,{className:"border rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-muted text-2xl",children:"📸"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Ready to post!"}),e.jsx("p",{className:"text-muted-foreground",children:'Click any image and use "Create Post" to share directly to your connected accounts.'})]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(Pi,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-primary/30 bg-gradient-to-r from-pink-500/5 via-purple-500/5 to-blue-500/5 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Su,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Mu,{className:"h-5 w-5 text-pink-600"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Post directly to social media"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your Facebook & Instagram accounts to post images with one click!"})]}),e.jsx(K,{asChild:!0,className:"gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600",children:e.jsxs(Pi,{to:"/social-connections",children:[e.jsx(dl,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(un,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Su,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Mu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(st,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:U.map(ge=>e.jsx("button",{onClick:()=>l(ge),className:It("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:B(ge)},ge))}),o!=="all"&&(Y?e.jsxs("a",{href:Y,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{_("images"),re()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(gl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),re()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(gu,{className:"h-4 w-4"}),"Reels"]})]}),b==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:re,className:"gap-2",children:[e.jsx(Rr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{size:"sm",onClick:oe,disabled:f,className:"gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]}),e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:"Please ensure your browser allows downloads from the LevelUp Dashboard."})]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(va,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&b==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(ge=>{const ye=i.has(ge.id);return e.jsx(Ee,{className:It("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ye&&"ring-2 ring-primary ring-offset-2"),onClick:()=>ce(ge),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Ege(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&&!u&&e.jsx("div",{className:"absolute top-0 left-0 w-24 h-24 overflow-hidden pointer-events-none",children:e.jsx("div",{className:"absolute flex items-center justify-center text-white font-bold text-[10px] tracking-wider uppercase",style:{top:"20px",left:"-34px",width:"136px",transform:"rotate(-45deg)",backgroundColor:"#2d5052",padding:"5px 0",boxShadow:"0 2px 4px rgba(0,0,0,0.25)"},children:ms(new Date(ge.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:It("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ye?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ye&&e.jsx(va,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},ge.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(gl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&b==="reels"&&e.jsx(e.Fragment,{children:q?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(q),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:Ege(q.image_url,400,75),alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy",decoding:"async"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(st,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(gu,{className:"h-3 w-3 mr-1"}),"Reel"]})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(gu,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),e.jsx(fs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ps,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:s&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-muted",children:e.jsx("div",{className:"aspect-[4/5]",children:e.jsx("img",{src:Ege(s.image_url,900,85),alt:"Social swag",className:"w-full h-full object-cover",decoding:"async"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-4",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(hn,{className:"h-4 w-4"}),ms(new Date(s.created_at),"MMMM d, yyyy")]}),s.post_date&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium rounded-full px-3 py-1 text-xs text-white",style:{background:"#406E71"},children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Post on ",ms(new Date(s.post_date+"T00:00:00"),"MMMM d, yyyy")]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-6",children:[t&&e.jsxs(K,{onClick:()=>{w({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx(Bn,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{variant:"outline",onClick:()=>Q(s.caption),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>ee(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ps,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:n&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-black flex items-center justify-center",children:e.jsx("div",{className:"aspect-[9/16] max-h-[70vh]",children:e.jsx("img",{src:n.image_url,alt:"Reel preview",className:"w-full h-full object-contain"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(gu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>Q(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(tn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(hUt,{open:!!j,onOpenChange:ge=>!ge&&w(null),imageUrl:(j==null?void 0:j.imageUrl)||"",imageId:(j==null?void 0:j.imageId)||"",defaultCaption:(j==null?void 0:j.caption)||"",swagItemId:j==null?void 0:j.imageId})]}),e.jsx(bs,{value:"scheduled",children:e.jsx(mUt,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(un,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Su,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Mu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(st,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:U.map(ge=>e.jsx("button",{onClick:()=>l(ge),className:It("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:B(ge)},ge))}),o!=="all"&&(Y?e.jsxs("a",{href:Y,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{_("images"),re()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(gl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),re()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(gu,{className:"h-4 w-4"}),"Reels"]})]}),b==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:re,className:"gap-2",children:[e.jsx(Rr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:oe,disabled:f,className:"gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(va,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&b==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(ge=>{const ye=i.has(ge.id);return e.jsx(Ee,{className:It("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ye&&"ring-2 ring-primary ring-offset-2"),onClick:()=>ce(ge),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:ge.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),u&&e.jsx("div",{className:It("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ye?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ye&&e.jsx(va,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},ge.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(gl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&b==="reels"&&e.jsx(e.Fragment,{children:q?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(q),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:q.image_url,alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(st,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(gu,{className:"h-3 w-3 mr-1"}),"Reel"]})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(gu,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),e.jsx(fs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(ps,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:s&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-muted",children:e.jsx("div",{className:"aspect-[4/5]",children:e.jsx("img",{src:s.image_url,alt:"Social swag",className:"w-full h-full object-cover"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(hn,{className:"h-4 w-4"}),ms(new Date(s.created_at),"MMMM d, yyyy")]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",onClick:()=>Q(s.caption),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>ee(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(ps,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:n&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-black flex items-center justify-center",children:e.jsx("div",{className:"aspect-[9/16] max-h-[70vh]",children:e.jsx("img",{src:n.image_url,alt:"Reel preview",className:"w-full h-full object-contain"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(gu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>Q(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(tn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},gUt=()=>{const{swagId:t}=yo(),{user:s}=Ds(),{toast:r}=Ua(),n=Qt(),{trackEngagement:a}=GO(),[o,l]=k.useState(""),{data:i,isLoading:c}=mt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:N,error:S}=await H.from("social_swag").select("*").eq("id",t).single();if(S)throw S;const{data:M}=await H.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...N,links:M||[]}},enabled:!!t});k.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=mt({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:N,error:S}=await H.from("social_swag_likes").select("*").eq("swag_id",t);if(S)throw S;return N},enabled:!!t}),{data:p=[]}=mt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:N,error:S}=await H.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(S)throw S;const M=[...new Set(N.map(O=>O.user_id))],{data:L}=await H.from("profiles").select("id, name").in("id",M),I=new Map((L==null?void 0:L.map(O=>[O.id,O.name]))||[]);return N.map(O=>({...O,user_name:I.get(O.user_id)||"Unknown User"}))},enabled:!!t}),f=Lt({mutationFn:async N=>{const{error:S}=await H.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:N});if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:N=>{r({title:"Error adding comment",description:N.message,variant:"destructive"})}}),g=Lt({mutationFn:async N=>{const{error:S}=await H.from("social_swag_comments").delete().eq("id",N);if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),b=Lt({mutationFn:async()=>{const N=u.find(S=>S.user_id===(s==null?void 0:s.id));if(N){const{error:S}=await H.from("social_swag_likes").delete().eq("id",N.id);if(S)throw S}else{const{error:S}=await H.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(S)throw S}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),_=u.some(N=>N.user_id===(s==null?void 0:s.id)),j=N=>N.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),w=N=>{N.preventDefault(),!(!o.trim()||!s)&&f.mutate(o.trim())};return c?e.jsx(Ms,{title:"Social Swag",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):i?e.jsx(Ms,{title:i.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Pi,{to:"/social-swag",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Social Swag"]})}),i.preview_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:i.preview_image_url,alt:i.title,className:"w-full max-h-[500px] object-contain"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:i.title})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(lE,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(K,{variant:_?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(sh,{className:`h-4 w-4 ${_?"fill-current":""}`}),u.length," ",u.length===1?"Like":"Likes"]})]})]}),i.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:i.description}})]}),i.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Bo,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(N=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{a("social_swag",i.id,i.title,"click_canva"),window.open(N.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:N.title}),e.jsx(tn,{className:"h-4 w-4 text-muted-foreground"})]},N.id))})]})}),e.jsx(rl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx($c,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:w,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:o,onChange:N=>l(N.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||f.isPending,children:e.jsx(Bn,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:p.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):p.map(N=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:j(N.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:N.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Uc(new Date(N.created_at),{addSuffix:!0})}),N.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>g.mutate(N.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:N.content})]})]})})},N.id))})]})]})}):e.jsx(Ms,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Bo,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Item not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This item may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(Pi,{to:"/social-swag",children:"Back to Social Swag"})})]})})},yUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.useState(!0),[i,c]=k.useState(!0),[u,p]=k.useState(!0),f=g=>g.split(" ").map(b=>b[0]).join("").toUpperCase().slice(0,2);return e.jsx("aside",{className:"w-64 shrink-0 hidden lg:block relative z-0",children:e.jsx("div",{className:"sticky top-4 space-y-4 max-h-[calc(100vh-8rem)] overflow-y-auto overscroll-contain",children:e.jsxs("div",{className:"space-y-2 pr-4",children:[e.jsxs(K,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx($_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(yf,{open:o,onOpenChange:l,children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"Categories"}),o?e.jsx(Eo,{className:"h-4 w-4"}):e.jsx(da,{className:"h-4 w-4"})]})}),e.jsx(bf,{className:"space-y-1 pl-2",children:t.map(g=>e.jsxs(K,{variant:r===g.id?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(g.id),children:[e.jsx("span",{className:"mr-2",children:g.icon||"📂"}),e.jsx("span",{className:"truncate",children:g.name})]},g.id))})]}),s.length>0&&e.jsxs(yf,{open:i,onOpenChange:c,children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Eo,{className:"h-4 w-4"}):e.jsx(da,{className:"h-4 w-4"})]})}),e.jsx(bf,{className:"space-y-1 pl-2",children:s.map(g=>e.jsxs(K,{variant:r===`group:${g.id}`?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(`group:${g.id}`),children:[e.jsx("span",{className:"mr-2",children:g.icon||"🔒"}),e.jsx("span",{className:"truncate",children:g.name})]},g.id))})]}),e.jsxs(yf,{open:u,onOpenChange:p,children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(pr,{className:"h-3 w-3"}),"Online Now",a.length>0&&e.jsx("span",{className:"ml-1 bg-green-500 text-white text-xs rounded-full px-1.5 py-0.5 min-w-[20px] text-center",children:a.length})]}),u?e.jsx(Eo,{className:"h-4 w-4"}):e.jsx(da,{className:"h-4 w-4"})]})}),e.jsx(bf,{className:"pl-2 space-y-1",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-2 px-2",children:"No one else online right now"}):a.map(g=>e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-7 w-7",children:[e.jsx($a,{src:g.avatarUrl}),e.jsx(kn,{className:"text-xs",children:f(g.name)})]}),e.jsx(_d,{className:"h-2.5 w-2.5 fill-green-500 text-green-500 absolute -bottom-0.5 -right-0.5"})]}),e.jsx("span",{className:"text-sm truncate",children:g.name})]},g.id))})]})]})})})},vUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.useState(!1),i=u=>u.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),c=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const p=r.replace("group:",""),f=s.find(g=>g.id===p);return f?`🔒 ${f.name}`:"Private Group"}const u=t.find(p=>p.id===r);return u?`${u.icon||"📂"} ${u.name}`:"Category"};return e.jsxs("div",{className:"lg:hidden flex items-center gap-2 mb-4",children:[e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:c()}),e.jsx(Eo,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(Bd,{className:"w-56 bg-background border",children:[e.jsxs(Ma,{onClick:()=>n("all"),children:[e.jsx($_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(uw,{}),e.jsx(Sve,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(Ma,{onClick:()=>n(u.id),children:[e.jsx("span",{className:"mr-2",children:u.icon||"📂"}),u.name]},u.id)),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(uw,{}),e.jsxs(Sve,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(Ma,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(eE,{open:o,onOpenChange:l,children:[e.jsx(rNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(pr,{className:"h-4 w-4"}),a.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-green-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center",children:a.length})]})}),e.jsxs(vC,{children:[e.jsx(tE,{children:e.jsxs(sE,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Gi,{className:"h-[calc(100vh-8rem)] mt-4",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No one else online right now"}):e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:u.avatarUrl}),e.jsx(kn,{children:i(u.name)})]}),e.jsx(_d,{className:"h-3 w-3 fill-green-500 text-green-500 absolute -bottom-0.5 -right-0.5"})]}),e.jsx("span",{className:"font-medium",children:u.name})]},u.id))})})]})]})]})};var Pge,Hue="HoverCard",[Ket]=ad(Hue,[F0]),Wue=F0(),[bUt,Lke]=Ket(Hue),Zet=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,c=Wue(s),u=k.useRef(0),p=k.useRef(0),f=k.useRef(!1),g=k.useRef(!1),[b,_]=ah({prop:n,defaultProp:a??!1,onChange:o,caller:Hue}),j=k.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>_(!0),l)},[l,_]),w=k.useCallback(()=>{clearTimeout(u.current),!f.current&&!g.current&&(p.current=window.setTimeout(()=>_(!1),i))},[i,_]),N=k.useCallback(()=>_(!1),[_]);return k.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(bUt,{scope:s,open:b,onOpenChange:_,onOpen:j,onClose:w,onDismiss:N,hasSelectionRef:f,isPointerDownOnContentRef:g,children:e.jsx(wO,{...c,children:r})})};Zet.displayName=Hue;var Yet="HoverCardTrigger",Xet=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Lke(Yet,r),o=Wue(r);return e.jsx(qA,{asChild:!0,...o,children:e.jsx(nn.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Ir(t.onPointerEnter,zle(a.onOpen)),onPointerLeave:Ir(t.onPointerLeave,zle(a.onClose)),onFocus:Ir(t.onFocus,a.onOpen),onBlur:Ir(t.onBlur,a.onClose),onTouchStart:Ir(t.onTouchStart,l=>l.preventDefault())})})});Xet.displayName=Yet;var _Ut="HoverCardPortal",[QMs,wUt]=Ket(_Ut,{forceMount:void 0}),Fle="HoverCardContent",Qet=k.forwardRef((t,s)=>{const r=wUt(Fle,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=Lke(Fle,t.__scopeHoverCard);return e.jsx(zd,{present:n||o.open,children:e.jsx(jUt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Ir(t.onPointerEnter,zle(o.onOpen)),onPointerLeave:Ir(t.onPointerLeave,zle(o.onClose)),ref:s})})});Qet.displayName=Fle;var jUt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,c=Lke(Fle,r),u=Wue(r),p=k.useRef(null),f=qa(s,p),[g,b]=k.useState(!1);return k.useEffect(()=>{if(g){const _=document.body;return Pge=_.style.userSelect||_.style.webkitUserSelect,_.style.userSelect="none",_.style.webkitUserSelect="none",()=>{_.style.userSelect=Pge,_.style.webkitUserSelect=Pge}}},[g]),k.useEffect(()=>{if(p.current){const _=()=>{b(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var w;((w=document.getSelection())==null?void 0:w.toString())!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",_),()=>{document.removeEventListener("pointerup",_),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),k.useEffect(()=>{p.current&&SUt(p.current).forEach(j=>j.setAttribute("tabindex","-1"))}),e.jsx(kw,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Ir(o,_=>{_.preventDefault()}),onDismiss:c.onDismiss,children:e.jsx(jO,{...u,...i,onPointerDown:Ir(i.onPointerDown,_=>{_.currentTarget.contains(_.target)&&b(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:f,style:{...i.style,userSelect:g?"text":void 0,WebkitUserSelect:g?"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)"}})})}),NUt="HoverCardArrow",kUt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Wue(r);return e.jsx(NO,{...a,...n,ref:s})});kUt.displayName=NUt;function zle(t){return s=>s.pointerType==="touch"?void 0:t()}function SUt(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;r.nextNode();)s.push(r.currentNode);return s}var CUt=Zet,MUt=Xet,Jet=Qet;const TUt=CUt,AUt=MUt,ett=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(Jet,{ref:a,align:s,sideOffset:r,className:It("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));ett.displayName=Jet.displayName;const EUt=[{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"}],PUt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),ttt=({reactions:t,children:s})=>{if(t.length===0)return e.jsx(e.Fragment,{children:s});const r={};return t.forEach(n=>{r[n.reaction_type]||(r[n.reaction_type]=[]),r[n.reaction_type].push(n)}),e.jsxs(TUt,{openDelay:200,closeDelay:100,children:[e.jsx(AUt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(ett,{className:"w-64 p-3 bg-popover border shadow-lg z-50",side:"top",align:"start",children:e.jsx("div",{className:"space-y-3",children:Object.entries(r).map(([n,a])=>{const o=EUt.find(l=>l.type===n);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-lg",children:o==null?void 0:o.emoji}),e.jsxs("span",{className:"text-sm font-medium text-foreground",children:[o==null?void 0:o.label," (",a.length,")"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[a.slice(0,10).map(l=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:l.user_avatar||void 0}),e.jsx(kn,{className:"text-[10px]",children:PUt(l.user_name||"U")})]}),e.jsx("span",{className:"text-sm text-foreground truncate",children:l.user_name||"Unknown User"})]},l.id)),a.length>10&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",a.length-10," more"]})]})]},n)})})})]})};function IUt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=k.useState(s),[l,i]=k.useState(!1);k.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const c=()=>{o(g=>g>0?g-1:t.length-1),i(!1)},u=()=>{o(g=>g{r&&(g.key==="ArrowLeft"&&c(),g.key==="ArrowRight"&&u(),g.key==="Escape"&&n(!1))},[r,t.length]);k.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const f=t[a];return e.jsx(fs,{open:r,onOpenChange:n,children:e.jsxs(ps,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>n(!1),children:e.jsx(Rr,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:c,children:e.jsx(cl,{className:"h-8 w-8"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:u,children:e.jsx(da,{className:"h-8 w-8"})})]}),t.length>1&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-50 text-white text-sm bg-black/50 px-3 py-1 rounded-full",children:[a+1," / ",t.length]}),(f==null?void 0:f.type)==="image"&&e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 left-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>i(!l),children:l?e.jsx(HM,{className:"h-5 w-5"}):e.jsx(K_,{className:"h-5 w-5"})}),e.jsx("div",{className:It("flex items-center justify-center w-full h-full min-h-[50vh] p-4",l?"cursor-zoom-out overflow-auto":"cursor-zoom-in"),onClick:()=>(f==null?void 0:f.type)==="image"&&i(!l),children:(f==null?void 0:f.type)==="video"?e.jsx("video",{src:f.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:g=>g.stopPropagation()}):e.jsx("img",{src:f==null?void 0:f.url,alt:"",className:It("object-contain transition-transform duration-200",l?"max-w-none max-h-none scale-150":"max-w-full max-h-[85vh]")})}),t.length>1&&e.jsx("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 flex gap-2 bg-black/50 p-2 rounded-lg max-w-[90vw] overflow-x-auto",children:t.map((g,b)=>e.jsx("button",{onClick:()=>{o(b),i(!1)},className:It("w-12 h-12 rounded overflow-hidden flex-shrink-0 border-2 transition-all",a===b?"border-white":"border-transparent opacity-60 hover:opacity-100"),children:g.type==="video"?e.jsx("video",{src:g.url,className:"w-full h-full object-cover"}):e.jsx("img",{src:g.url,alt:"",className:"w-full h-full object-cover"})},b))})]})})}const kz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],LUt=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=Qt(),[a,o]=k.useState(!1),l=s.find(f=>f.user_id===r),i=Lt({mutationFn:async f=>{l?l.reaction_type===f?await H.from("community_comment_reactions").delete().eq("id",l.id):await H.from("community_comment_reactions").update({reaction_type:f}).eq("id",l.id):await H.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:f})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),c={};return s.forEach(f=>{c[f.reaction_type]=(c[f.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(ttt,{reactions:s,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("div",{className:"flex -space-x-0.5",children:Object.keys(c).slice(0,2).map(f=>{var g;return e.jsx("span",{className:"text-sm",children:(g=kz.find(b=>b.type===f))==null?void 0:g.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs($o,{open:a,onOpenChange:o,children:[e.jsx(qo,{asChild:!0,children:e.jsx("button",{className:`text-xs hover:text-primary transition-colors ${l?"text-primary font-medium":"text-muted-foreground"}`,children:l?e.jsxs("span",{children:[(u=kz.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(p=kz.find(f=>f.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ni,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(Ro,{className:"w-auto p-1.5 bg-popover border shadow-lg z-50",side:"top",children:e.jsx("div",{className:"flex gap-0.5",children:kz.map(f=>e.jsx("button",{onClick:()=>i.mutate(f.type),className:"text-xl hover:scale-125 transition-transform p-1",title:f.label,children:f.emoji},f.type))})})]})]})};function Dke({content:t,className:s}){const r=/([@#])\[([^\]]+)\]\(([^)]+)\)|(https?:\/\/[^\s<>]+)/g,n=[];let a=0,o,l=0;for(;(o=r.exec(t))!==null;){if(o.index>a&&n.push(t.substring(a,o.index)),o[1]){const i=o[1],c=o[2],u=o[3],p=i==="#";n.push(e.jsx(Pi,{to:p?`/templates/${u}`:`/profile?user=${u}`,className:It("font-medium hover:underline",p?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:f=>f.stopPropagation(),children:p?c:`@${c}`},`mention-${l++}`))}else if(o[4]){const i=o[4],c=i.replace(/[.,;:!?)]+$/,""),u=i.slice(c.length);let p;try{const f=new URL(c);p=f.hostname+(f.pathname!=="/"?f.pathname.slice(0,20)+(f.pathname.length>20?"...":""):"")}catch{p=c.length>40?c.slice(0,40)+"...":c}n.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",onClick:f=>f.stopPropagation(),children:p},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(k.Fragment,{children:i},c))})}function Ble({value:t,onChange:s,placeholder:r="What's on your mind? Use @ to mention someone",className:n,minHeight:a="80px",onMentionsChange:o,onTemplatesChange:l,onKeyDown:i,mentionFormat:c="encoded",enableTemplateMentions:u=!1}){const p=k.useRef(null),f=k.useRef(null),[g,b]=k.useState(!1),[_,j]=k.useState("user"),[w,N]=k.useState(""),[S,M]=k.useState(null),[L,I]=k.useState(0),[O,q]=k.useState({top:0,left:0,width:0}),U=k.useRef(new Map),B=k.useRef(new Map),V=pe=>{if(c==="plain"){const Ie=[];return U.current.forEach((xe,we)=>{pe.includes(`@${we}`)&&Ie.push(xe)}),[...new Set(Ie)]}const _e=/@\[([^\]]+)\]\(([^)]+)\)/g,$e=[];let Ae;for(;(Ae=_e.exec(pe))!==null;)$e.push(Ae[2]);return[...new Set($e)]},Y=pe=>{if(c==="plain"){const Ie=[];return B.current.forEach((xe,we)=>{pe.includes(`#${we}`)&&Ie.push(xe)}),[...new Set(Ie)]}const _e=/#\[([^\]]+)\]\(([^)]+)\)/g,$e=[];let Ae;for(;(Ae=_e.exec(pe))!==null;)$e.push(Ae[2]);return[...new Set($e)]};k.useEffect(()=>{if(o){const pe=V(t);o(pe)}if(l){const pe=Y(t);l(pe)}},[t,o,l,c]);const{data:Q=[],isLoading:ee}=mt({queryKey:["mention-users",w],queryFn:async()=>{const pe=H.from("profiles").select("id, name").limit(8),_e=w.length>=1?pe.ilike("name",`%${w}%`):pe.order("name"),{data:$e,error:Ae}=await _e;if(Ae)throw Ae;const Ie=$e.map(xe=>xe.id),Ce=await zZe(Ie);return $e.map(xe=>({id:xe.id,name:xe.name||"Unknown",avatar_url:Ce.get(xe.id)}))},enabled:g&&_==="user",staleTime:3e4}),{data:X=[],isLoading:ie}=mt({queryKey:["mention-templates",w],queryFn:async()=>{let pe=H.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);w.length>=1&&(pe=pe.ilike("name",`%${w}%`));const{data:_e,error:$e}=await pe;if($e)throw $e;return _e||[]},enabled:g&&_==="template"&&u,staleTime:3e4}),re=_==="user"?ee:ie,oe=_==="user"?Q:X,ce=pe=>pe.split(" ").map(_e=>_e[0]).join("").toUpperCase().slice(0,2),ge=pe=>{const _e=pe.target.value,$e=pe.target.selectionStart;s(_e);const Ae=_e.substring(0,$e),Ie=Ae.lastIndexOf("@"),Ce=u?Ae.lastIndexOf("#"):-1;let xe=-1,we="user";if(Ie>Ce?(xe=Ie,we="user"):Ce>Ie&&u&&(xe=Ce,we="template"),xe!==-1){const Le=Ae.substring(xe+1),tt=Le.includes(" "),Te=Le.includes(` `);if(!tt&&!Te&&Le.length<=30){M(xe),N(Le),j(we),b(!0),I(0);return}}b(!1),M(null)},ye=pe=>{if(S===null)return;const _e=t.substring(0,S),$e=t.substring(S+w.length+1),Ae=_==="user"?"@":"#",Ie=c==="plain"?`${Ae}${pe.name} `:`${Ae}[${pe.name}](${pe.id}) `;c==="plain"&&(_==="user"?U.current.set(pe.name,pe.id):B.current.set(pe.name,pe.id));const Ce=_e+Ie+$e;s(Ce),b(!1),M(null),N(""),setTimeout(()=>{if(p.current){const xe=_e.length+Ie.length;p.current.focus(),p.current.setSelectionRange(xe,xe)}},0)},ue=pe=>{if(!(!g||oe.length===0))switch(pe.key){case"ArrowDown":pe.preventDefault(),I(_e=>(_e+1)%oe.length);break;case"ArrowUp":pe.preventDefault(),I(_e=>(_e-1+oe.length)%oe.length);break;case"Enter":oe[L]&&(pe.preventDefault(),ye(oe[L]));break;case"Escape":pe.preventDefault(),b(!1);break;case"Tab":oe[L]&&(pe.preventDefault(),ye(oe[L]));break}};return k.useEffect(()=>{const pe=_e=>{f.current&&!f.current.contains(_e.target)&&p.current&&!p.current.contains(_e.target)&&b(!1)};return document.addEventListener("mousedown",pe),()=>document.removeEventListener("mousedown",pe)},[]),k.useEffect(()=>{if(!g)return;const pe=()=>{const _e=p.current;if(!_e)return;const $e=_e.getBoundingClientRect();q({top:$e.bottom+4,left:$e.left,width:$e.width})};return pe(),window.addEventListener("resize",pe),window.addEventListener("scroll",pe,!0),()=>{window.removeEventListener("resize",pe),window.removeEventListener("scroll",pe,!0)}},[g,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Er,{ref:p,value:t,onChange:ge,onKeyDown:pe=>{ue(pe),pe.defaultPrevented||i==null||i(pe)},placeholder:r,className:It("resize-none",n),style:{minHeight:a}}),g&&yp.createPortal(e.jsxs("div",{ref:f,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:O.top,left:O.left,width:O.width,maxWidth:"320px"},children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b bg-muted/30",children:_==="user"?"👤 Mention a person":"📋 Link a template"}),re?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):oe.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:w.length<1?`Type to search ${_==="user"?"people":"templates"}...`:`No ${_==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:oe.map((pe,_e)=>e.jsx("li",{className:It("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",_e===L?"bg-accent":"hover:bg-accent/50"),onClick:()=>ye(pe),onMouseEnter:()=>I(_e),children:_==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:pe.avatar_url}),e.jsx(kn,{className:"text-xs",children:ce(pe.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:pe.name})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center overflow-hidden flex-shrink-0",children:pe.preview_image_url?e.jsx("img",{src:pe.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(ic,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:pe.name})]})},pe.id))})]}),document.body)]})}function DUt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const h8e=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function stt({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=Qt(),[c,u]=k.useState(!1),[p,f]=k.useState(""),[g,b]=k.useState([]),_=Lt({mutationFn:async({content:S,parentCommentId:M})=>{const{data:L,error:I}=await H.from("community_comments").insert({post_id:s,user_id:r,content:S,parent_comment_id:M}).select("id").single();if(I)throw I;const O=g;if(O.length>0&&L){const q=O.filter(U=>U!==r).map(U=>({comment_id:L.id,mentioned_user_id:U,mentioned_by_user_id:r}));q.length>0&&await H.from("community_comment_mentions").insert(q)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),b([]),u(!1)}}),j=Lt({mutationFn:async S=>{const{error:M}=await H.from("community_comments").delete().eq("id",S);if(M)throw M},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),w=()=>{p.trim()&&_.mutate({content:p,parentCommentId:t.id})};return e.jsxs("div",{className:l>0?"ml-8 border-l-2 border-muted pl-3":"",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx($a,{src:t.user_avatar||void 0}),e.jsx(kn,{className:"text-xs",children:h8e(t.user_name||"U")})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"bg-muted rounded-lg px-3 py-2",children:[e.jsx("div",{className:"font-medium text-sm",children:t.user_name}),e.jsx(Dke,{content:t.content,className:"text-sm break-words"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground flex-wrap",children:[e.jsx("span",{children:Uc(new Date(t.created_at),{addSuffix:!0})}),e.jsx(LUt,{commentId:t.id,reactions:t.reactions,currentUserId:r}),r&&l<2&&e.jsxs("button",{onClick:()=>u(!c),className:"hover:text-primary flex items-center gap-1",children:[e.jsx(NL,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>j.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),c&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(Nn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx($a,{src:n||void 0}),e.jsx(kn,{className:"text-xs",children:h8e((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(Ble,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:f,onMentionsChange:b,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:w,disabled:!p.trim()||_.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(Bn,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(S=>e.jsx(stt,{comment:S,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},S.id))})]})}const Sz=[{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"}],OUt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Ds(),{avatarUrl:a}=FZe(t==null?void 0:t.id),{onlineUsers:o}=BYe(),{toast:l}=Ua(),i=Qt(),c=k.useRef(null),[u,p]=k.useState("all"),[f,g]=k.useState(""),[b,_]=k.useState(""),[j,w]=k.useState(""),[N,S]=k.useState([]),[M,L]=k.useState([]),[I,O]=k.useState(""),[q,U]=k.useState(!1),[B,V]=k.useState(null),[Y,Q]=k.useState(""),[ee,X]=k.useState(new Set),[ie,re]=k.useState({}),[oe,ce]=k.useState({}),[ge,ye]=k.useState([]),[ue,pe]=k.useState([]),[_e,$e]=k.useState({open:!1,images:[],index:0});k.useEffect(()=>{if(u.startsWith("group:")){const it=u.replace("group:","");w(it),_("")}else u!=="all"?(_(u),w("")):(_(""),w(""))},[u]);const{data:Ae=[]}=mt({queryKey:["community-categories"],queryFn:async()=>{const{data:it,error:Dt}=await H.from("community_categories").select("*").order("sort_order");if(Dt)throw Dt;return it}}),{data:Ie=[]}=mt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:it,error:Dt}=await H.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Dt)throw Dt;return it}}),Ce=20,{data:xe,isLoading:we,hasNextPage:Le,fetchNextPage:tt,isFetchingNextPage:Te}=lUe({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:it})=>{var Be;const Dt=it*Ce,Vt=Dt+Ce;let hs=H.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Dt,Vt);if(u.startsWith("group:")){const Ye=u.replace("group:","");hs=hs.eq("private_group_id",Ye)}else u==="all"||(hs=hs.eq("category_id",u).is("private_group_id",null));const{data:Ts,error:Cs}=await hs;if(Cs)throw Cs;const cs=((Ts==null?void 0:Ts.length)||0)>Ce,er=(Ts||[]).slice(0,Ce);if(er.length===0)return{posts:[],hasMore:!1,nextPage:it+1};const xt=er.map(Ye=>Ye.id),Es=[...new Set(er.filter(Ye=>Ye.category_id).map(Ye=>Ye.category_id))].filter(Boolean),[ur,Mr,Lr,fn,ki]=await Promise.all([Es.length?H.from("community_categories").select("*").in("id",Es):Promise.resolve({data:[]}),H.from("community_post_media").select("*").in("post_id",xt).order("sort_order"),H.from("community_reactions").select("*").in("post_id",xt),H.from("community_comments").select("*").in("post_id",xt).order("created_at",{ascending:!0}),H.from("community_post_resources").select("*").in("post_id",xt)]),Ea=ur==null?void 0:ur.data,dr=Mr==null?void 0:Mr.data,Jr=Lr==null?void 0:Lr.data,Wr=fn==null?void 0:fn.data,dn=ki==null?void 0:ki.data,Yr=(Wr||[]).map(Ye=>Ye.id),[vi,ft]=await Promise.all([Yr.length?H.from("community_comment_reactions").select("*").in("comment_id",Yr):Promise.resolve({data:[]}),(()=>{const Ye=(dn||[]).filter(bt=>bt.resource_type==="template").map(bt=>bt.resource_id);return Ye.length===0?Promise.resolve({data:[]}):H.from("canva_templates").select("id, name, preview_image_url").in("id",Ye)})()]),ir=(vi==null?void 0:vi.data)||[],Vn=(ft==null?void 0:ft.data)||[],Sr=new Map(Vn.map(Ye=>[Ye.id,{name:Ye.name,preview_image_url:Ye.preview_image_url}])),jr=Array.from(new Set([...er.map(Ye=>Ye.user_id),...(Jr||[]).map(Ye=>Ye.user_id),...(Wr||[]).map(Ye=>Ye.user_id),...ir.map(Ye=>Ye.user_id)])),[ea,Pa]=await Promise.all([jr.length?H.from("profiles").select("id, name").in("id",jr):Promise.resolve({data:[]}),zZe(jr)]),Ii=new Map(((Be=ea==null?void 0:ea.data)==null?void 0:Be.map(Ye=>[Ye.id,Ye.name]))||[]),Fo=new Map((Ea||[]).map(Ye=>[Ye.id,Ye])),$t=Ye=>{const bt=new Map,gt=[];return Ye.forEach(Ft=>{bt.set(Ft.id,{...Ft,user_name:Ii.get(Ft.user_id)||"Unknown User",user_avatar:Pa.get(Ft.user_id),reactions:ir.filter(Zt=>Zt.comment_id===Ft.id).map(Zt=>({...Zt,user_name:Ii.get(Zt.user_id)||"Unknown User",user_avatar:Pa.get(Zt.user_id)})),replies:[]})}),Ye.forEach(Ft=>{const Zt=bt.get(Ft.id);if(Ft.parent_comment_id&&bt.has(Ft.parent_comment_id)){const Ut=bt.get(Ft.parent_comment_id);Ut.replies=Ut.replies||[],Ut.replies.push(Zt)}else gt.push(Zt)}),gt};return{posts:er.map(Ye=>{const bt=(dn||[]).filter(gt=>gt.post_id===Ye.id).map(gt=>{let Ft="",Zt=null;if(gt.resource_type==="template"){const Ut=Sr.get(gt.resource_id);Ft=(Ut==null?void 0:Ut.name)||"Unknown Template",Zt=(Ut==null?void 0:Ut.preview_image_url)||null}return{id:gt.id,resource_type:gt.resource_type,resource_id:gt.resource_id,resource_name:Ft,resource_preview_url:Zt}});return{...Ye,user_name:Ii.get(Ye.user_id)||"Unknown User",user_avatar:Pa.get(Ye.user_id),category:Ye.category_id?Fo.get(Ye.category_id):null,media:(dr||[]).filter(gt=>gt.post_id===Ye.id),reactions:((Jr||[]).filter(gt=>gt.post_id===Ye.id)||[]).map(gt=>({...gt,user_name:Ii.get(gt.user_id)||"Unknown User",user_avatar:Pa.get(gt.user_id)})),comments:$t((Wr||[]).filter(gt=>gt.post_id===Ye.id)),resources:bt}}),hasMore:cs,nextPage:it+1}},getNextPageParam:it=>it.hasMore?it.nextPage:void 0}),pt=k.useMemo(()=>(xe==null?void 0:xe.pages.flatMap(it=>it.posts))??[],[xe]),fe=Lt({mutationFn:async()=>{U(!0);const{data:it,error:Dt}=await H.from("community_posts").insert({user_id:t.id,category_id:j?null:b||null,private_group_id:j||null,content:f,link_url:I||null}).select().single();if(Dt)throw Dt;for(let hs=0;hs0){const hs=ge.filter(Ts=>Ts!==t.id).map(Ts=>({post_id:it.id,mentioned_user_id:Ts,mentioned_by_user_id:t.id}));hs.length>0&&await H.from("community_post_mentions").insert(hs)}const Vt=DUt(f);if(Vt.length>0){const hs=Vt.map(Ts=>({post_id:it.id,resource_type:"template",resource_id:Ts}));await H.from("community_post_resources").insert(hs)}return it},onSuccess:async it=>{var Dt;i.invalidateQueries({queryKey:["community-posts"]}),g(""),ye([]),pe([]),_(""),w(""),S([]),L([]),O(""),l({title:"Post created!"});try{const Vt=((Dt=t==null?void 0:t.user_metadata)==null?void 0:Dt.name)||"Someone",hs=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Ts=hs.length>50?hs.substring(0,50)+"...":hs;await H.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Vt}: ${Ts}`,url:"/community"}})}catch(Vt){console.error("Failed to send push notification:",Vt)}},onError:it=>{l({title:"Error creating post",description:it.message,variant:"destructive"})},onSettled:()=>U(!1)}),qe=Lt({mutationFn:async({postId:it,content:Dt})=>{const{error:Vt}=await H.from("community_posts").update({content:Dt}).eq("id",it);if(Vt)throw Vt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),V(null),Q(""),l({title:"Post updated!"})}}),at=Lt({mutationFn:async it=>{const{error:Dt}=await H.from("community_posts").delete().eq("id",it);if(Dt)throw Dt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),et=Lt({mutationFn:async({postId:it,isPinned:Dt})=>{const{error:Vt}=await H.from("community_posts").update({is_pinned:!Dt,pinned_at:Dt?null:new Date().toISOString(),pinned_by:Dt?null:t==null?void 0:t.id}).eq("id",it);if(Vt)throw Vt},onSuccess:(it,{isPinned:Dt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Dt?"Post unpinned":"Post pinned to top"})}}),Me=Lt({mutationFn:async({postId:it,reactionType:Dt})=>{var hs;const Vt=(hs=pt.find(Ts=>Ts.id===it))==null?void 0:hs.reactions.find(Ts=>Ts.user_id===(t==null?void 0:t.id));Vt?Vt.reaction_type===Dt?await H.from("community_reactions").delete().eq("id",Vt.id):await H.from("community_reactions").update({reaction_type:Dt}).eq("id",Vt.id):await H.from("community_reactions").insert({post_id:it,user_id:t.id,reaction_type:Dt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),rt=Lt({mutationFn:async({postId:it,content:Dt})=>{const{data:Vt,error:hs}=await H.from("community_comments").insert({post_id:it,user_id:t.id,content:Dt}).select("id").single();if(hs)throw hs;const Ts=oe[it]||[];if(Ts.length>0&&Vt){const Cs=Ts.filter(cs=>cs!==t.id).map(cs=>({comment_id:Vt.id,mentioned_user_id:cs,mentioned_by_user_id:t.id}));Cs.length>0&&await H.from("community_comment_mentions").insert(Cs)}},onSuccess:(it,{postId:Dt})=>{i.invalidateQueries({queryKey:["community-posts"]}),re(Vt=>({...Vt,[Dt]:""})),ce(Vt=>({...Vt,[Dt]:[]}))}});Lt({mutationFn:async it=>{const{error:Dt}=await H.from("community_comments").delete().eq("id",it);if(Dt)throw Dt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const He=it=>{const Dt=Array.from(it.target.files||[]);if(Dt.length+N.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}S(Vt=>[...Vt,...Dt]),Dt.forEach(Vt=>{const hs=new FileReader;hs.onloadend=()=>{L(Ts=>[...Ts,hs.result])},hs.readAsDataURL(Vt)})},ct=it=>{S(Dt=>Dt.filter((Vt,hs)=>hs!==it)),L(Dt=>Dt.filter((Vt,hs)=>hs!==it))},Ue=it=>it.split(" ").map(Dt=>Dt[0]).join("").toUpperCase().slice(0,2),Ze=it=>{const Dt={};return it.forEach(Vt=>{Dt[Vt.reaction_type]=(Dt[Vt.reaction_type]||0)+1}),Dt},Qe=it=>{var Dt;return(Dt=it.find(Vt=>Vt.user_id===(t==null?void 0:t.id)))==null?void 0:Dt.reaction_type},We=it=>it.reduce((Dt,Vt)=>Dt+1+(Vt.replies?We(Vt.replies):0),0),Je=it=>{if(n)return!0;if(!s||!it.private_group_id)return!1;const Dt=Ie.find(Vt=>Vt.id===it.private_group_id);return Dt!=null&&Dt.brokerage_id?r.some(Vt=>Vt.id===Dt.brokerage_id):!1};return e.jsx(Ms,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(yUt,{categories:Ae,privateGroups:Ie,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsxs("div",{className:"flex-1 min-w-0 max-w-2xl mx-auto lg:mx-0 space-y-6",children:[e.jsxs("div",{className:"px-1",children:[e.jsx("h1",{className:"text-4xl lg:text-5xl font-bold text-foreground",children:"Community"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Connect and share with fellow agents"})]}),e.jsx(vUt,{categories:Ae,privateGroups:Ie,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:a||void 0}),e.jsx(kn,{children:t!=null&&t.email?Ue(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(Ble,{placeholder:n?"What's on your mind? Use @ to mention someone, # to link a template":"What's on your mind? Use @ to mention someone",value:f,onChange:g,onMentionsChange:ye,onTemplatesChange:pe,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),M.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:M.map((it,Dt)=>{var Vt;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Vt=N[Dt])!=null&&Vt.type.startsWith("video/")?e.jsx("video",{src:it,className:"w-full h-full object-cover"}):e.jsx("img",{src:it,alt:"",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ct(Dt),children:e.jsx(Rr,{className:"h-3 w-3"})})]},Dt)})}),I&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:I,onChange:it=>O(it.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>O(""),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("input",{type:"file",ref:c,onChange:He,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var it;return(it=c.current)==null?void 0:it.click()},children:[e.jsx(gl,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var it;return(it=c.current)==null?void 0:it.click()},children:[e.jsx(An,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>O("https://"),children:[e.jsx(Bo,{className:"h-4 w-4 mr-1"}),"Link"]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[Ie.length>0?e.jsxs(Ks,{value:j||b||"none",onValueChange:it=>{it==="none"?(_(""),w("")):it.startsWith("group:")?(w(it.replace("group:","")),_("")):(_(it),w(""))},children:[e.jsx(Hs,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(Ys,{placeholder:"Select..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No category"}),Ae.map(it=>e.jsxs(Mt,{value:it.id,children:[it.icon," ",it.name]},it.id)),Ie.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-muted-foreground border-t mt-1 pt-1",children:"🔒 Private Groups"}),Ie.map(it=>e.jsxs(Mt,{value:`group:${it.id}`,children:[it.icon||"🔒"," ",it.name]},it.id))]})]})]}):e.jsxs(Ks,{value:b,onValueChange:_,children:[e.jsx(Hs,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(Ys,{placeholder:"Category"})}),e.jsx(Ws,{children:Ae.map(it=>e.jsxs(Mt,{value:it.id,children:[it.icon," ",it.name]},it.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>fe.mutate(),disabled:!f.trim()||q,children:[e.jsx(Bn,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),we?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((it,Dt)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(ys,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ys,{className:"h-4 w-32"}),e.jsx(ys,{className:"h-4 w-full"}),e.jsx(ys,{className:"h-4 w-3/4"})]})]})})},Dt))}):pt.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx($c,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No posts yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Be the first to start a conversation!"})]})}):e.jsxs("div",{className:"space-y-4",children:[pt.map(it=>{var Dt,Vt,hs,Ts;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:it.user_avatar||void 0}),e.jsx(kn,{children:Ue(it.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:it.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:Uc(new Date(it.created_at),{addSuffix:!0})}),it.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(st,{variant:"secondary",className:"text-xs",children:[it.category.icon," ",it.category.name]})]})]})]})]}),(it.user_id===(t==null?void 0:t.id)||Je(it))&&e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(fx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[Je(it)&&it.private_group_id&&e.jsx(Ma,{onClick:()=>et.mutate({postId:it.id,isPinned:it.is_pinned}),children:it.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(vL,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(V_,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),it.user_id===(t==null?void 0:t.id)&&e.jsxs(Ma,{onClick:()=>{V(it),Q(it.content)},children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ma,{className:"text-destructive",onClick:()=>at.mutate(it.id),children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),it.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),it.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(V_,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(Dke,{content:it.content})}),it.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${it.media.length===1?"grid-cols-1":it.media.length===2?"grid-cols-2":it.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:it.media.slice(0,4).map((Cs,cs)=>{const er=cs===3&&it.media.length>4,xt=it.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${it.media.length===1?"max-h-[500px]":it.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>$e({open:!0,images:it.media.map(Es=>({url:Es.media_url,type:Es.media_type==="video"?"video":"image"})),index:cs}),children:[Cs.media_type==="video"?e.jsx("video",{src:Cs.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:Cs.media_url,alt:"",className:"w-full h-full object-cover transition-transform group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})}),er&&e.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:e.jsxs("span",{className:"text-white text-2xl font-bold",children:["+",xt]})})]},Cs.id)})}),it.link_url&&e.jsxs("a",{href:it.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[it.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:it.link_image,alt:it.link_title||"Link preview",className:"w-full h-full object-cover",onError:Cs=>{Cs.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:it.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:it.link_title}),it.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:it.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(it.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(Bo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:it.link_url})]})})]}),it.reactions.length>0&&e.jsx(ttt,{reactions:it.reactions,children:e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[e.jsx("div",{className:"flex -space-x-1",children:Object.entries(Ze(it.reactions)).slice(0,3).map(([Cs])=>{var cs;return e.jsx("span",{className:"text-base",children:(cs=Sz.find(er=>er.type===Cs))==null?void 0:cs.emoji},Cs)})}),e.jsx("span",{children:it.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[Qe(it.reactions)?e.jsx("span",{className:"mr-1",children:(Dt=Sz.find(Cs=>Cs.type===Qe(it.reactions)))==null?void 0:Dt.emoji}):e.jsx(sh,{className:"h-4 w-4 mr-1"}),Qe(it.reactions)?(Vt=Sz.find(Cs=>Cs.type===Qe(it.reactions)))==null?void 0:Vt.label:"Like"]})}),e.jsx(Ro,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:Sz.map(Cs=>e.jsx("button",{onClick:()=>Me.mutate({postId:it.id,reactionType:Cs.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:Cs.label,children:Cs.emoji},Cs.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>X(Cs=>{const cs=new Set(Cs);return cs.has(it.id)?cs.delete(it.id):cs.add(it.id),cs}),children:[e.jsx($c,{className:"h-4 w-4 mr-1"}),(()=>{const Cs=We(it.comments);return Cs>0?`Comment (${Cs})`:"Comment"})()]})]}),ee.has(it.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[it.comments.map(Cs=>e.jsx(stt,{comment:Cs,postId:it.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:Je(it)},Cs.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:a||void 0}),e.jsx(kn,{className:"text-xs",children:Ue(((hs=t.email)==null?void 0:hs.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(Ble,{placeholder:"Write a comment... (use @ to mention)",value:ie[it.id]||"",onChange:Cs=>re(cs=>({...cs,[it.id]:Cs})),onMentionsChange:Cs=>ce(cs=>({...cs,[it.id]:Cs})),mentionFormat:"plain",onKeyDown:Cs=>{var cs;Cs.defaultPrevented||Cs.key==="Enter"&&!Cs.shiftKey&&((cs=ie[it.id])!=null&&cs.trim())&&(Cs.preventDefault(),rt.mutate({postId:it.id,content:ie[it.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var Cs;(Cs=ie[it.id])!=null&&Cs.trim()&&rt.mutate({postId:it.id,content:ie[it.id]})},disabled:!((Ts=ie[it.id])!=null&&Ts.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(Bn,{className:"h-4 w-4"})})]})]})]})]})},it.id)}),Le&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>tt(),disabled:Te,children:Te?"Loading…":"Load more posts"})})]}),e.jsx(fs,{open:!!B,onOpenChange:()=>V(null),children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Edit Post"})}),e.jsx(Er,{value:Y,onChange:it=>Q(it.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>V(null),children:"Cancel"}),e.jsx(K,{onClick:()=>{B&&qe.mutate({postId:B.id,content:Y})},disabled:!Y.trim(),children:"Save Changes"})]})]})}),e.jsx(IUt,{images:_e.images,initialIndex:_e.index,open:_e.open,onOpenChange:it=>$e(Dt=>({...Dt,open:it}))})]})]})})},M5={open:{label:"Open",icon:un,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:$c,color:"bg-blue-500"},resolved:{label:"Resolved",icon:xi,color:"bg-green-500"},closed:{label:"Closed",icon:vc,color:"bg-muted-foreground"}},m8e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function RUt(){const{user:t}=Ds(),s=Qt(),[r,n]=k.useState(null),[a,o]=k.useState(""),{data:l=[],isLoading:i}=mt({queryKey:["support-tickets"],queryFn:async()=>{const{data:f,error:g}=await H.from("support_tickets").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(g)throw g;return f},enabled:!!t}),{data:c=[]}=mt({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:f,error:g}=await H.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(g)throw g;return f},enabled:!!r}),u=Lt({mutationFn:async f=>{if(!r||!t)throw new Error("Missing data");const{error:g}=await H.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:f,is_admin_reply:!1});if(g)throw g},onSuccess:()=>{s.invalidateQueries({queryKey:["ticket-replies",r==null?void 0:r.id]}),o(""),me.success("Reply sent!")},onError:()=>{me.error("Failed to send reply")}}),p=()=>{a.trim()&&u.mutate(a)};if(r){const f=M5[r.status].icon;return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"secondary",children:m8e[r.category]}),e.jsxs(st,{className:M5[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),M5[r.status].label]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(gr,{children:["Created on ",ms(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Gi,{className:"h-[300px] pr-4",children:c.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:c.map(g=>{var b;return e.jsxs("div",{className:`p-4 rounded-lg ${g.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:g.is_admin_reply?"Support Team":((b=g.profiles)==null?void 0:b.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(g.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:g.content})]},g.id)})})}),r.status!=="closed"&&e.jsxs(e.Fragment,{children:[e.jsx(rl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Type your reply...",value:a,onChange:g=>o(g.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:p,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(Bn,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(Oe,{className:"p-6 sm:p-8",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-6",children:[e.jsx("div",{className:"p-4 bg-primary/20 rounded-full",children:e.jsx(Rv,{className:"h-8 w-8 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Need Help?"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Submit a support ticket and our team will get back to you as soon as possible."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(f1e,{trigger:e.jsxs(K,{size:"lg",className:"gap-2",children:[e.jsx($s,{className:"h-5 w-5"}),"Submit a Ticket"]})}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-muted rounded-lg",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Or text us: ",e.jsx("span",{className:"font-semibold text-foreground",children:"1-866-527-8668"})]})]})]})]})]})})}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Your Tickets"}),e.jsx(f1e,{trigger:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"New Ticket"]})})]}),i?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):l.length===0?e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx($c,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't submitted any support tickets. Use the button above to get started!"})]})}):e.jsx("div",{className:"space-y-3",children:l.map(f=>{const g=M5[f.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:f.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"outline",className:"text-xs",children:m8e[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(st,{className:M5[f.status].color,children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),M5[f.status].label]})]})})},f.id)})})]})})}function FUt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(_s,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(hn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(vs,{children:"Schedule Agent Onboarding"}),e.jsx(Gr,{children:"Book a one-on-one onboarding session with LevelUp"})]})]})}),t&&e.jsx("iframe",{src:"https://tidycal.com/jeremycollins/new-agent-onboarding",className:"w-full border-0 rounded-lg",style:{height:"600px",minHeight:"500px"},title:"Schedule Agent Onboarding"})]})})}function zUt({open:t,onOpenChange:s}){const{brokerageId:r}=Ds(),[n,a]=k.useState(""),[o,l]=k.useState([]),[i,c]=k.useState(!1),{data:u,isLoading:p}=mt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:j,error:w}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(w)throw w;return j},enabled:t&&!!r}),f=u==null?void 0:u.filter(j=>j.name.toLowerCase().includes(n.toLowerCase())||j.email.toLowerCase().includes(n.toLowerCase())),g=j=>{l(w=>w.includes(j)?w.filter(N=>N!==j):[...w,j])},b=async()=>{if(o.length===0){me.error("Please select at least one agent");return}c(!0);try{const{data:j,error:w}=await H.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(w)throw w;me.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(j){console.error("Error sending onboarding link:",j),me.error(j.message||"Failed to send onboarding link")}finally{c(!1)}},_=j=>{j||(l([]),a("")),s(j)};return e.jsx(fs,{open:t,onOpenChange:_,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Bn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(vs,{children:"Send Onboarding Link"}),e.jsx(Gr,{children:"Select agents to receive the onboarding booking link"})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:n,onChange:j=>a(j.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(f==null?void 0:f.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(pr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Gi,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(j=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>g(j.id),children:[e.jsx(Oo,{checked:o.includes(j.id),onCheckedChange:()=>g(j.id)}),e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"text-xs",children:j.name.split(" ").map(w=>w[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:j.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:j.email})]})]},j.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{onClick:b,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function BUt(){const[t,s]=k.useState(!1),[r,n]=k.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(pr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Agent Onboarding"}),e.jsx(gr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(K,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(Bn,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(FUt,{open:t,onOpenChange:s}),e.jsx(zUt,{open:r,onOpenChange:n})]})}function $Ut({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(_s,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(x0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(vs,{children:"Schedule Launch Meeting"}),e.jsx(Gr,{children:"Book a private LevelUp information session for your brokerage"})]})]})}),t&&e.jsx("iframe",{src:"https://tidycal.com/jeremycollins/levelup-launch-call",className:"w-full border-0 rounded-lg",style:{height:"600px",minHeight:"500px"},title:"Schedule Launch Meeting"})]})})}function qUt(){const[t,s]=k.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(x0,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Launch or ReLaunch Meeting"}),e.jsx(gr,{children:"Schedule a private LevelUp information session for your brokerage. Have one of our staff host a meeting to help your team get the most out of all our trainings, tools, and resources."})]})]})}),e.jsx(Oe,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(x0,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx($Ut,{open:t,onOpenChange:s})]})}function UUt(){const t=fr(),[s,r]=k.useState(""),[n,a]=k.useState(null),{data:o,isLoading:l}=mt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(w)throw w;return j}}),{data:i}=mt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(w)throw w;return j}}),{data:c}=mt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_pdfs").select("resource_id");if(w)throw w;return j}}),{data:u}=mt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_videos").select("resource_id");if(w)throw w;return j}}),{data:p}=mt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_links").select("resource_id");if(w)throw w;return j}}),f=o==null?void 0:o.filter(j=>{var S;const w=j.title.toLowerCase().includes(s.toLowerCase())||((S=j.description)==null?void 0:S.toLowerCase().includes(s.toLowerCase())),N=!n||j.category_id===n;return w&&N}),g=i==null?void 0:i.filter(j=>o==null?void 0:o.some(w=>w.category_id===j.id)),b=j=>{const w=(c==null?void 0:c.filter(M=>M.resource_id===j).length)||0,N=(u==null?void 0:u.filter(M=>M.resource_id===j).length)||0,S=(p==null?void 0:p.filter(M=>M.resource_id===j).length)||0;return{pdfCount:w,videoCount:N,linkCount:S}},_=j=>{t(`/brokerage-resources/${j}`)};return e.jsx(Ms,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(BUt,{}),e.jsx(qUt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search resources...",value:s,onChange:j=>r(j.target.value),className:"pl-10"})]}),g&&g.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(st,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),g.map(j=>e.jsx(st,{variant:n===j.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(j.id),children:j.name},j.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(f==null?void 0:f.length)||0," resource",(f==null?void 0:f.length)!==1?"s":""," available"]}),l?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((j,w)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-40 w-full"}),e.jsx(Pt,{children:e.jsx(ys,{className:"h-5 w-3/4"})}),e.jsxs(Oe,{children:[e.jsx(ys,{className:"h-4 w-full mb-2"}),e.jsx(ys,{className:"h-4 w-2/3"})]})]},w))}):(f==null?void 0:f.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(Gh,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resources found"}),e.jsx("p",{className:"text-muted-foreground",children:s||n?"Try adjusting your filters":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:f==null?void 0:f.map(j=>{const{pdfCount:w,videoCount:N,linkCount:S}=b(j.id),M=i==null?void 0:i.find(L=>L.id===j.category_id);return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>_(j.id),children:[j.preview_image_url?e.jsx("img",{src:j.preview_image_url,alt:j.title,className:"w-full h-40 object-cover"}):e.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:e.jsx(Gh,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Rt,{className:"text-lg line-clamp-1",children:j.title}),M&&e.jsx(st,{variant:"secondary",className:"shrink-0 text-xs",children:M.name})]})}),e.jsxs(Oe,{children:[j.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:j.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[w>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4"}),w]}),N>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(An,{className:"h-4 w-4"}),N]}),S>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bo,{className:"h-4 w-4"}),S]})]})]})]},j.id)})})]})})}const VUt=()=>{const{resourceId:t}=yo(),{data:s,isLoading:r}=mt({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await H.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await H.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await H.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:c}=await H.from("brokerage_resource_links").select("*").eq("resource_id",t).order("sort_order");return{...a,pdfs:l||[],videos:i||[],links:c||[]}},enabled:!!t}),n=a=>a?a<1024?a+" B":a<1024*1024?(a/1024).toFixed(1)+" KB":(a/(1024*1024)).toFixed(1)+" MB":"";return r?e.jsx(Ms,{title:"Brokerage Resources",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):s?e.jsx(Ms,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Pi,{to:"/brokerage-resources",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Resources"]})}),s.preview_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:s.preview_image_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),s.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:s.description}})]}),s.videos&&s.videos.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(An,{className:"h-4 w-4"}),"Videos (",s.videos.length,")"]}),e.jsx("div",{className:"space-y-4",children:s.videos.map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:a.title}),e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:a.video_url,className:"absolute top-0 left-0 w-full h-full rounded-lg border",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})]},a.id))})]})}),s.pdfs&&s.pdfs.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Sn,{className:"h-4 w-4"}),"Documents (",s.pdfs.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.pdfs.map(a=>e.jsxs("a",{href:a.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(Sn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:a.name}),a.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n(a.file_size)})]})]}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(tn,{className:"h-4 w-4"}),"Canva Templates (",s.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.links.map(a=>e.jsxs("a",{href:a.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(tn,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(tn,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Ms,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Gh,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Resource not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(Pi,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function HUt(){const{onlineUsers:t,totalOnline:s}=BYe();return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(st,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(_d,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No other users online right now"}):e.jsx(Gi,{className:"h-[300px] pr-4",children:e.jsx("div",{className:"space-y-3",children:t.map(r=>{var n;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-9 w-9",children:[e.jsx($a,{src:r.avatarUrl,alt:r.name}),e.jsx(kn,{className:"text-xs",children:(n=r.name)==null?void 0:n.split(" ").map(a=>a[0]).join("").slice(0,2).toUpperCase()})]}),e.jsx("span",{className:"absolute bottom-0 right-0 h-2.5 w-2.5 rounded-full bg-green-500 ring-2 ring-background"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:r.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Online ",Uc(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const p8e={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:pr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:LL,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:Mx,path:"/admin/subscriptions",color:"bg-gradient-to-br from-green-500/20 to-green-500/10 text-green-600"},{title:"Credit Management",description:"View and manage ReelFlow, Postcard, Letter & Check credits for all agents",icon:rL,path:"/admin/credits",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"},{title:"Subscription Discounts",description:"Create and manage coupon codes",icon:Fm,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:wd,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:pr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:zm,path:"/admin/prospector",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"Recruiting",description:"Manage agent recruit pipeline and outreach",icon:Tl,path:"/admin/recruiting",color:"bg-gradient-to-br from-emerald-500/20 to-green-500/10 text-emerald-600"}]},content:{label:"Content",sections:[{title:"Manage Templates",description:"Upload and organize Canva templates",icon:ic,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:Kh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:ty,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:pn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:pn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:d1,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:Od,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:Gh,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:Gh,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:cr,path:"/admin/agent-email-templates",color:"bg-rose-500/10 text-rose-600"},{title:"Mass Email Templates",description:"Create and manage shared campaign templates",icon:Ah,path:"/admin/email-campaigns/templates",color:"bg-teal-500/10 text-teal-600"}]},platform:{label:"Platform",sections:[{title:"Dashboard Management",description:"Configure banners and dashboard modules",icon:nS,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:ax,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:cr,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:Ah,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:MM,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:y0,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:ko,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:xo,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:dl,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:pr,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:Ah,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:so,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:OM,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:q_,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Jn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:cr,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:No,path:"/admin/analytics",color:"bg-emerald-500/10 text-emerald-600"},{title:"Brokerage Content Activity",description:"See which brokerages are creating custom content for agents",icon:Sh,path:"/admin/brokerage-content-activity",color:"bg-sky-500/10 text-sky-600"}]},lms:{label:"LevelUp U",sections:[{title:"Manage Courses",description:"Create and manage LMS training courses, modules, and access",icon:Kh,path:"/admin/lms",color:"bg-gradient-to-br from-primary/20 to-primary/10 text-primary"}]},"agent-os":{label:"Agent OS",sections:[{title:"Agent OS Control Center",description:"Manage InnerCircle feature: relationship types, action types, scripts, plans & feature flags",icon:ni,path:"/admin/agent-os",color:"bg-gradient-to-br from-rose-500/20 to-pink-500/10 text-rose-600"},{title:"Listing Exchange",description:"Approve, feature, and moderate community listings",icon:bn,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:ey,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:Sh,path:"/admin/guest-book-analytics",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"}]},beta:{label:"🧪 Beta Lab",sections:[{title:"Social Post Generator",description:"Auto-generate branded social media posts from MLS listing data",icon:gl,path:"/admin/beta/social-post-generator",color:"bg-gradient-to-br from-fuchsia-500/20 to-pink-500/10 text-fuchsia-600"},{title:"Postcard Direct Mail",description:"Upload monthly postcard designs and manage agent direct mail via Postalytics",icon:cr,path:"/admin/beta/postcard-manager",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"ReelFlow",description:"Turn property photos into cinematic video reels for social media",icon:B_,path:"/admin/beta/homereel",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"}]},"lead-sites":{label:"Lead Sites",sections:[{title:"All Sites",description:"Overview of all agent websites with status and quick actions",icon:su,path:"/admin/lead-sites",color:"bg-gradient-to-br from-sky-500/20 to-blue-500/10 text-sky-600"},{title:"MLS Feeds",description:"Manage MLS data feed connections, API keys, and coverage areas",icon:nL,path:"/admin/mls-feeds",color:"bg-gradient-to-br from-emerald-500/20 to-green-500/10 text-emerald-600"},{title:"Lead Analytics",description:"Cross-site lead capture stats, conversions, and top-performing sites",icon:ul,path:"/admin/lead-site-analytics",color:"bg-gradient-to-br from-amber-500/20 to-orange-500/10 text-amber-600"}]}};function WUt(){const t=fr();return e.jsx(Ms,{title:"Admin Dashboard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Admin Dashboard"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage all aspects of your platform"})]}),e.jsx("div",{className:"w-full lg:w-80",children:e.jsx(HUt,{})})]}),e.jsxs(ba,{defaultValue:"users",className:"w-full",children:[e.jsx(pa,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(p8e).map(([s,r])=>e.jsx(ns,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(p8e).map(([s,r])=>e.jsx(bs,{value:s,className:"mt-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:r.sections.map(n=>e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${n.color} mb-2 group-hover:scale-110 transition-transform`,children:e.jsx(n.icon,{className:"h-5 w-5"})}),e.jsx(Rt,{className:"text-base",children:n.title})]}),e.jsx(Oe,{className:"pt-0",children:e.jsx(gr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Rn=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:It("w-full caption-bottom text-sm",t),...s})}));Rn.displayName="Table";const Fn=k.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:It("[&_tr]:border-b",t),...s}));Fn.displayName="TableHeader";const zn=k.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:It("[&_tr:last-child]:border-0",t),...s}));zn.displayName="TableBody";const GUt=k.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:It("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));GUt.displayName="TableFooter";const Ss=k.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:It("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));Ss.displayName="TableRow";const St=k.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:It("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));St.displayName="TableHead";const dt=k.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:It("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));dt.displayName="TableCell";const KUt=k.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:It("mt-4 text-sm text-muted-foreground",t),...s}));KUt.displayName="TableCaption";const ZUt=()=>{const{isAdmin:t}=Ds(),s=fr(),[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(!1),[c,u]=k.useState(null);k.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:j,error:w}=await H.from("app_tiles").select("*").order("name");if(w)throw w;n(j||[])}catch(j){console.error("Error loading apps:",j),me.error("Failed to load apps")}finally{o(!1)}},f=async j=>{j.preventDefault();const w=new FormData(j.currentTarget),N={name:w.get("name"),description:w.get("description"),icon:w.get("icon"),app_id:w.get("app_id"),target_url:w.get("target_url"),required_tags:w.get("required_tags").split(",").map(S=>S.trim()).filter(Boolean)};try{if(c){const{error:S}=await H.from("app_tiles").update(N).eq("id",c.id);if(S)throw S;me.success("App updated successfully")}else{const{error:S}=await H.from("app_tiles").insert([N]);if(S)throw S;me.success("App created successfully")}i(!1),u(null),p()}catch(S){console.error("Error saving app:",S),me.error("Failed to save app")}},g=async j=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:w}=await H.from("app_tiles").delete().eq("id",j);if(w)throw w;me.success("App deleted successfully"),p()}catch(w){console.error("Error deleting app:",w),me.error("Failed to delete app")}},b=j=>{u(j),i(!0)},_=()=>{u(null),i(!0)};return a?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Manage Apps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create and configure application tiles"})]})]}),e.jsxs(fs,{open:l,onOpenChange:i,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:_,children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:c?"Edit App":"Create New App"}),e.jsx(Gr,{children:"Configure the application tile settings"})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"App Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:c==null?void 0:c.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"app_id",children:"App ID"}),e.jsx(ze,{id:"app_id",name:"app_id",defaultValue:c==null?void 0:c.app_id,placeholder:"agent_connect",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:c==null?void 0:c.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(ze,{id:"icon",name:"icon",defaultValue:c==null?void 0:c.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"target_url",children:"Target URL"}),e.jsx(ze,{id:"target_url",name:"target_url",type:"url",defaultValue:c==null?void 0:c.target_url,required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(ze,{id:"required_tags",name:"required_tags",defaultValue:c==null?void 0:c.required_tags.join(", "),placeholder:"levelup-member, agent-connect"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{type:"submit",children:c?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Application Tiles"}),e.jsx(gr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Oe,{children:r.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsxs(K,{onClick:_,children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"App ID"}),e.jsx(St,{children:"Target URL"}),e.jsx(St,{children:"Tags"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:r.map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-2xl",children:j.icon}),e.jsx(dt,{className:"font-medium",children:j.name}),e.jsx(dt,{className:"font-mono text-sm",children:j.app_id}),e.jsx(dt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:j.target_url}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:j.required_tags.map(w=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:w},w))})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>b(j),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>g(j.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},j.id))})]})})]})})]})};function oh({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Pi,{to:"/admin",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Admin Dashboard"]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:t}),s&&e.jsx("p",{className:"text-muted-foreground",children:s})]}),r]})]})}const f8e=({expiresAt:t,className:s})=>{const r=new Date().getTime(),n=new Date(t).getTime(),a=Math.ceil((n-r)/(1e3*60*60*24));return a<=0?e.jsxs(st,{variant:"destructive",className:It("gap-1",s),children:[e.jsx(Ku,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(st,{variant:"destructive",className:It("gap-1",s),children:[e.jsx(un,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(st,{className:It("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(un,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(st,{variant:"secondary",className:It("gap-1",s),children:[e.jsx(un,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},rtt=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=Ua(),l=k.useRef(null),[i,c]=k.useState([]),[u,p]=k.useState(""),[f,g]=k.useState(!1),[b,_]=k.useState("upload"),[j,w]=k.useState(null),N=()=>{c([]),p(""),_("upload"),w(null),l.current&&(l.current.value="")},S=()=>{N(),s(!1)},M=U=>{const B=U.split(` `).map(X=>X.trim()).filter(X=>X);if(B.length===0)return[];const V=B[0].toLowerCase(),Q=V.includes("first")||V.includes("last")||V.includes("email")||V.includes("name")||V.includes("phone")||V.includes("sms")||V.includes("consent")?B.slice(1):B,ee=[];for(const X of Q){const re=(X.includes(" ")?X.split(" "):X.split(",")).map(oe=>oe.trim().replace(/^["']|["']$/g,""));if(re.length>=2){let oe="",ce="",ge="",ye="",ue;if(re.length===2){const $e=re[0].split(" ");oe=$e[0]||"",ce=$e.slice(1).join(" ")||"",ge=re[1]}else if(re.length===3)oe=re[0],ce=re[1],ge=re[2];else if(re.length===4)oe=re[0],ce=re[1],ge=re[2],ye=re[3];else if(re.length>=5){oe=re[0],ce=re[1],ge=re[2],ye=re[3];const $e=re[4].toLowerCase();ue=$e==="true"||$e==="yes"||$e==="1"||$e==="y"}const _e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(ge);ee.push({firstName:oe.trim(),lastName:ce.trim(),email:ge.trim().toLowerCase(),phone:ye.trim()||void 0,smsConsent:ue,isValid:_e&&oe.trim().length>0,error:_e?oe.trim()?void 0:"Missing name":"Invalid email"})}}return ee},L=U=>{var Y;const B=(Y=U.target.files)==null?void 0:Y[0];if(!B)return;const V=new FileReader;V.onload=Q=>{var ie;const ee=(ie=Q.target)==null?void 0:ie.result,X=M(ee);if(X.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}c(X),_("preview")},V.readAsText(B)},I=async()=>{const U=i.filter(V=>V.isValid);if(U.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const B=n||u||null;g(!0);try{const{data:{session:V}}=await H.auth.getSession(),Y=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V==null?void 0:V.access_token}`},body:JSON.stringify({users:U.map(ee=>({firstName:ee.firstName,lastName:ee.lastName,email:ee.email,phone:ee.phone,smsConsent:ee.smsConsent})),brokerageId:B})}),Q=await Y.json();if(!Y.ok)throw new Error(Q.error||"Failed to import users");w(Q),_("result"),Q.created>0&&a(),o({title:"Import Complete",description:`${Q.created} user(s) created successfully.${Q.failed>0?` ${Q.failed} failed.`:""}`})}catch(V){console.error("Import error:",V),o({title:"Import Failed",description:V.message||"Failed to import users",variant:"destructive"})}finally{g(!1)}},O=i.filter(U=>U.isValid).length,q=i.filter(U=>!U.isValid).length;return e.jsx(fs,{open:t,onOpenChange:S,children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(a1,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(Gr,{children:"Upload a CSV file with agent information. Each row should contain First Name, Last Name, and Email."})]}),b==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:L,className:"hidden"}),e.jsx(li,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var U;return(U=l.current)==null?void 0:U.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Expected CSV Format:"}),e.jsxs("code",{className:"text-xs block bg-background p-2 rounded",children:["First Name, Last Name, Email, Phone, SMS Consent",e.jsx("br",{}),"John, Doe, john@example.com, 555-123-4567, yes",e.jsx("br",{}),"Jane, Smith, jane@example.com, 555-987-6543, true"]}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs",children:"Phone and SMS Consent columns are optional. SMS Consent accepts: yes/no, true/false, 1/0, y/n."})]})]}),b==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[!n&&r&&r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Assign to Brokerage (optional)"}),e.jsxs(Ks,{value:u||"none",onValueChange:U=>p(U==="none"?"":U),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select a brokerage..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No brokerage"}),r.map(U=>e.jsx(Mt,{value:U.id,children:U.name},U.id))]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[O," valid"]})]}),q>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(kl,{className:"h-4 w-4"}),e.jsxs("span",{children:[q," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30",children:[e.jsx(St,{children:"First Name"}),e.jsx(St,{children:"Last Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Phone"}),e.jsx(St,{children:"SMS"}),e.jsx(St,{children:"Status"})]})}),e.jsx(zn,{children:i.slice(0,100).map((U,B)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:U.firstName}),e.jsx(dt,{children:U.lastName}),e.jsx(dt,{children:U.email}),e.jsx(dt,{className:"text-muted-foreground",children:U.phone||"-"}),e.jsx(dt,{className:"text-muted-foreground",children:U.smsConsent===!0?"✓":U.smsConsent===!1?"✗":"-"}),e.jsx(dt,{children:U.isValid?e.jsx(st,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(st,{variant:"destructive",children:U.error||"Invalid"})})]},B))})]}),i.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),b==="result"&&j&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(sa,{className:"h-12 w-12 mx-auto text-green-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:[j.created," agent(s) created and invited"]}),j.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[j.failed," failed to create"]})]}),j.errors.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[e.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[j.errors.slice(0,10).map((U,B)=>e.jsxs("li",{children:["• ",U]},B)),j.errors.length>10&&e.jsxs("li",{children:["...and ",j.errors.length-10," more"]})]})]})]}),e.jsxs(qn,{children:[b==="upload"&&e.jsx(K,{variant:"outline",onClick:S,children:"Cancel"}),b==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:N,children:"Back"}),e.jsx(K,{onClick:I,disabled:f||O===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${O} Agent${O!==1?"s":""}`})]}),b==="result"&&e.jsx(K,{onClick:S,children:"Done"})]})]})})};function yl({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(St,{className:It("cursor-pointer select-none",o),...l,children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 font-semibold hover:text-foreground transition-colors w-full text-left",onClick:()=>n(t),children:[a,i?r==="asc"?e.jsx(ku,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Wh,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(bd,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function QO(t=null,s=null){const[r,n]=k.useState(t),[a,o]=k.useState(s),l=k.useCallback(c=>{r===c?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(c),o("asc"))},[r,a]),i=k.useCallback((c,u)=>{if(!r||!a||!u[r])return c;const p=u[r];return[...c].sort((f,g)=>{const b=p(f),_=p(g);if(b==null&&_==null)return 0;if(b==null)return 1;if(_==null)return-1;let j;return typeof b=="string"&&typeof _=="string"?j=b.localeCompare(_,void 0,{sensitivity:"base"}):j=b-_,a==="asc"?j:-j})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const YUt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Jn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:xo},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:ru}];function ntt({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=k.useState("custom"),[l,i]=k.useState(""),[c,u]=k.useState(""),p=aNt(),f=b=>{o(b.type),i(b.title),u(b.message)},g=async b=>{if(b.preventDefault(),!l.trim()){wn({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await p.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:c.trim()||void 0}),wn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{wn({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(ru,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),e.jsx(Gr,{children:"They'll see confetti and this message next time they log in!"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(be,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:YUt.map((b,_)=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f(b),className:"text-xs",children:[e.jsx(b.icon,{className:"h-3 w-3 mr-1"}),b.title]},_))})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(Ks,{value:a,onValueChange:b=>o(b),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(Mt,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(Mt,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(Mt,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ac,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:l,onChange:b=>i(b.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Er,{id:"message",value:c,onChange:b=>u(b.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[e.jsx(ru,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Ige={points_earned:{label:"Points Earned",icon:xo,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:bn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:ac,color:"bg-green-500"},custom:{label:"Custom",icon:pn,color:"bg-purple-500"}};function XUt(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("all"),{data:l=[],isLoading:i}=mt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:f}=await H.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(f)throw f;const g=[...new Set([...p.map(j=>j.user_id),...p.map(j=>j.created_by).filter(Boolean)])],{data:b}=await H.from("profiles").select("id, name, email").in("id",g),_=new Map((b==null?void 0:b.map(j=>[j.id,j]))||[]);return p.map(j=>{var w,N,S;return{...j,user_name:((w=_.get(j.user_id))==null?void 0:w.name)||"Unknown",user_email:((N=_.get(j.user_id))==null?void 0:N.email)||"",creator_name:j.created_by?((S=_.get(j.created_by))==null?void 0:S.name)||"System":"Auto-triggered"}})}}),c=l.filter(p=>{var _,j;const f=((_=p.user_name)==null?void 0:_.toLowerCase().includes(t.toLowerCase()))||((j=p.user_email)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||p.title.toLowerCase().includes(t.toLowerCase()),g=r==="all"||p.celebration_type===r,b=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return f&&g&&b}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(Ige).reduce((p,f)=>(p[f]=l.filter(g=>g.celebration_type===f).length,p),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ru,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(gr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by agent name, email, or title...",value:t,onChange:p=>s(p.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:r,onValueChange:n,children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Filter by type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),Object.entries(Ige).map(([p,f])=>e.jsx(Mt,{value:p,children:f.label},p))]})]}),e.jsxs(Ks,{value:a,onValueChange:o,children:[e.jsx(Hs,{className:"w-[140px]",children:e.jsx(Ys,{placeholder:"Status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"seen",children:"Seen"}),e.jsx(Mt,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Points"}),e.jsx(St,{children:"Created By"}),e.jsx(St,{children:"Created"}),e.jsx(St,{children:"Status"})]})}),e.jsx(zn,{children:c.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):c.map(p=>{const f=Ige[p.celebration_type],g=f.icon;return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(g,{className:"h-3 w-3"}),f.label]})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.user_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:p.user_email})]})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.title}),p.message&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:p.message})]})}),e.jsx(dt,{children:p.points_amount?e.jsxs(st,{variant:"secondary",children:["+",p.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:p.creator_name})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ms(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(dt,{children:p.seen_at?e.jsx(st,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(st,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},p.id)})})]})}),c.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",c.length," of ",l.length," celebrations"]})]})]})]})}const QUt=()=>{const{user:t}=Ds(),{toast:s}=Ua(),[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(!1),[c,u]=k.useState("all"),[p,f]=k.useState("all"),[g,b]=k.useState("new"),[_,j]=k.useState(new Set),w=k.useCallback(async()=>{try{o(!0);const{data:ee,error:X}=await H.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(X)throw X;const{data:ie,error:re}=await H.from("trial_email_exports").select("user_id");if(re)throw re;const oe=new Set((ie||[]).map(ge=>ge.user_id)),ce=(ee||[]).map(ge=>({...ge,converted_from_trial_at:ge.converted_from_trial_at??null,already_exported:oe.has(ge.id)}));ce.sort((ge,ye)=>new Date(ye.created_at).getTime()-new Date(ge.created_at).getTime()),n(ce)}catch(ee){console.error("Error loading trial users:",ee),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);k.useEffect(()=>{w()},[w]);const N=ee=>ee.trial_started_at?"ghl":"stripe",S=ee=>ee.trial_expires_at?ee.trial_expires_at:ee.subscription_end_date?ee.subscription_end_date:null,M=ee=>ee.converted_from_trial_at!==null,L=ee=>{if(M(ee))return!1;const X=S(ee);return X?new Date(X).getTime()<=Date.now():!1},I=r.filter(ee=>!(c!=="all"&&N(ee)!==c||p==="active"&&(L(ee)||M(ee))||p==="expired"&&!L(ee)||p==="converted"&&!M(ee)||g==="new"&&ee.already_exported||g==="exported"&&!ee.already_exported)),O=()=>{_.size===I.length?j(new Set):j(new Set(I.map(ee=>ee.id)))},q=ee=>{const X=new Set(_);X.has(ee)?X.delete(ee):X.add(ee),j(X)},U=async()=>{if(_.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const ee=r.filter(ue=>_.has(ue.id)),X="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",ie=ee.map(ue=>{const pe=(ue.name||"").split(" "),_e=pe[0]||"",$e=pe.slice(1).join(" ")||"",Ae=N(ue)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Ie=M(ue)?"Converted":L(ue)?"Expired":"Active",Ce=ue.created_at?new Date(ue.created_at).toLocaleDateString():"",xe=S(ue)?new Date(S(ue)).toLocaleDateString():"";return`"${_e}","${$e}","${ue.email}","${ue.phone||""}","${Ae}","${Ie}","${Ce}","${xe}"`}),re=[X,...ie].join(` `),oe=new Blob([re],{type:"text/csv"}),ce=URL.createObjectURL(oe),ge=document.createElement("a");ge.href=ce,ge.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,ge.click(),URL.revokeObjectURL(ce);const ye=ee.filter(ue=>!ue.already_exported).map(ue=>({user_id:ue.id,exported_by:t.id}));if(ye.length>0){const{error:ue}=await H.from("trial_email_exports").upsert(ye,{onConflict:"user_id"});ue&&console.error("Error marking exports:",ue)}s({title:"Export complete",description:`Downloaded ${ee.length} trial user(s). ${ye.length} newly marked as exported.`}),j(new Set),w()}catch(ee){console.error("Export error:",ee),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},B=r.filter(ee=>!ee.already_exported).length,V=r.filter(ee=>ee.already_exported).length,Y=r.filter(ee=>M(ee)).length,Q=r.filter(ee=>!L(ee)&&!M(ee)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Total"}),e.jsx(Rt,{className:"text-2xl",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"New (Not Exported)"}),e.jsx(Rt,{className:"text-2xl text-green-600",children:B})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Active Trials"}),e.jsx(Rt,{className:"text-2xl",children:Q})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Converted 🎉"}),e.jsx(Rt,{className:"text-2xl text-primary",children:Y})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Already Exported"}),e.jsx(Rt,{className:"text-2xl text-muted-foreground",children:V})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(Ks,{value:g,onValueChange:ee=>b(ee),children:[e.jsx(Hs,{className:"w-[160px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Users"}),e.jsx(Mt,{value:"new",children:"New Only"}),e.jsx(Mt,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(Ks,{value:c,onValueChange:ee=>u(ee),children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Trial Types"}),e.jsx(Mt,{value:"stripe",children:"Credit Card Trial"}),e.jsx(Mt,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(Ks,{value:p,onValueChange:ee=>f(ee),children:[e.jsx(Hs,{className:"w-[160px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),e.jsx(Mt,{value:"active",children:"Active Trial"}),e.jsx(Mt,{value:"expired",children:"Expired"}),e.jsx(Mt,{value:"converted",children:"Converted ✓"})]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(K,{onClick:U,disabled:l||_.size===0,children:[l?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Export Selected (",_.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:I.length>0&&_.size===I.length,onCheckedChange:O})}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Trial Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Signup Date"}),e.jsx(St,{children:"Expires / Renews"}),e.jsx(St,{children:"Exported"})]})}),e.jsx(zn,{children:I.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):I.map(ee=>{const X=N(ee),ie=M(ee),re=L(ee),oe=S(ee);return e.jsxs(Ss,{className:`hover:bg-muted/30 ${ie?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Oo,{checked:_.has(ee.id),onCheckedChange:()=>q(ee.id)})}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ee.name,ie&&e.jsx(ul,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(dt,{className:"text-muted-foreground",children:ee.email}),e.jsx(dt,{children:X==="stripe"?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(Mx,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(cr,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(dt,{children:ie?e.jsxs(st,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(ul,{className:"h-3 w-3"}),"Converted"]}):re?e.jsx(st,{variant:"destructive",children:"Expired"}):e.jsx(st,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(dt,{className:"text-sm",children:ee.created_at?new Date(ee.created_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-sm",children:ie&&oe?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(oe).toLocaleDateString()]}):oe?new Date(oe).toLocaleDateString():"—"}),e.jsx(dt,{children:ee.already_exported?e.jsx(sa,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(st,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},ee.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",I.length," of ",r.length," trial users · ",Y," converted to paid"]})]})},JUt=()=>{const[t,s]=k.useState([]),[r,n]=k.useState(!0);return k.useEffect(()=>{(async()=>{const{data:o,error:l}=await H.from("user_deletion_log").select("*").order("created_at",{ascending:!1});!l&&o&&s(o),n(!1)})()},[]),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Nr,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Oe,{children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Date"}),e.jsx(St,{children:"User"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Brokerage"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Deleted By"})]})}),e.jsx(zn,{children:t.map(a=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"whitespace-nowrap text-sm",children:ms(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(dt,{children:a.brokerage_name||"—"}),e.jsx(dt,{children:e.jsx(st,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(dt,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},_C=t=>{const{user:s}=Ds(),r=Qt(),n=mt({queryKey:["teams",t],queryFn:async()=>{let f=H.from("teams").select("*").order("created_at",{ascending:!1});t&&(f=f.eq("brokerage_id",t));const{data:g,error:b}=await f;if(b)throw b;return g||[]},enabled:!!s}),a=f=>mt({queryKey:["team-members",f],queryFn:async()=>{const{data:g,error:b}=await H.from("team_members").select("*").eq("team_id",f).order("role",{ascending:!0});if(b)throw b;const _=(g||[]).map(N=>N.user_id),{data:j}=await H.from("profiles").select("id, name, email, avatar_url").in("id",_),w=new Map((j||[]).map(N=>[N.id,N]));return(g||[]).map(N=>({...N,profile:w.get(N.user_id)||null}))},enabled:!!f}),o=Lt({mutationFn:async f=>{const g={name:f.name,created_by:s.id,description:f.description,contact_visibility:f.contact_visibility,lead_pond_enabled:f.lead_pond_enabled,shared_assets_enabled:f.shared_assets_enabled};f.brokerage_id&&(g.brokerage_id=f.brokerage_id);const{data:b,error:_}=await H.from("teams").insert(g).select().single();if(_)throw _;return b},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team created!")},onError:f=>{me.error("Failed to create team: "+f.message)}}),l=Lt({mutationFn:async({id:f,...g})=>{const{data:b,error:_}=await H.from("teams").update(g).eq("id",f).select().single();if(_)throw _;return b},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team updated")},onError:f=>{me.error("Failed to update team: "+f.message)}}),i=Lt({mutationFn:async f=>{const{error:g}=await H.from("teams").delete().eq("id",f);if(g)throw g},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team deleted")},onError:f=>{me.error("Failed to delete team: "+f.message)}}),c=Lt({mutationFn:async f=>{const{data:g,error:b}=await H.from("team_members").insert({team_id:f.team_id,user_id:f.user_id,role:f.role||"team_member"}).select().single();if(b)throw b.message.includes("duplicate")||b.message.includes("unique")?new Error("This agent is already on a team. They must be removed from their current team first."):b;return g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),me.success("Member added to team")},onError:f=>{me.error(f.message)}}),u=Lt({mutationFn:async f=>{const{error:g}=await H.from("team_members").delete().eq("id",f.member_id);if(g)throw g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),me.success("Member removed from team")},onError:f=>{me.error("Failed to remove member: "+f.message)}}),p=Lt({mutationFn:async f=>{const{error:g}=await H.from("team_members").update({role:f.role}).eq("id",f.member_id);if(g)throw g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),me.success("Member role updated")},onError:f=>{me.error("Failed to update role: "+f.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:c,removeMember:u,updateMemberRole:p,useTeamMembers:a}},eVt=()=>{const{user:t}=Ds();return mt({queryKey:["team-contacts",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.rpc("get_team_contacts",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},att=t=>{const{user:s}=Ds(),r=Qt(),n=mt({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:c}=await H.from("team_lead_pond").select("*").eq("team_id",t).order("created_at",{ascending:!1});if(c)throw c;if(!i||i.length===0)return[];const u=i.map(N=>N.contact_id),p=[...new Set(i.map(N=>N.added_by))],f=i.filter(N=>N.claimed_by).map(N=>N.claimed_by),g=[...new Set([...p,...f])],[b,_]=await Promise.all([H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",u),H.from("profiles").select("id, name, avatar_url").in("id",g)]),j=new Map((b.data||[]).map(N=>[N.id,N])),w=new Map((_.data||[]).map(N=>[N.id,N]));return i.map(N=>({...N,status:N.claimed_by?"claimed":"available",contact:j.get(N.contact_id)||null,contributor:w.get(N.added_by)||null,claimer:N.claimed_by&&w.get(N.claimed_by)||null}))},enabled:!!t&&!!s}),a=Lt({mutationFn:async i=>{const{data:c,error:u}=await H.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(u)throw u;return c},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Contact added to Lead Pond")},onError:i=>{me.error(i.message)}}),o=Lt({mutationFn:async i=>{const{error:c}=await H.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(c)throw c},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Lead claimed!")},onError:i=>{me.error(i.message)}}),l=Lt({mutationFn:async i=>{const{error:c}=await H.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(c)throw c},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Lead returned to pond")},onError:i=>{me.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},tVt=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.rpc("transfer_contact",{_contact_id:s.contactId,_to_user_id:s.toUserId,_notes:s.notes||null});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error);return a},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["team-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),me.success("Contact transferred successfully")},onError:s=>{me.error(s.message||"Failed to transfer contact")}})};function itt({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var I;const{user:o}=Ds(),{data:l}=$x(),{useTeamMembers:i}=_C(),{data:c=[]}=i((l==null?void 0:l.teamId)||""),u=tVt(),[p,f]=k.useState(null),[g,b]=k.useState(""),[_,j]=k.useState(!1),w=c.filter(O=>O.user_id!==(o==null?void 0:o.id)),N=async()=>{if(p){j(!0);try{for(const O of r)await u.mutateAsync({contactId:O,toUserId:p,notes:g||void 0});s(!1),f(null),b(""),a==null||a()}catch{}finally{j(!1)}}},S=w.find(O=>O.user_id===p),M=r.length>1,L=n.length>0?M?`${n.length} contacts`:n[0]:M?`${r.length} contacts`:"this contact";return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(s1,{className:"h-5 w-5"}),"Transfer ",L]}),e.jsxs(Gr,{children:["Select a team member to transfer ",M?"these contacts":"this contact"," to. The contact will be removed from the current owner's CRM and added to the selected member's."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),e.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):w.map(O=>{var q,U,B;return e.jsxs("button",{onClick:()=>f(O.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===O.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:((q=O.profile)==null?void 0:q.avatar_url)||""}),e.jsx(kn,{className:"text-xs",children:(((U=O.profile)==null?void 0:U.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((B=O.profile)==null?void 0:B.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:O.role.replace("_"," ")})]})]},O.user_id)})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Er,{id:"transfer-notes",value:g,onChange:O=>b(O.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:N,disabled:!p||_,children:[_?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(s1,{className:"h-4 w-4 mr-2"}),"Transfer",S?` to ${(I=S.profile)==null?void 0:I.name}`:""]})]})]})})}const Oke=()=>{const t=fr(),{data:s,isLoading:r}=eVt(),{data:n}=$x(),[a,o]=k.useState(""),[l,i]=k.useState("all"),[c,u]=k.useState(null),[p,f]=k.useState(""),g=(n==null?void 0:n.role)==="team_leader",b=k.useMemo(()=>{if(!s)return[];const j=new Map;return s.forEach(w=>{j.has(w.owner_user_id)||j.set(w.owner_user_id,{id:w.owner_user_id,name:w.owner_name||"Unknown",avatar:w.owner_avatar_url})}),Array.from(j.values())},[s]),_=k.useMemo(()=>{if(!s)return[];let j=s;if(l!=="all"&&(j=j.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();j=j.filter(N=>{var S,M,L;return(N.first_name+" "+(N.last_name||"")).toLowerCase().includes(w)||((S=N.email)==null?void 0:S.toLowerCase().includes(w))||((M=N.phone)==null?void 0:M.includes(w))||((L=N.owner_name)==null?void 0:L.toLowerCase().includes(w))})}return j},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"h-10 w-full"}),e.jsx(ys,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Team Contacts"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team contact sharing is not enabled, or you're not on a team. Ask your manager about contact visibility settings."})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:j=>o(j.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:l,onValueChange:i,children:[e.jsx(Hs,{className:"w-[200px]",children:e.jsx(Ys,{placeholder:"Filter by agent"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Team Members"}),b.map(j=>e.jsx(Mt,{value:j.id,children:j.name},j.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[_.length," contact",_.length!==1?"s":""," from ",b.length," teammate",b.length!==1?"s":""]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(Rn,{className:"min-w-[800px]",children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Contact Info"}),e.jsx(St,{children:"Address"}),e.jsx(St,{children:"Lead Source"}),e.jsx(St,{children:"Date Added"}),g&&e.jsx(St,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(zn,{children:_.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:g?7:6,className:"text-center py-8 text-muted-foreground",children:a||l!=="all"?"No contacts match your filters":"No team contacts available"})}):_.map(j=>e.jsxs(Ss,{className:`hover:bg-accent/50 ${g?"cursor-pointer":""}`,onClick:g?()=>t(`/mission-control/contacts/${j.id}`):void 0,children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("span",{className:g?"hover:text-primary hover:underline transition-colors":"",children:[j.first_name," ",j.last_name||""]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:j.owner_avatar_url||""}),e.jsx(kn,{className:"text-[10px]",children:(j.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:j.owner_name||"Unknown"})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[j.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(cr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:j.email})]}),j.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Un,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:j.phone})]}),!j.email&&!j.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(dt,{children:j.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(ma,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:j.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:j.lead_source?e.jsx(st,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:j.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ms(new Date(j.created_at),"MMM d, yyyy")})}),g&&e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:w=>{w.stopPropagation(),u(j.id),f(`${j.first_name} ${j.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(s1,{className:"h-4 w-4"})})})]},j.id))})]})})}),e.jsx(itt,{open:!!c,onOpenChange:j=>{j||u(null)},contactIds:c?[c]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},Rke=({teamId:t})=>{const{user:s}=Ds(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=att(t);if(console.log("[LeadPondView] render — teamId:",t,"itemCount:",r.length,"loading:",n),n)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(c=>e.jsx(ys,{className:"h-20 w-full"},c))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Xg,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Lead Pond is Empty"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team members can contribute contacts here for others to claim and follow up with."})]})});const l=r.filter(c=>c.status==="available"),i=r.filter(c=>c.status==="claimed");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Available (",l.length,")"]}),l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No leads available right now."}):e.jsx("div",{className:"space-y-2",children:l.map(c=>{var u,p,f,g,b,_,j;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=c.contact)==null?void 0:u.first_name," ",((p=c.contact)==null?void 0:p.last_name)||""]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((f=c.contact)==null?void 0:f.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3"})," ",c.contact.email]}),((g=c.contact)==null?void 0:g.phone)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"})," ",c.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(Nn,{className:"h-4 w-4",children:[e.jsx($a,{src:((b=c.contributor)==null?void 0:b.avatar_url)||""}),e.jsx(kn,{className:"text-[8px]",children:(((_=c.contributor)==null?void 0:_.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((j=c.contributor)==null?void 0:j.name)||"Unknown"]})]})]}),e.jsxs(K,{size:"sm",onClick:()=>a.mutate(c.id),disabled:a.isPending,children:[e.jsx(lL,{className:"mr-1 h-3 w-3"}),"Claim"]})]})},c.id)})})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Claimed (",i.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.map(c=>{var u,p,f;return e.jsx(Ee,{className:"opacity-75",children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=c.contact)==null?void 0:u.first_name," ",((p=c.contact)==null?void 0:p.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(st,{variant:"secondary",className:"text-xs",children:["Claimed by ",((f=c.claimer)==null?void 0:f.name)||"Unknown"]})})]}),c.claimed_by===(s==null?void 0:s.id)&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>o.mutate(c.id),disabled:o.isPending,children:[e.jsx(m1,{className:"mr-1 h-3 w-3"}),"Return"]})]})},c.id)})})]})]})},ott=({teamId:t})=>{const{useTeamMembers:s}=_C(),{data:r=[]}=s(t),n=r.map(b=>b.user_id),a=new Map(r.map(b=>[b.user_id,b.profile])),{data:o=[],isLoading:l}=mt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:b,error:_}=await H.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(_)throw _;return b||[]},enabled:n.length>0}),{data:i=[],isLoading:c}=mt({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:b,error:_}=await H.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(_)throw _;return b||[]},enabled:n.length>0}),{data:u=[],isLoading:p}=mt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:b,error:_}=await H.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(_)throw _;return b||[]},enabled:n.length>0});if(l||c||p)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(b=>e.jsx(ys,{className:"h-20 w-full"},b))});const g=b=>{const _=a.get(b);return{name:(_==null?void 0:_.name)||"Unknown",avatar:(_==null?void 0:_.avatar_url)||"",initials:((_==null?void 0:_.name)||"?").charAt(0).toUpperCase()}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(ey,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:o.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Presentations"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(bn,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Guest Books"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(An,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:u.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]}),e.jsxs(ba,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(ns,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(ns,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(bs,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(Lge,{icon:e.jsx(ey,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(b=>{const _=g(b.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx($a,{src:_.avatar}),e.jsx(kn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:b.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ms(new Date(b.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(st,{variant:b.status==="published"?"default":"secondary",className:"text-xs capitalize",children:b.status}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ln,{className:"h-3 w-3"}),b.view_count||0]})]})]})},b.id)})}),e.jsx(bs,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(Lge,{icon:e.jsx(bn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(b=>{const _=g(b.agent_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx($a,{src:_.avatar}),e.jsx(kn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:b.property_address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ms(new Date(b.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[b.is_active?e.jsx(st,{className:"text-xs",children:"Active"}):e.jsx(st,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(pr,{className:"h-3 w-3"}),b.visitor_count||0]})]})]})},b.id)})}),e.jsx(bs,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(Lge,{icon:e.jsx(An,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(b=>{const _=g(b.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx($a,{src:_.avatar}),e.jsx(kn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:b.title||b.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ms(new Date(b.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(st,{variant:"secondary",className:"text-xs capitalize",children:b.touch_type}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ln,{className:"h-3 w-3"}),b.view_count||0]})]})]})},b.id)})})]})]})},Lge=({icon:t,label:s})=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center text-muted-foreground",children:[t,e.jsx("p",{className:"mt-2 text-sm",children:s})]})}),ltt=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:c,isAddingMember:u})=>{var q,U;const{useTeamMembers:p}=_C(),{data:f=[],isLoading:g}=p(t.id),[b,_]=k.useState(!1),[j,w]=k.useState(""),[N,S]=k.useState("team_member"),{data:M}=mt({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:B}=await H.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),V=new Map;return(B||[]).forEach(Y=>{var Q;V.set(Y.user_id,((Q=Y.teams)==null?void 0:Q.name)||"another team")}),V}}),L=new Set(f.map(B=>B.user_id)),I=s.filter(B=>!L.has(B.id)),O=async()=>{j&&(await a(j,N),w(""),S("team_member"),_(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(K,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(ba,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"members",children:"Members"}),e.jsxs(ns,{value:"contacts",children:[e.jsx(eS,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(ns,{value:"lead-pond",children:[e.jsx(Xg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(ns,{value:"shared-assets",children:[e.jsx(Om,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(ns,{value:"settings",children:"Settings"})]}),e.jsxs(bs,{value:"members",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold",children:[t.name," — Members"]}),e.jsxs(fs,{open:b,onOpenChange:_,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Tl,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add Team Member"}),e.jsxs(Gr,{children:["Select an agent from your brokerage to add to ",t.name,"."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Agent"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[j&&(((q=I.find(B=>B.id===j))==null?void 0:q.name)||((U=I.find(B=>B.id===j))==null?void 0:U.email))||"Select an agent",e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Dx,{children:[e.jsx(Ox,{placeholder:"Search agents..."}),e.jsxs(Rx,{children:[e.jsx(Fx,{children:"No agents found."}),e.jsx(zx,{children:I.map(B=>{const V=M==null?void 0:M.get(B.id);return e.jsxs(bp,{value:B.name||B.email||B.id,disabled:!!V,onSelect:()=>w(B.id),children:[e.jsx(va,{className:It("mr-2 h-4 w-4",j===B.id?"opacity-100":"opacity-0")}),B.name||B.email,V&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",V,")"]})]},B.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Role"}),e.jsxs(Ks,{value:N,onValueChange:S,children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"team_leader",children:"Team Leader"}),e.jsx(Mt,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{onClick:O,disabled:!j||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),g?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(B=>e.jsx(ys,{className:"h-16 w-full"},B))}):f.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(pr,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No members yet. Add agents to this team."})]})}):e.jsx("div",{className:"space-y-2",children:f.map(B=>{var V,Y,Q,ee,X;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:((V=B.profile)==null?void 0:V.avatar_url)||""}),e.jsx(kn,{children:(((Y=B.profile)==null?void 0:Y.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Q=B.profile)==null?void 0:Q.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(ee=B.profile)==null?void 0:ee.email})]}),B.role==="team_leader"?e.jsxs(st,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Dm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(st,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ks,{value:B.role,onValueChange:ie=>l(B.id,ie),children:[e.jsx(Hs,{className:"w-[140px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"team_leader",children:"Team Leader"}),e.jsx(Mt,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(FL,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Remove Member?"}),e.jsxs(sc,{children:["Remove ",((X=B.profile)==null?void 0:X.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>o(B.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},B.id)})})]}),e.jsx(bs,{value:"contacts",className:"space-y-4",children:e.jsx(Oke,{})}),t.lead_pond_enabled&&e.jsx(bs,{value:"lead-pond",className:"space-y-4",children:e.jsx(Rke,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(bs,{value:"shared-assets",className:"space-y-4",children:e.jsx(ott,{teamId:t.id})}),e.jsxs(bs,{value:"settings",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-lg",children:"Team Settings"}),e.jsx(gr,{children:"Configure how this team operates."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Team Name"}),e.jsx(ze,{defaultValue:t.name,onBlur:B=>{B.target.value!==t.name&&n({name:B.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{defaultValue:t.description||"",onBlur:B=>{B.target.value!==(t.description||"")&&n({description:B.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Contact Visibility"}),e.jsxs(Ks,{defaultValue:t.contact_visibility,onValueChange:B=>n({contact_visibility:B}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(Mt,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(Mt,{value:"full_team",children:"Full Team — All team members can see shared contacts"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls whether team leaders and members can view each other's contacts."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Lead Pond"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable a shared lead pool where leaders can drop leads for members to claim."})]}),e.jsx(qr,{checked:t.lead_pond_enabled,onCheckedChange:B=>n({lead_pond_enabled:B})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Shared Assets"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow team members to access shared presentations, guest books, and videos."})]}),e.jsx(qr,{checked:t.shared_assets_enabled,onCheckedChange:B=>n({shared_assets_enabled:B})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Shared Video Library"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Let team members browse and use each other's videos from the Video Library."})]}),e.jsx(qr,{checked:t.shared_videos_enabled??!1,onCheckedChange:B=>n({shared_videos_enabled:B})})]})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsxs(K,{variant:"destructive",size:"sm",children:[e.jsx(Nr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete Team?"}),e.jsxs(sc,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},ctt=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[c,u]=k.useState(1),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(""),[w,N]=k.useState(""),[S,M]=k.useState([]),L=()=>{u(1),f(""),b(""),j(""),N(""),M([])},I=B=>{B||L(),s(B)},O=async()=>{const B=_&&_!=="none"?_:i||null;await r({name:p.trim(),description:g.trim()||void 0,brokerage_id:B,leaderId:w||void 0,memberIds:S.length>0?S:void 0}),L()},q=B=>{B!==w&&M(V=>V.includes(B)?V.filter(Y=>Y!==B):[...V,B])},U=a.filter(B=>B.id!==w);return e.jsx(fs,{open:t,onOpenChange:I,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:c===1?"Create New Team":"Assign Team Members"}),e.jsx(Gr,{children:c===1?"Name your team and add a description.":"Pick a leader and optionally add initial members."}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("div",{className:It("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:It("h-1.5 flex-1 rounded-full transition-colors",c===2?"bg-primary":"bg-muted")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 pr-1",children:c===1?e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(ze,{id:"team-name",value:p,onChange:B=>f(B.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"team-desc",children:"Description"}),e.jsx(Er,{id:"team-desc",value:g,onChange:B=>b(B.target.value),placeholder:"What is this team focused on?",rows:3})]}),o&&l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Brokerage"}),e.jsxs(Ks,{value:_,onValueChange:j,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No brokerage (independent)"}),l.map(B=>e.jsx(Mt,{value:B.id,children:B.name},B.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(Dm,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(Ks,{value:w,onValueChange:B=>{N(B),M(V=>V.filter(Y=>Y!==B))},children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No leader for now"}),a.map(B=>e.jsx(Mt,{value:B.id,children:B.name||B.email||"Unknown"},B.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(Tl,{className:"h-3.5 w-3.5"}),"Initial Members",S.length>0&&e.jsxs(st,{variant:"secondary",className:"ml-1 text-xs",children:[S.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:U.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(pr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):U.map(B=>{const V=S.includes(B.id);return e.jsxs("button",{type:"button",className:It("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",V&&"bg-primary/5"),onClick:()=>q(B.id),children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:B.avatar_url||""}),e.jsx(kn,{className:"text-xs",children:(B.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:B.email})]}),e.jsx("div",{className:It("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",V?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:V&&e.jsx(va,{className:"h-3 w-3"})})]},B.id)})})]})]})}),e.jsx(qn,{className:"gap-2 sm:gap-0",children:c===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(Qa,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Ja,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:O,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},sVt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=_C(),[c,u]=k.useState(!1),[p,f]=k.useState(null),[g,b]=k.useState(""),{data:_}=mt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:I,error:O}=await H.from("brokerages").select("id, name").order("name");if(O)throw O;return I||[]}}),{data:j}=mt({queryKey:["admin-team-member-info",t.map(I=>I.id).join(",")],queryFn:async()=>{var B;if(t.length===0)return{};const{data:I}=await H.from("team_members").select("team_id, user_id, role").in("team_id",t.map(V=>V.id));if(!I)return{};const O=I.filter(V=>V.role==="team_leader").map(V=>V.user_id);let q={};if(O.length>0){const{data:V}=await H.from("profiles").select("id, name").in("id",O);V&&(q=Object.fromEntries(V.map(Y=>[Y.id,{name:Y.name}])))}const U={};for(const V of t){const Y=I.filter(ee=>ee.team_id===V.id),Q=Y.find(ee=>ee.role==="team_leader");U[V.id]={count:Y.length,leaderName:Q&&((B=q[Q.user_id])==null?void 0:B.name)||null}}return U},enabled:t.length>0}),w=(p==null?void 0:p.brokerage_id)||null,{data:N}=mt({queryKey:["brokerage-agents-for-teams",w],queryFn:async()=>{let I=H.from("profiles").select("id, name, email, avatar_url").order("name");w&&(I=I.eq("brokerage_id",w));const{data:O,error:q}=await I;if(q)throw q;return O||[]},enabled:!!p}),S=Object.fromEntries((_||[]).map(I=>[I.id,I.name])),M=async I=>{const O=await r.mutateAsync({name:I.name,brokerage_id:I.brokerage_id||null,description:I.description});if(I.leaderId&&I.leaderId!=="none"&&await o.mutateAsync({team_id:O.id,user_id:I.leaderId,role:"team_leader"}),I.memberIds)for(const q of I.memberIds)await o.mutateAsync({team_id:O.id,user_id:q,role:"team_member"});u(!1)};if(p)return e.jsx(ltt,{team:p,brokerageAgents:N||[],onBack:()=>f(null),onUpdate:I=>n.mutateAsync({id:p.id,...I}).then(O=>f(O)),onAddMember:(I,O)=>o.mutateAsync({team_id:p.id,user_id:I,role:O}),onRemoveMember:I=>l.mutateAsync({team_id:p.id,member_id:I}),onUpdateRole:(I,O)=>i.mutateAsync({team_id:p.id,member_id:I,role:O}),onDeleteTeam:()=>{a.mutate(p.id),f(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const L=t.filter(I=>I.name.toLowerCase().includes(g.toLowerCase())||(I.description||"").toLowerCase().includes(g.toLowerCase()));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search teams...",value:g,onChange:I=>b(I.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[L.length," of ",t.length," teams"]})]}),e.jsxs(K,{size:"sm",onClick:()=>u(!0),children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(ctt,{open:c,onOpenChange:u,onCreateTeam:M,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:_,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Team Name"}),e.jsx(St,{className:"font-semibold",children:"Brokerage"}),e.jsx(St,{className:"font-semibold",children:"Leader"}),e.jsx(St,{className:"font-semibold",children:"Members"}),e.jsx(St,{className:"font-semibold",children:"Visibility"}),e.jsx(St,{className:"w-[100px]"})]})}),e.jsx(zn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(I=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-32"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-24"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-28"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-12"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx(dt,{children:e.jsx(ys,{className:"h-4 w-16"})})]},I))}):L.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:g?"No teams match your search":"No teams found. Create one to get started."})}):L.map(I=>{const O=j==null?void 0:j[I.id];return e.jsxs(Ss,{className:"hover:bg-muted/30",children:[e.jsxs(dt,{children:[e.jsx("button",{onClick:()=>f(I),className:"text-primary hover:underline font-medium",children:I.name}),I.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:I.description})]}),e.jsx(dt,{children:I.brokerage_id?e.jsx("span",{className:"text-sm",children:S[I.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(dt,{children:O!=null&&O.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Dm,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),O.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(dt,{children:e.jsxs(st,{variant:"secondary",className:"text-xs",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),(O==null?void 0:O.count)??0]})}),e.jsx(dt,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(th,{className:"h-3 w-3"}),I.contact_visibility.replace("_"," ")]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f(I),title:"Edit team",children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete team "${I.name}"? This cannot be undone.`)&&a.mutate(I.id)},title:"Delete team",children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})})]},I.id)})})]})})]})},rVt=()=>{const t=fr(),{user:s,isAdmin:r}=Ds(),{startImpersonation:n,isLoading:a}=Ide(),{toast:o}=Ua(),[l,i]=k.useState([]),[c,u]=k.useState([]),[p,f]=k.useState([]),[g,b]=k.useState({}),[_,j]=k.useState(!0),[w,N]=k.useState({}),[S,M]=k.useState(!1),[L,I]=k.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[O,q]=k.useState(!1),[U,B]=k.useState(""),[V,Y]=k.useState(1),[Q,ee]=k.useState(50),[X,ie]=k.useState("all"),[re,oe]=k.useState("all"),[ce,ge]=k.useState("all"),[ye,ue]=k.useState("all"),[pe,_e]=k.useState(!1),[$e,Ae]=k.useState(!1),[Ie,Ce]=k.useState(null),[xe,we]=k.useState(null),[Le,tt]=k.useState(!1),[Te,pt]=k.useState({name:"",email:"",brokerage_id:"",phone:""}),[fe,qe]=k.useState(null),[at,et]=k.useState(!1),[Me,rt]=k.useState(""),[He,ct]=k.useState(!1),[Ue,Ze]=k.useState(!1),[Qe,We]=k.useState(null),[Je,it]=k.useState(""),[Dt,Vt]=k.useState(!1),[hs,Ts]=k.useState(!1),[Cs,cs]=k.useState(null),[er,xt]=k.useState(!1),[Es,ur]=k.useState(!1),[Mr,Lr]=k.useState(null),[fn,ki]=k.useState(""),[Ea,dr]=k.useState(!1),[Jr,Wr]=k.useState({email:"",name:"",password:"",phone:""}),[dn,Yr]=k.useState(!1),[vi,ft]=k.useState(!1),[ir,Vn]=k.useState(""),[Sr,jr]=k.useState(!1),[ea,Pa]=k.useState(!1),[Ii,Fo]=k.useState(""),[$t,ke]=k.useState(new Set),[Be,Ye]=k.useState(!1),[bt,gt]=k.useState(!1),[Ft,Zt]=k.useState(null),[Ut,Xt]=k.useState(!1),[Ps,gs]=k.useState(null),[vr,Hr]=k.useState([]),[xr,Dn]=k.useState([]),[On,En]=k.useState(!1),[_a,vo]=k.useState({});k.useEffect(()=>{!s||!r||(ti(),hl())},[s,r]);const il=async()=>{try{const{data:jt,error:As}=await H.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(As)throw As;const Qs={};for(const xn of jt??[])Qs[xn.brokerage_id]||(Qs[xn.brokerage_id]=[]),Qs[xn.brokerage_id].push(xn.user_id);b(Qs)}catch(jt){console.error("Error loading brokerage manager assignments:",jt)}},ti=async()=>{try{j(!0);const{data:jt,error:As}=await H.functions.invoke("get-user-details");if(As)throw As;const Qs=jt.users||[];i(Qs),f(jt.brokerages||[]),await il();const xn=Qs.filter(gn=>gn.roles.includes("assistant"));if(xn.length>0){const gn=xn.map(Ur=>Ur.id),{data:ca}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",gn);if(ca&&ca.length>0){const Ur=[...new Set(ca.map(Op=>Op.agent_id))],{data:uo}=await H.from("profiles").select("id, name, email").in("id",Ur),Jx={};for(const Op of ca){const Zr=uo==null?void 0:uo.find(ev=>ev.id===Op.agent_id);Zr&&(Jx[Op.assistant_id]={agent_name:Zr.name||"",agent_email:Zr.email||""})}vo(Jx)}}}catch(jt){console.error("Error loading members:",jt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{j(!1)}},hl=async()=>{try{const{data:jt,error:As}=await H.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(As)throw As;u(jt||[])}catch(jt){console.error("Error loading apps:",jt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},oo=async jt=>{if(!Te.name.trim()||!Te.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Te.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Qs}=await H.from("profiles").update({name:Te.name.trim(),email:Te.email.trim(),brokerage_id:Te.brokerage_id||null,phone:Te.phone.trim()||null}).eq("id",jt);if(Qs)throw Qs;o({title:"Success",description:"Member details updated successfully"}),Ce(null),ti()}catch(Qs){console.error("Error updating member:",Qs),o({title:"Error",description:Qs.message||"Failed to update member",variant:"destructive"})}},Ia=async jt=>{try{const{data:{session:As}}=await H.auth.getSession(),Qs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${As==null?void 0:As.access_token}`},body:JSON.stringify({userId:jt})}),xn=await Qs.json();if(!Qs.ok)throw new Error(xn.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(As){console.error("Error resending welcome email:",As),o({title:"Error",description:As.message||"Failed to resend welcome email",variant:"destructive"})}},lo=async(jt,As)=>{try{const{error:Qs}=await H.functions.invoke("send-password-reset",{body:{email:jt,redirectTo:window.location.origin}});if(Qs)throw Qs;o({title:"Password Reset Sent",description:`Password reset email sent to ${As}`})}catch(Qs){console.error("Error sending password reset:",Qs),o({title:"Error",description:Qs.message||"Failed to send password reset email",variant:"destructive"})}},Ti=async(jt,As)=>{if(confirm(`Are you sure you want to delete ${As}? This action cannot be undone.`))try{const{data:{session:Qs}}=await H.auth.getSession(),xn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qs==null?void 0:Qs.access_token}`},body:JSON.stringify({userId:jt})}),gn=await xn.json();if(!xn.ok)throw new Error(gn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),ti()}catch(Qs){console.error("Error deleting user:",Qs),o({title:"Error",description:Qs.message||"Failed to delete user",variant:"destructive"})}},ua=async()=>{if(!L.email||!L.name||!L.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(L.role==="brokerage_manager"&&!L.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}M(!0);try{const{data:{session:jt}}=await H.auth.getSession(),As=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${jt==null?void 0:jt.access_token}`},body:JSON.stringify(L)}),Qs=await As.json();if(!As.ok)throw new Error(Qs.error||"Failed to create user");if(L.role&&L.role!=="user"&&Qs.userId){const xn=L.role==="brokerage_manager"?L.brokerage_id:void 0;await co(Qs.userId,L.role,"add",xn)}o({title:"Success",description:`User ${L.email} created successfully`}),I({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),q(!1),ti()}catch(jt){console.error("Error creating user:",jt),o({title:"Error",description:jt.message||"Failed to create user",variant:"destructive"})}finally{M(!1)}},co=async(jt,As,Qs,xn)=>{try{const{data:{session:gn}}=await H.auth.getSession(),ca={userId:jt,role:As,action:Qs};if(As==="brokerage_manager"){if(!xn){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}ca.brokerageId=xn}const Ur=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(ca)}),uo=await Ur.json();if(!Ur.ok)throw new Error(uo.error||"Failed to manage user role");o({title:"Success",description:`Role ${Qs==="add"?"added":"removed"} successfully`}),ti()}catch(gn){console.error("Error managing user role:",gn),o({title:"Error",description:gn.message||"Failed to manage user role",variant:"destructive"})}},Mc=(jt,As)=>As.length===0?!0:As.some(Qs=>jt.includes(Qs)),Wc=async(jt,As,Qs)=>{const xn=`${jt}-${As.id}`;qe(xn);try{if(Qs){const gn=l.find(Ur=>Ur.id===jt),ca=As.required_tags.filter(Ur=>gn==null?void 0:gn.tags.includes(Ur));for(const Ur of ca){const{error:uo}=await H.from("user_tags").delete().eq("user_id",jt).eq("tag",Ur);if(uo)throw uo}o({title:"Access Removed",description:`Removed access to ${As.name}`})}else if(As.required_tags.length>0){const{error:gn}=await H.from("user_tags").insert({user_id:jt,tag:As.required_tags[0]});if(gn)throw gn;o({title:"Access Granted",description:`Granted access to ${As.name}`})}await ti()}catch(gn){console.error("Error toggling access:",gn),o({title:"Error",description:gn.message||"Failed to update access",variant:"destructive"})}finally{qe(null)}},lu=async()=>{const jt=Me.trim();if(!jt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(jt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(Qs=>Qs.name.toLowerCase()===jt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}ct(!0);try{const{error:Qs}=await H.from("brokerages").insert({name:jt});if(Qs)throw Qs;o({title:"Success",description:`Brokerage "${jt}" created successfully`}),rt(""),et(!1),ti()}catch(Qs){console.error("Error creating brokerage:",Qs),o({title:"Error",description:Qs.message||"Failed to create brokerage",variant:"destructive"})}finally{ct(!1)}},Of=jt=>{We(jt),it(jt.name),Ze(!0)},zl=()=>{We(null),it(""),Ze(!1)},ch=async()=>{if(!Qe)return;const jt=Je.trim();if(!jt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(jt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Vt(!0);try{const{error:As}=await H.from("brokerages").update({name:jt}).eq("id",Qe.id);if(As)throw As;o({title:"Success",description:"Brokerage updated successfully"}),zl(),ti()}catch(As){console.error("Error updating brokerage:",As),o({title:"Error",description:As.message||"Failed to update brokerage",variant:"destructive"})}finally{Vt(!1)}},Sd=async(jt,As)=>{var Qs;if(!As||typeof As!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const xn={userId:jt,role:"brokerage_manager",action:"add",brokerageId:As};console.debug("[assignManagerToBrokerage] payload",xn);const{data:{session:gn}}=await H.auth.getSession(),ca=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(xn)}),Ur=await ca.json();if(!ca.ok&&!((Qs=Ur.error)!=null&&Qs.includes("duplicate")))throw new Error(Ur.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await ti()}catch(xn){console.error("Error assigning manager:",xn),o({title:"Error",description:xn.message||"Failed to assign manager",variant:"destructive"})}},Km=jt=>{cs(jt),Ts(!0)},Bl=async()=>{if(Cs){xt(!0);try{const jt=l.filter(xn=>xn.brokerage_id===Cs.id),{data:{session:As}}=await H.auth.getSession();for(const xn of jt){const gn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${As==null?void 0:As.access_token}`},body:JSON.stringify({userId:xn.id})});if(!gn.ok){const ca=await gn.json();console.error(`Failed to delete user ${xn.email}:`,ca.error)}}const{error:Qs}=await H.from("brokerages").delete().eq("id",Cs.id);if(Qs)throw Qs;o({title:"Success",description:`Brokerage "${Cs.name}" and ${jt.length} member(s) deleted`}),Ts(!1),cs(null),ti()}catch(jt){console.error("Error deleting brokerage:",jt),o({title:"Error",description:jt.message||"Failed to delete brokerage",variant:"destructive"})}finally{xt(!1)}}},Yx=jt=>{Lr(jt),ki(""),ur(!0)},vy=()=>{Lr(null),ki(""),ur(!1)},H1=async jt=>{try{const{error:As}=await H.from("profiles").update({brokerage_id:null}).eq("id",jt);if(As)throw As;o({title:"Success",description:"User removed from brokerage"}),ti()}catch(As){console.error("Error removing user from brokerage:",As),o({title:"Error",description:As.message||"Failed to remove user",variant:"destructive"})}},W1=async(jt,As)=>{try{const{error:Qs}=await H.from("profiles").update({brokerage_id:As}).eq("id",jt);if(Qs)throw Qs;o({title:"Success",description:"User added to brokerage"}),ti()}catch(Qs){console.error("Error adding user to brokerage:",Qs),o({title:"Error",description:Qs.message||"Failed to add user",variant:"destructive"})}},G1=async()=>{if(!Mr||!Jr.email||!Jr.name||!Jr.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Yr(!0);try{const{data:{session:jt}}=await H.auth.getSession(),As=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${jt==null?void 0:jt.access_token}`},body:JSON.stringify({...Jr,brokerage_id:Mr.id,role:"user"})}),Qs=await As.json();if(!As.ok)throw new Error(Qs.error||"Failed to create agent");o({title:"Success",description:`Agent ${Jr.email} created successfully`}),Wr({email:"",name:"",password:"",phone:""}),dr(!1),ti()}catch(jt){console.error("Error creating agent:",jt),o({title:"Error",description:jt.message||"Failed to create agent",variant:"destructive"})}finally{Yr(!1)}},Dp=jt=>l.filter(As=>As.brokerage_id===jt),am=jt=>{const As=Dp(jt);if(!fn)return As;const Qs=fn.toLowerCase();return As.filter(xn=>xn.name.toLowerCase().includes(Qs)||xn.email.toLowerCase().includes(Qs))},cu=jt=>l.filter(As=>As.brokerage_id!==jt),im=l.filter(jt=>{var Qs;if(U){const xn=U.toLowerCase();if(!(jt.name.toLowerCase().includes(xn)||jt.email.toLowerCase().includes(xn)||((Qs=jt.brokerage_name)==null?void 0:Qs.toLowerCase().includes(xn))))return!1}if(X==="claimed"&&!jt.claimed||X==="unclaimed"&&jt.claimed||re!=="all"&&!jt.roles.includes(re))return!1;const As=jt.is_trial||jt.subscription_status==="trialing";return!(ce==="trial"&&!As||ce==="non-trial"&&As||ye==="none"&&jt.brokerage_id||ye!=="all"&&ye!=="none"&&jt.brokerage_id!==ye)}),{sortKey:$d,sortDirection:Cd,handleSort:du,sortData:Rf}=QO("created_at","desc"),Ff=Rf(im,{name:jt=>{var As;return((As=jt.name)==null?void 0:As.toLowerCase())||""},brokerage:jt=>{var As;return((As=jt.brokerage_name)==null?void 0:As.toLowerCase())||""},status:jt=>jt.claimed?"active":"pending",role:jt=>jt.roles[0]||"",last_login:jt=>jt.last_sign_in_at?new Date(jt.last_sign_in_at).getTime():null,created_at:jt=>jt.created_at?new Date(jt.created_at).getTime():null}),Zm=Ff.length,Ym=Q===0,Md=Ym?1:Math.ceil(Zm/Q),Y0=Ym?0:(V-1)*Q,Xx=Ym?Zm:Y0+Q,El=Ff.slice(Y0,Xx),K1=jt=>{B(jt),Y(1)},Qx=jt=>{ee(jt),Y(1)},Lh=(jt,As)=>{jt(As),Y(1)},Ww=async(jt,As)=>{_e(!0);try{const Qs=l.find(Ur=>Ur.id===jt);if(!Qs)return;const xn=Qs.trial_expires_at?new Date(Qs.trial_expires_at):new Date,gn=new Date(xn.getTime()+As*24*60*60*1e3),{error:ca}=await H.from("profiles").update({trial_expires_at:gn.toISOString()}).eq("id",jt);if(ca)throw ca;o({title:"Trial Extended",description:`Trial extended by ${As} days`}),ti()}catch(Qs){console.error("Error extending trial:",Qs),o({title:"Error",description:Qs.message||"Failed to extend trial",variant:"destructive"})}finally{_e(!1)}},EC=async jt=>{Ae(!0);try{const{error:As}=await H.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",jt);if(As)throw As;o({title:"Account Converted",description:"User has been converted to a full account"}),ti(),by()}catch(As){console.error("Error converting trial:",As),o({title:"Error",description:As.message||"Failed to convert account",variant:"destructive"})}finally{Ae(!1)}},X0=async jt=>{En(!0);try{const{data:As}=await H.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",jt);if(As&&As.length>0){const xn=As.map(ca=>ca.assistant_id),{data:gn}=await H.from("profiles").select("id, name, email").in("id",xn);Hr(As.map(ca=>{const Ur=gn==null?void 0:gn.find(uo=>uo.id===ca.assistant_id);return{id:ca.id,assistant_id:ca.assistant_id,assistant_name:(Ur==null?void 0:Ur.name)||"Unknown",assistant_email:(Ur==null?void 0:Ur.email)||"",permissions:ca.permissions||{}}}))}else Hr([]);const{data:Qs}=await H.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",jt);if(Qs&&Qs.length>0){const xn=Qs.map(ca=>ca.agent_id),{data:gn}=await H.from("profiles").select("id, name, email").in("id",xn);Dn(Qs.map(ca=>{const Ur=gn==null?void 0:gn.find(uo=>uo.id===ca.agent_id);return{id:ca.id,agent_id:ca.agent_id,agent_name:(Ur==null?void 0:Ur.name)||"Unknown",agent_email:(Ur==null?void 0:Ur.email)||"",permissions:ca.permissions||{}}}))}else Dn([])}catch(As){console.error("Error loading assistant data:",As)}finally{En(!1)}},La=jt=>{we(jt),pt({name:jt.name,email:jt.email,brokerage_id:jt.brokerage_id||"",phone:jt.phone||""}),tt(!0),X0(jt.id)},by=()=>{we(null),tt(!1),pt({name:"",email:"",brokerage_id:"",phone:""})},Gw=async()=>{xe&&(await oo(xe.id),by())},PC=jt=>{ke(As=>{const Qs=new Set(As);return Qs.has(jt)?Qs.delete(jt):Qs.add(jt),Qs})},IC=()=>{if($t.size===El.length&&El.every(jt=>$t.has(jt.id))){const jt=new Set($t);El.forEach(As=>jt.delete(As.id)),ke(jt)}else{const jt=new Set($t);El.forEach(As=>jt.add(As.id)),ke(jt)}},om=()=>{ke(new Set)},Q0=async()=>{if($t.size===0)return;Ye(!0);let jt=0,As=0;try{const{data:{session:Qs}}=await H.auth.getSession();for(const xn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qs==null?void 0:Qs.access_token}`},body:JSON.stringify({userId:xn})})).ok?jt++:As++}catch{As++}o({title:"Bulk Email Complete",description:`Sent ${jt} emails${As>0?`, ${As} failed`:""}`}),om()}catch(Qs){o({title:"Error",description:Qs.message||"Failed to send emails",variant:"destructive"})}finally{Ye(!1)}},J0=async()=>{if($t.size===0)return;Ye(!0);let jt=0,As=0;try{const{data:{session:Qs}}=await H.auth.getSession();for(const xn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qs==null?void 0:Qs.access_token}`},body:JSON.stringify({userId:xn})})).ok?jt++:As++}catch{As++}o({title:"Bulk Password Reset Complete",description:`Sent ${jt} reset emails${As>0?`, ${As} failed`:""}`}),om()}catch(Qs){o({title:"Error",description:Qs.message||"Failed to send password reset emails",variant:"destructive"})}finally{Ye(!1)}},Kw=async()=>{if($t.size===0)return;const jt=l.filter(gn=>$t.has(gn.id)).map(gn=>gn.name).slice(0,5).join(", "),As=$t.size>5?` and ${$t.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${$t.size} users (${jt}${As})? This action cannot be undone.`))return;Ye(!0);let Qs=0,xn=0;try{const{data:{session:gn}}=await H.auth.getSession();for(const ca of $t)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:ca})})).ok?Qs++:xn++}catch{xn++}o({title:"Bulk Delete Complete",description:`Deleted ${Qs} users${xn>0?`, ${xn} failed`:""}`}),om(),ti()}catch(gn){o({title:"Error",description:gn.message||"Failed to delete users",variant:"destructive"})}finally{Ye(!1)}},Z1=async()=>{gt(!0);try{const{data:{session:jt}}=await H.auth.getSession(),As=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${jt==null?void 0:jt.access_token}`}});if(!As.ok){const xn=await As.json();throw new Error(xn.error||"Failed to sync phones")}const Qs=await As.json();o({title:"Phone Sync Complete",description:`Pulled ${Qs.summary.pulledFromGHL} from GHL, pushed ${Qs.summary.pushedToGHL} to GHL, ${Qs.summary.alreadySynced} already synced`}),ti()}catch(jt){o({title:"Error",description:jt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{gt(!1)}},Xm=async(jt,As)=>{Zt(jt);try{const{data:{session:Qs}}=await H.auth.getSession(),{data:xn}=await H.from("profiles").select("phone").eq("id",jt).single(),gn=(xn==null?void 0:xn.phone)||"",ca=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qs==null?void 0:Qs.access_token}`},body:JSON.stringify({email:As,action:"update",phone:gn||void 0})});if(!ca.ok){const uo=await ca.json();throw new Error(uo.error||"Failed to sync with GHL")}const Ur=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(As)}`,{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"}),ti()}catch(Qs){o({title:"Error",description:Qs.message||"Failed to sync phone",variant:"destructive"})}finally{Zt(null)}},_y=async jt=>{await n(jt)},Zw=()=>{if($t.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const jt=l.filter(uo=>$t.has(uo.id)),As=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Qs=jt.map(uo=>[uo.name,uo.email,uo.phone||"",uo.brokerage_name||"",uo.roles.join("; "),uo.claimed?"Claimed":"Unclaimed",new Date(uo.created_at).toLocaleDateString()]),xn=[As.join(","),...Qs.map(uo=>uo.map(Jx=>`"${(Jx||"").replace(/"/g,'""')}"`).join(","))].join(` `),gn=new Blob([xn],{type:"text/csv"}),ca=URL.createObjectURL(gn),Ur=document.createElement("a");Ur.href=ca,Ur.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Ur.click(),URL.revokeObjectURL(ca),o({title:"Export complete",description:`Exported ${jt.length} member(s)`})};return _?e.jsx(Ms,{title:"Members",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(Ms,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Member Management",description:"Manage users, roles, and permissions"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:Z1,disabled:bt,children:[bt?e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Un,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:bt?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:bt?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>ft(!0),children:[e.jsx(a1,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Import CSV"}),e.jsx("span",{className:"sm:hidden",children:"Import"})]}),e.jsxs(fs,{open:O,onOpenChange:q,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Tl,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Add Member"}),e.jsx("span",{className:"sm:hidden",children:"Add"})]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New User"}),e.jsx(Gr,{children:"Add a new user to the system. They'll be able to sign in immediately."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",placeholder:"John Doe",value:L.name,onChange:jt=>I({...L,name:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",placeholder:"john@example.com",value:L.email,onChange:jt=>I({...L,email:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"password",children:"Password"}),e.jsx(ze,{id:"password",type:"password",placeholder:"Min 6 characters",value:L.password,onChange:jt=>I({...L,password:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"555-123-4567",value:L.phone,onChange:jt=>I({...L,phone:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"brokerage",children:["Brokerage",L.role==="brokerage_manager"?" (required)":""]}),e.jsxs(Ks,{value:L.brokerage_id||"none",onValueChange:jt=>I({...L,brokerage_id:jt==="none"?"":jt}),children:[e.jsx(Hs,{id:"brokerage",children:e.jsx(Ys,{placeholder:L.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"None"}),p.map(jt=>e.jsx(Mt,{value:jt.id,children:jt.name},jt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"role",children:"Role"}),e.jsxs(Ks,{value:L.role,onValueChange:jt=>I({...L,role:jt}),children:[e.jsx(Hs,{id:"role",children:e.jsx(Ys,{placeholder:"Select role"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"user",children:"User"}),e.jsx(Mt,{value:"moderator",children:"Moderator"}),e.jsx(Mt,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(Mt,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(Ks,{value:L.trial_days||"none",onValueChange:jt=>I({...L,trial_days:jt==="none"?"":jt}),children:[e.jsx(Hs,{id:"trial_days",children:e.jsx(Ys,{placeholder:"No trial (full access)"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No trial (full access)"}),e.jsx(Mt,{value:"7",children:"7-day trial"}),e.jsx(Mt,{value:"30",children:"30-day trial"}),e.jsx(Mt,{value:"60",children:"60-day trial"}),e.jsx(Mt,{value:"90",children:"90-day trial"}),e.jsx(Mt,{value:"365",children:"1-year trial"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Trial accounts don't require a credit card. Access expires after the trial period."})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(K,{onClick:ua,disabled:S,children:S?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(ba,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"members",children:"Members"}),e.jsx(ns,{value:"brokerages",children:"Brokerages"}),e.jsx(ns,{value:"teams",children:"Teams"}),e.jsx(ns,{value:"trials",children:"Trial Users"}),e.jsx(ns,{value:"access",children:"Access Matrix"}),e.jsx(ns,{value:"celebrations",children:"Celebrations"}),e.jsx(ns,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(bs,{value:"members",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search members...",value:U,onChange:jt=>K1(jt.target.value),className:"pl-10 h-9"})]}),e.jsxs(Ks,{value:X,onValueChange:jt=>Lh(ie,jt),children:[e.jsx(Hs,{className:"w-[130px] h-9",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"claimed",children:"Active"}),e.jsx(Mt,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(Ks,{value:re,onValueChange:jt=>Lh(oe,jt),children:[e.jsx(Hs,{className:"w-[130px] h-9",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Roles"}),e.jsx(Mt,{value:"admin",children:"Admin"}),e.jsx(Mt,{value:"brokerage_manager",children:"Manager"}),e.jsx(Mt,{value:"assistant",children:"Assistant"}),e.jsx(Mt,{value:"user",children:"User"})]})]}),e.jsxs(Ks,{value:ce,onValueChange:jt=>Lh(ge,jt),children:[e.jsx(Hs,{className:"w-[130px] h-9",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Users"}),e.jsx(Mt,{value:"trial",children:"Trial Only"}),e.jsx(Mt,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(Ks,{value:ye,onValueChange:jt=>Lh(ue,jt),children:[e.jsx(Hs,{className:"w-[150px] h-9",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Brokerages"}),e.jsx(Mt,{value:"none",children:"No Brokerage"}),p.map(jt=>e.jsx(Mt,{value:jt.id,children:jt.name},jt.id))]})]}),(U||X!=="all"||re!=="all"||ce!=="all"||ye!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{B(""),ie("all"),oe("all"),ge("all"),ue("all"),Y(1)},children:[e.jsx(Rr,{className:"h-4 w-4 mr-1"}),"Clear"]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:Ym?`Showing all ${Zm} members`:`Showing ${Y0+1}-${Math.min(Xx,Zm)} of ${Zm} members`}),e.jsxs(Ks,{value:Q.toString(),onValueChange:jt=>Qx(Number(jt)),children:[e.jsx(Hs,{className:"h-9 w-[110px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"50",children:"50 / page"}),e.jsx(Mt,{value:"100",children:"100 / page"}),e.jsx(Mt,{value:"250",children:"250 / page"}),e.jsx(Mt,{value:"0",children:"All"})]})]})]})]}),$t.size>0&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/10 border border-primary/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($v,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[$t.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:Q0,disabled:Be,children:[Be?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(cr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Resend Invite"}),e.jsx("span",{className:"sm:hidden",children:"Invite"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:J0,disabled:Be,children:[Be?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Sp,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Password Reset"}),e.jsx("span",{className:"sm:hidden",children:"Reset"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:Zw,children:[e.jsx(yi,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Export"}),e.jsx("span",{className:"sm:hidden",children:"CSV"})]}),e.jsxs(K,{size:"sm",variant:"destructive",onClick:Kw,disabled:Be,children:[Be?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Nr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"}),e.jsx("span",{className:"sm:hidden",children:"Del"})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:om,disabled:Be,children:e.jsx(Rr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"w-[50px]",children:e.jsx(Oo,{checked:El.length>0&&El.every(jt=>$t.has(jt.id)),onCheckedChange:IC,"aria-label":"Select all on page"})}),e.jsx(yl,{sortKey:"name",currentSortKey:$d,currentDirection:Cd,onSort:du,children:"Name"}),e.jsx(yl,{sortKey:"brokerage",currentSortKey:$d,currentDirection:Cd,onSort:du,children:"Brokerage"}),e.jsx(yl,{sortKey:"status",currentSortKey:$d,currentDirection:Cd,onSort:du,children:"Status"}),e.jsx(yl,{sortKey:"role",currentSortKey:$d,currentDirection:Cd,onSort:du,children:"Role"}),e.jsx(yl,{sortKey:"last_login",currentSortKey:$d,currentDirection:Cd,onSort:du,children:"Last Login"}),e.jsx(yl,{sortKey:"created_at",currentSortKey:$d,currentDirection:Cd,onSort:du,children:"Member Since"}),e.jsx(St,{className:"w-[100px]"})]})}),e.jsx(zn,{children:El.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):El.map(jt=>e.jsxs(Ss,{className:`hover:bg-muted/30 ${$t.has(jt.id)?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Oo,{checked:$t.has(jt.id),onCheckedChange:()=>PC(jt.id),"aria-label":`Select ${jt.name}`})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>La(jt),className:"text-primary hover:underline font-medium text-left",children:jt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:jt.email})]})}),e.jsx(dt,{className:"text-muted-foreground",children:jt.brokerage_name||"—"}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const As=jt.is_trial&&jt.trial_expires_at||!jt.is_trial&&jt.subscription_status==="trialing"&&jt.subscription_end_date,Qs=jt.trial_expires_at||jt.subscription_end_date;if(As&&Qs){const xn=Math.ceil((new Date(Qs).getTime()-Date.now())/864e5),gn=xn<=0,ca=xn<=3;return e.jsx(st,{variant:"outline",className:It("w-fit",gn?"border-destructive text-destructive":ca?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:gn?"Trial Expired":`Trial · ${xn}d left`})}return e.jsx(st,{variant:jt.claimed?"default":"secondary",className:jt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:jt.claimed?"Active":"Pending"})})()})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col",children:[jt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:jt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),jt.roles.includes("assistant")&&_a[jt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",_a[jt.id].agent_name||_a[jt.id].agent_email]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:jt.last_sign_in_at?new Date(jt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-muted-foreground",children:jt.created_at?new Date(jt.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{gs(jt),Xt(!0)},title:"Send celebration",children:e.jsx(ru,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>La(jt),title:"Edit member",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Xm(jt.id,jt.email),disabled:Ft===jt.id,title:"Sync phone with GHL",children:Ft===jt.id?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Un,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ia(jt.id),title:"Resend welcome email",children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>lo(jt.email,jt.name),title:"Send password reset",children:e.jsx(rS,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>_y(jt.id),disabled:a||jt.id===(s==null?void 0:s.id),title:jt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${jt.name}`,children:a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(iS,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Ti(jt.id,jt.name),title:"Delete user",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},jt.id))})]})}),Md>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",V," of ",Md]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Y(1),disabled:V===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(jt=>Math.max(1,jt-1)),disabled:V===1,children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Md)},(jt,As)=>{let Qs;return Md<=5||V<=3?Qs=As+1:V>=Md-2?Qs=Md-4+As:Qs=V-2+As,e.jsx(K,{variant:V===Qs?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>Y(Qs),children:Qs},Qs)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(jt=>Math.min(Md,jt+1)),disabled:V===Md,children:e.jsx(da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Y(Md),disabled:V===Md,children:"Last"})]})]})]}),e.jsx(fs,{open:Le,onOpenChange:tt,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Member"}),e.jsx(Gr,{children:"Update member details, roles, and app access"})]}),xe&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-name",children:"Name"}),e.jsx(ze,{id:"edit-name",value:Te.name,onChange:jt=>pt({...Te,name:jt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-email",children:"Email"}),e.jsx(ze,{id:"edit-email",type:"email",value:Te.email,onChange:jt=>pt({...Te,email:jt.target.value}),maxLength:255})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(ze,{id:"edit-phone",type:"tel",value:Te.phone,onChange:jt=>pt({...Te,phone:jt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(Ks,{value:Te.brokerage_id||"none",onValueChange:jt=>pt({...Te,brokerage_id:jt==="none"?"":jt}),children:[e.jsx(Hs,{id:"edit-brokerage",children:e.jsx(Ys,{placeholder:"Select brokerage"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"None"}),p.map(jt=>e.jsx(Mt,{value:jt.id,children:jt.name},jt.id))]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Roles"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[xe.roles.map(jt=>e.jsxs(st,{variant:"default",className:"gap-1",children:[e.jsx(th,{className:"h-3 w-3"}),jt,jt==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>co(xe.id,jt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Rr,{className:"h-3 w-3"})})]},jt)),xe.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(Ks,{onValueChange:jt=>co(xe.id,jt,"add"),children:[e.jsx(Hs,{className:"w-[200px]",children:e.jsx(Ys,{placeholder:"Add role..."})}),e.jsxs(Ws,{children:[!xe.roles.includes("admin")&&e.jsx(Mt,{value:"admin",children:"Admin"}),!xe.roles.includes("user")&&e.jsx(Mt,{value:"user",children:"User"})]})]}),!xe.roles.includes("brokerage_manager")&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"To add as brokerage manager, use Brokerages tab → Manage"})]}),(vr.length>0||xr.length>0||xe.roles.includes("assistant"))&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Assistant Relationships"]}),On?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[vr.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Has assistants:"}),vr.map(jt=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:jt.assistant_name}),e.jsx(st,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:jt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(jt.permissions).filter(([,As])=>As).map(([As])=>e.jsx(st,{variant:"secondary",className:"text-[10px] capitalize",children:As},As))})]},jt.id))]}),xr.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Assists agents:"}),xr.map(jt=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:jt.agent_name}),e.jsx(st,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:jt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(jt.permissions).filter(([,As])=>As).map(([As])=>e.jsx(st,{variant:"secondary",className:"text-[10px] capitalize",children:As},As))})]},jt.id))]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"App Access"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toggle which apps this member can access"}),e.jsx("div",{className:"grid gap-3",children:c.map(jt=>{const As=Mc(xe.tags,jt.required_tags),Qs=`${xe.id}-${jt.id}`,xn=fe===Qs,gn=jt.required_tags.length===0;return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:jt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:jt.name}),gn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:xn?e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"}):gn?e.jsx(st,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(qr,{checked:As,onCheckedChange:()=>Wc(xe.id,jt,As)})})]},jt.id)})})]}),(xe.is_trial||xe.subscription_status==="trialing")&&e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(un,{className:"h-4 w-4"}),"Trial Status"]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-amber-50 dark:bg-amber-950/20 border-amber-200 dark:border-amber-800",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[xe.trial_expires_at&&e.jsx(f8e,{expiresAt:xe.trial_expires_at}),!xe.trial_expires_at&&xe.subscription_status==="trialing"&&xe.subscription_end_date&&e.jsx(f8e,{expiresAt:xe.subscription_end_date})]}),(xe.trial_expires_at||xe.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(xe.trial_expires_at||xe.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Ww(xe.id,7),disabled:pe,children:[e.jsx(R_,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Ww(xe.id,14),disabled:pe,children:[e.jsx(R_,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Ww(xe.id,30),disabled:pe,children:[e.jsx(R_,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>EC(xe.id),disabled:$e,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(G_,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),xe.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(xe.trial_started_at).toLocaleDateString(),xe.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(xe.trial_claimed_at).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Account Information"}),e.jsxs("div",{className:"text-sm space-y-1 text-muted-foreground",children:[xe.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(xe.email_confirmed_at).toLocaleString()]}),xe.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(xe.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(xe.created_at).toLocaleString()]})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:by,children:"Cancel"}),e.jsx(K,{onClick:Gw,children:"Save Changes"})]})]})}),e.jsxs(bs,{value:"access",children:[c.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(K,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Member Access Matrix"}),e.jsx(gr,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left p-4 font-semibold sticky left-0 bg-card z-10",children:"Member"}),c.map(jt=>e.jsx("th",{className:"text-center p-4 font-semibold min-w-[120px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("span",{className:"text-2xl",children:jt.icon}),e.jsx("span",{className:"text-sm",children:jt.name})]})},jt.id))]})}),e.jsxs("tbody",{children:[El.map(jt=>e.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[e.jsx("td",{className:"p-4 sticky left-0 bg-card z-10",children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:jt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:jt.email})]})}),c.map(As=>{const Qs=Mc(jt.tags,As.required_tags),xn=`${jt.id}-${As.id}`,gn=fe===xn;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:gn?e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(qr,{checked:Qs,onCheckedChange:()=>Wc(jt.id,As,Qs),disabled:As.required_tags.length===0})})},As.id)})]},jt.id)),El.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:c.length+1,className:"p-8 text-center text-muted-foreground",children:"No members found"})})]})]})}),Md>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",Y0+1,"-",Math.min(Xx,Zm)," of ",Zm," • Page ",V," of ",Md]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(jt=>Math.max(1,jt-1)),disabled:V===1,children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(jt=>Math.min(Md,jt+1)),disabled:V===Md,children:e.jsx(da,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(K,{variant:"outline",onClick:()=>t("/admin/apps"),children:"Manage Apps"})})]}),e.jsxs(bs,{value:"brokerages",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search brokerages...",value:ir,onChange:jt=>Vn(jt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(jt=>jt.name.toLowerCase().includes(ir.toLowerCase())).length," of ",p.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const jt=[];for(const Ur of p){const uo=g[Ur.id]??[];for(const Jx of uo){const Op=l.find(Zr=>Zr.id===Jx);if(Op){const Zr=(Op.name||"").trim().split(/\s+/),ev=Zr[0]||"",tv=Zr.slice(1).join(" ")||"";jt.push({firstName:ev,lastName:tv,email:Op.email,brokerageName:Ur.name})}}}if(jt.length===0){o({title:"No managers found to export"});return}const Qs=[["First Name","Last Name","Email","Brokerage Name"].join(","),...jt.map(Ur=>[Ur.firstName,Ur.lastName,Ur.email,Ur.brokerageName].map(uo=>`"${(uo||"").replace(/"/g,'""')}"`).join(","))].join(` `),xn=new Blob([Qs],{type:"text/csv"}),gn=URL.createObjectURL(xn),ca=document.createElement("a");ca.href=gn,ca.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,ca.click(),URL.revokeObjectURL(gn),o({title:`Exported ${jt.length} managers`})},children:[e.jsx(yi,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(fs,{open:at,onOpenChange:et,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New Brokerage"}),e.jsx(Gr,{children:"Add a new brokerage to the system."})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(ze,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Me,onChange:jt=>rt(jt.target.value),maxLength:100})]})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>et(!1),children:"Cancel"}),e.jsx(K,{onClick:lu,disabled:He,children:He?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(St,{className:"font-semibold",children:"Manager(s)"}),e.jsx(St,{className:"font-semibold",children:"Agents"}),e.jsx(St,{className:"w-[150px]"})]})}),e.jsx(zn,{children:(()=>{const jt=p.filter(As=>As.name.toLowerCase().includes(ir.toLowerCase()));return jt.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:ir?"No brokerages match your search":"No brokerages found"})}):jt.map(As=>{const Qs=l.filter(Ur=>Ur.brokerage_id===As.id),gn=(g[As.id]??[]).map(Ur=>l.find(uo=>uo.id===Ur)).filter(Boolean),ca=Qs.length;return e.jsxs(Ss,{className:"hover:bg-muted/30",children:[e.jsx(dt,{children:e.jsx("button",{onClick:()=>Of(As),className:"text-primary hover:underline font-medium",children:As.name})}),e.jsx(dt,{children:gn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:gn.map(Ur=>e.jsx(st,{variant:"secondary",className:"text-xs",children:Ur.name},Ur.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(dt,{children:[ca," member",ca!==1?"s":""]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-8",onClick:()=>Yx(As),children:[e.jsx(pr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Of(As),title:"Edit brokerage",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Km(As),title:"Delete brokerage",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},As.id)})})()})]})}),e.jsx(fs,{open:Ue,onOpenChange:Ze,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Brokerage"}),e.jsx(Gr,{children:"Update brokerage details and manage managers"})]}),Qe&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(ze,{id:"edit-brokerage-name",value:Je,onChange:jt=>it(jt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Managers"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click × to remove manager access for this brokerage (keeps them as a member)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(()=>{const As=(g[Qe.id]??[]).map(Qs=>l.find(xn=>xn.id===Qs)).filter(Boolean);return As.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):As.map(Qs=>e.jsxs(st,{variant:"default",className:"gap-1",children:[e.jsx(th,{className:"h-3 w-3"}),Qs.name,e.jsx("button",{onClick:()=>co(Qs.id,"brokerage_manager","remove",Qe.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Rr,{className:"h-3 w-3"})})]},Qs.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs($o,{open:Sr,onOpenChange:jr,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Sr,className:"w-full justify-between",children:["Search for a member...",e.jsx(cn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-full p-0",align:"start",children:e.jsxs(Dx,{children:[e.jsx(Ox,{placeholder:"Search by name or email..."}),e.jsxs(Rx,{className:"max-h-[200px]",children:[e.jsx(Fx,{children:"No members found."}),e.jsx(zx,{children:(()=>{const jt=new Set(g[Qe.id]??[]);return l.filter(As=>!jt.has(As.id)&&(r||As.brokerage_id===Qe.id)).map(As=>e.jsxs(bp,{value:`${As.name} ${As.email}`,onSelect:()=>{Sd(As.id,Qe.id),jr(!1)},children:[As.name," (",As.email,")"]},As.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(jt=>jt.brokerage_id===Qe.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(jt=>jt.brokerage_id===Qe.id).map(jt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:jt.name}),jt.roles.includes("brokerage_manager")&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Manager"})]},jt.id))})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:zl,children:"Cancel"}),e.jsx(K,{onClick:ch,disabled:Dt,children:Dt?"Saving...":"Save Changes"})]})]})}),e.jsx(fs,{open:hs,onOpenChange:Ts,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Gr,{children:['Are you sure you want to delete "',Cs==null?void 0:Cs.name,'"?']})]}),e.jsx("div",{className:"py-4",children:e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Warning: This action cannot be undone!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This will permanently delete:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground list-disc list-inside",children:[e.jsxs("li",{children:['The brokerage "',Cs==null?void 0:Cs.name,'"']}),e.jsxs("li",{children:["All ",l.filter(jt=>jt.brokerage_id===(Cs==null?void 0:Cs.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ts(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Bl,disabled:er,children:er?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(fs,{open:Es,onOpenChange:ur,children:e.jsxs(ps,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-5 w-5"}),"Manage ",Mr==null?void 0:Mr.name]}),e.jsx(Gr,{children:"Add, remove, or manage users in this brokerage"})]}),Mr&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search members...",value:fn,onChange:jt=>ki(jt.target.value),className:"pl-10 h-9"})]}),e.jsxs(fs,{open:Ea,onOpenChange:dr,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Tl,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add New Agent"}),e.jsxs(Gr,{children:["Create a new agent for ",Mr.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"agent-name",children:"Name"}),e.jsx(ze,{id:"agent-name",placeholder:"John Doe",value:Jr.name,onChange:jt=>Wr({...Jr,name:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"agent-email",children:"Email"}),e.jsx(ze,{id:"agent-email",type:"email",placeholder:"john@example.com",value:Jr.email,onChange:jt=>Wr({...Jr,email:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"agent-password",children:"Password"}),e.jsx(ze,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:Jr.password,onChange:jt=>Wr({...Jr,password:jt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(ze,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:Jr.phone,onChange:jt=>Wr({...Jr,phone:jt.target.value})})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>dr(!1),children:"Cancel"}),e.jsx(K,{onClick:G1,disabled:dn,children:dn?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs($o,{open:ea,onOpenChange:Pa,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":ea,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(cn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Dx,{children:[e.jsx(Ox,{placeholder:"Search users...",value:Ii,onValueChange:Fo}),e.jsxs(Rx,{children:[e.jsx(Fx,{children:"No users found."}),e.jsx(zx,{children:cu(Mr.id).filter(jt=>Ii===""||jt.name.toLowerCase().includes(Ii.toLowerCase())||jt.email.toLowerCase().includes(Ii.toLowerCase())).map(jt=>e.jsxs(bp,{value:`${jt.name} ${jt.email}`,onSelect:()=>{W1(jt.id,Mr.id),Pa(!1),Fo("")},children:[jt.name," (",jt.email,")"]},jt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Name"}),e.jsx(St,{className:"font-semibold",children:"Email"}),e.jsx(St,{className:"font-semibold",children:"Status"}),e.jsx(St,{className:"font-semibold",children:"Role"}),e.jsx(St,{className:"w-[120px]"})]})}),e.jsx(zn,{children:am(Mr.id).length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:fn?"No matching members found":"No members in this brokerage"})}):am(Mr.id).map(jt=>e.jsxs(Ss,{className:"hover:bg-muted/30",children:[e.jsx(dt,{className:"font-medium",children:jt.name}),e.jsx(dt,{className:"text-muted-foreground",children:jt.email}),e.jsx(dt,{children:jt.claimed?e.jsx(st,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(st,{variant:"secondary",children:"Pending"})}),e.jsx(dt,{children:jt.roles.includes("brokerage_manager")?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(th,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!jt.claimed&&e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ia(jt.id),title:"Resend welcome email",children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>H1(jt.id),title:"Remove from brokerage",children:e.jsx(Rr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>_y(jt.id),disabled:a||jt.id===(s==null?void 0:s.id),title:jt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${jt.name}`,children:a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(iS,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Ti(jt.id,jt.name),title:"Delete user",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},jt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Dp(Mr.id).length," total member",Dp(Mr.id).length!==1?"s":""," •",Dp(Mr.id).filter(jt=>jt.roles.includes("brokerage_manager")).length," manager",Dp(Mr.id).filter(jt=>jt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(qn,{children:e.jsx(K,{variant:"outline",onClick:vy,children:"Close"})})]})})]}),e.jsx(bs,{value:"teams",children:e.jsx(sVt,{})}),e.jsx(bs,{value:"trials",children:e.jsx(QUt,{})}),e.jsx(bs,{value:"celebrations",children:e.jsx(XUt,{})}),e.jsx(bs,{value:"deletions",children:e.jsx(JUt,{})})]})]}),e.jsx(rtt,{open:vi,onOpenChange:ft,brokerages:p,onSuccess:ti}),Ps&&e.jsx(ntt,{open:Ut,onOpenChange:jt=>{Xt(jt),jt||gs(null)},userId:Ps.id,userName:Ps.name})]})},nVt=()=>{const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(""),[c,u]=k.useState(""),[p,f]=k.useState(""),[g,b]=k.useState("");k.useEffect(()=>{_()},[]);const _=async()=>{const{data:I,error:O}=await H.from("invite_codes").select("*").order("created_at",{ascending:!1});O?(me.error("Failed to load invite codes"),console.error(O)):s(I||[]),n(!1)},j=async I=>{if(I.preventDefault(),!l.trim()){me.error("Please enter a code");return}o(!0);const{error:O}=await H.from("invite_codes").insert({code:l.trim().toUpperCase(),description:c.trim()||null,max_uses:p?parseInt(p):null,trial_days:g?parseInt(g):null});O?O.code==="23505"?me.error("This code already exists"):(me.error("Failed to create invite code"),console.error(O)):(me.success("Invite code created"),i(""),u(""),f(""),b(""),_()),o(!1)},w=async(I,O)=>{const{error:q}=await H.from("invite_codes").update({is_active:!O}).eq("id",I);q?me.error("Failed to update code"):s(t.map(U=>U.id===I?{...U,is_active:!O}:U))},N=async I=>{const{error:O}=await H.from("invite_codes").delete().eq("id",I);O?me.error("Failed to delete code"):(me.success("Code deleted"),s(t.filter(q=>q.id!==I)))},S="https://dashboard.relevelup.com",M=I=>{const O=`${S}/join?code=${I}`;navigator.clipboard.writeText(O),me.success("Link copied to clipboard")},L=`${S}/join`;return e.jsx(Ms,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Create New Code"}),e.jsxs(gr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:L})]})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:j,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"code",children:"Code"}),e.jsx(ze,{id:"code",placeholder:"WELCOME2024",value:l,onChange:I=>i(I.target.value),className:"w-40"})]}),e.jsxs("div",{className:"space-y-2 flex-1 min-w-[200px]",children:[e.jsx(be,{htmlFor:"description",children:"Description (optional)"}),e.jsx(ze,{id:"description",placeholder:"For marketing campaign",value:c,onChange:I=>u(I.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(ze,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:I=>f(I.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(ze,{id:"trialDays",type:"number",placeholder:"None",value:g,onChange:I=>b(I.target.value),className:"w-28"})]}),e.jsxs(K,{type:"submit",disabled:a,children:[a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Active Codes"})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No invite codes yet"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Code"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Uses"}),e.jsx(St,{children:"Trial"}),e.jsx(St,{children:"Created"}),e.jsx(St,{children:"Active"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(I=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono font-medium",children:I.code}),e.jsx(dt,{className:"text-muted-foreground",children:I.description||"—"}),e.jsxs(dt,{children:[I.uses_count,I.max_uses&&` / ${I.max_uses}`]}),e.jsx(dt,{children:I.trial_days?e.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[I.trial_days," days"]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-muted-foreground",children:ms(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx(qr,{checked:I.is_active,onCheckedChange:()=>w(I.id,I.is_active)})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>M(I.code),title:"Copy invite link",children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>N(I.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},I.id))})]})})]})]})})},JO=async t=>{try{const{data:s,error:r}=await H.from("push_notification_settings").select("is_enabled").eq("setting_key",t).maybeSingle();return r?(console.error("Error checking notification setting:",r),!0):(s==null?void 0:s.is_enabled)??!0}catch(s){return console.error("Error checking notification setting:",s),!0}},cE=async t=>{try{const{data:s,error:r}=await H.functions.invoke("send-push-notification",{body:t});return r?(console.error("Error sending notification:",r),{success:!1,error:r}):(console.log("Notification sent:",s),{success:!0,data:s})}catch(s){return console.error("Error sending notification:",s),{success:!1,error:s}}},aVt=async(t,s)=>await JO("new_templates")?cE({title:"New Template Available",body:`Check out the new template: ${t}`,url:`/templates/${s}`}):(console.log("New template notifications are disabled"),{success:!1,skipped:!0}),iVt=async(t,s)=>cE({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),oVt=async(t,s)=>await JO("new_events")?cE({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),lVt=async(t,s)=>await JO("new_toolbox")?cE({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),ibe=async(t,s)=>await JO("new_social_swag")?cE({title:"New Social Swag",body:`New social swag available: ${t}`,url:`/social-swag/${s}`}):(console.log("New social swag notifications are disabled"),{success:!1,skipped:!0}),cVt=async(t,s)=>await JO("new_newsletters")?cE({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),Cz={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 dVt(){const t=fr(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState(Cz),[c,u]=k.useState(null),[p,f]=k.useState(null),[g,b]=k.useState(!1),_=k.useRef(null),[j,w]=k.useState(!1),[N,S]=k.useState(null),[M,L]=k.useState(!1),[I,O]=k.useState(null),[q,U]=k.useState(null),[B,V]=k.useState(!0),[Y,Q]=k.useState(""),{data:ee,isLoading:X}=mt({queryKey:["admin-events"],queryFn:async()=>{const{data:Me,error:rt}=await H.from("events").select("*").order("event_date",{ascending:!0});if(rt)throw rt;return Me}}),{data:ie}=mt({queryKey:["event-registrations-count"],queryFn:async()=>{let Me=[],rt=0;const He=1e3;for(;;){const{data:Ue,error:Ze}=await H.from("event_registrations").select("event_id").range(rt,rt+He-1);if(Ze)throw Ze;if(!Ue||Ue.length===0||(Me=Me.concat(Ue),Ue.length{ct[Ue.event_id]=(ct[Ue.event_id]||0)+1}),ct}}),{data:re,isLoading:oe}=mt({queryKey:["event-registrations-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Me,error:rt}=await H.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",N.id).order("registered_at",{ascending:!1});if(rt)throw rt;if(!Me||Me.length===0)return[];const He=Me.map(Ze=>Ze.user_id).filter(Boolean);let ct=[];if(He.length>0){const{data:Ze,error:Qe}=await H.from("profiles").select("id, name, email").in("id",He);if(Qe)throw Qe;ct=Ze||[]}const Ue=new Map((ct==null?void 0:ct.map(Ze=>[Ze.id,Ze]))||[]);return Me.map(Ze=>({...Ze,profiles:Ze.user_id&&Ue.get(Ze.user_id)||null}))},enabled:!!N}),{data:ce,isLoading:ge}=mt({queryKey:["event-attendees-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Me,error:rt}=await H.from("event_attendees").select("id, user_id, zoom_email, zoom_name, join_time, leave_time, duration_minutes, manually_added, created_at").eq("event_id",N.id).order("created_at",{ascending:!1});if(rt)throw rt;if(!Me||Me.length===0)return[];const He=Me.map(We=>We.user_id).filter(Boolean);let ct=[];if(He.length>0){const{data:We,error:Je}=await H.from("profiles").select("id, name, email").in("id",He);if(Je)throw Je;ct=We||[]}const{data:Ue}=await H.from("agent_points").select("user_id").eq("event_id",N.id),Ze=new Set((Ue==null?void 0:Ue.map(We=>We.user_id))||[]),Qe=new Map((ct==null?void 0:ct.map(We=>[We.id,We]))||[]);return Me.map(We=>({...We,profiles:We.user_id&&Qe.get(We.user_id)||null,points_awarded:We.user_id?Ze.has(We.user_id):!1}))},enabled:!!N}),ye=Me=>{S(Me),w(!0)},ue=Lt({mutationFn:async Me=>{const{data:{session:rt}}=await H.auth.getSession();if(!rt)throw new Error("Not authenticated");const He=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt.access_token}`},body:JSON.stringify({event_id:Me})}),ct=await He.json();if(!He.ok)throw new Error(ct.error||"Failed to sync");return ct},onSuccess:Me=>{s.invalidateQueries({queryKey:["event-registrations-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),me.success(Me.message)},onError:Me=>{me.error("Failed to sync: "+Me.message)}}),pe=Lt({mutationFn:async Me=>{const{data:{session:rt}}=await H.auth.getSession();if(!rt)throw new Error("Not authenticated");const He=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt.access_token}`},body:JSON.stringify({event_id:Me})}),ct=await He.json();if(!He.ok)throw new Error(ct.error||"Failed to sync attendees");return ct},onSuccess:Me=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Me!=null&&Me.message?me.success(Me.message):me.success(`Synced ${Me.synced||0} attendees. ${Me.points_awarded||0} points awarded!`)},onError:Me=>{me.error("Failed to sync attendees: "+Me.message)}}),_e=Lt({mutationFn:async({eventId:Me,testMode:rt})=>{const{data:{session:He}}=await H.auth.getSession();if(!He)throw new Error("Not authenticated");const ct=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${He.access_token}`},body:JSON.stringify({event_id:Me,test_mode:rt})}),Ue=await ct.json();if(!ct.ok)throw new Error(Ue.error||"Failed to send reminders");return Ue},onSuccess:Me=>{Me.test?me.success(Me.message||"Test email sent!"):me.success(Me.message||`Reminder emails sent to ${Me.sent} registrants!`)},onError:Me=>{me.error("Failed to send reminders: "+Me.message)}}),{data:$e}=mt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Me=[],rt=0;const He=1e3;for(;;){const{data:ct,error:Ue}=await H.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(rt,rt+He-1);if(Ue)throw Ue;if(!ct||ct.length===0||(Me=[...Me,...ct],ct.length{const{error:Ue}=await H.from("event_attendees").update({user_id:rt}).eq("id",Me);if(Ue)throw Ue;if(ct&&He){const{error:Qe}=await H.from("zoom_email_aliases").upsert({user_id:rt,zoom_email:He.toLowerCase()},{onConflict:"zoom_email"});Qe&&console.error("Failed to save alias:",Qe)}const Ze=N==null?void 0:N.id;if(Ze){const{data:Qe}=await H.from("user_roles").select("id").eq("user_id",rt).eq("role","admin").single();if(!Qe){const{data:We}=await H.from("agent_points").select("id").eq("user_id",rt).eq("event_id",Ze).single();We||(await H.rpc("award_attendance_points",{p_user_id:rt,p_event_id:Ze,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await H.rpc("check_and_award_badges",{p_user_id:rt}))}}return{userId:rt,zoomEmail:He,shouldSaveAlias:ct}},onSuccess:Me=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let rt="Attendee linked and points awarded!";Me.shouldSaveAlias&&Me.zoomEmail&&(rt+=` Email "${Me.zoomEmail}" will be auto-matched in the future.`),me.success(rt),L(!1),O(null),U(null),Q("")},onError:Me=>{me.error("Failed to link attendee: "+Me.message)}}),Ie=Me=>{O(Me),U(null),V(!0),Q(""),L(!0)},Ce=()=>{!I||!q||Ae.mutate({attendeeId:I.id,userId:q,zoomEmail:I.zoom_email,shouldSaveAlias:B})},xe=($e==null?void 0:$e.filter(Me=>{var He,ct;if(!Y)return!0;const rt=Y.toLowerCase();return((He=Me.name)==null?void 0:He.toLowerCase().includes(rt))||((ct=Me.email)==null?void 0:ct.toLowerCase().includes(rt))}))||[],we=async Me=>{const rt=Me.name.split(".").pop(),ct=`${`${crypto.randomUUID()}.${rt}`}`,{error:Ue}=await H.storage.from("event-images").upload(ct,Me);if(Ue)throw Ue;const{data:{publicUrl:Ze}}=H.storage.from("event-images").getPublicUrl(ct);return Ze},Le=Me=>{var He;const rt=(He=Me.target.files)==null?void 0:He[0];if(rt){if(rt.size>5*1024*1024){me.error("Image must be less than 5MB");return}u(rt),f(URL.createObjectURL(rt))}},tt=()=>{u(null),f(null),i({...l,image_url:""}),_.current&&(_.current.value="")},Te=Lt({mutationFn:async Me=>{b(!0);let rt=Me.image_url;c&&(rt=await we(c)||"");const He=new Date(Me.event_date),[ct,Ue]=Me.event_time.split(":");He.setHours(parseInt(ct),parseInt(Ue));const Ze=[new Date(He)];if(Me.is_recurring&&Me.recurrence_end_date){let it=new Date(He);for(;Me.recurrence_pattern==="weekly"?it=y4(it,1):Me.recurrence_pattern==="biweekly"?it=y4(it,2):it=Bm(it,1),!(it>Me.recurrence_end_date);)Ze.push(new Date(it))}const Qe=Ze.map(it=>({title:Me.title,description:Me.description||null,image_url:rt||null,video_url:Me.video_url||null,event_date:it.toISOString(),zoom_link:Me.zoom_link,zoom_meeting_id:Me.zoom_meeting_id||null,capacity:Me.capacity?parseInt(Me.capacity):null,is_published:Me.is_published})),{data:We,error:Je}=await H.from("events").insert(Qe).select();if(Je)throw Je;return We&&We.length>0&&oVt(Me.title,We[0].id),Ze.length},onSuccess:Me=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success(Me>1?`${Me} recurring events created successfully`:"Event created successfully"),n(!1),i(Cz),u(null),f(null),b(!1)},onError:Me=>{me.error("Failed to create event: "+Me.message),b(!1)}}),pt=Lt({mutationFn:async({id:Me,data:rt})=>{b(!0);let He=rt.image_url;c&&(He=await we(c)||"");const ct=new Date(rt.event_date),[Ue,Ze]=rt.event_time.split(":");ct.setHours(parseInt(Ue),parseInt(Ze));const{error:Qe}=await H.from("events").update({title:rt.title,description:rt.description||null,image_url:He||null,video_url:rt.video_url||null,event_date:ct.toISOString(),zoom_link:rt.zoom_link,zoom_meeting_id:rt.zoom_meeting_id||null,capacity:rt.capacity?parseInt(rt.capacity):null,is_published:rt.is_published}).eq("id",Me);if(Qe)throw Qe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event updated successfully"),n(!1),o(null),i(Cz),u(null),f(null),b(!1)},onError:Me=>{me.error("Failed to update event: "+Me.message),b(!1)}}),fe=Lt({mutationFn:async Me=>{const{error:rt}=await H.from("events").delete().eq("id",Me);if(rt)throw rt},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event deleted successfully")},onError:Me=>{me.error("Failed to delete event: "+Me.message)}}),qe=Me=>{var He;const rt=new Date(Me.event_date);o(Me),i({title:Me.title,description:Me.description||"",image_url:Me.image_url||"",video_url:Me.video_url||"",event_date:rt,event_time:ms(rt,"HH:mm"),zoom_link:Me.zoom_link,zoom_meeting_id:Me.zoom_meeting_id||"",capacity:((He=Me.capacity)==null?void 0:He.toString())||"",is_published:Me.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Me.image_url||null),u(null),n(!0)},at=Me=>{if(Me.preventDefault(),!l.event_date){me.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){me.error("Please select an end date for recurring events");return}a?pt.mutate({id:a.id,data:l}):Te.mutate(l)},et=()=>{n(!1),o(null),i(Cz),u(null),f(null)};return e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/dashboard"),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Event Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage upcoming events"})]})]}),e.jsxs(Ee,{className:"mb-6",children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"All Events"}),e.jsxs(fs,{open:r,onOpenChange:Me=>!Me&&et(),children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:at,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:l.title,onChange:Me=>i({...l,title:Me.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(py,{content:l.description,onChange:Me=>i({...l,description:Me}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Event Image"}),e.jsx("input",{type:"file",ref:_,accept:"image/*",onChange:Le,className:"hidden"}),p?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:p,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:tt,children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs(K,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var Me;return(Me=_.current)==null?void 0:Me.click()},children:[e.jsx(li,{className:"h-6 w-6"}),e.jsx("span",{className:"text-sm",children:"Click to upload image"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Date *"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),l.event_date?ms(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:l.event_date,onSelect:Me=>i({...l,event_date:Me}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"time",children:"Time *"}),e.jsx(ze,{id:"time",type:"time",value:l.event_time,onChange:Me=>i({...l,event_time:Me.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(ze,{id:"zoom_link",value:l.zoom_link,onChange:Me=>i({...l,zoom_link:Me.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(ze,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Me=>i({...l,zoom_meeting_id:Me.target.value}),placeholder:"e.g., 1234567890 (find in Zoom dashboard)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional: Enter the numeric meeting ID for automatic Zoom registration"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(ze,{id:"video_url",value:l.video_url,onChange:Me=>i({...l,video_url:Me.target.value}),placeholder:"YouTube, Vimeo, or Bunny.net embed URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a preview/promo video for this event"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(ze,{id:"capacity",type:"number",value:l.capacity,onChange:Me=>i({...l,capacity:Me.target.value}),placeholder:"Leave empty for unlimited",min:"1"})]}),!a&&e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(qr,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Me=>i({...l,is_recurring:Me})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Frequency"}),e.jsxs(Ks,{value:l.recurrence_pattern,onValueChange:Me=>i({...l,recurrence_pattern:Me}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"weekly",children:"Weekly"}),e.jsx(Mt,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(Mt,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Repeat Until"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?ms(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:l.recurrence_end_date,onSelect:Me=>i({...l,recurrence_end_date:Me}),disabled:Me=>Me<(l.event_date||new Date),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),l.event_date&&l.recurrence_end_date&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create ",(()=>{let Me=1,rt=new Date(l.event_date);for(;rt=l.recurrence_pattern==="weekly"?y4(rt,1):l.recurrence_pattern==="biweekly"?y4(rt,2):Bm(rt,1),!(rt>l.recurrence_end_date);)Me++;return Me})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{htmlFor:"is_published",children:"Published"}),e.jsx(qr,{id:"is_published",checked:l.is_published,onCheckedChange:Me=>i({...l,is_published:Me})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:et,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:Te.isPending||pt.isPending||g,children:g?"Uploading...":a?"Update Event":l.is_recurring&&l.event_date&&l.recurrence_end_date?"Create Recurring Events":"Create Event"})]})]})]})]})]}),e.jsx(Oe,{children:X?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(ee==null?void 0:ee.length)===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No events yet. Create your first event!"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Date & Time"}),e.jsx(St,{children:"Registrations"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:ee==null?void 0:ee.map(Me=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:Me.title}),e.jsx(dt,{children:ms(new Date(Me.event_date),"PPP p")}),e.jsx(dt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>ye(Me),children:[e.jsx(pr,{className:"h-4 w-4"}),(ie==null?void 0:ie[Me.id])||0,Me.capacity&&` / ${Me.capacity}`]})}),e.jsx(dt,{children:e.jsx("span",{className:It("px-2 py-1 rounded-full text-xs font-medium",Me.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:Me.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(Me.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(tn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>qe(Me),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&fe.mutate(Me.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Me.id))})]})})]}),e.jsx(fs,{open:j,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),N==null?void 0:N.title]}),e.jsx(Gr,{children:"View registrations and attendees for this event"})]}),e.jsxs("div",{className:"flex items-center justify-end mb-4 gap-2 flex-wrap",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>_e.mutate({eventId:N.id,testMode:!0}),disabled:_e.isPending,children:[e.jsx(cr,{className:It("h-4 w-4 mr-2",_e.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>_e.mutate({eventId:N.id}),disabled:_e.isPending||!(re!=null&&re.length),children:[e.jsx(cr,{className:It("h-4 w-4 mr-2",_e.isPending&&"animate-spin")}),_e.isPending?"Sending...":"Send Reminder to All"]}),(N==null?void 0:N.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ue.mutate(N.id),disabled:ue.isPending,children:[e.jsx(Go,{className:It("h-4 w-4 mr-2",ue.isPending&&"animate-spin")}),ue.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>pe.mutate(N.id),disabled:pe.isPending,children:[e.jsx(xo,{className:It("h-4 w-4 mr-2",pe.isPending&&"animate-spin")}),pe.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(ba,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ns,{value:"registrations",className:"gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Registrations (",(re==null?void 0:re.length)||0,")"]}),e.jsxs(ns,{value:"attendees",className:"gap-2",children:[e.jsx(sa,{className:"h-4 w-4"}),"Attendees (",(ce==null?void 0:ce.length)||0,")"]})]}),e.jsx(bs,{value:"registrations",className:"mt-4",children:oe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(re==null?void 0:re.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(N==null?void 0:N.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Registered"}),e.jsx(St,{children:"Status"})]})}),e.jsx(zn,{children:re==null?void 0:re.map(Me=>{var Ue,Ze;const rt=((Ue=Me.profiles)==null?void 0:Ue.name)||Me.zoom_name||"Unknown",He=((Ze=Me.profiles)==null?void 0:Ze.email)||Me.zoom_email||null,ct=!Me.user_id;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[rt,ct&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(dt,{children:He?e.jsxs("a",{href:`mailto:${He}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(cr,{className:"h-3 w-3"}),He]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{className:"text-muted-foreground text-sm",children:ms(new Date(Me.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:Me.zoom_join_url?e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:"Registered"}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Me.id)})})]})}),e.jsx(bs,{value:"attendees",className:"mt-4",children:ge?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(ce==null?void 0:ce.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No attendees recorded yet."}),(N==null?void 0:N.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Attendees & Award Points" after the event ends to import actual participants from Zoom.'})]}):e.jsxs(e.Fragment,{children:[(ce==null?void 0:ce.filter(Me=>!Me.user_id).length)>0&&e.jsxs("div",{className:"mb-6 p-4 border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(kl,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),e.jsxs("h4",{className:"font-medium text-amber-800 dark:text-amber-200",children:["Unmatched Attendees (",ce==null?void 0:ce.filter(Me=>!Me.user_id).length,")"]})]}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 mb-3",children:"These attendees couldn't be matched to a profile. Link them to award points."}),e.jsx("div",{className:"space-y-2",children:ce==null?void 0:ce.filter(Me=>!Me.user_id).map(Me=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-background rounded border",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-sm",children:Me.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Me.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ie(Me),className:"gap-1",children:[e.jsx(dl,{className:"h-3 w-3"}),"Link to Profile"]})]},Me.id))})]}),e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Points"})]})}),e.jsx(zn,{children:ce==null?void 0:ce.filter(Me=>Me.user_id).map(Me=>{var ct,Ue;const rt=((ct=Me.profiles)==null?void 0:ct.name)||Me.zoom_name||"Unknown",He=((Ue=Me.profiles)==null?void 0:Ue.email)||Me.zoom_email||null;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[rt,Me.manually_added&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:"Manual"})]})}),e.jsx(dt,{children:He?e.jsxs("a",{href:`mailto:${He}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(cr,{className:"h-3 w-3"}),He]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{children:Me.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(un,{className:"h-3 w-3"}),Me.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:Me.points_awarded?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:[e.jsx(xo,{className:"h-3 w-3"}),"+10 pts"]}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Me.id)})})]})]})})]})]})}),e.jsx(fs,{open:M,onOpenChange:L,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(dl,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),e.jsx(Gr,{children:"Link this Zoom attendee to an existing member profile to award them points."})]}),I&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium",children:I.zoom_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.zoom_email||"No email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:Y,onChange:Me=>Q(Me.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:xe.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No profiles found"}):e.jsx("div",{className:"divide-y",children:xe.slice(0,20).map(Me=>e.jsxs("button",{type:"button",onClick:()=>U(Me.id),className:It("w-full p-3 text-left hover:bg-muted/50 transition-colors",q===Me.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Me.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Me.email})]},Me.id))})}),I.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Oo,{id:"save-alias",checked:B,onCheckedChange:Me=>V(Me)}),e.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsx(K,{onClick:Ce,disabled:!q||Ae.isPending,children:Ae.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function uVt({selectedKitIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l=[]}=mt({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:f,error:g}=await H.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(g)throw g;return f}}),i=l.filter(f=>t.includes(f.id)),c=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(g=>g!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"h-4 w-4"}),"Linked Toolkits"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(st,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Rr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs($o,{open:a,onOpenChange:o,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(Ml,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(Ro,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(cn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search toolkits...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:c.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No toolkits found":"All toolkits selected"}):c.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.featured_image_url?e.jsx("img",{src:f.featured_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(Ml,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:f.name})]},f.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link toolkits that agents can download alongside this template."})]})}const hVt=()=>{const{user:t}=Ds(),{toast:s}=Ua(),r=Qt(),[n,a]=Cc(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),[f,g]=k.useState(null),[b,_]=k.useState(0),[j,w]=k.useState(!1),[N,S]=k.useState(null),[M,L]=k.useState(""),[I,O]=k.useState([]),[q,U]=k.useState(""),[B,V]=k.useState(""),[Y,Q]=k.useState(!1),[ee,X]=k.useState(!1),{data:ie=[]}=mt({queryKey:["template-categories"],queryFn:async()=>{const{data:qe,error:at}=await H.from("template_categories").select("*").order("name");if(at)throw at;return qe}}),{data:re=[]}=mt({queryKey:["template-types"],queryFn:async()=>{const{data:qe,error:at}=await H.from("template_types").select("*").order("name");if(at)throw at;return qe}}),{data:oe=[],isLoading:ce}=mt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:qe,error:at}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(at)throw at;const{data:et,error:Me}=await H.from("template_links").select("*").order("sort_order");if(Me)throw Me;const{data:rt,error:He}=await H.from("template_guides").select("*").order("sort_order");if(He)throw He;return qe.map(Ue=>({...Ue,links:(et==null?void 0:et.filter(Ze=>Ze.template_id===Ue.id))||[],guides:(rt==null?void 0:rt.filter(Ze=>Ze.template_id===Ue.id))||[]}))}});k.useEffect(()=>{const qe=n.get("edit");if(qe&&oe.length>0){const at=oe.find(et=>et.id===qe);at&&($e(at),a({},{replace:!0}))}},[oe,n]);const ge=Lt({mutationFn:async qe=>{const{data:at,error:et}=await H.from("template_categories").insert({name:qe}).select().single();if(et)throw et;return at},onSuccess:qe=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:qe.id}),U(""),Q(!1),s({title:"Category added"})},onError:qe=>{s({title:"Error adding category",description:qe.message,variant:"destructive"})}}),ye=Lt({mutationFn:async qe=>{const{data:at,error:et}=await H.from("template_types").insert({name:qe}).select().single();if(et)throw et;return at},onSuccess:qe=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:qe.id}),V(""),X(!1),s({title:"Type added"})},onError:qe=>{s({title:"Error adding type",description:qe.message,variant:"destructive"})}}),ue=Lt({mutationFn:async qe=>{var He;let at=qe.existingImageUrl;if(qe.image){const ct=qe.image.name.split(".").pop(),Ue=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ct}`,{error:Ze}=await H.storage.from("template-previews").upload(Ue,qe.image);if(Ze)throw Ze;const{data:Qe}=H.storage.from("template-previews").getPublicUrl(Ue);at=Qe.publicUrl}const et={name:qe.template.name,description:qe.template.description||null,category_id:qe.template.category_id||null,type_id:qe.template.type_id||null,preview_image_url:at,video_url:qe.videoUrl||null,publish_date:qe.template.publish_date?new Date(qe.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Me=qe.templateId;if(Me){const{error:ct}=await H.from("canva_templates").update(et).eq("id",Me);if(ct)throw ct;const{error:Ue}=await H.from("template_links").delete().eq("template_id",Me);if(Ue)throw Ue;const Ze=((He=qe.existingGuides)==null?void 0:He.map(Je=>Je.id).filter(Boolean))||[],Qe=qe.template.guides.map(Je=>Je.id).filter(Boolean),We=Ze.filter(Je=>!Qe.includes(Je));We.length>0&&await H.from("template_guides").delete().in("id",We)}else{const{data:ct,error:Ue}=await H.from("canva_templates").insert(et).select().single();if(Ue)throw Ue;Me=ct.id,aVt(qe.template.name,ct.id)}const rt=qe.template.links.filter(ct=>ct.title.trim()&&ct.canva_share_link.trim());if(rt.length>0){const ct=rt.map((Ze,Qe)=>({template_id:Me,title:Ze.title.trim(),canva_share_link:Ze.canva_share_link.trim(),sort_order:Qe})),{error:Ue}=await H.from("template_links").insert(ct);if(Ue)throw Ue}for(let ct=0;ct0)){const{error:ct}=await H.from("resource_kit_templates").insert(qe.linkedKitIds.map(Ue=>({template_id:Me,kit_id:Ue})));if(ct)throw ct}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),_e(),l(!1),s({title:i?"Template updated":"Template created"})},onError:qe=>{s({title:"Error saving template",description:qe.message,variant:"destructive"})}}),pe=Lt({mutationFn:async qe=>{const{error:at}=await H.from("canva_templates").delete().eq("id",qe);if(at)throw at},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:qe=>{s({title:"Error deleting template",description:qe.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:""}),S(null),L(""),c(null),Q(!1),X(!1),U(""),V(""),g(null),_(0),w(!1),O([])},$e=async qe=>{var et;c(qe),p({name:qe.name,description:qe.description||"",category_id:qe.category_id||"",type_id:qe.type_id||"",publish_date:qe.publish_date?new Date(qe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:qe.links&&qe.links.length>0?qe.links.map(Me=>({id:Me.id,title:Me.title,canva_share_link:Me.canva_share_link,sort_order:Me.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((et=qe.guides)==null?void 0:et.map(Me=>({id:Me.id,name:Me.name,file_url:Me.file_url,file_type:Me.file_type,file_size:Me.file_size,sort_order:Me.sort_order})))||[],video_url:qe.video_url||""}),L(qe.preview_image_url||""),g(null);const{data:at}=await H.from("resource_kit_templates").select("kit_id").eq("template_id",qe.id);O((at||[]).map(Me=>Me.kit_id)),l(!0)},Ae=qe=>{var et;const at=(et=qe.target.files)==null?void 0:et[0];at&&(S(at),L(URL.createObjectURL(at)))},Ie=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Ce=qe=>{if(u.links.length<=1)return;const at=u.links.filter((et,Me)=>Me!==qe);p({...u,links:at})},xe=(qe,at,et)=>{const Me=[...u.links];Me[qe]={...Me[qe],[at]:et},p({...u,links:Me})},we=qe=>{const at=qe.target.files;if(!at)return;const et=Array.from(at).map((Me,rt)=>({name:Me.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Me.type,file_size:Me.size,sort_order:u.guides.length+rt,file:Me}));p({...u,guides:[...u.guides,...et]}),qe.target.value=""},Le=qe=>{const at=u.guides.filter((et,Me)=>Me!==qe);p({...u,guides:at})},tt=(qe,at)=>{const et=[...u.guides];et[qe]={...et[qe],name:at},p({...u,guides:et})},Te=async()=>{if(!f)return null;w(!0),_(0);try{const{data:qe,error:at}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(at)throw new Error(at.message);const{videoId:et,libraryId:Me}=qe,{data:rt,error:He}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:et}});if(He)throw new Error(He.message);const ct=new XMLHttpRequest;return await new Promise((Ze,Qe)=>{ct.upload.addEventListener("progress",We=>{if(We.lengthComputable){const Je=Math.round(We.loaded/We.total*100);_(Je)}}),ct.addEventListener("load",()=>{ct.status>=200&&ct.status<300?Ze():Qe(new Error(`Upload failed with status ${ct.status}`))}),ct.addEventListener("error",()=>Qe(new Error("Upload failed"))),ct.open("PUT",rt.uploadUrl),ct.setRequestHeader("AccessKey",rt.apiKey),ct.send(f)}),`https://player.mediadelivery.net/embed/${Me}/${et}`}catch(qe){return console.error("Bunny upload error:",qe),s({title:"Video upload failed",description:qe instanceof Error?qe.message:"Unknown error",variant:"destructive"}),null}finally{w(!1)}},pt=qe=>{var et;const at=(et=qe.target.files)==null?void 0:et[0];at&&g(at),qe.target.value=""},fe=async qe=>{if(qe.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Me=>Me.title.trim()&&Me.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let et=u.video_url;if(f){const Me=await Te();if(!Me)return;et=Me}ue.mutate({template:u,image:N,existingImageUrl:(i==null?void 0:i.preview_image_url)||null,templateId:i==null?void 0:i.id,existingGuides:i==null?void 0:i.guides,videoUrl:et,linkedKitIds:I})};return e.jsx(Ms,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Manage Templates",description:"Create and manage Canva templates"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:oe.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ie.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:re.length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:qe=>{l(qe),qe||_e()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:fe,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:u.name,onChange:qe=>p({...u,name:qe.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(py,{content:u.description,onChange:qe=>p({...u,description:qe}),placeholder:"Brief description of the template",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Canva Links *"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ie,className:"gap-1",children:[e.jsx($s,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((qe,at)=>e.jsxs("div",{className:"flex gap-2 items-start p-3 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{value:qe.title,onChange:et=>xe(at,"title",et.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(ze,{value:qe.canva_share_link,onChange:et=>xe(at,"canva_share_link",et.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Ce(at),children:e.jsx(Rr,{className:"h-4 w-4"})})]},at))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Category"}),Y?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:q,onChange:qe=>U(qe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>q.trim()&&ge.mutate(q.trim()),disabled:ge.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q(!1),U("")},children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:u.category_id,onValueChange:qe=>p({...u,category_id:qe}),children:[e.jsx(Hs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:ie.map(qe=>e.jsx(Mt,{value:qe.id,children:qe.name},qe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Q(!0),children:e.jsx($s,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Template Type"}),ee?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:B,onChange:qe=>V(qe.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>B.trim()&&ye.mutate(B.trim()),disabled:ye.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{X(!1),V("")},children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:u.type_id,onValueChange:qe=>p({...u,type_id:qe}),children:[e.jsx(Hs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select type"})}),e.jsx(Ws,{children:re.map(qe=>e.jsx(Mt,{value:qe.id,children:qe.name},qe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>X(!0),children:e.jsx($s,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:u.publish_date,onChange:qe=>p({...u,publish_date:qe.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates are sorted by publish date (newest first) on the member page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[M?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:M,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx(K,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{S(null),L("")},children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsx("div",{className:"w-32 h-24 rounded-lg border-2 border-dashed border-muted-foreground/25 flex items-center justify-center",children:e.jsx(gl,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:Ae,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Upload a preview image for this template"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Video (Optional)"}),u.video_url&&!f?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(An,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):j?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",b,"%"]})]}),e.jsx(Bi,{value:b,className:"h-2"})]}):f?e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(An,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:f.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(f.size/1024/1024).toFixed(1)," MB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>g(null),children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(ze,{type:"file",accept:"video/*",onChange:pt,className:"hidden"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 border-2 border-dashed rounded-lg hover:border-primary/50 transition-colors",children:[e.jsx(An,{className:"h-8 w-8 text-muted-foreground/50"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Click to upload a video"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload a video to embed on the template page (Bunny.net)"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(ze,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:we,className:"hidden"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(li,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((qe,at)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(Sn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(ze,{value:qe.name,onChange:et=>tt(at,et.target.value),placeholder:"Guide name",className:"flex-1"}),qe.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(qe.file_size/1024).toFixed(0)," KB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>Le(at),children:e.jsx(Rr,{className:"h-4 w-4"})})]},qe.id||at))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No guide files added. Upload PDFs to help agents understand how to use this template."})]}),e.jsx(uVt,{selectedKitIds:I,onChange:O}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),_e()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:ue.isPending,children:ue.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:ce?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):oe.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Preview"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Links"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:oe.map(qe=>{var at,et,Me,rt,He;return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:qe.preview_image_url?e.jsx("img",{src:qe.preview_image_url,alt:qe.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(gl,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(dt,{className:"font-medium",children:qe.name}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(st,{variant:"secondary",children:[((at=qe.links)==null?void 0:at.length)||0," link",(((et=qe.links)==null?void 0:et.length)||0)!==1?"s":""]}),(((Me=qe.guides)==null?void 0:Me.length)||0)>0&&e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),(rt=qe.guides)==null?void 0:rt.length," guide",(((He=qe.guides)==null?void 0:He.length)||0)!==1?"s":""]})]})}),e.jsx(dt,{children:qe.category?e.jsx(st,{variant:"secondary",children:qe.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{children:qe.type?e.jsx(st,{variant:"outline",children:qe.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{className:"text-muted-foreground",children:new Date(qe.publish_date).toLocaleDateString()}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"icon",variant:"ghost",onClick:()=>$e(qe),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&pe.mutate(qe.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},qe.id)})})]})})})]})})};function dtt({selectedTemplateIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l=[]}=mt({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:f,error:g}=await H.from("canva_templates").select("id, name, preview_image_url").order("name");if(g)throw g;return f}}),i=l.filter(f=>t.includes(f.id)),c=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(g=>g!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(aS,{className:"h-4 w-4"}),"Linked Templates"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(st,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Rr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs($o,{open:a,onOpenChange:o,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(aS,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(Ro,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(cn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search templates...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:c.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No templates found":"All templates selected"}):c.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.preview_image_url?e.jsx("img",{src:f.preview_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(aS,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:f.name})]},f.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link templates that agents can use alongside this content."})]})}const mVt=[{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"}],pVt=()=>{const{user:t}=Ds(),[s,r]=Cc(),{toast:n}=Ua(),a=Qt(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,g]=k.useState(null),[b,_]=k.useState(""),[j,w]=k.useState([]),[N,S]=k.useState([]),[M,L]=k.useState([]),[I,O]=k.useState([]),[q,U]=k.useState(""),[B,V]=k.useState(!1),[Y,Q]=k.useState(null),[ee,X]=k.useState(0),[ie,re]=k.useState(!1),[oe,ce]=k.useState(null),{data:ge=[]}=mt({queryKey:["academy-categories"],queryFn:async()=>{const{data:fe,error:qe}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(qe)throw qe;return fe}}),{data:ye=[],isLoading:ue}=mt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:fe,error:qe}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(qe)throw qe;const{data:at,error:et}=await H.from("academy_resources").select("*").order("sort_order");if(et)throw et;return fe.map(rt=>({...rt,resources:(at==null?void 0:at.filter(He=>He.video_id===rt.id))||[]}))}});k.useEffect(()=>{const fe=s.get("edit");if(fe&&ye.length>0){const qe=ye.find(at=>at.id===fe);qe&&(Ce(qe),r({},{replace:!0}))}},[ye,s]);const pe=Lt({mutationFn:async fe=>{const{data:qe,error:at}=await H.from("academy_categories").insert({name:fe,sort_order:ge.length}).select().single();if(at)throw at;return qe},onSuccess:fe=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:fe.id}),U(""),V(!1),n({title:"Category added"})},onError:fe=>{n({title:"Error adding category",description:fe.message,variant:"destructive"})}}),_e=Lt({mutationFn:async fe=>{let qe=fe.existingThumbnailUrl;if(fe.thumbnail){const Me=fe.thumbnail.name.split(".").pop(),rt=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Me}`,{error:He}=await H.storage.from("academy-resources").upload(rt,fe.thumbnail);if(He)throw He;const{data:ct}=H.storage.from("academy-resources").getPublicUrl(rt);qe=ct.publicUrl}const at={title:fe.video.title,description:fe.video.description||null,video_url:fe.video.video_url,video_type:fe.video.video_type,duration:fe.video.duration||null,thumbnail_url:qe,category_id:fe.video.category_id||null,publish_date:fe.video.publish_date?new Date(fe.video.publish_date).toISOString():new Date().toISOString(),is_published:fe.video.is_published,created_by:t==null?void 0:t.id};let et=fe.videoId;if(et){const{error:Me}=await H.from("academy_videos").update(at).eq("id",et);if(Me)throw Me}else{const{data:Me,error:rt}=await H.from("academy_videos").insert(at).select().single();if(rt)throw rt;et=Me.id,iVt(fe.video.title,Me.id)}if(fe.resourcesToDelete.length>0){const{error:Me}=await H.from("academy_resources").delete().in("id",fe.resourcesToDelete);if(Me)throw Me}for(let Me=0;Me0){const{error:Me}=await H.from("academy_video_templates").insert(I.map(rt=>({video_id:et,template_id:rt})));if(Me)throw Me}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Ie(),l(!1),n({title:i?"Video updated":"Video created"})},onError:fe=>{n({title:"Error saving video",description:fe.message,variant:"destructive"})}}),$e=Lt({mutationFn:async fe=>{const{error:qe}=await H.from("academy_videos").delete().eq("id",fe);if(qe)throw qe},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:fe=>{n({title:"Error deleting video",description:fe.message,variant:"destructive"})}}),Ae=Lt({mutationFn:async({id:fe,is_published:qe})=>{const{error:at}=await H.from("academy_videos").update({is_published:qe}).eq("id",fe);if(at)throw at},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:fe=>{n({title:"Error updating video",description:fe.message,variant:"destructive"})}}),Ie=()=>{p({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),g(null),_(""),w([]),S([]),L([]),c(null),O([]),U(""),Q(null),X(0),re(!1),ce(null)},Ce=async fe=>{c(fe),p({title:fe.title,description:fe.description||"",video_url:fe.video_url,video_type:fe.video_type,duration:fe.duration||"",category_id:fe.category_id||"",publish_date:fe.publish_date?new Date(fe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:fe.is_published}),_(fe.thumbnail_url||""),S(fe.resources||[]),w([]),L([]);const{data:qe}=await H.from("academy_video_templates").select("template_id").eq("video_id",fe.id);O((qe||[]).map(at=>at.template_id)),l(!0)},xe=fe=>{var at;const qe=(at=fe.target.files)==null?void 0:at[0];qe&&(g(qe),_(URL.createObjectURL(qe)))},we=fe=>{const qe=fe.target.files;if(qe){const at=Array.from(qe).map(et=>({file:et,title:et.name.replace(/\.[^/.]+$/,"")}));w([...j,...at])}fe.target.value=""},Le=fe=>{w(j.filter((qe,at)=>at!==fe))},tt=fe=>{L([...M,fe]),S(N.filter(qe=>qe.id!==fe))},Te=async()=>{if(!Y)return null;re(!0),X(0);try{const{data:fe,error:qe}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||Y.name}});if(qe)throw new Error(qe.message);const{videoId:at,libraryId:et}=fe;ce(at);const{data:Me,error:rt}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:at}});if(rt)throw new Error(rt.message);const He=new XMLHttpRequest;return await new Promise((Ue,Ze)=>{He.upload.addEventListener("progress",Qe=>{if(Qe.lengthComputable){const We=Math.round(Qe.loaded/Qe.total*100);X(We)}}),He.addEventListener("load",()=>{He.status>=200&&He.status<300?Ue():Ze(new Error(`Upload failed with status ${He.status}`))}),He.addEventListener("error",()=>Ze(new Error("Upload failed"))),He.open("PUT",Me.uploadUrl),He.setRequestHeader("AccessKey",Me.apiKey),He.send(Y)}),`https://player.mediadelivery.net/embed/${et}/${at}`}catch(fe){return console.error("Bunny upload error:",fe),n({title:"Video upload failed",description:fe instanceof Error?fe.message:"Unknown error",variant:"destructive"}),null}finally{re(!1)}},pt=async fe=>{if(fe.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let qe=u.video_url;if(u.video_type==="bunny_stream"&&Y&&!i){const at=await Te();if(!at)return;qe=at}else if(!u.video_url.trim()&&u.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(u.video_type==="bunny_stream"&&!Y&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}_e.mutate({video:{...u,video_url:qe},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:j,resourcesToDelete:M})};return e.jsx(Ms,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Manage Academy",description:"Create and manage training videos and resources"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ye.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ye.filter(fe=>fe.is_published).length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:fe=>{l(fe),fe||Ie()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:pt,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:u.title,onChange:fe=>p({...u,title:fe.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(py,{content:u.description,onChange:fe=>p({...u,description:fe}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Video Type"}),e.jsxs(Ks,{value:u.video_type,onValueChange:fe=>{p({...u,video_type:fe,video_url:""}),Q(null)},disabled:ie,children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:mVt.map(fe=>e.jsx(Mt,{value:fe.value,children:fe.label},fe.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(be,{children:["Upload Video File ",!i&&"*"]}),i&&u.video_url&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Current video: ",e.jsx("a",{href:u.video_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"View"})]}),!i&&e.jsxs(e.Fragment,{children:[e.jsx(ze,{type:"file",accept:"video/*",onChange:fe=>{var at;const qe=(at=fe.target.files)==null?void 0:at[0];qe&&Q(qe)},disabled:ie}),Y&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(An,{className:"h-4 w-4"}),Y.name," (",(Y.size/(1024*1024)).toFixed(1)," MB)"]}),ie&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(Bi,{value:ee,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[ee,"%"]})]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(ze,{id:"video_url",value:u.video_url,onChange:fe=>p({...u,video_url:fe.target.value}),placeholder:"https://...",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"duration",children:"Duration"}),e.jsx(ze,{id:"duration",value:u.duration,onChange:fe=>p({...u,duration:fe.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:u.publish_date,onChange:fe=>p({...u,publish_date:fe.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Category"}),B?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:q,onChange:fe=>U(fe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>q.trim()&&pe.mutate(q.trim()),disabled:pe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{V(!1),U("")},children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:u.category_id,onValueChange:fe=>p({...u,category_id:fe}),children:[e.jsx(Hs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:ge.map(fe=>e.jsx(Mt,{value:fe.id,children:fe.name},fe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>V(!0),children:e.jsx($s,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Thumbnail Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[b&&e.jsx("img",{src:b,alt:"Thumbnail preview",className:"w-32 h-20 object-cover rounded-md border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:xe,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Recommended: 16:9 aspect ratio"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Resource Files"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{className:"cursor-pointer gap-1",children:[e.jsx(li,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:we,className:"hidden"})]})})]}),(N.length>0||j.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[N.map(fe=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:fe.title}),e.jsx(st,{variant:"outline",className:"text-xs",children:fe.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>tt(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Rr,{className:"h-4 w-4"})})]},fe.id)),j.map((fe,qe)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:fe.title,onChange:at=>{const et=[...j];et[qe].title=at.target.value,w(et)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(st,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Le(qe),className:"text-destructive hover:text-destructive",children:e.jsx(Rr,{className:"h-4 w-4"})})]},qe))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(dtt,{selectedTemplateIds:I,onChange:O}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_published",checked:u.is_published,onCheckedChange:fe=>p({...u,is_published:fe})}),e.jsx(be,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(qn,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ie,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:_e.isPending||ie,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):_e.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:ue?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):ye.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(An,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No videos yet"}),e.jsx("p",{className:"text-sm",children:"Add your first academy video"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Resources"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(zn,{children:ye.map(fe=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[fe.thumbnail_url?e.jsx("img",{src:fe.thumbnail_url,alt:"",className:"w-16 h-10 object-cover rounded"}):e.jsx("div",{className:"w-16 h-10 bg-muted rounded flex items-center justify-center",children:e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:fe.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:fe.video_type.replace("_"," ")})]})]})}),e.jsx(dt,{children:fe.category?e.jsx(st,{variant:"outline",children:fe.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:fe.duration||"-"}),e.jsx(dt,{children:fe.resources&&fe.resources.length>0?e.jsxs(st,{variant:"secondary",children:[fe.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:new Date(fe.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(qr,{checked:fe.is_published,onCheckedChange:qe=>Ae.mutate({id:fe.id,is_published:qe})})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ce(fe),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>$e.mutate(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},fe.id))})]})})})]})})};function fVt(){var _e,$e,Ae;const t=Qt(),[s,r]=Cc(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=k.useState(null),[f,g]=k.useState(""),[b,_]=k.useState([]),[j,w]=k.useState([]),[N,S]=k.useState([]),[M,L]=k.useState(null),{data:I,isLoading:O}=mt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Ie,error:Ce}=await H.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Ce)throw Ce;return Ie}}),{data:q}=mt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Ie,error:Ce}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Ce)throw Ce;return Ie}}),{data:U}=mt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Ie,error:Ce}=await H.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Ce)throw Ce;return Ie}});k.useEffect(()=>{const Ie=s.get("edit");if(Ie&&I&&I.length>0&&q&&U){const Ce=I.find(xe=>xe.id===Ie);Ce&&(V(Ce),r({},{replace:!0}))}},[I,q,U,s]);const B=()=>{c({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),g(""),_([]),w([]),S([]),l(null)},V=async Ie=>{l(Ie),c({name:Ie.name,description:Ie.description||"",publish_date:Ie.publish_date.split("T")[0],is_published:Ie.is_published}),g(Ie.featured_image_url||"");const Ce=(q==null?void 0:q.filter(Le=>Le.kit_id===Ie.id))||[];_(Ce.map(Le=>({id:Le.id,name:Le.name,file_url:Le.file_url,file_type:Le.file_type,file_size:Le.file_size,sort_order:Le.sort_order})));const xe=(U==null?void 0:U.filter(Le=>Le.kit_id===Ie.id))||[];w(xe.map(Le=>({id:Le.id,title:Le.title,canva_share_link:Le.canva_share_link,sort_order:Le.sort_order})));const{data:we}=await H.from("resource_kit_templates").select("template_id").eq("kit_id",Ie.id);S((we||[]).map(Le=>Le.template_id)),a(!0)},Y=Ie=>{var xe;const Ce=(xe=Ie.target.files)==null?void 0:xe[0];Ce&&(p(Ce),g(URL.createObjectURL(Ce)))},Q=()=>{_([...b,{name:"",file_url:"",sort_order:b.length}])},ee=Ie=>{_(b.filter((Ce,xe)=>xe!==Ie))},X=(Ie,Ce,xe)=>{const we=[...b];we[Ie]={...we[Ie],[Ce]:xe},_(we)},ie=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},re=Ie=>{w(j.filter((Ce,xe)=>xe!==Ie))},oe=(Ie,Ce,xe)=>{const we=[...j];we[Ie]={...we[Ie],[Ce]:xe},w(we)},ce=(Ie,Ce)=>{var we;const xe=(we=Ce.target.files)==null?void 0:we[0];if(xe){const Le=[...b],tt=xe.name.replace(/\.[^/.]+$/,"");Le[Ie]={...Le[Ie],file:xe,file_type:xe.type,file_size:xe.size,name:Le[Ie].name||tt},_(Le)}},ge=Lt({mutationFn:async()=>{let Ie=(o==null?void 0:o.featured_image_url)||null;if(u){const tt=u.name.split(".").pop(),Te=`${Date.now()}.${tt}`,{error:pt}=await H.storage.from("resource-kits").upload(`featured/${Te}`,u);if(pt)throw pt;const{data:fe}=H.storage.from("resource-kits").getPublicUrl(`featured/${Te}`);Ie=fe.publicUrl}const Ce={name:i.name,description:i.description||null,featured_image_url:Ie,publish_date:i.publish_date,is_published:i.is_published};let xe;const we=!o,Le=(o==null?void 0:o.is_published)||!1;if(o){const{error:tt}=await H.from("resource_kits").update(Ce).eq("id",o.id);if(tt)throw tt;xe=o.id;const Te=(q==null?void 0:q.filter(Me=>Me.kit_id===o.id).map(Me=>Me.id))||[],pt=b.filter(Me=>Me.id).map(Me=>Me.id),fe=Te.filter(Me=>!pt.includes(Me));fe.length>0&&await H.from("resource_kit_files").delete().in("id",fe);const qe=(U==null?void 0:U.filter(Me=>Me.kit_id===o.id).map(Me=>Me.id))||[],at=j.filter(Me=>Me.id).map(Me=>Me.id),et=qe.filter(Me=>!at.includes(Me));et.length>0&&await H.from("resource_kit_links").delete().in("id",et)}else{const{data:tt,error:Te}=await H.from("resource_kits").insert(Ce).select().single();if(Te)throw Te;xe=tt.id}for(let tt=0;tt0){const{error:tt}=await H.from("resource_kit_templates").insert(N.map(Te=>({kit_id:xe,template_id:Te})));if(tt)throw tt}return{kitId:xe,kitName:i.name,isNewKit:we,wasPublished:Le,isPublished:i.is_published}},onSuccess:Ie=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),me.success(o?"Resource kit updated":"Resource kit created"),Ie.isPublished&&(Ie.isNewKit||!Ie.wasPublished)&&lVt(Ie.kitName,Ie.kitId),a(!1),B()},onError:Ie=>{me.error("Failed to save resource kit: "+Ie.message)}}),ye=Lt({mutationFn:async Ie=>{const{error:Ce}=await H.from("resource_kits").delete().eq("id",Ie);if(Ce)throw Ce},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),me.success("Resource kit deleted")},onError:Ie=>{me.error("Failed to delete: "+Ie.message)}}),ue=Ie=>{if(Ie.preventDefault(),!i.name){me.error("Please enter a name");return}ge.mutate()},pe=Ie=>(q==null?void 0:q.filter(Ce=>Ce.kit_id===Ie).length)||0;return e.jsx(Ms,{title:"Toolbox Management",description:"Create and manage resource kits for agents",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(I==null?void 0:I.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(I==null?void 0:I.filter(Ie=>Ie.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{B(),a(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Files"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:O?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(I==null?void 0:I.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):I==null?void 0:I.map(Ie=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ie.featured_image_url?e.jsx("img",{src:Ie.featured_image_url,alt:Ie.name,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(Ml,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ie.name}),Ie.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ie.description})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),pe(Ie.id)]})}),e.jsx(dt,{children:ms(new Date(Ie.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ie.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Ie.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const Ce=(q==null?void 0:q.filter(we=>we.kit_id===Ie.id))||[],xe=(U==null?void 0:U.filter(we=>we.kit_id===Ie.id))||[];L({...Ie,files:Ce,links:xe})},children:e.jsx(Ln,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>V(Ie),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&ye.mutate(Ie.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ie.id))})]})})}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:ue,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Featured Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f?e.jsx("img",{src:f,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):e.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:e.jsx(Ml,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(ze,{type:"file",accept:"image/*",onChange:Y})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:i.name,onChange:Ie=>c({...i,name:Ie.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(py,{content:i.description,onChange:Ie=>c({...i,description:Ie}),placeholder:"Brief description of this resource kit",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:Ie=>c({...i,publish_date:Ie.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(qr,{checked:i.is_published,onCheckedChange:Ie=>c({...i,is_published:Ie})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:i.is_published?"Visible to agents":"Hidden from agents"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(be,{children:"Resource Files"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Q,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),b.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No files added yet. Click "Add File" to include resources.'}):e.jsx("div",{className:"space-y-3",children:b.map((Ie,Ce)=>e.jsxs("div",{className:"border rounded-md p-3 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("span",{className:"text-sm font-medium",children:["File ",Ce+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ee(Ce),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsx(ze,{placeholder:"File name (e.g., Getting Started Guide)",value:Ie.name,onChange:xe=>X(Ce,"name",xe.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"file",onChange:xe=>ce(Ce,xe),className:"flex-1"}),Ie.file_url&&!Ie.file&&e.jsx("a",{href:Ie.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Ie.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Ce))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(be,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ie,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),j.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No Canva links added yet. Click "Add Canva Link" to include templates.'}):e.jsx("div",{className:"space-y-3",children:j.map((Ie,Ce)=>e.jsxs("div",{className:"border rounded-md p-3 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Canva Link ",Ce+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>re(Ce),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsx(ze,{placeholder:"Link title (e.g., Social Media Post Template)",value:Ie.title,onChange:xe=>oe(Ce,"title",xe.target.value)}),e.jsx(ze,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Ie.canva_share_link,onChange:xe=>oe(Ce,"canva_share_link",xe.target.value)})]},Ce))})]}),e.jsx(dtt,{selectedTemplateIds:N,onChange:S}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:ge.isPending,children:ge.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!M,onOpenChange:()=>L(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(vs,{children:M==null?void 0:M.name})}),e.jsxs("div",{className:"space-y-4",children:[(M==null?void 0:M.featured_image_url)&&e.jsx("img",{src:M.featured_image_url,alt:M.name,className:"w-full h-48 object-cover rounded-lg"}),(M==null?void 0:M.description)&&e.jsx("p",{className:"text-muted-foreground",children:M.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((_e=M==null?void 0:M.files)==null?void 0:_e.length)||0,")"]}),(($e=M==null?void 0:M.files)==null?void 0:$e.length)===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No files in this kit"}):e.jsx("div",{className:"space-y-2",children:(Ae=M==null?void 0:M.files)==null?void 0:Ae.map(Ie=>e.jsxs("a",{href:Ie.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(Sn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ie.name})]},Ie.id))})]}),(M==null?void 0:M.links)&&M.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",M.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:M.links.map(Ie=>e.jsxs("a",{href:Ie.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(Bo,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ie.title})]},Ie.id))})]})]})]})})]})})}const xVt=()=>{const{user:t}=Ds(),{toast:s}=Ua(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=k.useState(null),[f,g]=k.useState(""),{data:b=[],isLoading:_}=mt({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:U,error:B}=await H.from("social_swag").select("*").order("publish_date",{ascending:!1});if(B)throw B;const{data:V,error:Y}=await H.from("social_swag_links").select("*").order("sort_order");if(Y)throw Y;return U.map(ee=>({...ee,links:(V==null?void 0:V.filter(X=>X.swag_id===ee.id))||[]}))}}),j=Lt({mutationFn:async U=>{let B=U.existingImageUrl;if(U.image){const ie=U.image.name.split(".").pop(),re=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ie}`,{error:oe}=await H.storage.from("template-previews").upload(re,U.image);if(oe)throw oe;const{data:ce}=H.storage.from("template-previews").getPublicUrl(re);B=ce.publicUrl}const V={title:U.item.title,description:U.item.description||null,preview_image_url:B,publish_date:U.item.publish_date?new Date(U.item.publish_date).toISOString():new Date().toISOString(),is_published:U.item.is_published,created_by:t==null?void 0:t.id};let Y=U.itemId;const Q=!Y,ee=(o==null?void 0:o.is_published)||!1;if(Y){const{error:ie}=await H.from("social_swag").update(V).eq("id",Y);if(ie)throw ie;await H.from("social_swag_links").delete().eq("swag_id",Y)}else{const{data:ie,error:re}=await H.from("social_swag").insert(V).select().single();if(re)throw re;Y=ie.id}const X=U.item.links.filter(ie=>ie.title.trim()&&ie.canva_share_link.trim());if(X.length>0){const ie=X.map((oe,ce)=>({swag_id:Y,title:oe.title.trim(),canva_share_link:oe.canva_share_link.trim(),sort_order:ce})),{error:re}=await H.from("social_swag_links").insert(ie);if(re)throw re}return{itemId:Y,itemTitle:U.item.title,isNewItem:Q,wasPublished:ee,isPublished:U.item.is_published}},onSuccess:U=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:o?"Item updated":"Item created"}),U.isPublished&&(U.isNewItem||!U.wasPublished)&&ibe(U.itemTitle,U.itemId),a(!1),N()},onError:U=>{s({title:"Error saving item",description:U.message,variant:"destructive"})}}),w=Lt({mutationFn:async U=>{const{error:B}=await H.from("social_swag").delete().eq("id",U);if(B)throw B},onSuccess:()=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:"Item deleted"})},onError:U=>{s({title:"Error deleting item",description:U.message,variant:"destructive"})}}),N=()=>{c({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),p(null),g(""),l(null)},S=U=>{l(U),c({title:U.title,description:U.description||"",publish_date:U.publish_date?new Date(U.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:U.is_published,links:U.links&&U.links.length>0?U.links.map(B=>({id:B.id,title:B.title,canva_share_link:B.canva_share_link,sort_order:B.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),g(U.preview_image_url||""),a(!0)},M=U=>{var V;const B=(V=U.target.files)==null?void 0:V[0];B&&(p(B),g(URL.createObjectURL(B)))},L=()=>{c({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},I=U=>{if(i.links.length<=1)return;const B=i.links.filter((V,Y)=>Y!==U);c({...i,links:B})},O=(U,B,V)=>{const Y=[...i.links];Y[U]={...Y[U],[B]:V},c({...i,links:Y})},q=U=>{if(U.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}j.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ms,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Manage Social Swag",description:"Create and manage social media content"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.filter(U=>U.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:U=>{a(U),U||N()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:o?"Edit Item":"Add New Item"})}),e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:i.title,onChange:U=>c({...i,title:U.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(py,{content:i.description,onChange:U=>c({...i,description:U}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:U=>c({...i,publish_date:U.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:U=>c({...i,is_published:U})}),e.jsx(be,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),g("")},children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(gl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(ze,{type:"file",accept:"image/*",onChange:M,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:L,children:[e.jsx($s,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((U,B)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",B+1]}),i.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>I(B),children:e.jsx(Rr,{className:"h-3 w-3"})})]}),e.jsx(ze,{placeholder:"Link title (e.g., Instagram Post)",value:U.title,onChange:V=>O(B,"title",V.target.value)}),e.jsx(ze,{placeholder:"Canva share link",value:U.canva_share_link,onChange:V=>O(B,"canva_share_link",V.target.value)})]})},B))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:j.isPending,children:j.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):b.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No items yet. Click "Add Item" to create your first one.'}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-16",children:"Preview"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Links"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:b.map(U=>{var B;return e.jsxs(Ss,{children:[e.jsx(dt,{children:U.preview_image_url?e.jsx("img",{src:U.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(gl,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:U.title}),e.jsxs(dt,{children:[((B=U.links)==null?void 0:B.length)||0," links"]}),e.jsx(dt,{children:new Date(U.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(st,{variant:U.is_published?"default":"secondary",children:U.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${U.id}`,"_blank"),children:e.jsx(Ln,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(U),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&w.mutate(U.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},U.id)})})]})})})]})})};function gVt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const Gue=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function dE(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function Fke(t){return"nodeType"in t}function Pp(t){var s,r;return t?dE(t)?t:Fke(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function zke(t){const{Document:s}=Pp(t);return t instanceof s}function eR(t){return dE(t)?!1:t instanceof Pp(t).HTMLElement}function utt(t){return t instanceof Pp(t).SVGElement}function uE(t){return t?dE(t)?t.document:Fke(t)?zke(t)?t:eR(t)||utt(t)?t.ownerDocument:document:document:document}const I0=Gue?k.useLayoutEffect:k.useEffect;function Bke(t){const s=k.useRef(t);return I0(()=>{s.current=t}),k.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=k.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function _D(t,s){s===void 0&&(s=[t]);const r=k.useRef(t);return I0(()=>{r.current!==t&&(r.current=t)},s),r}function tR(t,s){const r=k.useRef();return k.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function $le(t){const s=Bke(t),r=k.useRef(null),n=k.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function obe(t){const s=k.useRef();return k.useEffect(()=>{s.current=t},[t]),s.current}let Dge={};function sR(t,s){return k.useMemo(()=>{if(s)return s;const r=Dge[t]==null?0:Dge[t]+1;return Dge[t]=r,t+"-"+r},[t,s])}function htt(t){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a{const i=Object.entries(l);for(const[c,u]of i){const p=o[c];p!=null&&(o[c]=p+t*u)}return o},{...s})}}const rT=htt(1),wD=htt(-1);function vVt(t){return"clientX"in t&&"clientY"in t}function $ke(t){if(!t)return!1;const{KeyboardEvent:s}=Pp(t.target);return s&&t instanceof s}function bVt(t){if(!t)return!1;const{TouchEvent:s}=Pp(t.target);return s&&t instanceof s}function lbe(t){if(bVt(t)){if(t.touches&&t.touches.length){const{clientX:s,clientY:r}=t.touches[0];return{x:s,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:s,clientY:r}=t.changedTouches[0];return{x:s,y:r}}}return vVt(t)?{x:t.clientX,y:t.clientY}:null}const JS=Object.freeze({Translate:{toString(t){if(!t)return;const{x:s,y:r}=t;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:s,scaleY:r}=t;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[JS.Translate.toString(t),JS.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),x8e="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function _Vt(t){return t.matches(x8e)?t:t.querySelector(x8e)}const wVt={display:"none"};function jVt(t){let{id:s,value:r}=t;return ht.createElement("div",{id:s,style:wVt},r)}function NVt(t){let{id:s,announcement:r,ariaLiveType:n="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ht.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function kVt(){const[t,s]=k.useState("");return{announce:k.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const mtt=k.createContext(null);function SVt(t){const s=k.useContext(mtt);k.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function CVt(){const[t]=k.useState(()=>new Set),s=k.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[k.useCallback(n=>{let{type:a,event:o}=n;t.forEach(l=>{var i;return(i=l[a])==null?void 0:i.call(l,o)})},[t]),s]}const MVt={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. `},TVt={onDragStart(t){let{active:s}=t;return"Picked up draggable item "+s.id+"."},onDragOver(t){let{active:s,over:r}=t;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(t){let{active:s,over:r}=t;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(t){let{active:s}=t;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function AVt(t){let{announcements:s=TVt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=MVt}=t;const{announce:o,announcement:l}=kVt(),i=sR("DndLiveRegion"),[c,u]=k.useState(!1);if(k.useEffect(()=>{u(!0)},[]),SVt(k.useMemo(()=>({onDragStart(f){let{active:g}=f;o(s.onDragStart({active:g}))},onDragMove(f){let{active:g,over:b}=f;s.onDragMove&&o(s.onDragMove({active:g,over:b}))},onDragOver(f){let{active:g,over:b}=f;o(s.onDragOver({active:g,over:b}))},onDragEnd(f){let{active:g,over:b}=f;o(s.onDragEnd({active:g,over:b}))},onDragCancel(f){let{active:g,over:b}=f;o(s.onDragCancel({active:g,over:b}))}}),[o,s])),!c)return null;const p=ht.createElement(ht.Fragment,null,ht.createElement(jVt,{id:n,value:a.draggable}),ht.createElement(NVt,{id:i,announcement:l}));return r?yp.createPortal(p,r):p}var yu;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(yu||(yu={}));function qle(){}function Ule(t,s){return k.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function qke(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const uy=Object.freeze({x:0,y:0});function ptt(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function ftt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function EVt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function g8e(t){let{left:s,top:r,height:n,width:a}=t;return[{x:s,y:r},{x:s+a,y:r},{x:s,y:r+n},{x:s+a,y:r+n}]}function xtt(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function y8e(t,s,r){return s===void 0&&(s=t.left),r===void 0&&(r=t.top),{x:s+t.width*.5,y:r+t.height*.5}}const Uke=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=y8e(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=ptt(y8e(c),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(ftt)},PVt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=g8e(s),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=g8e(c),p=a.reduce((g,b,_)=>g+ptt(u[_],b),0),f=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort(ftt)};function IVt(t,s){const r=Math.max(s.top,t.top),n=Math.max(s.left,t.left),a=Math.min(s.left+s.width,t.left+t.width),o=Math.min(s.top+s.height,t.top+t.height),l=a-n,i=o-r;if(n{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=[];for(const o of n){const{id:l}=o,i=r.get(l);if(i){const c=IVt(i,s);c>0&&a.push({id:l,data:{droppableContainer:o,value:c}})}}return a.sort(EVt)};function DVt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function gtt(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:uy}function OVt(t){return function(r){for(var n=arguments.length,a=new Array(n>1?n-1:0),o=1;o({...l,top:l.top+t*i.y,bottom:l.bottom+t*i.y,left:l.left+t*i.x,right:l.right+t*i.x}),{...r})}}const RVt=OVt(1);function FVt(t){if(t.startsWith("matrix3d(")){const s=t.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(t.startsWith("matrix(")){const s=t.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function zVt(t,s,r){const n=FVt(s);if(!n)return t;const{scaleX:a,scaleY:o,x:l,y:i}=n,c=t.left-l-(1-a)*parseFloat(r),u=t.top-i-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),p=a?t.width/a:t.width,f=o?t.height/o:t.height;return{width:p,height:f,top:u,right:c+p,bottom:u+f,left:c}}const BVt={ignoreTransform:!1};function hE(t,s){s===void 0&&(s=BVt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=Pp(t).getComputedStyle(t);u&&(r=zVt(r,u,p))}const{top:n,left:a,width:o,height:l,bottom:i,right:c}=r;return{top:n,left:a,width:o,height:l,bottom:i,right:c}}function v8e(t){return hE(t,{ignoreTransform:!0})}function $Vt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function qVt(t,s){return s===void 0&&(s=Pp(t).getComputedStyle(t)),s.position==="fixed"}function UVt(t,s){s===void 0&&(s=Pp(t).getComputedStyle(t));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=s[a];return typeof o=="string"?r.test(o):!1})}function Kue(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(zke(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!eR(a)||utt(a)||r.includes(a))return r;const o=Pp(t).getComputedStyle(a);return a!==t&&UVt(a,o)&&r.push(a),qVt(a,o)?r:n(a.parentNode)}return t?n(t):r}function ytt(t){const[s]=Kue(t,1);return s??null}function Oge(t){return!Gue||!t?null:dE(t)?t:Fke(t)?zke(t)||t===uE(t).scrollingElement?window:eR(t)?t:null:null}function vtt(t){return dE(t)?t.scrollX:t.scrollLeft}function btt(t){return dE(t)?t.scrollY:t.scrollTop}function cbe(t){return{x:vtt(t),y:btt(t)}}var Wu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Wu||(Wu={}));function _tt(t){return!Gue||!t?!1:t===document.scrollingElement}function wtt(t){const s={x:0,y:0},r=_tt(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-r.width,y:t.scrollHeight-r.height},a=t.scrollTop<=s.y,o=t.scrollLeft<=s.x,l=t.scrollTop>=n.y,i=t.scrollLeft>=n.x;return{isTop:a,isLeft:o,isBottom:l,isRight:i,maxScroll:n,minScroll:s}}const VVt={x:.2,y:.2};function HVt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:c}=r;n===void 0&&(n=10),a===void 0&&(a=VVt);const{isTop:u,isBottom:p,isLeft:f,isRight:g}=wtt(t),b={x:0,y:0},_={x:0,y:0},j={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+j.height?(b.y=Wu.Backward,_.y=n*Math.abs((s.top+j.height-o)/j.height)):!p&&c>=s.bottom-j.height&&(b.y=Wu.Forward,_.y=n*Math.abs((s.bottom-j.height-c)/j.height)),!g&&i>=s.right-j.width?(b.x=Wu.Forward,_.x=n*Math.abs((s.right-j.width-i)/j.width)):!f&&l<=s.left+j.width&&(b.x=Wu.Backward,_.x=n*Math.abs((s.left+j.width-l)/j.width)),{direction:b,speed:_}}function WVt(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:l}=window;return{top:0,left:0,right:o,bottom:l,width:o,height:l}}const{top:s,left:r,right:n,bottom:a}=t.getBoundingClientRect();return{top:s,left:r,right:n,bottom:a,width:t.clientWidth,height:t.clientHeight}}function jtt(t){return t.reduce((s,r)=>rT(s,cbe(r)),uy)}function GVt(t){return t.reduce((s,r)=>s+vtt(r),0)}function KVt(t){return t.reduce((s,r)=>s+btt(r),0)}function ZVt(t,s){if(s===void 0&&(s=hE),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);ytt(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const YVt=[["x",["left","right"],GVt],["y",["top","bottom"],KVt]];class Vke{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Kue(r),a=jtt(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of YVt)for(const c of l)Object.defineProperty(this,c,{get:()=>{const u=i(n),p=a[o]-u;return this.rect[c]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class u8{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=s}add(s,r,n){var a;(a=this.target)==null||a.addEventListener(s,r,n),this.listeners.push([s,r,n])}}function XVt(t){const{EventTarget:s}=Pp(t);return t instanceof s?t:uE(t)}function Rge(t,s){const r=Math.abs(t.x),n=Math.abs(t.y);return typeof s=="number"?Math.sqrt(r**2+n**2)>s:"x"in s&&"y"in s?r>s.x&&n>s.y:"x"in s?r>s.x:"y"in s?n>s.y:!1}var ux;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ux||(ux={}));function b8e(t){t.preventDefault()}function QVt(t){t.stopPropagation()}var To;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(To||(To={}));const Ntt={start:[To.Space,To.Enter],cancel:[To.Esc],end:[To.Space,To.Enter,To.Tab]},JVt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case To.Right:return{...r,x:r.x+25};case To.Left:return{...r,x:r.x-25};case To.Down:return{...r,y:r.y+25};case To.Up:return{...r,y:r.y-25}}};class Hke{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new u8(uE(r)),this.windowListeners=new u8(Pp(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ux.Resize,this.handleCancel),this.windowListeners.add(ux.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ux.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&ZVt(n),r(uy)}handleKeyDown(s){if($ke(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=Ntt,coordinateGetter:l=JVt,scrollBehavior:i="smooth"}=a,{code:c}=s;if(o.end.includes(c)){this.handleEnd(s);return}if(o.cancel.includes(c)){this.handleCancel(s);return}const{collisionRect:u}=n.current,p=u?{x:u.left,y:u.top}:uy;this.referenceCoordinates||(this.referenceCoordinates=p);const f=l(s,{active:r,context:n.current,currentCoordinates:p});if(f){const g=wD(f,p),b={x:0,y:0},{scrollableAncestors:_}=n.current;for(const j of _){const w=s.code,{isTop:N,isRight:S,isLeft:M,isBottom:L,maxScroll:I,minScroll:O}=wtt(j),q=WVt(j),U={x:Math.min(w===To.Right?q.right-q.width/2:q.right,Math.max(w===To.Right?q.left:q.left+q.width/2,f.x)),y:Math.min(w===To.Down?q.bottom-q.height/2:q.bottom,Math.max(w===To.Down?q.top:q.top+q.height/2,f.y))},B=w===To.Right&&!S||w===To.Left&&!M,V=w===To.Down&&!L||w===To.Up&&!N;if(B&&U.x!==f.x){const Y=j.scrollLeft+g.x,Q=w===To.Right&&Y<=I.x||w===To.Left&&Y>=O.x;if(Q&&!g.y){j.scrollTo({left:Y,behavior:i});return}Q?b.x=j.scrollLeft-Y:b.x=w===To.Right?j.scrollLeft-I.x:j.scrollLeft-O.x,b.x&&j.scrollBy({left:-b.x,behavior:i});break}else if(V&&U.y!==f.y){const Y=j.scrollTop+g.y,Q=w===To.Down&&Y<=I.y||w===To.Up&&Y>=O.y;if(Q&&!g.x){j.scrollTo({top:Y,behavior:i});return}Q?b.y=j.scrollTop-Y:b.y=w===To.Down?j.scrollTop-I.y:j.scrollTop-O.y,b.y&&j.scrollBy({top:-b.y,behavior:i});break}}this.handleMove(s,rT(wD(f,this.referenceCoordinates),b))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Hke.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=Ntt,onActivation:a}=s,{active:o}=r;const{code:l}=t.nativeEvent;if(n.start.includes(l)){const i=o.activatorNode.current;return i&&t.target!==i?!1:(t.preventDefault(),a==null||a({event:t.nativeEvent}),!0)}return!1}}];function _8e(t){return!!(t&&"distance"in t)}function w8e(t){return!!(t&&"delay"in t)}class Wke{constructor(s,r,n){var a;n===void 0&&(n=XVt(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:o}=s,{target:l}=o;this.props=s,this.events=r,this.document=uE(l),this.documentListeners=new u8(this.document),this.listeners=new u8(n),this.windowListeners=new u8(Pp(l)),this.initialCoordinates=(a=lbe(o))!=null?a:uy,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(ux.Resize,this.handleCancel),this.windowListeners.add(ux.DragStart,b8e),this.windowListeners.add(ux.VisibilityChange,this.handleCancel),this.windowListeners.add(ux.ContextMenu,b8e),this.documentListeners.add(ux.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(w8e(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(_8e(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:n,onPending:a}=this.props;a(n,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(ux.Click,QVt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ux.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:a,props:o}=this,{onMove:l,options:{activationConstraint:i}}=o;if(!a)return;const c=(r=lbe(s))!=null?r:uy,u=wD(a,c);if(!n&&i){if(_8e(i)){if(i.tolerance!=null&&Rge(u,i.tolerance))return this.handleCancel();if(Rge(u,i.distance))return this.handleStart()}if(w8e(i)&&Rge(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}s.cancelable&&s.preventDefault(),l(c)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===To.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const eHt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class rR extends Wke{constructor(s){const{event:r}=s,n=uE(r.target);super(s,eHt,n)}}rR.activators=[{eventName:"onPointerDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const tHt={move:{name:"mousemove"},end:{name:"mouseup"}};var dbe;(function(t){t[t.RightClick=2]="RightClick"})(dbe||(dbe={}));class sHt extends Wke{constructor(s){super(s,tHt,uE(s.event.target))}}sHt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===dbe.RightClick?!1:(n==null||n({event:r}),!0)}}];const Fge={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class rHt extends Wke{constructor(s){super(s,Fge)}static setup(){return window.addEventListener(Fge.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Fge.move.name,s)};function s(){}}}rHt.activators=[{eventName:"onTouchStart",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;const{touches:a}=r;return a.length>1?!1:(n==null||n({event:r}),!0)}}];var h8;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(h8||(h8={}));var Vle;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Vle||(Vle={}));function nHt(t){let{acceleration:s,activator:r=h8.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=Vle.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:g}=t;const b=iHt({delta:f,disabled:!o}),[_,j]=yVt(),w=k.useRef({x:0,y:0}),N=k.useRef({x:0,y:0}),S=k.useMemo(()=>{switch(r){case h8.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case h8.DraggableRect:return a}},[r,a,c]),M=k.useRef(null),L=k.useCallback(()=>{const O=M.current;if(!O)return;const q=w.current.x*N.current.x,U=w.current.y*N.current.y;O.scrollBy(q,U)},[]),I=k.useMemo(()=>i===Vle.TreeOrder?[...u].reverse():u,[i,u]);k.useEffect(()=>{if(!o||!u.length||!S){j();return}for(const O of I){if((n==null?void 0:n(O))===!1)continue;const q=u.indexOf(O),U=p[q];if(!U)continue;const{direction:B,speed:V}=HVt(O,U,S,s,g);for(const Y of["x","y"])b[Y][B[Y]]||(V[Y]=0,B[Y]=0);if(V.x>0||V.y>0){j(),M.current=O,_(L,l),w.current=V,N.current=B;return}}w.current={x:0,y:0},N.current={x:0,y:0},j()},[s,L,n,j,o,l,JSON.stringify(S),JSON.stringify(b),_,u,I,p,JSON.stringify(g)])}const aHt={x:{[Wu.Backward]:!1,[Wu.Forward]:!1},y:{[Wu.Backward]:!1,[Wu.Forward]:!1}};function iHt(t){let{delta:s,disabled:r}=t;const n=obe(s);return tR(a=>{if(r||!n||!a)return aHt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[Wu.Backward]:a.x[Wu.Backward]||o.x===-1,[Wu.Forward]:a.x[Wu.Forward]||o.x===1},y:{[Wu.Backward]:a.y[Wu.Backward]||o.y===-1,[Wu.Forward]:a.y[Wu.Forward]||o.y===1}}},[r,s,n])}function oHt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return tR(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function lHt(t,s){return k.useMemo(()=>t.reduce((r,n)=>{const{sensor:a}=n,o=a.activators.map(l=>({eventName:l.eventName,handler:s(l.handler,n)}));return[...r,...o]},[]),[t,s])}var jD;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(jD||(jD={}));var ube;(function(t){t.Optimized="optimized"})(ube||(ube={}));const j8e=new Map;function cHt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=k.useState(null),{frequency:i,measure:c,strategy:u}=a,p=k.useRef(t),f=w(),g=_D(f),b=k.useCallback(function(N){N===void 0&&(N=[]),!g.current&&l(S=>S===null?N:S.concat(N.filter(M=>!S.includes(M))))},[g]),_=k.useRef(null),j=tR(N=>{if(f&&!r)return j8e;if(!N||N===j8e||p.current!==t||o!=null){const S=new Map;for(let M of t){if(!M)continue;if(o&&o.length>0&&!o.includes(M.id)&&M.rect.current){S.set(M.id,M.rect.current);continue}const L=M.node.current,I=L?new Vke(c(L),L):null;M.rect.current=I,I&&S.set(M.id,I)}return S}return N},[t,o,r,f,c]);return k.useEffect(()=>{p.current=t},[t]),k.useEffect(()=>{f||b()},[r,f]),k.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),k.useEffect(()=>{f||typeof i!="number"||_.current!==null||(_.current=setTimeout(()=>{b(),_.current=null},i))},[i,f,b,...n]),{droppableRects:j,measureDroppableContainers:b,measuringScheduled:o!=null};function w(){switch(u){case jD.Always:return!1;case jD.BeforeDragging:return r;default:return!r}}}function ktt(t,s){return tR(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function dHt(t,s){return ktt(t,s)}function uHt(t){let{callback:s,disabled:r}=t;const n=Bke(s),a=k.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return k.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Zue(t){let{callback:s,disabled:r}=t;const n=Bke(s),a=k.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return k.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function hHt(t){return new Vke(hE(t),t)}function N8e(t,s,r){s===void 0&&(s=hHt);const[n,a]=k.useState(null);function o(){a(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??r)!=null?u:null}const p=s(t);return JSON.stringify(c)===JSON.stringify(p)?c:p})}const l=uHt({callback(c){if(t)for(const u of c){const{type:p,target:f}=u;if(p==="childList"&&f instanceof HTMLElement&&f.contains(t)){o();break}}}}),i=Zue({callback:o});return I0(()=>{o(),t?(i==null||i.observe(t),l==null||l.observe(document.body,{childList:!0,subtree:!0})):(i==null||i.disconnect(),l==null||l.disconnect())},[t]),n}function mHt(t){const s=ktt(t);return gtt(t,s)}const k8e=[];function pHt(t){const s=k.useRef(t),r=tR(n=>t?n&&n!==k8e&&t&&s.current&&t.parentNode===s.current.parentNode?n:Kue(t):k8e,[t]);return k.useEffect(()=>{s.current=t},[t]),r}function fHt(t){const[s,r]=k.useState(null),n=k.useRef(t),a=k.useCallback(o=>{const l=Oge(o.target);l&&r(i=>i?(i.set(l,cbe(l)),new Map(i)):null)},[]);return k.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(c=>{const u=Oge(c);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,cbe(u)]):null}).filter(c=>c!=null);r(i.length?new Map(i):null),n.current=t}return()=>{l(t),l(o)};function l(i){i.forEach(c=>{const u=Oge(c);u==null||u.removeEventListener("scroll",a)})}},[a,t]),k.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>rT(o,l),uy):jtt(t):uy,[t,s])}function S8e(t,s){s===void 0&&(s=[]);const r=k.useRef(null);return k.useEffect(()=>{r.current=null},s),k.useEffect(()=>{const n=t!==uy;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?wD(t,r.current):uy}function xHt(t){k.useEffect(()=>{if(!Gue)return;const s=t.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of s)r==null||r()}},t.map(s=>{let{sensor:r}=s;return r}))}function gHt(t,s){return k.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function Stt(t){return k.useMemo(()=>t?$Vt(t):null,[t])}const C8e=[];function yHt(t,s){s===void 0&&(s=hE);const[r]=t,n=Stt(r?Pp(r):null),[a,o]=k.useState(C8e);function l(){o(()=>t.length?t.map(c=>_tt(c)?n:new Vke(s(c),c)):C8e)}const i=Zue({callback:l});return I0(()=>{i==null||i.disconnect(),l(),t.forEach(c=>i==null?void 0:i.observe(c))},[t]),a}function vHt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return eR(s)?s:t}function bHt(t){let{measure:s}=t;const[r,n]=k.useState(null),a=k.useCallback(u=>{for(const{target:p}of u)if(eR(p)){n(f=>{const g=s(p);return f?{...f,width:g.width,height:g.height}:g});break}},[s]),o=Zue({callback:a}),l=k.useCallback(u=>{const p=vHt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,c]=$le(l);return k.useMemo(()=>({nodeRef:i,rect:r,setRef:c}),[r,i,c])}const _Ht=[{sensor:rR,options:{}},{sensor:Hke,options:{}}],wHt={current:{}},Pie={draggable:{measure:v8e},droppable:{measure:v8e,strategy:jD.WhileDragging,frequency:ube.Optimized},dragOverlay:{measure:hE}};class m8 extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,n;return(r=(n=this.get(s))==null?void 0:n.node.current)!=null?r:void 0}}const jHt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new m8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:qle},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Pie,measureDroppableContainers:qle,windowRect:null,measuringScheduled:!1},NHt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:qle,draggableNodes:new Map,over:null,measureDroppableContainers:qle},Yue=k.createContext(NHt),Ctt=k.createContext(jHt);function kHt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new m8}}}function SHt(t,s){switch(s.type){case yu.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case yu.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:s.coordinates.x-t.draggable.initialCoordinates.x,y:s.coordinates.y-t.draggable.initialCoordinates.y}}};case yu.DragEnd:case yu.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case yu.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new m8(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case yu.SetDroppableDisabled:{const{id:r,key:n,disabled:a}=s,o=t.droppable.containers.get(r);if(!o||n!==o.key)return t;const l=new m8(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case yu.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new m8(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function CHt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=k.useContext(Yue),o=obe(n),l=obe(r==null?void 0:r.id);return k.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!$ke(o)||document.activeElement===o.target)return;const i=a.get(l);if(!i)return;const{activatorNode:c,node:u}=i;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const p of[c.current,u.current]){if(!p)continue;const f=_Vt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function MHt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function THt(t){return k.useMemo(()=>({draggable:{...Pie.draggable,...t==null?void 0:t.draggable},droppable:{...Pie.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Pie.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function AHt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=k.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;I0(()=>{if(!l&&!i||!s){o.current=!1;return}if(o.current||!n)return;const u=s==null?void 0:s.node.current;if(!u||u.isConnected===!1)return;const p=r(u),f=gtt(p,n);if(l||(f.x=0),i||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=ytt(u);g&&g.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const Mtt=k.createContext({...uy,scaleX:1,scaleY:1});var Jb;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Jb||(Jb={}));const Gke=k.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:c=!0,children:u,sensors:p=_Ht,collisionDetection:f=LVt,measuring:g,modifiers:b,..._}=s;const j=k.useReducer(SHt,void 0,kHt),[w,N]=j,[S,M]=CVt(),[L,I]=k.useState(Jb.Uninitialized),O=L===Jb.Initialized,{draggable:{active:q,nodes:U,translate:B},droppable:{containers:V}}=w,Y=q!=null?U.get(q):null,Q=k.useRef({initial:null,translated:null}),ee=k.useMemo(()=>{var Ea;return q!=null?{id:q,data:(Ea=Y==null?void 0:Y.data)!=null?Ea:wHt,rect:Q}:null},[q,Y]),X=k.useRef(null),[ie,re]=k.useState(null),[oe,ce]=k.useState(null),ge=_D(_,Object.values(_)),ye=sR("DndDescribedBy",l),ue=k.useMemo(()=>V.getEnabled(),[V]),pe=THt(g),{droppableRects:_e,measureDroppableContainers:$e,measuringScheduled:Ae}=cHt(ue,{dragging:O,dependencies:[B.x,B.y],config:pe.droppable}),Ie=oHt(U,q),Ce=k.useMemo(()=>oe?lbe(oe):null,[oe]),xe=ki(),we=dHt(Ie,pe.draggable.measure);AHt({activeNode:q!=null?U.get(q):null,config:xe.layoutShiftCompensation,initialRect:we,measure:pe.draggable.measure});const Le=N8e(Ie,pe.draggable.measure,we),tt=N8e(Ie?Ie.parentElement:null),Te=k.useRef({activatorEvent:null,active:null,activeNode:Ie,collisionRect:null,collisions:null,droppableRects:_e,draggableNodes:U,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),pt=V.getNodeFor((r=Te.current.over)==null?void 0:r.id),fe=bHt({measure:pe.dragOverlay.measure}),qe=(n=fe.nodeRef.current)!=null?n:Ie,at=O?(a=fe.rect)!=null?a:Le:null,et=!!(fe.nodeRef.current&&fe.rect),Me=mHt(et?null:Le),rt=Stt(qe?Pp(qe):null),He=pHt(O?pt??Ie:null),ct=yHt(He),Ue=MHt(b,{transform:{x:B.x-Me.x,y:B.y-Me.y,scaleX:1,scaleY:1},activatorEvent:oe,active:ee,activeNodeRect:Le,containerNodeRect:tt,draggingNodeRect:at,over:Te.current.over,overlayNodeRect:fe.rect,scrollableAncestors:He,scrollableAncestorRects:ct,windowRect:rt}),Ze=Ce?rT(Ce,B):null,Qe=fHt(He),We=S8e(Qe),Je=S8e(Qe,[Le]),it=rT(Ue,We),Dt=at?RVt(at,Ue):null,Vt=ee&&Dt?f({active:ee,collisionRect:Dt,droppableRects:_e,droppableContainers:ue,pointerCoordinates:Ze}):null,hs=xtt(Vt,"id"),[Ts,Cs]=k.useState(null),cs=et?Ue:rT(Ue,Je),er=DVt(cs,(o=Ts==null?void 0:Ts.rect)!=null?o:null,Le),xt=k.useRef(null),Es=k.useCallback((Ea,dr)=>{let{sensor:Jr,options:Wr}=dr;if(X.current==null)return;const dn=U.get(X.current);if(!dn)return;const Yr=Ea.nativeEvent,vi=new Jr({active:X.current,activeNode:dn,event:Yr,options:Wr,context:Te,onAbort(ir){if(!U.get(ir))return;const{onDragAbort:Sr}=ge.current,jr={id:ir};Sr==null||Sr(jr),S({type:"onDragAbort",event:jr})},onPending(ir,Vn,Sr,jr){if(!U.get(ir))return;const{onDragPending:Pa}=ge.current,Ii={id:ir,constraint:Vn,initialCoordinates:Sr,offset:jr};Pa==null||Pa(Ii),S({type:"onDragPending",event:Ii})},onStart(ir){const Vn=X.current;if(Vn==null)return;const Sr=U.get(Vn);if(!Sr)return;const{onDragStart:jr}=ge.current,ea={activatorEvent:Yr,active:{id:Vn,data:Sr.data,rect:Q}};yp.unstable_batchedUpdates(()=>{jr==null||jr(ea),I(Jb.Initializing),N({type:yu.DragStart,initialCoordinates:ir,active:Vn}),S({type:"onDragStart",event:ea}),re(xt.current),ce(Yr)})},onMove(ir){N({type:yu.DragMove,coordinates:ir})},onEnd:ft(yu.DragEnd),onCancel:ft(yu.DragCancel)});xt.current=vi;function ft(ir){return async function(){const{active:Sr,collisions:jr,over:ea,scrollAdjustedTranslate:Pa}=Te.current;let Ii=null;if(Sr&&Pa){const{cancelDrop:Fo}=ge.current;Ii={activatorEvent:Yr,active:Sr,collisions:jr,delta:Pa,over:ea},ir===yu.DragEnd&&typeof Fo=="function"&&await Promise.resolve(Fo(Ii))&&(ir=yu.DragCancel)}X.current=null,yp.unstable_batchedUpdates(()=>{N({type:ir}),I(Jb.Uninitialized),Cs(null),re(null),ce(null),xt.current=null;const Fo=ir===yu.DragEnd?"onDragEnd":"onDragCancel";if(Ii){const $t=ge.current[Fo];$t==null||$t(Ii),S({type:Fo,event:Ii})}})}}},[U]),ur=k.useCallback((Ea,dr)=>(Jr,Wr)=>{const dn=Jr.nativeEvent,Yr=U.get(Wr);if(X.current!==null||!Yr||dn.dndKit||dn.defaultPrevented)return;const vi={active:Yr};Ea(Jr,dr.options,vi)===!0&&(dn.dndKit={capturedBy:dr.sensor},X.current=Wr,Es(Jr,dr))},[U,Es]),Mr=lHt(p,ur);xHt(p),I0(()=>{Le&&L===Jb.Initializing&&I(Jb.Initialized)},[Le,L]),k.useEffect(()=>{const{onDragMove:Ea}=ge.current,{active:dr,activatorEvent:Jr,collisions:Wr,over:dn}=Te.current;if(!dr||!Jr)return;const Yr={active:dr,activatorEvent:Jr,collisions:Wr,delta:{x:it.x,y:it.y},over:dn};yp.unstable_batchedUpdates(()=>{Ea==null||Ea(Yr),S({type:"onDragMove",event:Yr})})},[it.x,it.y]),k.useEffect(()=>{const{active:Ea,activatorEvent:dr,collisions:Jr,droppableContainers:Wr,scrollAdjustedTranslate:dn}=Te.current;if(!Ea||X.current==null||!dr||!dn)return;const{onDragOver:Yr}=ge.current,vi=Wr.get(hs),ft=vi&&vi.rect.current?{id:vi.id,rect:vi.rect.current,data:vi.data,disabled:vi.disabled}:null,ir={active:Ea,activatorEvent:dr,collisions:Jr,delta:{x:dn.x,y:dn.y},over:ft};yp.unstable_batchedUpdates(()=>{Cs(ft),Yr==null||Yr(ir),S({type:"onDragOver",event:ir})})},[hs]),I0(()=>{Te.current={activatorEvent:oe,active:ee,activeNode:Ie,collisionRect:Dt,collisions:Vt,droppableRects:_e,draggableNodes:U,draggingNode:qe,draggingNodeRect:at,droppableContainers:V,over:Ts,scrollableAncestors:He,scrollAdjustedTranslate:it},Q.current={initial:at,translated:Dt}},[ee,Ie,Vt,Dt,U,qe,at,_e,V,Ts,He,it]),nHt({...xe,delta:B,draggingRect:Dt,pointerCoordinates:Ze,scrollableAncestors:He,scrollableAncestorRects:ct});const Lr=k.useMemo(()=>({active:ee,activeNode:Ie,activeNodeRect:Le,activatorEvent:oe,collisions:Vt,containerNodeRect:tt,dragOverlay:fe,draggableNodes:U,droppableContainers:V,droppableRects:_e,over:Ts,measureDroppableContainers:$e,scrollableAncestors:He,scrollableAncestorRects:ct,measuringConfiguration:pe,measuringScheduled:Ae,windowRect:rt}),[ee,Ie,Le,oe,Vt,tt,fe,U,V,_e,Ts,$e,He,ct,pe,Ae,rt]),fn=k.useMemo(()=>({activatorEvent:oe,activators:Mr,active:ee,activeNodeRect:Le,ariaDescribedById:{draggable:ye},dispatch:N,draggableNodes:U,over:Ts,measureDroppableContainers:$e}),[oe,Mr,ee,Le,N,ye,U,Ts,$e]);return ht.createElement(mtt.Provider,{value:M},ht.createElement(Yue.Provider,{value:fn},ht.createElement(Ctt.Provider,{value:Lr},ht.createElement(Mtt.Provider,{value:er},u)),ht.createElement(CHt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ht.createElement(AVt,{...i,hiddenTextDescribedById:ye}));function ki(){const Ea=(ie==null?void 0:ie.autoScrollEnabled)===!1,dr=typeof c=="object"?c.enabled===!1:c===!1,Jr=O&&!Ea&&!dr;return typeof c=="object"?{...c,enabled:Jr}:{enabled:Jr}}}),EHt=k.createContext(null),M8e="button",PHt="Draggable";function IHt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=sR(PHt),{activators:l,activatorEvent:i,active:c,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:g}=k.useContext(Yue),{role:b=M8e,roleDescription:_="draggable",tabIndex:j=0}=a??{},w=(c==null?void 0:c.id)===s,N=k.useContext(w?Mtt:EHt),[S,M]=$le(),[L,I]=$le(),O=gHt(l,s),q=_D(r);I0(()=>(f.set(s,{id:s,key:o,node:S,activatorNode:L,data:q}),()=>{const B=f.get(s);B&&B.key===o&&f.delete(s)}),[f,s]);const U=k.useMemo(()=>({role:b,tabIndex:j,"aria-disabled":n,"aria-pressed":w&&b===M8e?!0:void 0,"aria-roledescription":_,"aria-describedby":p.draggable}),[n,b,j,w,_,p.draggable]);return{active:c,activatorEvent:i,activeNodeRect:u,attributes:U,isDragging:w,listeners:n?void 0:O,node:S,over:g,setNodeRef:M,setActivatorNodeRef:I,transform:N}}function LHt(){return k.useContext(Ctt)}const DHt="Droppable",OHt={timeout:25};function RHt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=sR(DHt),{active:l,dispatch:i,over:c,measureDroppableContainers:u}=k.useContext(Yue),p=k.useRef({disabled:r}),f=k.useRef(!1),g=k.useRef(null),b=k.useRef(null),{disabled:_,updateMeasurementsFor:j,timeout:w}={...OHt,...a},N=_D(j??n),S=k.useCallback(()=>{if(!f.current){f.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{u(Array.isArray(N.current)?N.current:[N.current]),b.current=null},w)},[w]),M=Zue({callback:S,disabled:_||!l}),L=k.useCallback((U,B)=>{M&&(B&&(M.unobserve(B),f.current=!1),U&&M.observe(U))},[M]),[I,O]=$le(L),q=_D(s);return k.useEffect(()=>{!M||!I.current||(M.disconnect(),f.current=!1,M.observe(I.current))},[I,M]),k.useEffect(()=>(i({type:yu.RegisterDroppable,element:{id:n,key:o,disabled:r,node:I,rect:g,data:q}}),()=>i({type:yu.UnregisterDroppable,key:o,id:n})),[n]),k.useEffect(()=>{r!==p.current.disabled&&(i({type:yu.SetDroppableDisabled,id:n,key:o,disabled:r}),p.current.disabled=r)},[n,o,r,i]),{active:l,rect:g,isOver:(c==null?void 0:c.id)===n,node:I,over:c,setNodeRef:O}}function Kke(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function FHt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function Mz(t){return t!==null&&t>=0}function zHt(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let r=0;r{var s;let{rects:r,activeNodeRect:n,activeIndex:a,overIndex:o,index:l}=t;const i=(s=r[a])!=null?s:n;if(!i)return null;const c=$Ht(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-c,y:0,...Tz}:l=o?{x:i.width+c,y:0,...Tz}:{x:0,y:0,...Tz}};function $Ht(t,s,r){const n=t[s],a=t[s-1],o=t[s+1];return!n||!a&&!o?0:r{let{rects:s,activeIndex:r,overIndex:n,index:a}=t;const o=Kke(s,n,r),l=s[a],i=o[a];return!i||!l?null:{x:i.left-l.left,y:i.top-l.top,scaleX:i.width/l.width,scaleY:i.height/l.height}},Ttt="Sortable",Att=ht.createContext({activeIndex:-1,containerId:Ttt,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:nR,disabled:{draggable:!1,droppable:!1}});function Zke(t){let{children:s,id:r,items:n,strategy:a=nR,disabled:o=!1}=t;const{active:l,dragOverlay:i,droppableRects:c,over:u,measureDroppableContainers:p}=LHt(),f=sR(Ttt,r),g=i.rect!==null,b=k.useMemo(()=>n.map(O=>typeof O=="object"&&"id"in O?O.id:O),[n]),_=l!=null,j=l?b.indexOf(l.id):-1,w=u?b.indexOf(u.id):-1,N=k.useRef(b),S=!zHt(b,N.current),M=w!==-1&&j===-1||S,L=BHt(o);I0(()=>{S&&_&&p(b)},[S,b,_,p]),k.useEffect(()=>{N.current=b},[b]);const I=k.useMemo(()=>({activeIndex:j,containerId:f,disabled:L,disableTransforms:M,items:b,overIndex:w,useDragOverlay:g,sortedRects:FHt(b,c),strategy:a}),[j,f,L.draggable,L.droppable,M,b,w,c,g,a]);return ht.createElement(Att.Provider,{value:I},s)}const qHt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return Kke(r,n,a).indexOf(s)},UHt=t=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:c,transition:u}=t;return!u||!n||i!==o&&a===l?!1:r?!0:l!==a&&s===c},VHt={duration:200,easing:"ease"},Ett="transform",HHt=JS.Transition.toString({property:Ett,duration:0,easing:"linear"}),WHt={roleDescription:"sortable"};function GHt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=k.useState(null),i=k.useRef(r);return I0(()=>{if(!s&&r!==i.current&&n.current){const c=a.current;if(c){const u=hE(n.current,{ignoreTransform:!0}),p={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(p.x||p.y)&&l(p)}}r!==i.current&&(i.current=r)},[s,r,n,a]),k.useEffect(()=>{o&&l(null)},[o]),o}function Yke(t){let{animateLayoutChanges:s=UHt,attributes:r,disabled:n,data:a,getNewIndex:o=qHt,id:l,strategy:i,resizeObserverConfig:c,transition:u=VHt}=t;const{items:p,containerId:f,activeIndex:g,disabled:b,disableTransforms:_,sortedRects:j,overIndex:w,useDragOverlay:N,strategy:S}=k.useContext(Att),M=KHt(n,b),L=p.indexOf(l),I=k.useMemo(()=>({sortable:{containerId:f,index:L,items:p},...a}),[f,a,L,p]),O=k.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:q,node:U,isOver:B,setNodeRef:V}=RHt({id:l,data:I,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...c}}),{active:Y,activatorEvent:Q,activeNodeRect:ee,attributes:X,setNodeRef:ie,listeners:re,isDragging:oe,over:ce,setActivatorNodeRef:ge,transform:ye}=IHt({id:l,data:I,attributes:{...WHt,...r},disabled:M.draggable}),ue=gVt(V,ie),pe=!!Y,_e=pe&&!_&&Mz(g)&&Mz(w),$e=!N&&oe,Ae=$e&&_e?ye:null,Ce=_e?Ae??(i??S)({rects:j,activeNodeRect:ee,activeIndex:g,overIndex:w,index:L}):null,xe=Mz(g)&&Mz(w)?o({id:l,items:p,activeIndex:g,overIndex:w}):L,we=Y==null?void 0:Y.id,Le=k.useRef({activeId:we,items:p,newIndex:xe,containerId:f}),tt=p!==Le.current.items,Te=s({active:Y,containerId:f,isDragging:oe,isSorting:pe,id:l,index:L,items:p,newIndex:Le.current.newIndex,previousItems:Le.current.items,previousContainerId:Le.current.containerId,transition:u,wasDragging:Le.current.activeId!=null}),pt=GHt({disabled:!Te,index:L,node:U,rect:q});return k.useEffect(()=>{pe&&Le.current.newIndex!==xe&&(Le.current.newIndex=xe),f!==Le.current.containerId&&(Le.current.containerId=f),p!==Le.current.items&&(Le.current.items=p)},[pe,xe,f,p]),k.useEffect(()=>{if(we===Le.current.activeId)return;if(we!=null&&Le.current.activeId==null){Le.current.activeId=we;return}const qe=setTimeout(()=>{Le.current.activeId=we},50);return()=>clearTimeout(qe)},[we]),{active:Y,activeIndex:g,attributes:X,data:I,rect:q,index:L,newIndex:xe,items:p,isOver:B,isSorting:pe,isDragging:oe,listeners:re,node:U,overIndex:w,over:ce,setNodeRef:ue,setActivatorNodeRef:ge,setDroppableNodeRef:V,setDraggableNodeRef:ie,transform:pt??Ce,transition:fe()};function fe(){if(pt||tt&&Le.current.newIndex===L)return HHt;if(!($e&&!$ke(Q)||!u)&&(pe||Te))return JS.Transition.toString({...u,property:Ett})}}function KHt(t,s){var r,n;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(r=t==null?void 0:t.draggable)!=null?r:s.draggable,droppable:(n=t==null?void 0:t.droppable)!=null?n:s.droppable}}function Hle(t){if(!t)return!1;const s=t.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const ZHt=[To.Down,To.Right,To.Up,To.Left],YHt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(ZHt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const c=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=a.get(f.id);if(g)switch(t.code){case To.Down:n.topg.top&&c.push(f);break;case To.Left:n.left>g.left&&c.push(f);break;case To.Right:n.left1&&(p=u[1].id),p!=null){const f=o.get(r.id),g=o.get(p),b=g?a.get(g.id):null,_=g==null?void 0:g.node.current;if(_&&b&&f&&g){const w=Kue(_).some((O,q)=>i[q]!==O),N=Ptt(f,g),S=XHt(f,g),M=w||!N?{x:0,y:0}:{x:S?n.width-b.width:0,y:S?n.height-b.height:0},L={x:b.left,y:b.top};return M.x&&M.y?L:wD(L,M)}}}};function Ptt(t,s){return!Hle(t)||!Hle(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function XHt(t,s){return!Hle(t)||!Hle(s)||!Ptt(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>r(t),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(st,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(hn,{className:"h-2.5 w-2.5"}),ms(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:It("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"h-3 w-3"}),t.post_date?ms(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(Ro,{className:"w-auto p-0",align:"start",children:[e.jsx(wf,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?ms(f,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"}),t.post_date&&e.jsx("div",{className:"p-2 border-t",children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const JHt=()=>{const t=Qt(),[s,r]=k.useState("all"),[n,a]=k.useState(!1),[o,l]=k.useState(ms(new Date,"yyyy-MM")),[i,c]=k.useState([]),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(""),[N,S]=k.useState(null),[M,L]=k.useState(!1),[I,O]=k.useState(!1),[q,U]=k.useState(ms(new Date,"yyyy-MM")),[B,V]=k.useState(null),[Y,Q]=k.useState(""),[ee,X]=k.useState(""),[ie,re]=k.useState(""),[oe,ce]=k.useState(!1),ge=qke(Ule(rR,{activationConstraint:{distance:5}}),Ule(Hke,{coordinateGetter:YHt})),{data:ye=[],isLoading:ue}=mt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Ze,error:Qe}=await H.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(Qe)throw Qe;return Ze}}),{data:pe=[]}=mt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Ze,error:Qe}=await H.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(Qe)throw Qe;return Ze}}),{data:_e=[]}=mt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Ze,error:Qe}=await H.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(Qe)throw Qe;return Ze}}),$e=[...new Set(ye.map(Ze=>Ze.month))].sort((Ze,Qe)=>Qe.localeCompare(Ze)),Ae=s==="all"?ye:ye.filter(Ze=>Ze.month===s),Ie=Ze=>{const Qe=bje(Ze,"yyyy-MM",new Date);return ms(Qe,"MMMM yyyy")},Ce=Ze=>{_(Ze),w(Ze.caption),S(Ze.post_date)},xe=async()=>{if(b){L(!0);try{const{error:Ze}=await H.from("social_swag_2").update({caption:j,post_date:N}).eq("id",b.id);if(Ze)throw Ze;me.success("Image updated"),_(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{me.error("Failed to update image")}finally{L(!1)}}},we=async Ze=>{const{active:Qe,over:We}=Ze;if(!We||Qe.id===We.id)return;const Je=Ae,it=Je.findIndex(hs=>hs.id===Qe.id),Dt=Je.findIndex(hs=>hs.id===We.id);if(it===-1||Dt===-1)return;const Vt=Kke(Je,it,Dt);t.setQueryData(["admin-social-swag-2"],hs=>{if(!hs)return hs;const Ts={};return Vt.forEach((Cs,cs)=>{Ts[Cs.id]=cs}),hs.map(Cs=>Ts[Cs.id]!==void 0?{...Cs,sort_order:Ts[Cs.id]}:Cs).sort((Cs,cs)=>Cs.month!==cs.month?cs.month.localeCompare(Cs.month):Cs.sort_order-cs.sort_order)});try{await Promise.all(Vt.map((hs,Ts)=>H.from("social_swag_2").update({sort_order:Ts}).eq("id",hs.id)))}catch{me.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Le=Ze=>{const We=Array.from(Ze.target.files||[]).sort((Je,it)=>Je.name.localeCompare(it.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(Je=>({file:Je,preview:URL.createObjectURL(Je),caption:""}));c(Je=>[...Je,...We].slice(0,16))},tt=Ze=>{c(Qe=>{const We=[...Qe];return URL.revokeObjectURL(We[Ze].preview),We.splice(Ze,1),We})},Te=(Ze,Qe)=>{c(We=>{const Je=[...We];return Je[Ze]={...Je[Ze],caption:Qe},Je})},pt=async()=>{var Qe;if(i.length===0){me.error("Please add at least one image");return}if(i.filter(We=>!We.caption.trim()).length>0){me.error("Please add captions to all images");return}p(!0);try{const{data:We}=await H.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),Je=(((Qe=We==null?void 0:We[0])==null?void 0:Qe.sort_order)??-1)+1;for(let it=0;it{const Qe=Ze.image_url.split("/social-swag-2/");Qe[1]&&await H.storage.from("social-swag-2").remove([Qe[1]]);const{error:We}=await H.from("social_swag_2").delete().eq("id",Ze.id);if(We)throw We},onSuccess:()=>{me.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>me.error("Failed to delete image")}),qe=Lt({mutationFn:async({id:Ze,postDate:Qe})=>{const{error:We}=await H.from("social_swag_2").update({post_date:Qe}).eq("id",Ze);if(We)throw We},onSuccess:()=>{me.success("Post date updated"),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>me.error("Failed to update post date")}),at=Lt({mutationFn:async({month:Ze,link:Qe})=>{const{error:We}=await H.from("social_swag_2_months").upsert({month:Ze,canva_link:Qe||null},{onConflict:"month"});if(We)throw We},onSuccess:()=>{me.success("Canva link updated"),g(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>me.error("Failed to update Canva link")}),et=Ze=>{var Qe;return((Qe=pe.find(We=>We.month===Ze))==null?void 0:Qe.canva_link)||""},Me=Ze=>_e.find(Qe=>Qe.month===Ze)||null,rt=Ze=>{var We;const Qe=(We=Ze.target.files)==null?void 0:We[0];Qe&&(V(Qe),Q(URL.createObjectURL(Qe)))},He=()=>{Y&&URL.revokeObjectURL(Y),V(null),Q(""),X(""),re("")},ct=async()=>{if(!B){me.error("Please select an image");return}ce(!0);try{const Ze=B.name.split(".").pop(),Qe=`reels/${q}-${Date.now()}.${Ze}`,{error:We}=await H.storage.from("social-swag-2").upload(Qe,B);if(We)throw We;const{data:{publicUrl:Je}}=H.storage.from("social-swag-2").getPublicUrl(Qe),{error:it}=await H.from("social_swag_2_reels").upsert({month:q,image_url:Je,canva_link:ie||null,caption:ee||null},{onConflict:"month"});if(it)throw it;me.success("Reel uploaded successfully!"),ibe(`${Ie(q)} Reel`,"social-swag-2"),He(),O(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Ze){console.error("Reel upload error:",Ze),me.error("Failed to upload reel")}finally{ce(!1)}},Ue=Lt({mutationFn:async Ze=>{const Qe=Ze.image_url.split("/social-swag-2/");Qe[1]&&await H.storage.from("social-swag-2").remove([Qe[1]]);const{error:We}=await H.from("social_swag_2_reels").delete().eq("id",Ze.id);if(We)throw We},onSuccess:()=>{me.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>me.error("Failed to delete reel")});return e.jsxs(Ms,{title:"Admin - Social Swag 2.0",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Social Swag 2.0"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage monthly social media images and captions"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(fs,{open:n,onOpenChange:a,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Month"}),e.jsx(ze,{type:"month",value:o,onChange:Ze=>l(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{children:["Images (",i.length,"/16)"]}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Le,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(li,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select images (max 16)"})]})]})]}),i.length>0&&e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map((Ze,Qe)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative aspect-[4/5] rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Ze.preview,alt:`Upload ${Qe+1}`,className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>tt(Qe),children:e.jsx(Rr,{className:"h-3 w-3"})})]}),e.jsx(Er,{placeholder:"Caption...",value:Ze.caption,onChange:We=>Te(Qe,We.target.value),className:"text-xs h-20"})]},Qe))}),e.jsx(K,{onClick:pt,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(fs,{open:I,onOpenChange:Ze=>{O(Ze),Ze||He()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(gu,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(ps,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Month"}),e.jsx(ze,{type:"month",value:q,onChange:Ze=>U(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Reel Preview Image"}),Y?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Y,alt:"Reel preview",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(Y),V(null),Q("")},children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:rt,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(gu,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select reel preview image"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Canva Download Link"}),e.jsx(ze,{value:ie,onChange:Ze=>re(Ze.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Caption"}),e.jsx(Er,{value:ee,onChange:Ze=>X(Ze.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:ct,disabled:oe||!B,className:"w-full gap-2",children:oe?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ye.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:$e.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ba,{value:s,onValueChange:r,children:e.jsxs(pa,{children:[e.jsx(ns,{value:"all",children:"All"}),$e.map(Ze=>e.jsx(ns,{value:Ze,children:Ie(Ze)},Ze))]})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(be,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Ie(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(ze,{value:f.link,onChange:Ze=>g({...f,link:Ze.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>at.mutate(f),children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g(null),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-sm",children:et(s)||"No link set"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g({month:s,link:et(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(gu,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(be,{className:"text-sm text-muted-foreground",children:["Reel for ",Ie(s)]}),(()=>{const Ze=Me(s);return Ze?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Ze.image_url,alt:"Reel preview",className:"w-16 h-28 object-cover rounded"}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("p",{className:"line-clamp-2",children:Ze.caption||"No caption"}),Ze.canva_link&&e.jsx("a",{href:Ze.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(K,{variant:"destructive",size:"sm",onClick:()=>Ue.mutate(Ze),children:e.jsx(Nr,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),ue?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):Ae.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(gl,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images yet. Upload some!"})]}):e.jsx(Gke,{sensors:ge,collisionDetection:Uke,onDragEnd:we,children:e.jsx(Zke,{items:Ae.map(Ze=>Ze.id),strategy:nR,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Ae.map(Ze=>e.jsx(QHt,{item:Ze,onEdit:Ce,onDelete:Qe=>fe.mutate(Qe),onDateChange:(Qe,We)=>qe.mutate({id:Qe,postDate:We})},Ze.id))})})})]}),e.jsx(fs,{open:!!b,onOpenChange:Ze=>{Ze||_(null)},children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Edit Image"})}),b&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"aspect-[4/5] max-h-48 w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:b.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Caption"}),e.jsx(Er,{value:j,onChange:Ze=>w(Ze.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("flex-1 justify-start gap-2 font-normal",!N&&"text-muted-foreground"),children:[e.jsx(hn,{className:"h-4 w-4"}),N?ms(new Date(N+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:N?new Date(N+"T00:00:00"):void 0,onSelect:Ze=>S(Ze?ms(Ze,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),N&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(null),children:e.jsx(Rr,{className:"h-4 w-4"})})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(null),children:"Cancel"}),e.jsx(K,{onClick:xe,disabled:M,className:"gap-2",children:M?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},eWt=()=>{const{toast:t}=Ua(),s=Qt(),[r,n]=k.useState("categories"),[a,o]=k.useState(!1),[l,i]=k.useState(null),[c,u]=k.useState({name:"",description:"",icon:""}),[p,f]=k.useState(!1),[g,b]=k.useState(null),[_,j]=k.useState({name:"",description:"",icon:""}),[w,N]=k.useState(!1),[S,M]=k.useState(null),[L,I]=k.useState(""),{data:O=[],isLoading:q}=mt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:we,error:Le}=await H.from("community_categories").select("*").order("sort_order");if(Le)throw Le;return we}}),{data:U=[],isLoading:B}=mt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:we,error:Le}=await H.from("community_private_groups").select("*").order("sort_order");if(Le)throw Le;return we}}),{data:V=[]}=mt({queryKey:["admin-group-members",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:we,error:Le}=await H.from("community_private_group_members").select("*").eq("group_id",S.id);if(Le)throw Le;return we},enabled:!!S}),{data:Y=[]}=mt({queryKey:["admin-all-profiles"],queryFn:async()=>{let Le=[],tt=0,Te=!0;for(;Te;){const{data:pt,error:fe}=await H.from("profiles").select("id, name, email, brokerage_id").order("name").range(tt,tt+1e3-1);if(fe)throw fe;pt&&pt.length>0?(Le=[...Le,...pt],tt+=1e3,Te=pt.length===1e3):Te=!1}return Le}}),{data:Q=[]}=mt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:we,error:Le}=await H.from("brokerages").select("*").order("name");if(Le)throw Le;return we}}),ee=Lt({mutationFn:async we=>{if(we.id){const{error:Le}=await H.from("community_categories").update({name:we.name,description:we.description||null,icon:we.icon||null}).eq("id",we.id);if(Le)throw Le}else{const Le=Math.max(...O.map(Te=>Te.sort_order),0),{error:tt}=await H.from("community_categories").insert({name:we.name,description:we.description||null,icon:we.icon||null,sort_order:Le+1});if(tt)throw tt}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:we=>{t({title:"Error",description:we.message,variant:"destructive"})}}),X=Lt({mutationFn:async we=>{const{error:Le}=await H.from("community_categories").delete().eq("id",we);if(Le)throw Le},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ie=Lt({mutationFn:async({id:we,direction:Le})=>{const tt=O.findIndex(Te=>Te.id===we);if(Le==="up"&&tt>0){const Te=O[tt-1],pt=O[tt];await H.from("community_categories").update({sort_order:pt.sort_order}).eq("id",Te.id),await H.from("community_categories").update({sort_order:Te.sort_order}).eq("id",pt.id)}else if(Le==="down"&&tts.invalidateQueries({queryKey:["admin-community-categories"]})}),re=Lt({mutationFn:async we=>{if(we.id){const{error:Le}=await H.from("community_private_groups").update({name:we.name,description:we.description||null,icon:we.icon||null}).eq("id",we.id);if(Le)throw Le}else{const Le=Math.max(...U.map(Te=>Te.sort_order),0),{error:tt}=await H.from("community_private_groups").insert({name:we.name,description:we.description||null,icon:we.icon||null,sort_order:Le+1});if(tt)throw tt}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),b(null),j({name:"",description:"",icon:""}),t({title:g?"Private group updated!":"Private group created!"})},onError:we=>{t({title:"Error",description:we.message,variant:"destructive"})}}),oe=Lt({mutationFn:async we=>{const{error:Le}=await H.from("community_private_groups").delete().eq("id",we);if(Le)throw Le},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),ce=Lt({mutationFn:async({id:we,direction:Le})=>{const tt=U.findIndex(Te=>Te.id===we);if(Le==="up"&&tt>0){const Te=U[tt-1],pt=U[tt];await H.from("community_private_groups").update({sort_order:pt.sort_order}).eq("id",Te.id),await H.from("community_private_groups").update({sort_order:Te.sort_order}).eq("id",pt.id)}else if(Le==="down"&&tts.invalidateQueries({queryKey:["admin-private-groups"]})}),ge=Lt({mutationFn:async({groupId:we,userId:Le,isMember:tt})=>{if(tt){const{error:Te}=await H.from("community_private_group_members").delete().eq("group_id",we).eq("user_id",Le);if(Te)throw Te}else{const{error:Te}=await H.from("community_private_group_members").insert({group_id:we,user_id:Le});if(Te)throw Te}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ye=Lt({mutationFn:async({groupId:we,brokerageId:Le,isMember:tt})=>{if(tt){const{error:Te}=await H.from("community_private_group_members").delete().eq("group_id",we).eq("brokerage_id",Le);if(Te)throw Te}else{const{error:Te}=await H.from("community_private_group_members").insert({group_id:we,brokerage_id:Le});if(Te)throw Te}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ue=we=>{i(we),u({name:we.name,description:we.description||"",icon:we.icon||""}),o(!0)},pe=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},_e=we=>{b(we),j({name:we.name,description:we.description||"",icon:we.icon||""}),f(!0)},$e=()=>{b(null),j({name:"",description:"",icon:""}),f(!0)},Ae=we=>{M(we),I(""),N(!0)},Ie=we=>V.some(Le=>Le.user_id===we),Ce=we=>V.some(Le=>Le.brokerage_id===we),xe=Y.filter(we=>we.name.toLowerCase().includes(L.toLowerCase())||we.email.toLowerCase().includes(L.toLowerCase()));return e.jsx(Ms,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(ba,{value:r,onValueChange:n,children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"categories",children:"Public Categories"}),e.jsxs(ns,{value:"private-groups",children:[e.jsx(Th,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(bs,{value:"categories",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Categories visible to all community members"}),e.jsxs(K,{onClick:pe,children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[50px]",children:"Order"}),e.jsx(St,{className:"w-[80px]",children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(zn,{children:q?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):O.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):O.map((we,Le)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Le===0,onClick:()=>ie.mutate({id:we.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Le===O.length-1,onClick:()=>ie.mutate({id:we.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:we.icon||"📁"}),e.jsx(dt,{className:"font-medium",children:we.name}),e.jsx(dt,{className:"text-muted-foreground",children:we.description||"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ue(we),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&X.mutate(we.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},we.id))})]})})})]}),e.jsxs(bs,{value:"private-groups",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Private groups visible only to assigned members or brokerages"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ka,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:$e,children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[50px]",children:"Order"}),e.jsx(St,{className:"w-[80px]",children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"w-[120px]",children:"Members"}),e.jsx(St,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(zn,{children:B?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):U.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):U.map((we,Le)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Le===0,onClick:()=>ce.mutate({id:we.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Le===U.length-1,onClick:()=>ce.mutate({id:we.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:we.icon||"🔒"}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[we.name,we.brokerage_id?e.jsxs(st,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(st,{variant:"secondary",className:"text-xs",children:[e.jsx(Th,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:we.description||"—"}),e.jsx(dt,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ae(we),children:[e.jsx(pr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[!we.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_e(we),children:e.jsx(Ra,{className:"h-4 w-4"})}),!we.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&oe.mutate(we.id)},children:e.jsx(Nr,{className:"h-4 w-4"})}),we.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},we.id))})]})})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:l?"Edit Category":"Create Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(ze,{value:c.icon,onChange:we=>u(Le=>({...Le,icon:we.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(ze,{value:c.name,onChange:we=>u(Le=>({...Le,name:we.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Er,{value:c.description,onChange:we=>u(Le=>({...Le,description:we.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ee.mutate({...c,id:l==null?void 0:l.id}),disabled:!c.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(fs,{open:p,onOpenChange:f,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:g?"Edit Private Group":"Create Private Group"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(ze,{value:_.icon,onChange:we=>j(Le=>({...Le,icon:we.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(ze,{value:_.name,onChange:we=>j(Le=>({...Le,name:we.target.value})),placeholder:"e.g., Pioneers",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Er,{value:_.description,onChange:we=>j(Le=>({...Le,description:we.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>re.mutate({..._,id:g==null?void 0:g.id}),disabled:!_.name.trim(),children:g?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(fs,{open:w,onOpenChange:N,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Manage Members: ",S==null?void 0:S.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ba,{defaultValue:"brokerages",children:[e.jsxs(pa,{className:"w-full",children:[e.jsx(ns,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(ns,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(bs,{value:"brokerages",className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select brokerages to grant all their agents access to this private group."}),e.jsx(Gi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Q.map(we=>e.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oo,{checked:Ce(we.id),onCheckedChange:()=>{S&&ye.mutate({groupId:S.id,brokerageId:we.id,isMember:Ce(we.id)})}}),e.jsx("span",{className:"font-medium",children:we.name})]}),e.jsxs(st,{variant:"secondary",children:[Y.filter(Le=>Le.brokerage_id===we.id).length," agents"]})]},we.id)),Q.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(bs,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search users...",value:L,onChange:we=>I(we.target.value),className:"pl-9"})]}),e.jsx(Gi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[xe.map(we=>e.jsx("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oo,{checked:Ie(we.id),onCheckedChange:()=>{S&&ge.mutate({groupId:S.id,userId:we.id,isMember:Ie(we.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:we.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:we.email})]})]})},we.id)),xe.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No users found"})]})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{onClick:()=>N(!1),children:"Done"})})]})]})})]})})},T8e=t=>{switch(t){case"academy_video":return e.jsx(nl,{className:"h-3 w-3"});case"template":return e.jsx(Sn,{className:"h-3 w-3"});case"toolbox":return e.jsx(Ml,{className:"h-3 w-3"});case"newsletter":return e.jsx(d1,{className:"h-3 w-3"});case"social_swag":return e.jsx(pn,{className:"h-3 w-3"});default:return e.jsx(tn,{className:"h-3 w-3"})}},tWt=t=>{switch(t){case"academy_video":return"Academy";case"template":return"Template";case"toolbox":return"Toolbox";case"newsletter":return"Newsletter";case"social_swag":return"Social Swag";default:return t}},sWt=t=>{switch(t){case"view":return"Viewed";case"click_canva":return"Clicked Canva";case"click_pdf":return"Downloaded PDF";case"click_video":return"Watched Video";case"click_link":return"Clicked Link";case"click_drive":return"Clicked Drive";default:return t}},rWt=()=>{const{toast:t}=Ua(),[s,r]=k.useState([]),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,c]=k.useState(!0),[u,p]=k.useState(""),[f,g]=k.useState(null),[b,_]=k.useState([]),[j,w]=k.useState([]);k.useEffect(()=>{N()},[]);const N=async()=>{try{c(!0);const{data:V,error:Y}=await H.from("activity_logs").select(` id, user_id, app_name, launched_at, profiles ( name, email, brokerages ( name ) ) `).order("launched_at",{ascending:!1}).limit(5e3);if(Y)throw Y;const{data:Q,error:ee}=await H.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(ee)throw ee;const X=[...new Set((Q==null?void 0:Q.map(ue=>ue.user_id))||[])],{data:ie}=await H.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",X),re=new Map((ie==null?void 0:ie.map(ue=>[ue.id,ue]))||[]),oe=(V==null?void 0:V.map(ue=>{var pe,_e,$e,Ae;return{id:ue.id,user_id:ue.user_id,app_name:ue.app_name,launched_at:ue.launched_at,user_name:((pe=ue.profiles)==null?void 0:pe.name)||"Unknown",user_email:((_e=ue.profiles)==null?void 0:_e.email)||"Unknown",brokerage_name:((Ae=($e=ue.profiles)==null?void 0:$e.brokerages)==null?void 0:Ae.name)||null}}))||[],ce=(Q==null?void 0:Q.map(ue=>{var _e;const pe=re.get(ue.user_id);return{id:ue.id,user_id:ue.user_id,resource_type:ue.resource_type,resource_id:ue.resource_id,resource_title:ue.resource_title,action_type:ue.action_type,created_at:ue.created_at,user_name:(pe==null?void 0:pe.name)||"Unknown",user_email:(pe==null?void 0:pe.email)||"Unknown",brokerage_name:((_e=pe==null?void 0:pe.brokerages)==null?void 0:_e.name)||null}}))||[];r(oe),a(ce);const ge=new Map;oe.forEach(ue=>{if(!ge.has(ue.user_id))ge.set(ue.user_id,{user_id:ue.user_id,user_name:ue.user_name,user_email:ue.user_email,brokerage_name:ue.brokerage_name,last_activity_type:"app",last_activity_name:ue.app_name,last_activity_at:ue.launched_at,total_app_launches:1,total_content_views:0});else{const pe=ge.get(ue.user_id);pe.total_app_launches++,new Date(ue.launched_at)>new Date(pe.last_activity_at)&&(pe.last_activity_type="app",pe.last_activity_name=ue.app_name,pe.last_activity_at=ue.launched_at)}}),ce.forEach(ue=>{if(!ge.has(ue.user_id))ge.set(ue.user_id,{user_id:ue.user_id,user_name:ue.user_name,user_email:ue.user_email,brokerage_name:ue.brokerage_name,last_activity_type:ue.resource_type,last_activity_name:ue.resource_title,last_activity_at:ue.created_at,total_app_launches:0,total_content_views:1});else{const pe=ge.get(ue.user_id);pe.total_content_views++,new Date(ue.created_at)>new Date(pe.last_activity_at)&&(pe.last_activity_type=ue.resource_type,pe.last_activity_name=ue.resource_title,pe.last_activity_at=ue.created_at)}});const ye=Array.from(ge.values()).sort((ue,pe)=>new Date(pe.last_activity_at).getTime()-new Date(ue.last_activity_at).getTime());l(ye)}catch(V){console.error("Error loading activity:",V),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{c(!1)}},S=V=>{g({id:V.user_id,name:V.user_name,email:V.user_email});const Y=s.filter(ee=>ee.user_id===V.user_id),Q=n.filter(ee=>ee.user_id===V.user_id);_(Y),w(Q)},M=()=>{g(null),_([]),w([])},{sortKey:L,sortDirection:I,handleSort:O,sortData:q}=QO("last_activity_at","desc"),U=o.filter(V=>{var Q;if(!u)return!0;const Y=u.toLowerCase();return V.user_name.toLowerCase().includes(Y)||V.user_email.toLowerCase().includes(Y)||((Q=V.brokerage_name)==null?void 0:Q.toLowerCase().includes(Y))}),B=q(U,{user:V=>{var Y;return((Y=V.user_name)==null?void 0:Y.toLowerCase())||""},brokerage:V=>{var Y;return((Y=V.brokerage_name)==null?void 0:Y.toLowerCase())||""},last_activity_at:V=>new Date(V.last_activity_at).getTime(),apps:V=>V.total_app_launches,content:V=>V.total_content_views});return i?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"User Activity"}),e.jsx(gr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or brokerage...",value:u,onChange:V=>p(V.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(yl,{sortKey:"user",currentSortKey:L,currentDirection:I,onSort:O,children:"User"}),e.jsx(yl,{sortKey:"brokerage",currentSortKey:L,currentDirection:I,onSort:O,children:"Brokerage"}),e.jsx(St,{children:"Last Activity"}),e.jsx(yl,{sortKey:"last_activity_at",currentSortKey:L,currentDirection:I,onSort:O,children:"Last Active"}),e.jsx(yl,{sortKey:"apps",currentSortKey:L,currentDirection:I,onSort:O,className:"text-right",children:"Apps"}),e.jsx(yl,{sortKey:"content",currentSortKey:L,currentDirection:I,onSort:O,className:"text-right",children:"Content"})]})}),e.jsx(zn,{children:B.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):B.map(V=>e.jsxs(Ss,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>S(V),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:V.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:V.user_email})]})}),e.jsx(dt,{children:V.brokerage_name?e.jsx(st,{variant:"outline",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:e.jsx("div",{className:"flex items-center gap-2",children:V.last_activity_type==="app"?e.jsxs(st,{variant:"secondary",children:[e.jsx(tn,{className:"h-3 w-3 mr-1"}),V.last_activity_name]}):e.jsxs(st,{variant:"outline",className:"flex items-center gap-1",children:[T8e(V.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:V.last_activity_name})]})})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(V.last_activity_at),{addSuffix:!0})}),e.jsx(dt,{className:"text-right",children:e.jsx(st,{variant:"outline",children:V.total_app_launches})}),e.jsx(dt,{className:"text-right",children:e.jsx(st,{variant:"outline",children:V.total_content_views})})]},V.user_id))})]})})]})]}),e.jsx(fs,{open:!!f,onOpenChange:V=>!V&&M(),children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Gr,{children:f==null?void 0:f.email})]}),e.jsxs(ba,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ns,{value:"content",children:["Content (",j.length,")"]}),e.jsxs(ns,{value:"apps",children:["App Launches (",b.length,")"]})]}),e.jsx(bs,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Resource"}),e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Time"})]})}),e.jsx(zn,{children:j.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):j.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs(st,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[T8e(V.resource_type),tWt(V.resource_type)]})}),e.jsx(dt,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:V.resource_title})}),e.jsx(dt,{children:e.jsx(st,{variant:"secondary",children:sWt(V.action_type)})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(V.created_at),{addSuffix:!0})})]},V.id))})]})})}),e.jsx(bs,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"App"}),e.jsx(St,{children:"Time"})]})}),e.jsx(zn,{children:b.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):b.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(st,{variant:"secondary",children:V.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(V.launched_at),{addSuffix:!0})})]},V.id))})]})})})]})]})})]})},nWt=()=>{const{toast:t}=Ua(),[s,r]=k.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=k.useState(!0);k.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await H.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await H.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),c=(l||0)-(i||0),{count:u}=await H.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await H.from("activity_logs").select("*",{count:"exact",head:!0}),f=new Date;f.setDate(f.getDate()-7);const{count:g}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",f.toISOString()),b=new Date;b.setMonth(b.getMonth()-1);const{count:_}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",b.toISOString()),{data:j}=await H.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),w=new Set(j==null?void 0:j.map(N=>N.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:c,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:g||0,launchesThisMonth:_||0,uniqueActiveThisWeek:w})}catch(l){console.error("Error loading analytics:",l),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalUsers}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.activeUsers," active, ",s.pendingUsers," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.activeUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.totalUsers>0?`${Math.round(s.activeUsers/s.totalUsers*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.pendingUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalBrokerages}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(ul,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},A8e={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},E8e={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 Itt({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(""),[c,u]=k.useState("all");k.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let O=[];if(t&&s){const{data:X}=await H.from("profiles").select("id").eq("brokerage_id",s);if(O=(X==null?void 0:X.map(ie=>ie.id))||[],O.length===0){n([]),o(!1);return}}let q=H.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&O.length>0&&(q=q.or(`sender_id.in.(${O.join(",")}),recipient_id.in.(${O.join(",")})`));const{data:U,error:B}=await q;if(B)throw B;const V=new Set;U==null||U.forEach(X=>{V.add(X.sender_id),V.add(X.recipient_id)});const{data:Y}=await H.from("profiles").select("id, name, email").in("id",Array.from(V)),Q=new Map((Y==null?void 0:Y.map(X=>[X.id,X]))||[]),ee=(U==null?void 0:U.map(X=>({...X,sender:Q.get(X.sender_id),recipient:Q.get(X.recipient_id)})))||[];n(ee)}catch(O){console.error("Error loading shares:",O)}finally{o(!1)}},{sortKey:f,sortDirection:g,handleSort:b,sortData:_}=QO("created_at","desc"),j=r.filter(O=>{var B,V;const q=l===""||O.resource_title.toLowerCase().includes(l.toLowerCase())||((B=O.sender)==null?void 0:B.name.toLowerCase().includes(l.toLowerCase()))||((V=O.recipient)==null?void 0:V.name.toLowerCase().includes(l.toLowerCase())),U=c==="all"||O.resource_type===c;return q&&U}),w=_(j,{resource:O=>{var q;return((q=O.resource_title)==null?void 0:q.toLowerCase())||""},type:O=>O.resource_type,sender:O=>{var q,U;return((U=(q=O.sender)==null?void 0:q.name)==null?void 0:U.toLowerCase())||""},recipient:O=>{var q,U;return((U=(q=O.recipient)==null?void 0:q.name)==null?void 0:U.toLowerCase())||""},status:O=>O.is_read?1:0,created_at:O=>new Date(O.created_at).getTime()}),N=r.length,S=new Set(r.map(O=>O.sender_id)).size,M=new Set(r.map(O=>O.recipient_id)).size,L=r.length>0?Math.round(r.filter(O=>O.is_read).length/r.length*100):0,I=r.reduce((O,q)=>(O[q.resource_type]=(O[q.resource_type]||0)+1,O),{});return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((O,q)=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(ys,{className:"h-8 w-16"})})]},q))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(ys,{className:"h-[300px]"})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(wd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:N})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:S})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(ul,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:M})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[L,"%"]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(I).map(([O,q])=>e.jsxs(st,{variant:"secondary",className:E8e[O],children:[A8e[O],": ",q]},O)),Object.keys(I).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Share History"}),e.jsxs(gr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:O=>i(O.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:c,onValueChange:u,children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Resource type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),e.jsx(Mt,{value:"event",children:"Events"}),e.jsx(Mt,{value:"template",children:"Templates"}),e.jsx(Mt,{value:"academy_video",children:"Academy Videos"}),e.jsx(Mt,{value:"resource_kit",children:"Resource Kits"}),e.jsx(Mt,{value:"newsletter",children:"Newsletters"}),e.jsx(Mt,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(Gi,{className:"h-[400px]",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(yl,{sortKey:"resource",currentSortKey:f,currentDirection:g,onSort:b,children:"Resource"}),e.jsx(yl,{sortKey:"type",currentSortKey:f,currentDirection:g,onSort:b,children:"Type"}),e.jsx(yl,{sortKey:"sender",currentSortKey:f,currentDirection:g,onSort:b,children:"Sender"}),e.jsx(yl,{sortKey:"recipient",currentSortKey:f,currentDirection:g,onSort:b,children:"Recipient"}),e.jsx(yl,{sortKey:"status",currentSortKey:f,currentDirection:g,onSort:b,children:"Status"}),e.jsx(yl,{sortKey:"created_at",currentSortKey:f,currentDirection:g,onSort:b,children:"Date"})]})}),e.jsx(zn,{children:w.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):w.map(O=>{var q,U;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium max-w-[200px] truncate",children:O.resource_title}),e.jsx(dt,{children:e.jsx(st,{variant:"secondary",className:E8e[O.resource_type],children:A8e[O.resource_type]})}),e.jsx(dt,{children:((q=O.sender)==null?void 0:q.name)||"Unknown"}),e.jsx(dt,{children:((U=O.recipient)==null?void 0:U.name)||"Unknown"}),e.jsx(dt,{children:e.jsx(st,{variant:O.is_read?"default":"outline",children:O.is_read?"Read":"Unread"})}),e.jsx(dt,{className:"text-muted-foreground",children:ms(new Date(O.created_at),"MMM d, yyyy")})]},O.id)})})]})})]})]})]})}const zge={academy_video:{label:"Academy Videos",icon:An,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:Ln},template:{label:"Templates",icon:zv,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:wh},toolbox:{label:"Toolkit",icon:ty,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:yi},newsletter:{label:"Newsletters",icon:cr,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:wh},social_swag:{label:"Social Swag",icon:ic,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:wh},event:{label:"Events",icon:hn,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:wh}};function P8e(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function aWt(t,s){return t==="toolbox"?s.downloads:s.clicks}function iWt(){var O;const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(null),l=k.useRef(null),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=QO("total_views","desc");k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:q,error:U}=await H.rpc("get_admin_content_engagement");if(U)throw U;s(q||[])}catch(q){console.error("Error loading content engagement:",q)}finally{n(!1)}},g=q=>{o(U=>{const B=U===q?null:q;return requestAnimationFrame(()=>{var V;(V=l.current)==null||V.scrollIntoView({behavior:"smooth",block:"start"})}),B})};if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-4",children:[...Array(4)].map((q,U)=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(ys,{className:"h-8 w-16"})})]},U))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8",children:e.jsx(ys,{className:"h-64 w-full"})})})]});const b=t.reduce((q,U)=>q+U.total_views,0),_=t.reduce((q,U)=>q+U.total_clicks,0),j=t.reduce((q,U)=>q+U.total_downloads,0),w=t.length,N=t.reduce((q,U)=>(q[U.resource_type]||(q[U.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),q[U.resource_type].views+=U.total_views,q[U.resource_type].clicks+=U.total_clicks,q[U.resource_type].downloads+=U.total_downloads,q[U.resource_type].assets+=1,q[U.resource_type].uniqueUsers+=U.unique_users,q),{}),S=a?t.filter(q=>q.resource_type===a):t,M=p(S,{asset:q=>{var U;return((U=q.resource_title)==null?void 0:U.toLowerCase())||""},type:q=>q.resource_type,views:q=>q.total_views,actions:q=>P8e(q),unique_users:q=>q.unique_users,last_activity:q=>q.last_engaged_at?new Date(q.last_engaged_at).getTime():0}),L=a?zge[a]||{label:a,icon:Ln,actionLabel:"Actions"}:null,I=L==null?void 0:L.icon;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-5",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(Ln,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:b.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all content"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(wh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:_.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link & Canva clicks"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(ul,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(wh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[b>0?Math.round((_+j)/b*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(gr,{children:"Click a category to see individual asset performance"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(N).map(([q,U])=>{const B=zge[q]||{label:q,icon:Ln,color:"bg-muted text-muted-foreground",actionIcon:wh},V=B.icon,Y=a===q;return e.jsxs("button",{type:"button",onClick:()=>g(q),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${Y?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${B.color}`,children:e.jsx(V,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:B.label}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ln,{className:"h-3 w-3"})," ",U.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B.actionIcon,{className:"h-3 w-3"})," ",aWt(q,U)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pr,{className:"h-3 w-3"})," ",U.uniqueUsers]})]})]}),e.jsxs(st,{variant:"secondary",className:"text-[10px]",children:[U.assets," items"]})]},q)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{className:"text-sm font-medium flex items-center gap-2",children:L&&I?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"h-4 w-4"}),L.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(gr,{children:a?`${S.length} ${((O=L==null?void 0:L.label)==null?void 0:O.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(Ja,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Oe,{children:S.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No engagement data yet. As users view and click content, stats will appear here."}):e.jsx(Gi,{className:"h-[400px]",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[40px]",children:"#"}),e.jsx(yl,{sortKey:"asset",currentSortKey:i,currentDirection:c,onSort:u,children:"Asset"}),!a&&e.jsx(yl,{sortKey:"type",currentSortKey:i,currentDirection:c,onSort:u,children:"Type"}),e.jsx(yl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Views"}),e.jsx(yl,{sortKey:"actions",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:L?L.actionLabel:"Actions"}),e.jsx(yl,{sortKey:"unique_users",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(yl,{sortKey:"last_activity",currentSortKey:i,currentDirection:c,onSort:u,children:"Last Activity"})]})}),e.jsx(zn,{children:M.map((q,U)=>{const B=zge[q.resource_type]||{label:q.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-muted-foreground text-xs",children:U+1}),e.jsx(dt,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:q.resource_title})}),!a&&e.jsx(dt,{children:e.jsx(st,{className:`text-[10px] ${B.color}`,children:B.label})}),e.jsx(dt,{className:"text-right font-medium",children:q.total_views}),e.jsx(dt,{className:"text-right font-medium",children:P8e(q)}),e.jsx(dt,{className:"text-right",children:q.unique_users}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:q.last_engaged_at?Uc(new Date(q.last_engaged_at),{addSuffix:!0}):"—"})]},`${q.resource_type}-${q.resource_id}`)})})]})})})]})})]})}var oWt=Array.isArray,Ip=oWt,lWt=typeof Gv=="object"&&Gv&&Gv.Object===Object&&Gv,Ltt=lWt,cWt=Ltt,dWt=typeof self=="object"&&self&&self.Object===Object&&self,uWt=cWt||dWt||Function("return this")(),q0=uWt,hWt=q0,mWt=hWt.Symbol,aR=mWt,I8e=aR,Dtt=Object.prototype,pWt=Dtt.hasOwnProperty,fWt=Dtt.toString,JP=I8e?I8e.toStringTag:void 0;function xWt(t){var s=pWt.call(t,JP),r=t[JP];try{t[JP]=void 0;var n=!0}catch{}var a=fWt.call(t);return n&&(s?t[JP]=r:delete t[JP]),a}var gWt=xWt,yWt=Object.prototype,vWt=yWt.toString;function bWt(t){return vWt.call(t)}var _Wt=bWt,L8e=aR,wWt=gWt,jWt=_Wt,NWt="[object Null]",kWt="[object Undefined]",D8e=L8e?L8e.toStringTag:void 0;function SWt(t){return t==null?t===void 0?kWt:NWt:D8e&&D8e in Object(t)?wWt(t):jWt(t)}var q1=SWt;function CWt(t){return t!=null&&typeof t=="object"}var U1=CWt,MWt=q1,TWt=U1,AWt="[object Symbol]";function EWt(t){return typeof t=="symbol"||TWt(t)&&MWt(t)==AWt}var mE=EWt,PWt=Ip,IWt=mE,LWt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,DWt=/^\w*$/;function OWt(t,s){if(PWt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||IWt(t)?!0:DWt.test(t)||!LWt.test(t)||s!=null&&t in Object(s)}var Xke=OWt;function RWt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var zw=RWt;const pE=Po(zw);var FWt=q1,zWt=zw,BWt="[object AsyncFunction]",$Wt="[object Function]",qWt="[object GeneratorFunction]",UWt="[object Proxy]";function VWt(t){if(!zWt(t))return!1;var s=FWt(t);return s==$Wt||s==qWt||s==BWt||s==UWt}var Qke=VWt;const Mi=Po(Qke);var HWt=q0,WWt=HWt["__core-js_shared__"],GWt=WWt,Bge=GWt,O8e=function(){var t=/[^.]+$/.exec(Bge&&Bge.keys&&Bge.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function KWt(t){return!!O8e&&O8e in t}var ZWt=KWt,YWt=Function.prototype,XWt=YWt.toString;function QWt(t){if(t!=null){try{return XWt.call(t)}catch{}try{return t+""}catch{}}return""}var Ott=QWt,JWt=Qke,eGt=ZWt,tGt=zw,sGt=Ott,rGt=/[\\^$.*+?()[\]{}|]/g,nGt=/^\[object .+?Constructor\]$/,aGt=Function.prototype,iGt=Object.prototype,oGt=aGt.toString,lGt=iGt.hasOwnProperty,cGt=RegExp("^"+oGt.call(lGt).replace(rGt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function dGt(t){if(!tGt(t)||eGt(t))return!1;var s=JWt(t)?cGt:nGt;return s.test(sGt(t))}var uGt=dGt;function hGt(t,s){return t==null?void 0:t[s]}var mGt=hGt,pGt=uGt,fGt=mGt;function xGt(t,s){var r=fGt(t,s);return pGt(r)?r:void 0}var wC=xGt,gGt=wC,yGt=gGt(Object,"create"),Xue=yGt,R8e=Xue;function vGt(){this.__data__=R8e?R8e(null):{},this.size=0}var bGt=vGt;function _Gt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var wGt=_Gt,jGt=Xue,NGt="__lodash_hash_undefined__",kGt=Object.prototype,SGt=kGt.hasOwnProperty;function CGt(t){var s=this.__data__;if(jGt){var r=s[t];return r===NGt?void 0:r}return SGt.call(s,t)?s[t]:void 0}var MGt=CGt,TGt=Xue,AGt=Object.prototype,EGt=AGt.hasOwnProperty;function PGt(t){var s=this.__data__;return TGt?s[t]!==void 0:EGt.call(s,t)}var IGt=PGt,LGt=Xue,DGt="__lodash_hash_undefined__";function OGt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=LGt&&s===void 0?DGt:s,this}var RGt=OGt,FGt=bGt,zGt=wGt,BGt=MGt,$Gt=IGt,qGt=RGt;function fE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var aKt=nKt,iKt=Que;function oKt(t,s){var r=this.__data__,n=iKt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var lKt=oKt,cKt=HGt,dKt=JGt,uKt=sKt,hKt=aKt,mKt=lKt;function xE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},C4=function(s){return eC(s)&&s.indexOf("%")===s.length-1},ln=function(s){return IZt(s)&&!iR(s)},RZt=function(s){return $i(s)},ju=function(s){return ln(s)||eC(s)},FZt=0,yE=function(s){var r=++FZt;return"".concat(s||"").concat(r)},Am=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!ln(s)&&!eC(s))return n;var o;if(C4(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return iR(o)&&(o=n),a&&o>r&&(o=r),o},l_=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},zZt=function(s){if(!Array.isArray(s))return!1;for(var r=s.length,n={},a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function WZt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function mbe(t){"@babel/helpers - typeof";return mbe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},mbe(t)}var V8e={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"},y1=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},H8e=null,qge=null,l4e=function t(s){if(s===H8e&&Array.isArray(qge))return qge;var r=[];return k.Children.forEach(s,function(n){$i(n)||(MZt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),qge=r,H8e=s,r};function Nf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return y1(a)}):n=[y1(s)],l4e(t).forEach(function(a){var o=jf(a,"type.displayName")||jf(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function sf(t,s){var r=Nf(t,s);return r&&r[0]}var W8e=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!ln(n)||n<=0||!ln(a)||a<=0)},GZt=["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"],KZt=function(s){return s&&s.type&&eC(s.type)&&GZt.indexOf(s.type)>=0},ZZt=function(s){return s&&mbe(s)==="object"&&"clipDot"in s},YZt=function(s,r,n,a){var o,l=(o=$ge==null?void 0:$ge[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!Mi(s)&&(a&&l.includes(r)||qZt.includes(r))||n&&o4e.includes(r)},ai=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(k.isValidElement(s)&&(a=s.props),!pE(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;YZt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},pbe=function t(s,r){if(s===r)return!0;var n=k.Children.count(s);if(n!==k.Children.count(r))return!1;if(n===0)return!0;if(n===1)return G8e(Array.isArray(s)?s[0]:s,Array.isArray(r)?r[0]:r);for(var a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function tYt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function xbe(t){var s=t.children,r=t.width,n=t.height,a=t.viewBox,o=t.className,l=t.style,i=t.title,c=t.desc,u=eYt(t,JZt),p=a||{width:r,height:n,x:0,y:0},f=Vi("recharts-surface",o);return ht.createElement("svg",fbe({},ai(u,!0,"svg"),{className:f,width:r,height:n,style:l,viewBox:"".concat(p.x," ").concat(p.y," ").concat(p.width," ").concat(p.height)}),ht.createElement("title",null,i),ht.createElement("desc",null,c),s)}var sYt=["children","className"];function gbe(){return gbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function nYt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Zo=ht.forwardRef(function(t,s){var r=t.children,n=t.className,a=rYt(t,sYt),o=Vi("recharts-layer",n);return ht.createElement("g",gbe({className:o},ai(a,!0),{ref:s}),r)}),ry=function(s,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),o=2;oa?0:a+s),r=r>a?a:r,r<0&&(r+=a),a=s>r?0:r-s>>>0,s>>>=0;for(var o=Array(a);++n=n?t:oYt(t,s,r)}var cYt=lYt,dYt="\\ud800-\\udfff",uYt="\\u0300-\\u036f",hYt="\\ufe20-\\ufe2f",mYt="\\u20d0-\\u20ff",pYt=uYt+hYt+mYt,fYt="\\ufe0e\\ufe0f",xYt="\\u200d",gYt=RegExp("["+xYt+dYt+pYt+fYt+"]");function yYt(t){return gYt.test(t)}var Wtt=yYt;function vYt(t){return t.split("")}var bYt=vYt,Gtt="\\ud800-\\udfff",_Yt="\\u0300-\\u036f",wYt="\\ufe20-\\ufe2f",jYt="\\u20d0-\\u20ff",NYt=_Yt+wYt+jYt,kYt="\\ufe0e\\ufe0f",SYt="["+Gtt+"]",ybe="["+NYt+"]",vbe="\\ud83c[\\udffb-\\udfff]",CYt="(?:"+ybe+"|"+vbe+")",Ktt="[^"+Gtt+"]",Ztt="(?:\\ud83c[\\udde6-\\uddff]){2}",Ytt="[\\ud800-\\udbff][\\udc00-\\udfff]",MYt="\\u200d",Xtt=CYt+"?",Qtt="["+kYt+"]?",TYt="(?:"+MYt+"(?:"+[Ktt,Ztt,Ytt].join("|")+")"+Qtt+Xtt+")*",AYt=Qtt+Xtt+TYt,EYt="(?:"+[Ktt+ybe+"?",ybe,Ztt,Ytt,SYt].join("|")+")",PYt=RegExp(vbe+"(?="+vbe+")|"+EYt+AYt,"g");function IYt(t){return t.match(PYt)||[]}var LYt=IYt,DYt=bYt,OYt=Wtt,RYt=LYt;function FYt(t){return OYt(t)?RYt(t):DYt(t)}var zYt=FYt,BYt=cYt,$Yt=Wtt,qYt=zYt,UYt=Btt;function VYt(t){return function(s){s=UYt(s);var r=$Yt(s)?qYt(s):void 0,n=r?r[0]:s.charAt(0),a=r?BYt(r,1).join(""):s.slice(1);return n[t]()+a}}var HYt=VYt,WYt=HYt,GYt=WYt("toUpperCase"),KYt=GYt;const hhe=Po(KYt);function Kl(t){return function(){return t}}const Jtt=Math.cos,Kle=Math.sin,fy=Math.sqrt,Zle=Math.PI,mhe=2*Zle,bbe=Math.PI,_be=2*bbe,i4=1e-6,ZYt=_be-i4;function est(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return est;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;ai4)if(!(Math.abs(f*c-u*p)>i4)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let b=n-l,_=a-i,j=c*c+u*u,w=b*b+_*_,N=Math.sqrt(j),S=Math.sqrt(g),M=o*Math.tan((bbe-Math.acos((j+g-w)/(2*N*S)))/2),L=M/S,I=M/N;Math.abs(L-1)>i4&&this._append`L${s+L*p},${r+L*f}`,this._append`A${o},${o},0,0,${+(f*b>p*_)},${this._x1=s+I*c},${this._y1=r+I*u}`}}arc(s,r,n,a,o,l){if(s=+s,r=+r,n=+n,l=!!l,n<0)throw new Error(`negative radius: ${n}`);let i=n*Math.cos(a),c=n*Math.sin(a),u=s+i,p=r+c,f=1^l,g=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>i4||Math.abs(this._y1-p)>i4)&&this._append`L${u},${p}`,n&&(g<0&&(g=g%_be+_be),g>ZYt?this._append`A${n},${n},0,1,${f},${s-i},${r-c}A${n},${n},0,1,${f},${this._x1=u},${this._y1=p}`:g>i4&&this._append`A${n},${n},0,${+(g>=bbe)},${f},${this._x1=s+n*Math.cos(o)},${this._y1=r+n*Math.sin(o)}`)}rect(s,r,n,a){this._append`M${this._x0=this._x1=+s},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function c4e(t){let s=3;return t.digits=function(r){if(!arguments.length)return s;if(r==null)s=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);s=n}return t},()=>new XYt(s)}function d4e(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function tst(t){this._context=t}tst.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;default:this._context.lineTo(t,s);break}}};function phe(t){return new tst(t)}function sst(t){return t[0]}function rst(t){return t[1]}function nst(t,s){var r=Kl(!0),n=null,a=phe,o=null,l=c4e(i);t=typeof t=="function"?t:t===void 0?sst:Kl(t),s=typeof s=="function"?s:s===void 0?rst:Kl(s);function i(c){var u,p=(c=d4e(c)).length,f,g=!1,b;for(n==null&&(o=a(b=l())),u=0;u<=p;++u)!(u=b;--_)i.point(M[_],L[_]);i.lineEnd(),i.areaEnd()}N&&(M[g]=+t(w,g,f),L[g]=+s(w,g,f),i.point(n?+n(w,g,f):M[g],r?+r(w,g,f):L[g]))}if(S)return i=null,S+""||null}function p(){return nst().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Kl(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Kl(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Kl(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Kl(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Kl(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Kl(+f),u):r},u.lineX0=u.lineY0=function(){return p().x(t).y(s)},u.lineY1=function(){return p().x(t).y(r)},u.lineX1=function(){return p().x(n).y(s)},u.defined=function(f){return arguments.length?(a=typeof f=="function"?f:Kl(!!f),u):a},u.curve=function(f){return arguments.length?(l=f,o!=null&&(i=l(o)),u):l},u.context=function(f){return arguments.length?(f==null?o=i=null:i=l(o=f),u):o},u}class ast{constructor(s,r){this._context=s,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(s,r){switch(s=+s,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(s,r):this._context.moveTo(s,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+s)/2,this._y0,this._x0,r,s,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,s,this._y0,s,r);break}}this._x0=s,this._y0=r}}function QYt(t){return new ast(t,!0)}function JYt(t){return new ast(t,!1)}const u4e={draw(t,s){const r=fy(s/Zle);t.moveTo(r,0),t.arc(0,0,r,0,mhe)}},eXt={draw(t,s){const r=fy(s/5)/2;t.moveTo(-3*r,-r),t.lineTo(-r,-r),t.lineTo(-r,-3*r),t.lineTo(r,-3*r),t.lineTo(r,-r),t.lineTo(3*r,-r),t.lineTo(3*r,r),t.lineTo(r,r),t.lineTo(r,3*r),t.lineTo(-r,3*r),t.lineTo(-r,r),t.lineTo(-3*r,r),t.closePath()}},ist=fy(1/3),tXt=ist*2,sXt={draw(t,s){const r=fy(s/tXt),n=r*ist;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},rXt={draw(t,s){const r=fy(s),n=-r/2;t.rect(n,n,r,r)}},nXt=.8908130915292852,ost=Kle(Zle/10)/Kle(7*Zle/10),aXt=Kle(mhe/10)*ost,iXt=-Jtt(mhe/10)*ost,oXt={draw(t,s){const r=fy(s*nXt),n=aXt*r,a=iXt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=mhe*o/5,i=Jtt(l),c=Kle(l);t.lineTo(c*r,-i*r),t.lineTo(i*n-c*a,c*n+i*a)}t.closePath()}},Uge=fy(3),lXt={draw(t,s){const r=-fy(s/(Uge*3));t.moveTo(0,r*2),t.lineTo(-Uge*r,-r),t.lineTo(Uge*r,-r),t.closePath()}},Qf=-.5,Jf=fy(3)/2,wbe=1/fy(12),cXt=(wbe/2+1)*3,dXt={draw(t,s){const r=fy(s/cXt),n=r/2,a=r*wbe,o=n,l=r*wbe+r,i=-o,c=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,c),t.lineTo(Qf*n-Jf*a,Jf*n+Qf*a),t.lineTo(Qf*o-Jf*l,Jf*o+Qf*l),t.lineTo(Qf*i-Jf*c,Jf*i+Qf*c),t.lineTo(Qf*n+Jf*a,Qf*a-Jf*n),t.lineTo(Qf*o+Jf*l,Qf*l-Jf*o),t.lineTo(Qf*i+Jf*c,Qf*c-Jf*i),t.closePath()}};function uXt(t,s){let r=null,n=c4e(a);t=typeof t=="function"?t:Kl(t||u4e),s=typeof s=="function"?s:Kl(s===void 0?64:+s);function a(){let o;if(r||(r=o=n()),t.apply(this,arguments).draw(r,+s.apply(this,arguments)),o)return r=null,o+""||null}return a.type=function(o){return arguments.length?(t=typeof o=="function"?o:Kl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Kl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function Yle(){}function Xle(t,s,r){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+s)/6,(t._y0+4*t._y1+r)/6)}function lst(t){this._context=t}lst.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:Xle(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Xle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function hXt(t){return new lst(t)}function cst(t){this._context=t}cst.prototype={areaStart:Yle,areaEnd:Yle,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._x2=t,this._y2=s;break;case 1:this._point=2,this._x3=t,this._y3=s;break;case 2:this._point=3,this._x4=t,this._y4=s,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+s)/6);break;default:Xle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function mXt(t){return new cst(t)}function dst(t){this._context=t}dst.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+t)/6,n=(this._y0+4*this._y1+s)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:Xle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function pXt(t){return new dst(t)}function ust(t){this._context=t}ust.prototype={areaStart:Yle,areaEnd:Yle,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,s){t=+t,s=+s,this._point?this._context.lineTo(t,s):(this._point=1,this._context.moveTo(t,s))}};function fXt(t){return new ust(t)}function Z8e(t){return t<0?-1:1}function Y8e(t,s,r){var n=t._x1-t._x0,a=s-t._x1,o=(t._y1-t._y0)/(n||a<0&&-0),l=(r-t._y1)/(a||n<0&&-0),i=(o*a+l*n)/(n+a);return(Z8e(o)+Z8e(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function X8e(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function Vge(t,s,r){var n=t._x0,a=t._y0,o=t._x1,l=t._y1,i=(o-n)/3;t._context.bezierCurveTo(n+i,a+i*s,o-i,l-i*r,o,l)}function Qle(t){this._context=t}Qle.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:Vge(this,this._t0,X8e(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){var r=NaN;if(t=+t,s=+s,!(t===this._x1&&s===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;break;case 2:this._point=3,Vge(this,X8e(this,r=Y8e(this,t,s)),r);break;default:Vge(this,this._t0,r=Y8e(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function hst(t){this._context=new mst(t)}(hst.prototype=Object.create(Qle.prototype)).point=function(t,s){Qle.prototype.point.call(this,s,t)};function mst(t){this._context=t}mst.prototype={moveTo:function(t,s){this._context.moveTo(s,t)},closePath:function(){this._context.closePath()},lineTo:function(t,s){this._context.lineTo(s,t)},bezierCurveTo:function(t,s,r,n,a,o){this._context.bezierCurveTo(s,t,n,r,o,a)}};function xXt(t){return new Qle(t)}function gXt(t){return new hst(t)}function pst(t){this._context=t}pst.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,s=this._y,r=t.length;if(r)if(this._line?this._context.lineTo(t[0],s[0]):this._context.moveTo(t[0],s[0]),r===2)this._context.lineTo(t[1],s[1]);else for(var n=Q8e(t),a=Q8e(s),o=0,l=1;l=0;--s)a[s]=(l[s]-a[s+1])/o[s];for(o[r-1]=(t[r]+a[r-1])/2,s=0;s=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,s),this._context.lineTo(t,s);else{var r=this._x*(1-this._t)+t*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,s)}break}}this._x=t,this._y=s}};function vXt(t){return new fhe(t,.5)}function bXt(t){return new fhe(t,0)}function _Xt(t){return new fhe(t,1)}function XT(t,s){if((l=t.length)>1)for(var r=1,n,a,o=t[s[0]],l,i=o.length;r=0;)r[s]=s;return r}function wXt(t,s){return t[s]}function jXt(t){const s=[];return s.key=t,s}function NXt(){var t=Kl([]),s=jbe,r=XT,n=wXt;function a(o){var l=Array.from(t.apply(this,arguments),jXt),i,c=l.length,u=-1,p;for(const f of o)for(i=0,++u;i0){for(var r,n,a=0,o=t[0].length,l;a0){for(var r=0,n=t[s[0]],a,o=n.length;r0)||!((o=(a=t[s[0]]).length)>0))){for(var r=0,n=1,a,o,l;n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function IXt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var fst={symbolCircle:u4e,symbolCross:eXt,symbolDiamond:sXt,symbolSquare:rXt,symbolStar:oXt,symbolTriangle:lXt,symbolWye:dXt},LXt=Math.PI/180,DXt=function(s){var r="symbol".concat(hhe(s));return fst[r]||u4e},OXt=function(s,r,n){if(r==="area")return s;switch(n){case"cross":return 5*s*s/9;case"diamond":return .5*s*s/Math.sqrt(3);case"square":return s*s;case"star":{var a=18*LXt;return 1.25*s*s*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*s*s/4;case"wye":return(21-10*Math.sqrt(3))*s*s/8;default:return Math.PI*s*s/4}},RXt=function(s,r){fst["symbol".concat(hhe(s))]=r},h4e=function(s){var r=s.type,n=r===void 0?"circle":r,a=s.size,o=a===void 0?64:a,l=s.sizeType,i=l===void 0?"area":l,c=PXt(s,MXt),u=eDe(eDe({},c),{},{type:n,size:o,sizeType:i}),p=function(){var w=DXt(n),N=uXt().type(w).size(OXt(o,i,n));return N()},f=u.className,g=u.cx,b=u.cy,_=ai(u,!0);return g===+g&&b===+b&&o===+o?ht.createElement("path",Nbe({},_,{className:Vi("recharts-symbols",f),transform:"translate(".concat(g,", ").concat(b,")"),d:p()})):null};h4e.registerSymbol=RXt;function QT(t){"@babel/helpers - typeof";return QT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},QT(t)}function kbe(){return kbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var S=b.inactive?u:b.color;return ht.createElement("li",kbe({className:w,style:f,key:"legend-item-".concat(_)},tC(n.props,b,_)),ht.createElement(xbe,{width:l,height:l,viewBox:p,style:g},n.renderIcon(b)),ht.createElement("span",{className:"recharts-legend-item-text",style:{color:S}},j?j(N,b,_):N))})}},{key:"render",value:function(){var n=this.props,a=n.payload,o=n.layout,l=n.align;if(!a||!a.length)return null;var i={padding:0,margin:0,textAlign:o==="horizontal"?l:"left"};return ht.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(k.PureComponent);kD(m4e,"displayName","Legend");kD(m4e,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var GXt=Jue;function KXt(){this.__data__=new GXt,this.size=0}var ZXt=KXt;function YXt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var XXt=YXt;function QXt(t){return this.__data__.get(t)}var JXt=QXt;function eQt(t){return this.__data__.has(t)}var tQt=eQt,sQt=Jue,rQt=e4e,nQt=t4e,aQt=200;function iQt(t,s){var r=this.__data__;if(r instanceof sQt){var n=r.__data__;if(!rQt||n.lengthi))return!1;var u=o.get(t),p=o.get(s);if(u&&p)return u==s&&p==t;var f=-1,g=!0,b=r&MQt?new NQt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=PJt}var g4e=IJt,LJt=q1,DJt=g4e,OJt=U1,RJt="[object Arguments]",FJt="[object Array]",zJt="[object Boolean]",BJt="[object Date]",$Jt="[object Error]",qJt="[object Function]",UJt="[object Map]",VJt="[object Number]",HJt="[object Object]",WJt="[object RegExp]",GJt="[object Set]",KJt="[object String]",ZJt="[object WeakMap]",YJt="[object ArrayBuffer]",XJt="[object DataView]",QJt="[object Float32Array]",JJt="[object Float64Array]",ees="[object Int8Array]",tes="[object Int16Array]",ses="[object Int32Array]",res="[object Uint8Array]",nes="[object Uint8ClampedArray]",aes="[object Uint16Array]",ies="[object Uint32Array]",fc={};fc[QJt]=fc[JJt]=fc[ees]=fc[tes]=fc[ses]=fc[res]=fc[nes]=fc[aes]=fc[ies]=!0;fc[RJt]=fc[FJt]=fc[YJt]=fc[zJt]=fc[XJt]=fc[BJt]=fc[$Jt]=fc[qJt]=fc[UJt]=fc[VJt]=fc[HJt]=fc[WJt]=fc[GJt]=fc[KJt]=fc[ZJt]=!1;function oes(t){return OJt(t)&&DJt(t.length)&&!!fc[LJt(t)]}var les=oes;function ces(t){return function(s){return t(s)}}var Sst=ces,sce={exports:{}};sce.exports;(function(t,s){var r=Ltt,n=s&&!s.nodeType&&s,a=n&&!0&&t&&!t.nodeType&&t,o=a&&a.exports===n,l=o&&r.process,i=function(){try{var c=a&&a.require&&a.require("util").types;return c||l&&l.binding&&l.binding("util")}catch{}}();t.exports=i})(sce,sce.exports);var des=sce.exports,ues=les,hes=Sst,oDe=des,lDe=oDe&&oDe.isTypedArray,mes=lDe?hes(lDe):ues,Cst=mes,pes=gJt,fes=f4e,xes=Ip,ges=kst,yes=x4e,ves=Cst,bes=Object.prototype,_es=bes.hasOwnProperty;function wes(t,s){var r=xes(t),n=!r&&fes(t),a=!r&&!n&&ges(t),o=!r&&!n&&!a&&ves(t),l=r||n||a||o,i=l?pes(t.length,String):[],c=i.length;for(var u in t)(s||_es.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||yes(u,c)))&&i.push(u);return i}var jes=wes,Nes=Object.prototype;function kes(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||Nes;return t===r}var Ses=kes;function Ces(t,s){return function(r){return t(s(r))}}var Mst=Ces,Mes=Mst,Tes=Mes(Object.keys,Object),Aes=Tes,Ees=Ses,Pes=Aes,Ies=Object.prototype,Les=Ies.hasOwnProperty;function Des(t){if(!Ees(t))return Pes(t);var s=[];for(var r in Object(t))Les.call(t,r)&&r!="constructor"&&s.push(r);return s}var Oes=Des,Res=Qke,Fes=g4e;function zes(t){return t!=null&&Fes(t.length)&&!Res(t)}var oR=zes,Bes=jes,$es=Oes,qes=oR;function Ues(t){return qes(t)?Bes(t):$es(t)}var xhe=Ues,Ves=aJt,Hes=fJt,Wes=xhe;function Ges(t){return Ves(t,Wes,Hes)}var Kes=Ges,cDe=Kes,Zes=1,Yes=Object.prototype,Xes=Yes.hasOwnProperty;function Qes(t,s,r,n,a,o){var l=r&Zes,i=cDe(t),c=i.length,u=cDe(s),p=u.length;if(c!=p&&!l)return!1;for(var f=c;f--;){var g=i[f];if(!(l?g in s:Xes.call(s,g)))return!1}var b=o.get(t),_=o.get(s);if(b&&_)return b==s&&_==t;var j=!0;o.set(t,s),o.set(s,t);for(var w=l;++f-1}var Yss=Zss;function Xss(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=hrs){var u=s?null:drs(t);if(u)return urs(u);l=!1,a=crs,c=new irs}else c=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Mrs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Trs(t){return t.value}function Ars(t,s){if(ht.isValidElement(t))return ht.cloneElement(t,s);if(typeof t=="function")return ht.createElement(t,s);s.ref;var r=Crs(s,vrs);return ht.createElement(m4e,r)}var kDe=1,aT=function(t){function s(){var r;brs(this,s);for(var n=arguments.length,a=new Array(n),o=0;okDe||Math.abs(a.height-this.lastBoundingBox.height)>kDe)&&(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?Cv({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,o=a.layout,l=a.align,i=a.verticalAlign,c=a.margin,u=a.chartWidth,p=a.chartHeight,f,g;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(l==="center"&&o==="vertical"){var b=this.getBBoxSnapshot();f={left:((u||0)-b.width)/2}}else f=l==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(i==="middle"){var _=this.getBBoxSnapshot();g={top:((p||0)-_.height)/2}}else g=i==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return Cv(Cv({},f),g)}},{key:"render",value:function(){var n=this,a=this.props,o=a.content,l=a.width,i=a.height,c=a.wrapperStyle,u=a.payloadUniqBy,p=a.payload,f=Cv(Cv({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(c)),c);return ht.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(b){n.wrapperNode=b}},Ars(o,Cv(Cv({},this.props),{},{payload:Dst(p,u,Trs)})))}}],[{key:"getWithHeight",value:function(n,a){var o=Cv(Cv({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&ln(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(k.PureComponent);ghe(aT,"displayName","Legend");ghe(aT,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var SDe=aR,Ers=f4e,Prs=Ip,CDe=SDe?SDe.isConcatSpreadable:void 0;function Irs(t){return Prs(t)||Ers(t)||!!(CDe&&t&&t[CDe])}var Lrs=Irs,Drs=jst,Ors=Lrs;function Fst(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=Ors),a||(a=[]);++o0&&r(i)?s>1?Fst(i,s-1,r,n,a):Drs(a,i):n||(a[a.length]=i)}return a}var zst=Fst;function Rrs(t){return function(s,r,n){for(var a=-1,o=Object(s),l=n(s),i=l.length;i--;){var c=l[t?i:++a];if(r(o[c],c,o)===!1)break}return s}}var Frs=Rrs,zrs=Frs,Brs=zrs(),$rs=Brs,qrs=$rs,Urs=xhe;function Vrs(t,s){return t&&qrs(t,s,Urs)}var Bst=Vrs,Hrs=oR;function Wrs(t,s){return function(r,n){if(r==null)return r;if(!Hrs(r))return t(r,n);for(var a=r.length,o=s?a:-1,l=Object(r);(s?o--:++os||o&&l&&c&&!i&&!u||n&&l&&c||!r&&c||!a)return 1;if(!n&&!o&&!u&&t=i)return c;var u=r[n];return c*(u=="desc"?-1:1)}}return t.index-s.index}var ins=ans,Kge=r4e,ons=n4e,lns=U0,cns=$st,dns=tns,uns=Sst,hns=ins,mns=_E,pns=Ip;function fns(t,s,r){s.length?s=Kge(s,function(o){return pns(o)?function(l){return ons(l,o.length===1?o[0]:o)}:o}):s=[mns];var n=-1;s=Kge(s,uns(lns));var a=cns(t,function(o,l,i){var c=Kge(s,function(u){return u(o)});return{criteria:c,index:++n,value:o}});return dns(a,function(o,l){return hns(o,l,r)})}var xns=fns;function gns(t,s,r){switch(r.length){case 0:return t.call(s);case 1:return t.call(s,r[0]);case 2:return t.call(s,r[0],r[1]);case 3:return t.call(s,r[0],r[1],r[2])}return t.apply(s,r)}var yns=gns,vns=yns,TDe=Math.max;function bns(t,s,r){return s=TDe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=TDe(n.length-s,0),l=Array(o);++a0){if(++s>=Ans)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var Lns=Ins,Dns=Tns,Ons=Lns,Rns=Ons(Dns),Fns=Rns,zns=_E,Bns=_ns,$ns=Fns;function qns(t,s){return $ns(Bns(t,s,zns),t+"")}var Uns=qns,Vns=Jke,Hns=oR,Wns=x4e,Gns=zw;function Kns(t,s,r){if(!Gns(r))return!1;var n=typeof s;return(n=="number"?Hns(r)&&Wns(s,r.length):n=="string"&&s in r)?Vns(r[s],t):!1}var yhe=Kns,Zns=zst,Yns=xns,Xns=Uns,EDe=yhe,Qns=Xns(function(t,s){if(t==null)return[];var r=s.length;return r>1&&EDe(t,s[0],s[1])?s=[]:r>2&&EDe(s[0],s[1],s[2])&&(s=[s[0]]),Yns(t,Zns(s,1),[])}),Jns=Qns;const b4e=Po(Jns);function SD(t){"@babel/helpers - typeof";return SD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},SD(t)}function Ibe(){return Ibe=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s.x),"".concat(eI,"-left"),ln(r)&&s&&ln(s.x)&&r=s.y),"".concat(eI,"-top"),ln(n)&&s&&ln(s.y)&&nj?Math.max(p,c[n]):Math.max(f,c[n])}function pas(t){var s=t.translateX,r=t.translateY,n=t.useTranslate3d;return{transform:n?"translate3d(".concat(s,"px, ").concat(r,"px, 0)"):"translate(".concat(s,"px, ").concat(r,"px)")}}function fas(t){var s=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,a=t.position,o=t.reverseDirection,l=t.tooltipBox,i=t.useTranslate3d,c=t.viewBox,u,p,f;return l.height>0&&l.width>0&&r?(p=LDe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:c,viewBoxDimension:c.width}),f=LDe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:c,viewBoxDimension:c.height}),u=pas({translateX:p,translateY:f,useTranslate3d:i})):u=has,{cssProperties:u,cssClasses:mas({translateX:p,translateY:f,coordinate:r})}}function eA(t){"@babel/helpers - typeof";return eA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},eA(t)}function DDe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function ODe(t){for(var s=1;sRDe||Math.abs(n.height-this.state.lastBoundingBox.height)>RDe)&&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,c=a.animationEasing,u=a.children,p=a.coordinate,f=a.hasPayload,g=a.isAnimationActive,b=a.offset,_=a.position,j=a.reverseDirection,w=a.useTranslate3d,N=a.viewBox,S=a.wrapperStyle,M=fas({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:b,position:_,reverseDirection:j,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:N}),L=M.cssClasses,I=M.cssProperties,O=ODe(ODe({transition:g&&o?"transform ".concat(i,"ms ").concat(c):void 0},I),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},S);return ht.createElement("div",{tabIndex:-1,className:L,style:O,ref:function(U){n.wrapperNode=U}},u)}}])}(k.PureComponent),kas=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},jC={isSsr:kas()};function tA(t){"@babel/helpers - typeof";return tA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},tA(t)}function FDe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function zDe(t){for(var s=1;s0;return ht.createElement(Nas,{allowEscapeViewBox:l,animationDuration:i,animationEasing:c,isAnimationActive:g,active:o,coordinate:p,hasPayload:O,offset:b,position:w,reverseDirection:N,useTranslate3d:S,viewBox:M,wrapperStyle:L},Das(u,zDe(zDe({},this.props),{},{payload:I})))}}])}(k.PureComponent);_4e(hp,"displayName","Tooltip");_4e(hp,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!jC.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 Oas=q0,Ras=function(){return Oas.Date.now()},Fas=Ras,zas=/\s/;function Bas(t){for(var s=t.length;s--&&zas.test(t.charAt(s)););return s}var $as=Bas,qas=$as,Uas=/^\s+/;function Vas(t){return t&&t.slice(0,qas(t)+1).replace(Uas,"")}var Has=Vas,Was=Has,BDe=zw,Gas=mE,$De=NaN,Kas=/^[-+]0x[0-9a-f]+$/i,Zas=/^0b[01]+$/i,Yas=/^0o[0-7]+$/i,Xas=parseInt;function Qas(t){if(typeof t=="number")return t;if(Gas(t))return $De;if(BDe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=BDe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=Was(t);var r=Zas.test(t);return r||Yas.test(t)?Xas(t.slice(2),r?2:8):Kas.test(t)?$De:+t}var Gst=Qas,Jas=zw,Yge=Fas,qDe=Gst,eis="Expected a function",tis=Math.max,sis=Math.min;function ris(t,s,r){var n,a,o,l,i,c,u=0,p=!1,f=!1,g=!0;if(typeof t!="function")throw new TypeError(eis);s=qDe(s)||0,Jas(r)&&(p=!!r.leading,f="maxWait"in r,o=f?tis(qDe(r.maxWait)||0,s):o,g="trailing"in r?!!r.trailing:g);function b(O){var q=n,U=a;return n=a=void 0,u=O,l=t.apply(U,q),l}function _(O){return u=O,i=setTimeout(N,s),p?b(O):l}function j(O){var q=O-c,U=O-u,B=s-q;return f?sis(B,o-U):B}function w(O){var q=O-c,U=O-u;return c===void 0||q>=s||q<0||f&&U>=o}function N(){var O=Yge();if(w(O))return S(O);i=setTimeout(N,j(O))}function S(O){return i=void 0,g&&n?b(O):(n=a=void 0,l)}function M(){i!==void 0&&clearTimeout(i),u=0,n=c=a=i=void 0}function L(){return i===void 0?l:S(Yge())}function I(){var O=Yge(),q=w(O);if(n=arguments,a=this,c=O,q){if(i===void 0)return _(c);if(f)return clearTimeout(i),i=setTimeout(N,s),b(c)}return i===void 0&&(i=setTimeout(N,s)),l}return I.cancel=M,I.flush=L,I}var nis=ris,ais=nis,iis=zw,ois="Expected a function";function lis(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(ois);return iis(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),ais(t,s,{leading:n,maxWait:s,trailing:a})}var cis=lis;const Kst=Po(cis);function MD(t){"@babel/helpers - typeof";return MD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},MD(t)}function UDe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Iz(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(ee=Kst(ee,j,{trailing:!0,leading:!1}));var X=new ResizeObserver(ee),ie=I.current.getBoundingClientRect(),re=ie.width,oe=ie.height;return Y(re,oe),X.observe(I.current),function(){X.disconnect()}},[Y,j]);var Q=k.useMemo(function(){var ee=B.containerWidth,X=B.containerHeight;if(ee<0||X<0)return null;ry(C4(l)||C4(c),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,c),ry(!r||r>0,"The aspect(%s) must be greater than zero.",r);var ie=C4(l)?ee:l,re=C4(c)?X:c;r&&r>0&&(ie?re=ie/r:re&&(ie=re*r),g&&re>g&&(re=g)),ry(ie>0||re>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,ie,re,l,c,p,f,r);var oe=!Array.isArray(b)&&y1(b.type).endsWith("Chart");return ht.Children.map(b,function(ce){return ht.isValidElement(ce)?k.cloneElement(ce,Iz({width:ie,height:re},oe?{style:Iz({height:"100%",width:"100%",maxHeight:re,maxWidth:ie},ce.props.style)}:{})):ce})},[r,b,c,g,f,p,B,l]);return ht.createElement("div",{id:w?"".concat(w):void 0,className:Vi("recharts-responsive-container",N),style:Iz(Iz({},L),{},{width:l,height:c,minWidth:p,minHeight:f,maxHeight:g}),ref:I},Q)}),lR=function(s){return null};lR.displayName="Cell";function TD(t){"@babel/helpers - typeof";return TD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},TD(t)}function HDe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Rbe(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||jC.isSsr)return{width:0,height:0};var n=jis(r),a=JSON.stringify({text:s,copyStyle:n});if(T5.widthCache[a])return T5.widthCache[a];try{var o=document.getElementById(WDe);o||(o=document.createElement("span"),o.setAttribute("id",WDe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Rbe(Rbe({},wis),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),c={width:i.width,height:i.height};return T5.widthCache[a]=c,++T5.cacheCount>_is&&(T5.cacheCount=0,T5.widthCache={}),c}catch{return{width:0,height:0}}},Nis=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function AD(t){"@babel/helpers - typeof";return AD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},AD(t)}function ice(t,s){return Mis(t)||Cis(t,s)||Sis(t,s)||kis()}function kis(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sis(t,s){if(t){if(typeof t=="string")return GDe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return GDe(t,s)}}function GDe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function qis(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function JDe(t,s){return Wis(t)||His(t,s)||Vis(t,s)||Uis()}function Uis(){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 Vis(t,s){if(t){if(typeof t=="string")return eOe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return eOe(t,s)}}function eOe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[];return ie.reduce(function(re,oe){var ce=oe.word,ge=oe.width,ye=re[re.length-1];if(ye&&(a==null||o||ye.width+ge+noe.width?re:oe})};if(!p)return b;for(var j="…",w=function(ie){var re=f.slice(0,ie),oe=Qst({breakAll:u,style:c,children:re+j}).wordsWithComputedWidth,ce=g(oe),ge=ce.length>l||_(ce).width>Number(a);return[ge,ce]},N=0,S=f.length-1,M=0,L;N<=S&&M<=f.length-1;){var I=Math.floor((N+S)/2),O=I-1,q=w(O),U=JDe(q,2),B=U[0],V=U[1],Y=w(I),Q=JDe(Y,1),ee=Q[0];if(!B&&!ee&&(N=I+1),B&&ee&&(S=I-1),!B&&ee){L=V;break}M++}return L||b},tOe=function(s){var r=$i(s)?[]:s.toString().split(Xst);return[{words:r}]},Kis=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!jC.isSsr){var c,u,p=Qst({breakAll:l,children:a,style:o});if(p){var f=p.wordsWithComputedWidth,g=p.spaceWidth;c=f,u=g}else return tOe(a);return Gis({breakAll:l,children:a,maxLines:i,style:o},c,u,r,n)}return tOe(a)},sOe="#808080",sC=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.lineHeight,i=l===void 0?"1em":l,c=s.capHeight,u=c===void 0?"0.71em":c,p=s.scaleToFit,f=p===void 0?!1:p,g=s.textAnchor,b=g===void 0?"start":g,_=s.verticalAnchor,j=_===void 0?"end":_,w=s.fill,N=w===void 0?sOe:w,S=QDe(s,Bis),M=k.useMemo(function(){return Kis({breakAll:S.breakAll,children:S.children,maxLines:S.maxLines,scaleToFit:f,style:S.style,width:S.width})},[S.breakAll,S.children,S.maxLines,f,S.style,S.width]),L=S.dx,I=S.dy,O=S.angle,q=S.className,U=S.breakAll,B=QDe(S,$is);if(!ju(n)||!ju(o))return null;var V=n+(ln(L)?L:0),Y=o+(ln(I)?I:0),Q;switch(j){case"start":Q=Xge("calc(".concat(u,")"));break;case"middle":Q=Xge("calc(".concat((M.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:Q=Xge("calc(".concat(M.length-1," * -").concat(i,")"));break}var ee=[];if(f){var X=M[0].width,ie=S.width;ee.push("scale(".concat((ln(ie)?ie/X:1)/X,")"))}return O&&ee.push("rotate(".concat(O,", ").concat(V,", ").concat(Y,")")),ee.length&&(B.transform=ee.join(" ")),ht.createElement("text",Fbe({},ai(B,!0),{x:V,y:Y,className:Vi("recharts-text",q),textAnchor:b,fill:N.includes("url")?sOe:N}),M.map(function(re,oe){var ce=re.words.join(U?"":" ");return ht.createElement("tspan",{x:V,dy:oe===0?Q:i,key:"".concat(ce,"-").concat(oe)},ce)}))};function rw(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function Zis(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function w4e(t){let s,r,n;t.length!==2?(s=rw,r=(i,c)=>rw(t(i),c),n=(i,c)=>t(i)-c):(s=t===rw||t===Zis?t:Yis,r=t,n=t);function a(i,c,u=0,p=i.length){if(u>>1;r(i[f],c)<0?u=f+1:p=f}while(u>>1;r(i[f],c)<=0?u=f+1:p=f}while(uu&&n(i[f-1],c)>-n(i[f],c)?f-1:f}return{left:a,center:l,right:o}}function Yis(){return 0}function Jst(t){return t===null?NaN:+t}function*Xis(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const Qis=w4e(rw),cR=Qis.right;w4e(Jst).center;class rOe extends Map{constructor(s,r=tos){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),s!=null)for(const[n,a]of s)this.set(n,a)}get(s){return super.get(nOe(this,s))}has(s){return super.has(nOe(this,s))}set(s,r){return super.set(Jis(this,s),r)}delete(s){return super.delete(eos(this,s))}}function nOe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function Jis({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function eos({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function tos(t){return t!==null&&typeof t=="object"?t.valueOf():t}function sos(t=rw){if(t===rw)return ert;if(typeof t!="function")throw new TypeError("compare is not a function");return(s,r)=>{const n=t(s,r);return n||n===0?n:(t(r,r)===0)-(t(s,s)===0)}}function ert(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const ros=Math.sqrt(50),nos=Math.sqrt(10),aos=Math.sqrt(2);function oce(t,s,r){const n=(s-t)/Math.max(0,r),a=Math.floor(Math.log10(n)),o=n/Math.pow(10,a),l=o>=ros?10:o>=nos?5:o>=aos?2:1;let i,c,u;return a<0?(u=Math.pow(10,-a)/l,i=Math.round(t*u),c=Math.round(s*u),i/us&&--c,u=-u):(u=Math.pow(10,a)*l,i=Math.round(t/u),c=Math.round(s/u),i*us&&--c),c0))return[];if(t===s)return[t];const n=s=a))return[];const i=o-a+1,c=new Array(i);if(n)if(l<0)for(let u=0;u=n)&&(r=n);return r}function iOe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function trt(t,s,r=0,n=1/0,a){if(s=Math.floor(s),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(t.length-1,n)),!(r<=s&&s<=n))return t;for(a=a===void 0?ert:sos(a);n>r;){if(n-r>600){const c=n-r+1,u=s-r+1,p=Math.log(c),f=.5*Math.exp(2*p/3),g=.5*Math.sqrt(p*f*(c-f)/c)*(u-c/2<0?-1:1),b=Math.max(r,Math.floor(s-u*f/c+g)),_=Math.min(n,Math.floor(s+(c-u)*f/c+g));trt(t,s,b,_,a)}const o=t[s];let l=r,i=n;for(tI(t,r,s),a(t[n],o)>0&&tI(t,r,n);l0;)--i}a(t[r],o)===0?tI(t,r,i):(++i,tI(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function tI(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function ios(t,s,r){if(t=Float64Array.from(Xis(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return iOe(t);if(s>=1)return aOe(t);var n,a=(n-1)*s,o=Math.floor(a),l=aOe(trt(t,o).subarray(0,o+1)),i=iOe(t.subarray(o+1));return l+(i-l)*(a-o)}}function oos(t,s,r=Jst){if(!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return+r(t[0],0,t);if(s>=1)return+r(t[n-1],n-1,t);var n,a=(n-1)*s,o=Math.floor(a),l=+r(t[o],o,t),i=+r(t[o+1],o+1,t);return l+(i-l)*(a-o)}}function los(t,s,r){t=+t,s=+s,r=(a=arguments.length)<2?(s=t,t=0,1):a<3?1:+r;for(var n=-1,a=Math.max(0,Math.ceil((s-t)/r))|0,o=new Array(a);++n>8&15|s>>4&240,s>>4&15|s&240,(s&15)<<4|s&15,1):r===8?Dz(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?Dz(s>>12&15|s>>8&240,s>>8&15|s>>4&240,s>>4&15|s&240,((s&15)<<4|s&15)/255):null):(s=dos.exec(t))?new _p(s[1],s[2],s[3],1):(s=uos.exec(t))?new _p(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=hos.exec(t))?Dz(s[1],s[2],s[3],s[4]):(s=mos.exec(t))?Dz(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=pos.exec(t))?mOe(s[1],s[2]/100,s[3]/100,1):(s=fos.exec(t))?mOe(s[1],s[2]/100,s[3]/100,s[4]):oOe.hasOwnProperty(t)?dOe(oOe[t]):t==="transparent"?new _p(NaN,NaN,NaN,0):null}function dOe(t){return new _p(t>>16&255,t>>8&255,t&255,1)}function Dz(t,s,r,n){return n<=0&&(t=s=r=NaN),new _p(t,s,r,n)}function yos(t){return t instanceof dR||(t=LD(t)),t?(t=t.rgb(),new _p(t.r,t.g,t.b,t.opacity)):new _p}function Ube(t,s,r,n){return arguments.length===1?yos(t):new _p(t,s,r,n??1)}function _p(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}N4e(_p,Ube,rrt(dR,{brighter(t){return t=t==null?lce:Math.pow(lce,t),new _p(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?PD:Math.pow(PD,t),new _p(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new _p(kS(this.r),kS(this.g),kS(this.b),cce(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:uOe,formatHex:uOe,formatHex8:vos,formatRgb:hOe,toString:hOe}));function uOe(){return`#${M4(this.r)}${M4(this.g)}${M4(this.b)}`}function vos(){return`#${M4(this.r)}${M4(this.g)}${M4(this.b)}${M4((isNaN(this.opacity)?1:this.opacity)*255)}`}function hOe(){const t=cce(this.opacity);return`${t===1?"rgb(":"rgba("}${kS(this.r)}, ${kS(this.g)}, ${kS(this.b)}${t===1?")":`, ${t})`}`}function cce(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function kS(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function M4(t){return t=kS(t),(t<16?"0":"")+t.toString(16)}function mOe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Hg(t,s,r,n)}function nrt(t){if(t instanceof Hg)return new Hg(t.h,t.s,t.l,t.opacity);if(t instanceof dR||(t=LD(t)),!t)return new Hg;if(t instanceof Hg)return t;t=t.rgb();var s=t.r/255,r=t.g/255,n=t.b/255,a=Math.min(s,r,n),o=Math.max(s,r,n),l=NaN,i=o-a,c=(o+a)/2;return i?(s===o?l=(r-n)/i+(r0&&c<1?0:l,new Hg(l,i,c,t.opacity)}function bos(t,s,r,n){return arguments.length===1?nrt(t):new Hg(t,s,r,n??1)}function Hg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}N4e(Hg,bos,rrt(dR,{brighter(t){return t=t==null?lce:Math.pow(lce,t),new Hg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?PD:Math.pow(PD,t),new Hg(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,s=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*s,a=2*r-n;return new _p(Qge(t>=240?t-240:t+120,a,n),Qge(t,a,n),Qge(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Hg(pOe(this.h),Oz(this.s),Oz(this.l),cce(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=cce(this.opacity);return`${t===1?"hsl(":"hsla("}${pOe(this.h)}, ${Oz(this.s)*100}%, ${Oz(this.l)*100}%${t===1?")":`, ${t})`}`}}));function pOe(t){return t=(t||0)%360,t<0?t+360:t}function Oz(t){return Math.max(0,Math.min(1,t||0))}function Qge(t,s,r){return(t<60?s+(r-s)*t/60:t<180?r:t<240?s+(r-s)*(240-t)/60:s)*255}const k4e=t=>()=>t;function _os(t,s){return function(r){return t+r*s}}function wos(t,s,r){return t=Math.pow(t,r),s=Math.pow(s,r)-t,r=1/r,function(n){return Math.pow(t+n*s,r)}}function jos(t){return(t=+t)==1?art:function(s,r){return r-s?wos(s,r,t):k4e(isNaN(s)?r:s)}}function art(t,s){var r=s-t;return r?_os(t,r):k4e(isNaN(t)?s:t)}const fOe=function t(s){var r=jos(s);function n(a,o){var l=r((a=Ube(a)).r,(o=Ube(o)).r),i=r(a.g,o.g),c=r(a.b,o.b),u=art(a.opacity,o.opacity);return function(p){return a.r=l(p),a.g=i(p),a.b=c(p),a.opacity=u(p),a+""}}return n.gamma=t,n}(1);function Nos(t,s){s||(s=[]);var r=t?Math.min(s.length,t.length):0,n=s.slice(),a;return function(o){for(a=0;ar&&(o=s.slice(r,o),i[l]?i[l]+=o:i[++l]=o),(n=n[0])===(a=a[0])?i[l]?i[l]+=a:i[++l]=a:(i[++l]=null,c.push({i:l,x:dce(n,a)})),r=Jge.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function Dos(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?Oos:Dos,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?o:(c||(c=i(t.map(n),s,r)))(n(l(g)))}return f.invert=function(g){return l(a((u||(u=i(s,t.map(n),dce)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,uce),p()):t.slice()},f.range=function(g){return arguments.length?(s=Array.from(g),p()):s.slice()},f.rangeRound=function(g){return s=Array.from(g),r=S4e,p()},f.clamp=function(g){return arguments.length?(l=g?!0:Em,p()):l!==Em},f.interpolate=function(g){return arguments.length?(r=g,p()):r},f.unknown=function(g){return arguments.length?(o=g,f):o},function(g,b){return n=g,a=b,p()}}function C4e(){return vhe()(Em,Em)}function Ros(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function hce(t,s){if((r=(t=s?t.toExponential(s-1):t.toExponential()).indexOf("e"))<0)return null;var r,n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function sA(t){return t=hce(Math.abs(t)),t?t[1]:NaN}function Fos(t,s){return function(r,n){for(var a=r.length,o=[],l=0,i=t[0],c=0;a>0&&i>0&&(c+i+1>n&&(i=Math.max(1,n-c)),o.push(r.substring(a-=i,a+i)),!((c+=i+1)>n));)i=t[l=(l+1)%t.length];return o.reverse().join(s)}}function zos(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var Bos=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function DD(t){if(!(s=Bos.exec(t)))throw new Error("invalid format: "+t);var s;return new M4e({fill:s[1],align:s[2],sign:s[3],symbol:s[4],zero:s[5],width:s[6],comma:s[7],precision:s[8]&&s[8].slice(1),trim:s[9],type:s[10]})}DD.prototype=M4e.prototype;function M4e(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}M4e.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 $os(t){e:for(var s=t.length,r=1,n=-1,a;r0&&(n=0);break}return n>0?t.slice(0,n)+t.slice(a+1):t}var irt;function qos(t,s){var r=hce(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(irt=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")+hce(t,Math.max(0,s+o-1))[0]}function gOe(t,s){var r=hce(t,s);if(!r)return t+"";var n=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+n:n.length>a+1?n.slice(0,a+1)+"."+n.slice(a+1):n+new Array(a-n.length+2).join("0")}const yOe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Ros,e:(t,s)=>t.toExponential(s),f:(t,s)=>t.toFixed(s),g:(t,s)=>t.toPrecision(s),o:t=>Math.round(t).toString(8),p:(t,s)=>gOe(t*100,s),r:gOe,s:qos,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function vOe(t){return t}var bOe=Array.prototype.map,_Oe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Uos(t){var s=t.grouping===void 0||t.thousands===void 0?vOe:Fos(bOe.call(t.grouping,Number),t.thousands+""),r=t.currency===void 0?"":t.currency[0]+"",n=t.currency===void 0?"":t.currency[1]+"",a=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?vOe:zos(bOe.call(t.numerals,String)),l=t.percent===void 0?"%":t.percent+"",i=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=DD(f);var g=f.fill,b=f.align,_=f.sign,j=f.symbol,w=f.zero,N=f.width,S=f.comma,M=f.precision,L=f.trim,I=f.type;I==="n"?(S=!0,I="g"):yOe[I]||(M===void 0&&(M=12),L=!0,I="g"),(w||g==="0"&&b==="=")&&(w=!0,g="0",b="=");var O=j==="$"?r:j==="#"&&/[boxX]/.test(I)?"0"+I.toLowerCase():"",q=j==="$"?n:/[%p]/.test(I)?l:"",U=yOe[I],B=/[defgprs%]/.test(I);M=M===void 0?6:/[gprs]/.test(I)?Math.max(1,Math.min(21,M)):Math.max(0,Math.min(20,M));function V(Y){var Q=O,ee=q,X,ie,re;if(I==="c")ee=U(Y)+ee,Y="";else{Y=+Y;var oe=Y<0||1/Y<0;if(Y=isNaN(Y)?c:U(Math.abs(Y),M),L&&(Y=$os(Y)),oe&&+Y==0&&_!=="+"&&(oe=!1),Q=(oe?_==="("?_:i:_==="-"||_==="("?"":_)+Q,ee=(I==="s"?_Oe[8+irt/3]:"")+ee+(oe&&_==="("?")":""),B){for(X=-1,ie=Y.length;++Xre||re>57){ee=(re===46?a+Y.slice(X+1):Y.slice(X))+ee,Y=Y.slice(0,X);break}}}S&&!w&&(Y=s(Y,1/0));var ce=Q.length+Y.length+ee.length,ge=ce>1)+Q+Y+ee+ge.slice(ce);break;default:Y=ge+Q+Y+ee;break}return o(Y)}return V.toString=function(){return f+""},V}function p(f,g){var b=u((f=DD(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(sA(g)/3)))*3,j=Math.pow(10,-_),w=_Oe[8+_/3];return function(N){return b(j*N)+w}}return{format:u,formatPrefix:p}}var Rz,T4e,ort;Vos({thousands:",",grouping:[3],currency:["$",""]});function Vos(t){return Rz=Uos(t),T4e=Rz.format,ort=Rz.formatPrefix,Rz}function Hos(t){return Math.max(0,-sA(Math.abs(t)))}function Wos(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(sA(s)/3)))*3-sA(Math.abs(t)))}function Gos(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,sA(s)-sA(t))+1}function lrt(t,s,r,n){var a=$be(t,s,r),o;switch(n=DD(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=Wos(a,l))&&(n.precision=o),ort(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=Gos(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=Hos(a))&&(n.precision=o-(n.type==="%")*2);break}}return T4e(n)}function Bw(t){var s=t.domain;return t.ticks=function(r){var n=s();return zbe(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return lrt(a[0],a[a.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=s(),a=0,o=n.length-1,l=n[a],i=n[o],c,u,p=10;for(i0;){if(u=Bbe(l,i,r),u===c)return n[a]=l,n[o]=i,s(n);if(u>0)l=Math.floor(l/u)*u,i=Math.ceil(i/u)*u;else if(u<0)l=Math.ceil(l*u)/u,i=Math.floor(i*u)/u;else break;c=u}return t},t}function mce(){var t=C4e();return t.copy=function(){return uR(t,mce())},Wx.apply(t,arguments),Bw(t)}function crt(t){var s;function r(n){return n==null||isNaN(n=+n)?s:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(t=Array.from(n,uce),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return crt(t).unknown(s)},t=arguments.length?Array.from(t,uce):[0,1],Bw(r)}function drt(t,s){t=t.slice();var r=0,n=t.length-1,a=t[r],o=t[n],l;return oMath.pow(t,s)}function Qos(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),s=>Math.log(s)/t)}function NOe(t){return(s,r)=>-t(-s,r)}function A4e(t){const s=t(wOe,jOe),r=s.domain;let n=10,a,o;function l(){return a=Qos(n),o=Xos(n),r()[0]<0?(a=NOe(a),o=NOe(o),t(Kos,Zos)):t(wOe,jOe),s}return s.base=function(i){return arguments.length?(n=+i,l()):n},s.domain=function(i){return arguments.length?(r(i),l()):r()},s.ticks=i=>{const c=r();let u=c[0],p=c[c.length-1];const f=p0){for(;g<=b;++g)for(_=1;_p)break;N.push(j)}}else for(;g<=b;++g)for(_=n-1;_>=1;--_)if(j=g>0?_/o(-g):_*o(g),!(jp)break;N.push(j)}N.length*2{if(i==null&&(i=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=DD(c)).precision==null&&(c.trim=!0),c=T4e(c)),i===1/0)return c;const u=Math.max(1,n*i/s.ticks().length);return p=>{let f=p/o(Math.round(a(p)));return f*nr(drt(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function urt(){const t=A4e(vhe()).domain([1,10]);return t.copy=()=>uR(t,urt()).base(t.base()),Wx.apply(t,arguments),t}function kOe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function SOe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function E4e(t){var s=1,r=t(kOe(s),SOe(s));return r.constant=function(n){return arguments.length?t(kOe(s=+n),SOe(s)):s},Bw(r)}function hrt(){var t=E4e(vhe());return t.copy=function(){return uR(t,hrt()).constant(t.constant())},Wx.apply(t,arguments)}function COe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function Jos(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function els(t){return t<0?-t*t:t*t}function P4e(t){var s=t(Em,Em),r=1;function n(){return r===1?t(Em,Em):r===.5?t(Jos,els):t(COe(r),COe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},Bw(s)}function I4e(){var t=P4e(vhe());return t.copy=function(){return uR(t,I4e()).exponent(t.exponent())},Wx.apply(t,arguments),t}function tls(){return I4e.apply(null,arguments).exponent(.5)}function MOe(t){return Math.sign(t)*t*t}function sls(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function mrt(){var t=C4e(),s=[0,1],r=!1,n;function a(o){var l=sls(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(MOe(o))},a.domain=function(o){return arguments.length?(t.domain(o),a):t.domain()},a.range=function(o){return arguments.length?(t.range((s=Array.from(o,uce)).map(MOe)),a):s.slice()},a.rangeRound=function(o){return a.range(o).round(!0)},a.round=function(o){return arguments.length?(r=!!o,a):r},a.clamp=function(o){return arguments.length?(t.clamp(o),a):t.clamp()},a.unknown=function(o){return arguments.length?(n=o,a):n},a.copy=function(){return mrt(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},Wx.apply(a,arguments),Bw(a)}function prt(){var t=[],s=[],r=[],n;function a(){var l=0,i=Math.max(1,s.length);for(r=new Array(i-1);++l0?r[i-1]:t[0],i=r?[n[r-1],s]:[n[u-1],n[u]]},l.unknown=function(c){return arguments.length&&(o=c),l},l.thresholds=function(){return n.slice()},l.copy=function(){return frt().domain([t,s]).range(a).unknown(o)},Wx.apply(Bw(l),arguments)}function xrt(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[cR(t,o,0,n)]:r}return a.domain=function(o){return arguments.length?(t=Array.from(o),n=Math.min(t.length,s.length-1),a):t.slice()},a.range=function(o){return arguments.length?(s=Array.from(o),n=Math.min(t.length,s.length-1),a):s.slice()},a.invertExtent=function(o){var l=s.indexOf(o);return[t[l-1],t[l]]},a.unknown=function(o){return arguments.length?(r=o,a):r},a.copy=function(){return xrt().domain(t).range(s).unknown(r)},Wx.apply(a,arguments)}const eye=new Date,tye=new Date;function Lu(t,s,r,n){function a(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return a.floor=o=>(t(o=new Date(+o)),o),a.ceil=o=>(t(o=new Date(o-1)),s(o,1),t(o),o),a.round=o=>{const l=a(o),i=a.ceil(o);return o-l(s(o=new Date(+o),l==null?1:Math.floor(l)),o),a.range=(o,l,i)=>{const c=[];if(o=a.ceil(o),i=i==null?1:Math.floor(i),!(o0))return c;let u;do c.push(u=new Date(+o)),s(o,i),t(o);while(uLu(l=>{if(l>=l)for(;t(l),!o(l);)l.setTime(l-1)},(l,i)=>{if(l>=l)if(i<0)for(;++i<=0;)for(;s(l,-1),!o(l););else for(;--i>=0;)for(;s(l,1),!o(l););}),r&&(a.count=(o,l)=>(eye.setTime(+o),tye.setTime(+l),t(eye),t(tye),Math.floor(r(eye,tye))),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 pce=Lu(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);pce.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Lu(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):pce);pce.range;const Qv=1e3,wx=Qv*60,Jv=wx*60,E1=Jv*24,L4e=E1*7,TOe=E1*30,sye=E1*365,T4=Lu(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*Qv)},(t,s)=>(s-t)/Qv,t=>t.getUTCSeconds());T4.range;const D4e=Lu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Qv)},(t,s)=>{t.setTime(+t+s*wx)},(t,s)=>(s-t)/wx,t=>t.getMinutes());D4e.range;const O4e=Lu(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*wx)},(t,s)=>(s-t)/wx,t=>t.getUTCMinutes());O4e.range;const R4e=Lu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Qv-t.getMinutes()*wx)},(t,s)=>{t.setTime(+t+s*Jv)},(t,s)=>(s-t)/Jv,t=>t.getHours());R4e.range;const F4e=Lu(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*Jv)},(t,s)=>(s-t)/Jv,t=>t.getUTCHours());F4e.range;const hR=Lu(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*wx)/E1,t=>t.getDate()-1);hR.range;const bhe=Lu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/E1,t=>t.getUTCDate()-1);bhe.range;const grt=Lu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/E1,t=>Math.floor(t/E1));grt.range;function NC(t){return Lu(s=>{s.setDate(s.getDate()-(s.getDay()+7-t)%7),s.setHours(0,0,0,0)},(s,r)=>{s.setDate(s.getDate()+r*7)},(s,r)=>(r-s-(r.getTimezoneOffset()-s.getTimezoneOffset())*wx)/L4e)}const _he=NC(0),fce=NC(1),rls=NC(2),nls=NC(3),rA=NC(4),als=NC(5),ils=NC(6);_he.range;fce.range;rls.range;nls.range;rA.range;als.range;ils.range;function kC(t){return Lu(s=>{s.setUTCDate(s.getUTCDate()-(s.getUTCDay()+7-t)%7),s.setUTCHours(0,0,0,0)},(s,r)=>{s.setUTCDate(s.getUTCDate()+r*7)},(s,r)=>(r-s)/L4e)}const whe=kC(0),xce=kC(1),ols=kC(2),lls=kC(3),nA=kC(4),cls=kC(5),dls=kC(6);whe.range;xce.range;ols.range;lls.range;nA.range;cls.range;dls.range;const z4e=Lu(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,s)=>{t.setMonth(t.getMonth()+s)},(t,s)=>s.getMonth()-t.getMonth()+(s.getFullYear()-t.getFullYear())*12,t=>t.getMonth());z4e.range;const B4e=Lu(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCMonth(t.getUTCMonth()+s)},(t,s)=>s.getUTCMonth()-t.getUTCMonth()+(s.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());B4e.range;const P1=Lu(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,s)=>{t.setFullYear(t.getFullYear()+s)},(t,s)=>s.getFullYear()-t.getFullYear(),t=>t.getFullYear());P1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Lu(s=>{s.setFullYear(Math.floor(s.getFullYear()/t)*t),s.setMonth(0,1),s.setHours(0,0,0,0)},(s,r)=>{s.setFullYear(s.getFullYear()+r*t)});P1.range;const I1=Lu(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCFullYear(t.getUTCFullYear()+s)},(t,s)=>s.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());I1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Lu(s=>{s.setUTCFullYear(Math.floor(s.getUTCFullYear()/t)*t),s.setUTCMonth(0,1),s.setUTCHours(0,0,0,0)},(s,r)=>{s.setUTCFullYear(s.getUTCFullYear()+r*t)});I1.range;function yrt(t,s,r,n,a,o){const l=[[T4,1,Qv],[T4,5,5*Qv],[T4,15,15*Qv],[T4,30,30*Qv],[o,1,wx],[o,5,5*wx],[o,15,15*wx],[o,30,30*wx],[a,1,Jv],[a,3,3*Jv],[a,6,6*Jv],[a,12,12*Jv],[n,1,E1],[n,2,2*E1],[r,1,L4e],[s,1,TOe],[s,3,3*TOe],[t,1,sye]];function i(u,p,f){const g=pw).right(l,g);if(b===l.length)return t.every($be(u/sye,p/sye,f));if(b===0)return pce.every(Math.max($be(u,p,f),1));const[_,j]=l[g/l[b-1][2]53)return null;"w"in Te||(Te.w=1),"Z"in Te?(fe=nye(sI(Te.y,0,1)),qe=fe.getUTCDay(),fe=qe>4||qe===0?xce.ceil(fe):xce(fe),fe=bhe.offset(fe,(Te.V-1)*7),Te.y=fe.getUTCFullYear(),Te.m=fe.getUTCMonth(),Te.d=fe.getUTCDate()+(Te.w+6)%7):(fe=rye(sI(Te.y,0,1)),qe=fe.getDay(),fe=qe>4||qe===0?fce.ceil(fe):fce(fe),fe=hR.offset(fe,(Te.V-1)*7),Te.y=fe.getFullYear(),Te.m=fe.getMonth(),Te.d=fe.getDate()+(Te.w+6)%7)}else("W"in Te||"U"in Te)&&("w"in Te||(Te.w="u"in Te?Te.u%7:"W"in Te?1:0),qe="Z"in Te?nye(sI(Te.y,0,1)).getUTCDay():rye(sI(Te.y,0,1)).getDay(),Te.m=0,Te.d="W"in Te?(Te.w+6)%7+Te.W*7-(qe+5)%7:Te.w+Te.U*7-(qe+6)%7);return"Z"in Te?(Te.H+=Te.Z/100|0,Te.M+=Te.Z%100,nye(Te)):rye(Te)}}function U(we,Le,tt,Te){for(var pt=0,fe=Le.length,qe=tt.length,at,et;pt=qe)return-1;if(at=Le.charCodeAt(pt++),at===37){if(at=Le.charAt(pt++),et=I[at in AOe?Le.charAt(pt++):at],!et||(Te=et(we,tt,Te))<0)return-1}else if(at!=tt.charCodeAt(Te++))return-1}return Te}function B(we,Le,tt){var Te=u.exec(Le.slice(tt));return Te?(we.p=p.get(Te[0].toLowerCase()),tt+Te[0].length):-1}function V(we,Le,tt){var Te=b.exec(Le.slice(tt));return Te?(we.w=_.get(Te[0].toLowerCase()),tt+Te[0].length):-1}function Y(we,Le,tt){var Te=f.exec(Le.slice(tt));return Te?(we.w=g.get(Te[0].toLowerCase()),tt+Te[0].length):-1}function Q(we,Le,tt){var Te=N.exec(Le.slice(tt));return Te?(we.m=S.get(Te[0].toLowerCase()),tt+Te[0].length):-1}function ee(we,Le,tt){var Te=j.exec(Le.slice(tt));return Te?(we.m=w.get(Te[0].toLowerCase()),tt+Te[0].length):-1}function X(we,Le,tt){return U(we,s,Le,tt)}function ie(we,Le,tt){return U(we,r,Le,tt)}function re(we,Le,tt){return U(we,n,Le,tt)}function oe(we){return l[we.getDay()]}function ce(we){return o[we.getDay()]}function ge(we){return c[we.getMonth()]}function ye(we){return i[we.getMonth()]}function ue(we){return a[+(we.getHours()>=12)]}function pe(we){return 1+~~(we.getMonth()/3)}function _e(we){return l[we.getUTCDay()]}function $e(we){return o[we.getUTCDay()]}function Ae(we){return c[we.getUTCMonth()]}function Ie(we){return i[we.getUTCMonth()]}function Ce(we){return a[+(we.getUTCHours()>=12)]}function xe(we){return 1+~~(we.getUTCMonth()/3)}return{format:function(we){var Le=O(we+="",M);return Le.toString=function(){return we},Le},parse:function(we){var Le=q(we+="",!1);return Le.toString=function(){return we},Le},utcFormat:function(we){var Le=O(we+="",L);return Le.toString=function(){return we},Le},utcParse:function(we){var Le=q(we+="",!0);return Le.toString=function(){return we},Le}}}var AOe={"-":"",_:" ",0:"0"},lh=/^\s*\d+/,xls=/^%/,gls=/[\\^$*+?|[\]().{}]/g;function Qo(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function vls(t,s,r){var n=lh.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function bls(t,s,r){var n=lh.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function _ls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function wls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function jls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function EOe(t,s,r){var n=lh.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function POe(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function Nls(t,s,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(s.slice(r,r+6));return n?(t.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function kls(t,s,r){var n=lh.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Sls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function IOe(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Cls(t,s,r){var n=lh.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function LOe(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Mls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Tls(t,s,r){var n=lh.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Als(t,s,r){var n=lh.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Els(t,s,r){var n=lh.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function Pls(t,s,r){var n=xls.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function Ils(t,s,r){var n=lh.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function Lls(t,s,r){var n=lh.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function DOe(t,s){return Qo(t.getDate(),s,2)}function Dls(t,s){return Qo(t.getHours(),s,2)}function Ols(t,s){return Qo(t.getHours()%12||12,s,2)}function Rls(t,s){return Qo(1+hR.count(P1(t),t),s,3)}function vrt(t,s){return Qo(t.getMilliseconds(),s,3)}function Fls(t,s){return vrt(t,s)+"000"}function zls(t,s){return Qo(t.getMonth()+1,s,2)}function Bls(t,s){return Qo(t.getMinutes(),s,2)}function $ls(t,s){return Qo(t.getSeconds(),s,2)}function qls(t){var s=t.getDay();return s===0?7:s}function Uls(t,s){return Qo(_he.count(P1(t)-1,t),s,2)}function brt(t){var s=t.getDay();return s>=4||s===0?rA(t):rA.ceil(t)}function Vls(t,s){return t=brt(t),Qo(rA.count(P1(t),t)+(P1(t).getDay()===4),s,2)}function Hls(t){return t.getDay()}function Wls(t,s){return Qo(fce.count(P1(t)-1,t),s,2)}function Gls(t,s){return Qo(t.getFullYear()%100,s,2)}function Kls(t,s){return t=brt(t),Qo(t.getFullYear()%100,s,2)}function Zls(t,s){return Qo(t.getFullYear()%1e4,s,4)}function Yls(t,s){var r=t.getDay();return t=r>=4||r===0?rA(t):rA.ceil(t),Qo(t.getFullYear()%1e4,s,4)}function Xls(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Qo(s/60|0,"0",2)+Qo(s%60,"0",2)}function OOe(t,s){return Qo(t.getUTCDate(),s,2)}function Qls(t,s){return Qo(t.getUTCHours(),s,2)}function Jls(t,s){return Qo(t.getUTCHours()%12||12,s,2)}function ecs(t,s){return Qo(1+bhe.count(I1(t),t),s,3)}function _rt(t,s){return Qo(t.getUTCMilliseconds(),s,3)}function tcs(t,s){return _rt(t,s)+"000"}function scs(t,s){return Qo(t.getUTCMonth()+1,s,2)}function rcs(t,s){return Qo(t.getUTCMinutes(),s,2)}function ncs(t,s){return Qo(t.getUTCSeconds(),s,2)}function acs(t){var s=t.getUTCDay();return s===0?7:s}function ics(t,s){return Qo(whe.count(I1(t)-1,t),s,2)}function wrt(t){var s=t.getUTCDay();return s>=4||s===0?nA(t):nA.ceil(t)}function ocs(t,s){return t=wrt(t),Qo(nA.count(I1(t),t)+(I1(t).getUTCDay()===4),s,2)}function lcs(t){return t.getUTCDay()}function ccs(t,s){return Qo(xce.count(I1(t)-1,t),s,2)}function dcs(t,s){return Qo(t.getUTCFullYear()%100,s,2)}function ucs(t,s){return t=wrt(t),Qo(t.getUTCFullYear()%100,s,2)}function hcs(t,s){return Qo(t.getUTCFullYear()%1e4,s,4)}function mcs(t,s){var r=t.getUTCDay();return t=r>=4||r===0?nA(t):nA.ceil(t),Qo(t.getUTCFullYear()%1e4,s,4)}function pcs(){return"+0000"}function ROe(){return"%"}function FOe(t){return+t}function zOe(t){return Math.floor(+t/1e3)}var A5,jrt,Nrt;fcs({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 fcs(t){return A5=fls(t),jrt=A5.format,A5.parse,Nrt=A5.utcFormat,A5.utcParse,A5}function xcs(t){return new Date(t)}function gcs(t){return t instanceof Date?+t:+new Date(+t)}function $4e(t,s,r,n,a,o,l,i,c,u){var p=C4e(),f=p.invert,g=p.domain,b=u(".%L"),_=u(":%S"),j=u("%I:%M"),w=u("%I %p"),N=u("%a %d"),S=u("%b %d"),M=u("%B"),L=u("%Y");function I(O){return(c(O)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>ios(t,o/n))},r.copy=function(){return Mrt(s).domain(t)},V1.apply(r,arguments)}function Nhe(){var t=0,s=.5,r=1,n=1,a,o,l,i,c,u=Em,p,f=!1,g;function b(j){return isNaN(j=+j)?g:(j=.5+((j=+p(j))-o)*(n*js}var Prt=Ncs,kcs=khe,Scs=Prt,Ccs=_E;function Mcs(t){return t&&t.length?kcs(t,Ccs,Scs):void 0}var Tcs=Mcs;const She=Po(Tcs);function Acs(t,s){return tt.e^o.s<0?1:-1;for(n=o.d.length,a=t.d.length,s=0,r=nt.d[s]^o.s<0?1:-1;return n===a?0:n>a^o.s<0?1:-1};aa.decimalPlaces=aa.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*yc;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};aa.dividedBy=aa.div=function(t){return v1(this,new this.constructor(t))};aa.dividedToIntegerBy=aa.idiv=function(t){var s=this,r=s.constructor;return Fl(v1(s,new r(t),0,1),r.precision)};aa.equals=aa.eq=function(t){return!this.cmp(t)};aa.exponent=function(){return nu(this)};aa.greaterThan=aa.gt=function(t){return this.cmp(t)>0};aa.greaterThanOrEqualTo=aa.gte=function(t){return this.cmp(t)>=0};aa.isInteger=aa.isint=function(){return this.e>this.d.length-2};aa.isNegative=aa.isneg=function(){return this.s<0};aa.isPositive=aa.ispos=function(){return this.s>0};aa.isZero=function(){return this.s===0};aa.lessThan=aa.lt=function(t){return this.cmp(t)<0};aa.lessThanOrEqualTo=aa.lte=function(t){return this.cmp(t)<1};aa.logarithm=aa.log=function(t){var s,r=this,n=r.constructor,a=n.precision,o=a+5;if(t===void 0)t=new n(10);else if(t=new n(t),t.s<1||t.eq(uf))throw Error(Bx+"NaN");if(r.s<1)throw Error(Bx+(r.s?"NaN":"-Infinity"));return r.eq(uf)?new n(0):(Bc=!1,s=v1(OD(r,o),OD(t,o),o),Bc=!0,Fl(s,a))};aa.minus=aa.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Rrt(s,t):Drt(s,(t.s=-t.s,t))};aa.modulo=aa.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(Bx+"NaN");return r.s?(Bc=!1,s=v1(r,t,0,1).times(t),Bc=!0,r.minus(s)):Fl(new n(r),a)};aa.naturalExponential=aa.exp=function(){return Ort(this)};aa.naturalLogarithm=aa.ln=function(){return OD(this)};aa.negated=aa.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};aa.plus=aa.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Drt(s,t):Rrt(s,(t.s=-t.s,t))};aa.precision=aa.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(SS+t);if(s=nu(a)+1,n=a.d.length-1,r=n*yc+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return t&&s>r?s:r};aa.squareRoot=aa.sqrt=function(){var t,s,r,n,a,o,l,i=this,c=i.constructor;if(i.s<1){if(!i.s)return new c(0);throw Error(Bx+"NaN")}for(t=nu(i),Bc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=c0(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=NE((t+1)/2)-(t<0||t%2),a==1/0?s="5e"+t:(s=a.toExponential(),s=s.slice(0,s.indexOf("e")+1)+t),n=new c(s)):n=new c(a.toString()),r=c.precision,a=l=r+3;;)if(o=n,n=o.plus(v1(i,o,l+2)).times(.5),c0(o.d).slice(0,l)===(s=c0(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(Fl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return Bc=!0,Fl(n,r)};aa.times=aa.mul=function(t){var s,r,n,a,o,l,i,c,u,p=this,f=p.constructor,g=p.d,b=(t=new f(t)).d;if(!p.s||!t.s)return new f(0);for(t.s*=p.s,r=p.e+t.e,c=g.length,u=b.length,c=0;){for(s=0,a=c+n;a>n;)i=o[a]+b[n]*g[a-n-1]+s,o[a--]=i%Vu|0,s=i/Vu|0;o[a]=(o[a]+s)%Vu|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,Bc?Fl(t,f.precision):t};aa.toDecimalPlaces=aa.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(L0(t,0,jE),s===void 0?s=n.rounding:L0(s,0,8),Fl(r,t+nu(r)+1,s))};aa.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=rC(n,!0):(L0(t,0,jE),s===void 0?s=a.rounding:L0(s,0,8),n=Fl(new a(n),t+1,s),r=rC(n,!0,t+1)),r};aa.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?rC(a):(L0(t,0,jE),s===void 0?s=o.rounding:L0(s,0,8),n=Fl(new o(a),t+nu(a)+1,s),r=rC(n.abs(),!1,t+nu(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};aa.toInteger=aa.toint=function(){var t=this,s=t.constructor;return Fl(new s(t),nu(t)+1,s.rounding)};aa.toNumber=function(){return+this};aa.toPower=aa.pow=function(t){var s,r,n,a,o,l,i=this,c=i.constructor,u=12,p=+(t=new c(t));if(!t.s)return new c(uf);if(i=new c(i),!i.s){if(t.s<1)throw Error(Bx+"Infinity");return i}if(i.eq(uf))return i;if(n=c.precision,t.eq(uf))return Fl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=Lrt){for(a=new c(uf),s=Math.ceil(n/yc+4),Bc=!1;r%2&&(a=a.times(i),qOe(a.d,s)),r=NE(r/2),r!==0;)i=i.times(i),qOe(i.d,s);return Bc=!0,t.s<0?new c(uf).div(a):Fl(a,n)}}else if(o<0)throw Error(Bx+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,Bc=!1,a=t.times(OD(i,n+u)),Bc=!0,a=Ort(a),a.s=o,a};aa.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=nu(a),n=rC(a,r<=o.toExpNeg||r>=o.toExpPos)):(L0(t,1,jE),s===void 0?s=o.rounding:L0(s,0,8),a=Fl(new o(a),t,s),r=nu(a),n=rC(a,t<=r||r<=o.toExpNeg,t)),n};aa.toSignificantDigits=aa.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(L0(t,1,jE),s===void 0?s=n.rounding:L0(s,0,8)),Fl(new n(r),t,s)};aa.toString=aa.valueOf=aa.val=aa.toJSON=aa[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=nu(t),r=t.constructor;return rC(t,s<=r.toExpNeg||s>=r.toExpPos)};function Drt(t,s){var r,n,a,o,l,i,c,u,p=t.constructor,f=p.precision;if(!t.s||!s.s)return s.s||(s=new p(t)),Bc?Fl(s,f):s;if(c=t.d,u=s.d,l=t.e,a=s.e,c=c.slice(),o=l-a,o){for(o<0?(n=c,o=-o,i=u.length):(n=u,a=l,i=c.length),l=Math.ceil(f/yc),i=l>i?l+1:i+1,o>i&&(o=i,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(i=c.length,o=u.length,i-o<0&&(o=i,n=u,u=c,c=n),r=0;o;)r=(c[--o]=c[o]+u[o]+r)/Vu|0,c[o]%=Vu;for(r&&(c.unshift(r),++a),i=c.length;c[--i]==0;)c.pop();return s.d=c,s.e=a,Bc?Fl(s,f):s}function L0(t,s,r){if(t!==~~t||tr)throw Error(SS+t)}function c0(t){var s,r,n,a=t.length-1,o="",l=t[0];if(a>0){for(o+=l,s=1;sl?1:-1;else for(i=c=0;ia[i]?1:-1;break}return c}function r(n,a,o){for(var l=0;o--;)n[o]-=l,l=n[o]1;)n.shift()}return function(n,a,o,l){var i,c,u,p,f,g,b,_,j,w,N,S,M,L,I,O,q,U,B=n.constructor,V=n.s==a.s?1:-1,Y=n.d,Q=a.d;if(!n.s)return new B(n);if(!a.s)throw Error(Bx+"Division by zero");for(c=n.e-a.e,q=Q.length,I=Y.length,b=new B(V),_=b.d=[],u=0;Q[u]==(Y[u]||0);)++u;if(Q[u]>(Y[u]||0)&&--c,o==null?S=o=B.precision:l?S=o+(nu(n)-nu(a))+1:S=o,S<0)return new B(0);if(S=S/yc+2|0,u=0,q==1)for(p=0,Q=Q[0],S++;(u1&&(Q=t(Q,p),Y=t(Y,p),q=Q.length,I=Y.length),L=q,j=Y.slice(0,q),w=j.length;w=Vu/2&&++O;do p=0,i=s(Q,j,q,w),i<0?(N=j[0],q!=w&&(N=N*Vu+(j[1]||0)),p=N/O|0,p>1?(p>=Vu&&(p=Vu-1),f=t(Q,p),g=f.length,w=j.length,i=s(f,j,g,w),i==1&&(p--,r(f,q16)throw Error(V4e+nu(t));if(!t.s)return new p(uf);for(Bc=!1,i=f,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(l4(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(uf),p.precision=i;;){if(a=Fl(a.times(t),i),r=r.times(++c),l=o.plus(v1(a,r,i)),c0(l.d).slice(0,i)===c0(o.d).slice(0,i)){for(;u--;)o=Fl(o.times(o),i);return p.precision=f,s==null?(Bc=!0,Fl(o,f)):o}o=l}}function nu(t){for(var s=t.e*yc,r=t.d[0];r>=10;r/=10)s++;return s}function aye(t,s,r){if(s>t.LN10.sd())throw Bc=!0,r&&(t.precision=r),Error(Bx+"LN10 precision limit exceeded");return Fl(new t(t.LN10),s)}function e_(t){for(var s="";t--;)s+="0";return s}function OD(t,s){var r,n,a,o,l,i,c,u,p,f=1,g=10,b=t,_=b.d,j=b.constructor,w=j.precision;if(b.s<1)throw Error(Bx+(b.s?"NaN":"-Infinity"));if(b.eq(uf))return new j(0);if(s==null?(Bc=!1,u=w):u=s,b.eq(10))return s==null&&(Bc=!0),aye(j,u);if(u+=g,j.precision=u,r=c0(_),n=r.charAt(0),o=nu(b),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)b=b.times(t),r=c0(b.d),n=r.charAt(0),f++;o=nu(b),n>1?(b=new j("0."+r),o++):b=new j(n+"."+r.slice(1))}else return c=aye(j,u+2,w).times(o+""),b=OD(new j(n+"."+r.slice(1)),u-g).plus(c),j.precision=w,s==null?(Bc=!0,Fl(b,w)):b;for(i=l=b=v1(b.minus(uf),b.plus(uf),u),p=Fl(b.times(b),u),a=3;;){if(l=Fl(l.times(p),u),c=i.plus(v1(l,new j(a),u)),c0(c.d).slice(0,u)===c0(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(aye(j,u+2,w).times(o+""))),i=v1(i,new j(f),u),j.precision=w,s==null?(Bc=!0,Fl(i,w)):i;i=c,a+=2}}function $Oe(t,s){var r,n,a;for((r=s.indexOf("."))>-1&&(s=s.replace(".","")),(n=s.search(/e/i))>0?(r<0&&(r=n),r+=+s.slice(n+1),s=s.substring(0,n)):r<0&&(r=s.length),n=0;s.charCodeAt(n)===48;)++n;for(a=s.length;s.charCodeAt(a-1)===48;)--a;if(s=s.slice(n,a),s){if(a-=n,r=r-n-1,t.e=NE(r/yc),t.d=[],n=(r+1)%yc,r<0&&(n+=yc),ngce||t.e<-gce))throw Error(V4e+r)}else t.s=0,t.e=0,t.d=[0];return t}function Fl(t,s,r){var n,a,o,l,i,c,u,p,f=t.d;for(l=1,o=f[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=yc,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/yc),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=yc,a=n-yc+l}if(r!==void 0&&(o=l4(10,l-a-1),i=u/o%10|0,c=s<0||f[p+1]!==void 0||u%o,c=r<4?(i||c)&&(r==0||r==(t.s<0?3:2)):i>5||i==5&&(r==4||c||r==6&&(n>0?a>0?u/l4(10,l-a):0:f[p-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return c?(o=nu(t),f.length=1,s=s-o-1,f[0]=l4(10,(yc-s%yc)%yc),t.e=NE(-s/yc)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(n==0?(f.length=p,o=1,p--):(f.length=p+1,o=l4(10,yc-n),f[p]=a>0?(u/l4(10,l-a)%l4(10,a)|0)*o:0),c)for(;;)if(p==0){(f[0]+=o)==Vu&&(f[0]=1,++t.e);break}else{if(f[p]+=o,f[p]!=Vu)break;f[p--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if(Bc&&(t.e>gce||t.e<-gce))throw Error(V4e+nu(t));return t}function Rrt(t,s){var r,n,a,o,l,i,c,u,p,f,g=t.constructor,b=g.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new g(t),Bc?Fl(s,b):s;if(c=t.d,f=s.d,n=s.e,u=t.e,c=c.slice(),l=u-n,l){for(p=l<0,p?(r=c,l=-l,i=f.length):(r=f,n=u,i=c.length),a=Math.max(Math.ceil(b/yc),i)+2,l>a&&(l=a,r.length=1),r.reverse(),a=l;a--;)r.push(0);r.reverse()}else{for(a=c.length,i=f.length,p=a0;--a)c[i++]=0;for(a=f.length;a>l;){if(c[--a]0?o=o.charAt(0)+"."+o.slice(1)+e_(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+e_(-a-1)+o,r&&(n=r-l)>0&&(o+=e_(n))):a>=l?(o+=e_(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+e_(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=e_(n))),t.s<0?"-"+o:o}function qOe(t,s){if(t.length>s)return t.length=s,!0}function Frt(t){var s,r,n;function a(o){var l=this;if(!(l instanceof a))return new a(o);if(l.constructor=a,o instanceof a){l.s=o.s,l.e=o.e,l.d=(o=o.d)?o.slice():o;return}if(typeof o=="number"){if(o*0!==0)throw Error(SS+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 $Oe(l,o.toString())}else if(typeof o!="string")throw Error(SS+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,Xcs.test(o))$Oe(l,o);else throw Error(SS+o)}if(a.prototype=aa,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=Frt,a.config=a.set=Qcs,t===void 0&&(t={}),t)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],s=0;s=a[s+1]&&n<=a[s+2])this[r]=n;else throw Error(SS+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(SS+r+": "+n);return this}var H4e=Frt(Ycs);uf=new H4e(1);const Nl=H4e;function Jcs(t){return rds(t)||sds(t)||tds(t)||eds()}function eds(){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 tds(t,s){if(t){if(typeof t=="string")return Wbe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Wbe(t,s)}}function sds(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function rds(t){if(Array.isArray(t))return Wbe(t)}function Wbe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s?r.apply(void 0,a):t(s-l,UOe(function(){for(var i=arguments.length,c=new Array(i),u=0;ut.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,a=!1,o=void 0;try{for(var l=t[Symbol.iterator](),i;!(n=(i=l.next()).done)&&(r.push(i.value),!(s&&r.length===s));n=!0);}catch(c){a=!0,o=c}finally{try{!n&&l.return!=null&&l.return()}finally{if(a)throw o}}return r}}function yds(t){if(Array.isArray(t))return t}function Urt(t){var s=RD(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function Vrt(t,s,r){if(t.lte(0))return new Nl(0);var n=The.getDigitCount(t.toNumber()),a=new Nl(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new Nl(Math.ceil(o.div(l).toNumber())).add(r).mul(l),c=i.mul(a);return s?c:new Nl(Math.ceil(c))}function vds(t,s,r){var n=1,a=new Nl(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new Nl(10).pow(The.getDigitCount(t)-1),a=new Nl(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new Nl(Math.floor(t)))}else t===0?a=new Nl(Math.floor((s-1)/2)):r||(a=new Nl(Math.floor(t)));var l=Math.floor((s-1)/2),i=ods(ids(function(c){return a.add(new Nl(c-l).mul(n)).toNumber()}),Gbe);return i(0,s)}function Hrt(t,s,r,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((s-t)/(r-1)))return{step:new Nl(0),tickMin:new Nl(0),tickMax:new Nl(0)};var o=Vrt(new Nl(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new Nl(0):(l=new Nl(t).add(s).div(2),l=l.sub(new Nl(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),c=Math.ceil(new Nl(s).sub(l).div(o).toNumber()),u=i+c+1;return u>r?Hrt(t,s,r,n,a+1):(u0?c+(r-u):c,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new Nl(i).mul(o)),tickMax:l.add(new Nl(c).mul(o))})}function bds(t){var s=RD(t,2),r=s[0],n=s[1],a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=Math.max(a,2),i=Urt([r,n]),c=RD(i,2),u=c[0],p=c[1];if(u===-1/0||p===1/0){var f=p===1/0?[u].concat(Zbe(Gbe(0,a-1).map(function(){return 1/0}))):[].concat(Zbe(Gbe(0,a-1).map(function(){return-1/0})),[p]);return r>n?Kbe(f):f}if(u===p)return vds(u,a,o);var g=Hrt(u,p,l,o),b=g.step,_=g.tickMin,j=g.tickMax,w=The.rangeStep(_,j.add(new Nl(.1).mul(b)),b);return r>n?Kbe(w):w}function _ds(t,s){var r=RD(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=Urt([n,a]),i=RD(l,2),c=i[0],u=i[1];if(c===-1/0||u===1/0)return[n,a];if(c===u)return[c];var p=Math.max(s,2),f=Vrt(new Nl(u).sub(c).div(p-1),o,0),g=[].concat(Zbe(The.rangeStep(new Nl(c),new Nl(u).sub(new Nl(.99).mul(f)),f)),[u]);return n>a?Kbe(g):g}var wds=$rt(bds),jds=$rt(_ds),Nds="Invariant failed";function nC(t,s){throw new Error(Nds)}var kds=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function aA(t){"@babel/helpers - typeof";return aA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},aA(t)}function yce(){return yce=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Pds(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Ids(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Lds(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,l=-1,i=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0;if(i<=1)return 0;if(o&&o.axisType==="angleAxis"&&Math.abs(Math.abs(o.range[1]-o.range[0])-360)<=1e-6)for(var c=o.range,u=0;u0?a[u-1].coordinate:a[i-1].coordinate,f=a[u].coordinate,g=u>=i-1?a[0].coordinate:a[u+1].coordinate,b=void 0;if(Tm(f-p)!==Tm(g-f)){var _=[];if(Tm(g-f)===Tm(c[1]-c[0])){b=g;var j=f+c[1]-c[0];_[0]=Math.min(j,(j+p)/2),_[1]=Math.max(j,(j+p)/2)}else{b=p;var w=g+c[1]-c[0];_[0]=Math.min(f,(w+f)/2),_[1]=Math.max(f,(w+f)/2)}var N=[Math.min(f,(b+f)/2),Math.max(f,(b+f)/2)];if(s>N[0]&&s<=N[1]||s>=_[0]&&s<=_[1]){l=a[u].index;break}}else{var S=Math.min(p,g),M=Math.max(p,g);if(s>(S+f)/2&&s<=(M+f)/2){l=a[u].index;break}}}else for(var L=0;L0&&L(n[L].coordinate+n[L-1].coordinate)/2&&s<=(n[L].coordinate+n[L+1].coordinate)/2||L===i-1&&s>(n[L].coordinate+n[L-1].coordinate)/2){l=n[L].index;break}return l},W4e=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?fd(fd({},s.type.defaultProps),s.props):s.props,l=o.stroke,i=o.fill,c;switch(a){case"Line":c=l;break;case"Area":case"Radar":c=l&&l!=="none"?l:i;break;default:c=i;break}return c},Xds=function(s){var r=s.barSize,n=s.totalSize,a=s.stackGroups,o=a===void 0?{}:a;if(!o)return{};for(var l={},i=Object.keys(o),c=0,u=i.length;c=0});if(N&&N.length){var S=N[0].type.defaultProps,M=S!==void 0?fd(fd({},S),N[0].props):N[0].props,L=M.barSize,I=M[w];l[I]||(l[I]=[]);var O=$i(L)?r:L;l[I].push({item:N[0],stackList:N.slice(1),barSize:$i(O)?void 0:Am(O,n,0)})}}return l},Qds=function(s){var r=s.barGap,n=s.barCategoryGap,a=s.bandSize,o=s.sizeList,l=o===void 0?[]:o,i=s.maxBarSize,c=l.length;if(c<1)return null;var u=Am(r,a,0,!0),p,f=[];if(l[0].barSize===+l[0].barSize){var g=!1,b=a/c,_=l.reduce(function(L,I){return L+I.barSize||0},0);_+=(c-1)*u,_>=a&&(_-=(c-1)*u,u=0),_>=a&&b>0&&(g=!0,b*=.9,_=c*b);var j=(a-_)/2>>0,w={offset:j-u,size:0};p=l.reduce(function(L,I){var O={item:I.item,position:{offset:w.offset+w.size+u,size:g?b:I.barSize}},q=[].concat(WOe(L),[O]);return w=q[q.length-1].position,I.stackList&&I.stackList.length&&I.stackList.forEach(function(U){q.push({item:U,position:w})}),q},f)}else{var N=Am(n,a,0,!0);a-2*N-(c-1)*u<=0&&(u=0);var S=(a-2*N-(c-1)*u)/c;S>1&&(S>>=0);var M=i===+i?Math.min(S,i):S;p=l.reduce(function(L,I,O){var q=[].concat(WOe(L),[{item:I.item,position:{offset:N+(S+u)*O+(S-M)/2,size:M}}]);return I.stackList&&I.stackList.length&&I.stackList.forEach(function(U){q.push({item:U,position:q[q.length-1].position})}),q},f)}return p},Jds=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,c=l-(i.left||0)-(i.right||0),u=Zrt({children:o,legendWidth:c});if(u){var p=a||{},f=p.width,g=p.height,b=u.align,_=u.verticalAlign,j=u.layout;if((j==="vertical"||j==="horizontal"&&_==="middle")&&b!=="center"&&ln(s[b]))return fd(fd({},s),{},lT({},b,s[b]+(f||0)));if((j==="horizontal"||j==="vertical"&&b==="center")&&_!=="middle"&&ln(s[_]))return fd(fd({},s),{},lT({},_,s[_]+(g||0)))}return s},eus=function(s,r,n){return $i(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},Yrt=function(s,r,n,a,o){var l=r.props.children,i=Nf(l,pR).filter(function(u){return eus(a,o,u.props.direction)});if(i&&i.length){var c=i.map(function(u){return u.props.dataKey});return s.reduce(function(u,p){var f=_u(p,n);if($i(f))return u;var g=Array.isArray(f)?[Che(f),She(f)]:[f,f],b=c.reduce(function(_,j){var w=_u(p,j,0),N=g[0]-Math.abs(Array.isArray(w)?w[0]:w),S=g[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(N,_[0]),Math.max(S,_[1])]},[1/0,-1/0]);return[Math.min(b[0],u[0]),Math.max(b[1],u[1])]},[1/0,-1/0])}return null},tus=function(s,r,n,a,o){var l=r.map(function(i){return Yrt(s,i,n,o,a)}).filter(function(i){return!$i(i)});return l&&l.length?l.reduce(function(i,c){return[Math.min(i[0],c[0]),Math.max(i[1],c[1])]},[1/0,-1/0]):null},Xrt=function(s,r,n,a,o){var l=r.map(function(c){var u=c.props.dataKey;return n==="number"&&u&&Yrt(s,c,u,a)||x8(s,u,n,o)});if(n==="number")return l.reduce(function(c,u){return[Math.min(c[0],u[0]),Math.max(c[1],u[1])]},[1/0,-1/0]);var i={};return l.reduce(function(c,u){for(var p=0,f=u.length;p=2?Tm(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var p=(s.ticks||s.niceTicks).map(function(f){var g=o?o.indexOf(f):f;return{coordinate:a(g)+u,value:f,offset:u}});return p.filter(function(f){return!iR(f.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(f,g){return{coordinate:a(f)+u,value:f,index:g,offset:u}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(f){return{coordinate:a(f)+u,value:f,offset:u}}):a.domain().map(function(f,g){return{coordinate:a(f)+u,value:o?o[f]:f,index:g,offset:u}})},iye=new WeakMap,Fz=function(s,r){if(typeof r!="function")return s;iye.has(s)||iye.set(s,new WeakMap);var n=iye.get(s);if(n.has(r))return n.get(r);var a=function(){s.apply(void 0,arguments),r.apply(void 0,arguments)};return n.set(r,a),a},ent=function(s,r,n){var a=s.scale,o=s.type,l=s.layout,i=s.axisType;if(a==="auto")return l==="radial"&&i==="radiusAxis"?{scale:ED(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:mce(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:f8(),realScaleType:"point"}:o==="category"?{scale:ED(),realScaleType:"band"}:{scale:mce(),realScaleType:"linear"};if(eC(a)){var c="scale".concat(hhe(a));return{scale:(BOe[c]||f8)(),realScaleType:BOe[c]?c:"point"}}return Mi(a)?{scale:a}:{scale:f8(),realScaleType:"point"}},KOe=1e-4,tnt=function(s){var r=s.domain();if(!(!r||r.length<=2)){var n=r.length,a=s.range(),o=Math.min(a[0],a[1])-KOe,l=Math.max(a[0],a[1])+KOe,i=s(r[0]),c=s(r[n-1]);(il||cl)&&s.domain([r[0],r[n-1]])}},sus=function(s,r){if(!s)return null;for(var n=0,a=s.length;na)&&(o[1]=a),o[0]>a&&(o[0]=a),o[1]=0?(s[i][n][0]=o,s[i][n][1]=o+c,o=s[i][n][1]):(s[i][n][0]=l,s[i][n][1]=l+c,l=s[i][n][1])}},aus=function(s){var r=s.length;if(!(r<=0))for(var n=0,a=s[0].length;n=0?(s[l][n][0]=o,s[l][n][1]=o+i,o=s[l][n][1]):(s[l][n][0]=0,s[l][n][1]=0)}},ius={sign:nus,expand:kXt,none:XT,silhouette:SXt,wiggle:CXt,positive:aus},ous=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=ius[n],l=NXt().keys(a).value(function(i,c){return+_u(i,c,0)}).order(jbe).offset(o);return l(s)},lus=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,c={},u=i.reduce(function(f,g){var b,_=(b=g.type)!==null&&b!==void 0&&b.defaultProps?fd(fd({},g.type.defaultProps),g.props):g.props,j=_.stackId,w=_.hide;if(w)return f;var N=_[n],S=f[N]||{hasStack:!1,stackGroups:{}};if(ju(j)){var M=S.stackGroups[j]||{numericAxisId:n,cateAxisId:a,items:[]};M.items.push(g),S.hasStack=!0,S.stackGroups[j]=M}else S.stackGroups[yE("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[g]};return fd(fd({},f),{},lT({},N,S))},c),p={};return Object.keys(u).reduce(function(f,g){var b=u[g];if(b.hasStack){var _={};b.stackGroups=Object.keys(b.stackGroups).reduce(function(j,w){var N=b.stackGroups[w];return fd(fd({},j),{},lT({},w,{numericAxisId:n,cateAxisId:a,items:N.items,stackedData:ous(s,N.items,o)}))},_)}return fd(fd({},f),{},lT({},g,b))},p)},snt=function(s,r){var n=r.realScaleType,a=r.type,o=r.tickCount,l=r.originalDomain,i=r.allowDecimals,c=n||r.scale;if(c!=="auto"&&c!=="linear")return null;if(o&&a==="number"&&l&&(l[0]==="auto"||l[1]==="auto")){var u=s.domain();if(!u.length)return null;var p=wds(u,o,i);return s.domain([Che(p),She(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),g=jds(f,o,i);return{niceTicks:g}}return null};function ZOe(t){var s=t.axis,r=t.ticks,n=t.bandSize,a=t.entry,o=t.index,l=t.dataKey;if(s.type==="category"){if(!s.allowDuplicatedCategory&&s.dataKey&&!$i(a[s.dataKey])){var i=Wle(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var c=_u(a,$i(l)?s.dataKey:l);return $i(c)?null:s.scale(c)}var YOe=function(s){var r=s.axis,n=s.ticks,a=s.offset,o=s.bandSize,l=s.entry,i=s.index;if(r.type==="category")return n[i]?n[i].coordinate+a:null;var c=_u(l,r.dataKey,r.domain[i]);return $i(c)?null:r.scale(c)-o/2+a},cus=function(s){var r=s.numericAxis,n=r.scale.domain();if(r.type==="number"){var a=Math.min(n[0],n[1]),o=Math.max(n[0],n[1]);return a<=0&&o>=0?0:o<0?o:a}return n[0]},dus=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?fd(fd({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(ju(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},uus=function(s){return s.reduce(function(r,n){return[Che(n.concat([r[0]]).filter(ln)),She(n.concat([r[1]]).filter(ln))]},[1/0,-1/0])},rnt=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,c=i.reduce(function(u,p){var f=uus(p.slice(r,n+1));return[Math.min(u[0],f[0]),Math.max(u[1],f[1])]},[1/0,-1/0]);return[Math.min(c[0],a[0]),Math.max(c[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},XOe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,QOe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Jbe=function(s,r,n){if(Mi(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(ln(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(XOe.test(s[0])){var o=+XOe.exec(s[0])[1];a[0]=r[0]-o}else Mi(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(ln(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(QOe.test(s[1])){var l=+QOe.exec(s[1])[1];a[1]=r[1]+l}else Mi(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},bce=function(s,r,n){if(s&&s.scale&&s.scale.bandwidth){var a=s.scale.bandwidth();if(!n||a>0)return a}if(s&&r&&r.length>=2){for(var o=b4e(r,function(f){return f.coordinate}),l=1/0,i=1,c=o.length;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(s-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},bus=function(s,r,n,a,o){var l=s.width,i=s.height,c=s.startAngle,u=s.endAngle,p=Am(s.cx,l,l/2),f=Am(s.cy,i,i/2),g=int(l,i,n),b=Am(s.innerRadius,g,0),_=Am(s.outerRadius,g,g*.8),j=Object.keys(r);return j.reduce(function(w,N){var S=r[N],M=S.domain,L=S.reversed,I;if($i(S.range))a==="angleAxis"?I=[c,u]:a==="radiusAxis"&&(I=[b,_]),L&&(I=[I[1],I[0]]);else{I=S.range;var O=I,q=pus(O,2);c=q[0],u=q[1]}var U=ent(S,o),B=U.realScaleType,V=U.scale;V.domain(M).range(I),tnt(V);var Y=snt(V,Dv(Dv({},S),{},{realScaleType:B})),Q=Dv(Dv(Dv({},S),Y),{},{range:I,radius:_,realScaleType:B,scale:V,cx:p,cy:f,innerRadius:b,outerRadius:_,startAngle:c,endAngle:u});return Dv(Dv({},w),{},ant({},N,Q))},{})},_us=function(s,r){var n=s.x,a=s.y,o=r.x,l=r.y;return Math.sqrt(Math.pow(n-o,2)+Math.pow(a-l,2))},wus=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=_us({x:n,y:a},{x:o,y:l});if(i<=0)return{radius:i};var c=(n-o)/i,u=Math.acos(c);return a>l&&(u=2*Math.PI-u),{radius:i,angle:vus(u),angleInRadian:u}},jus=function(s){var r=s.startAngle,n=s.endAngle,a=Math.floor(r/360),o=Math.floor(n/360),l=Math.min(a,o);return{startAngle:r-l*360,endAngle:n-l*360}},Nus=function(s,r){var n=r.startAngle,a=r.endAngle,o=Math.floor(n/360),l=Math.floor(a/360),i=Math.min(o,l);return s+i*360},sRe=function(s,r){var n=s.x,a=s.y,o=wus({x:n,y:a},r),l=o.radius,i=o.angle,c=r.innerRadius,u=r.outerRadius;if(lu)return!1;if(l===0)return!0;var p=jus(r),f=p.startAngle,g=p.endAngle,b=i,_;if(f<=g){for(;b>g;)b-=360;for(;b=f&&b<=g}else{for(;b>f;)b-=360;for(;b=g&&b<=f}return _?Dv(Dv({},r),{},{radius:l,angle:Nus(b,r)}):null},ont=function(s){return!k.isValidElement(s)&&!Mi(s)&&typeof s!="boolean"?s.className:""};function $D(t){"@babel/helpers - typeof";return $D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},$D(t)}var kus=["offset"];function Sus(t){return Aus(t)||Tus(t)||Mus(t)||Cus()}function Cus(){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 Mus(t,s){if(t){if(typeof t=="string")return e_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e_e(t,s)}}function Tus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Aus(t){if(Array.isArray(t))return e_e(t)}function e_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Pus(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function rRe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function hu(t){for(var s=1;s=0?1:-1,M,L;a==="insideStart"?(M=b+S*l,L=j):a==="insideEnd"?(M=_-S*l,L=!j):a==="end"&&(M=_+S*l,L=j),L=N<=0?L:!L;var I=nc(u,p,w,M),O=nc(u,p,w,M+(L?1:-1)*359),q="M".concat(I.x,",").concat(I.y,` A`).concat(w,",").concat(w,",0,1,").concat(L?0:1,`, `).concat(O.x,",").concat(O.y),U=$i(s.id)?yE("recharts-radial-line-"):s.id;return ht.createElement("text",qD({},n,{dominantBaseline:"central",className:Vi("recharts-radial-bar-label",i)}),ht.createElement("defs",null,ht.createElement("path",{id:U,d:q})),ht.createElement("textPath",{xlinkHref:"#".concat(U)},r))},zus=function(s){var r=s.viewBox,n=s.offset,a=s.position,o=r,l=o.cx,i=o.cy,c=o.innerRadius,u=o.outerRadius,p=o.startAngle,f=o.endAngle,g=(p+f)/2;if(a==="outside"){var b=nc(l,i,u+n,g),_=b.x,j=b.y;return{x:_,y:j,textAnchor:_>=l?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"end"};var w=(c+u)/2,N=nc(l,i,w,g),S=N.x,M=N.y;return{x:S,y:M,textAnchor:"middle",verticalAnchor:"middle"}},Bus=function(s){var r=s.viewBox,n=s.parentViewBox,a=s.offset,o=s.position,l=r,i=l.x,c=l.y,u=l.width,p=l.height,f=p>=0?1:-1,g=f*a,b=f>0?"end":"start",_=f>0?"start":"end",j=u>=0?1:-1,w=j*a,N=j>0?"end":"start",S=j>0?"start":"end";if(o==="top"){var M={x:i+u/2,y:c-f*a,textAnchor:"middle",verticalAnchor:b};return hu(hu({},M),n?{height:Math.max(c-n.y,0),width:u}:{})}if(o==="bottom"){var L={x:i+u/2,y:c+p+g,textAnchor:"middle",verticalAnchor:_};return hu(hu({},L),n?{height:Math.max(n.y+n.height-(c+p),0),width:u}:{})}if(o==="left"){var I={x:i-w,y:c+p/2,textAnchor:N,verticalAnchor:"middle"};return hu(hu({},I),n?{width:Math.max(I.x-n.x,0),height:p}:{})}if(o==="right"){var O={x:i+u+w,y:c+p/2,textAnchor:S,verticalAnchor:"middle"};return hu(hu({},O),n?{width:Math.max(n.x+n.width-O.x,0),height:p}:{})}var q=n?{width:u,height:p}:{};return o==="insideLeft"?hu({x:i+w,y:c+p/2,textAnchor:S,verticalAnchor:"middle"},q):o==="insideRight"?hu({x:i+u-w,y:c+p/2,textAnchor:N,verticalAnchor:"middle"},q):o==="insideTop"?hu({x:i+u/2,y:c+g,textAnchor:"middle",verticalAnchor:_},q):o==="insideBottom"?hu({x:i+u/2,y:c+p-g,textAnchor:"middle",verticalAnchor:b},q):o==="insideTopLeft"?hu({x:i+w,y:c+g,textAnchor:S,verticalAnchor:_},q):o==="insideTopRight"?hu({x:i+u-w,y:c+g,textAnchor:N,verticalAnchor:_},q):o==="insideBottomLeft"?hu({x:i+w,y:c+p-g,textAnchor:S,verticalAnchor:b},q):o==="insideBottomRight"?hu({x:i+u-w,y:c+p-g,textAnchor:N,verticalAnchor:b},q):pE(o)&&(ln(o.x)||C4(o.x))&&(ln(o.y)||C4(o.y))?hu({x:i+Am(o.x,u),y:c+Am(o.y,p),textAnchor:"end",verticalAnchor:"end"},q):hu({x:i+u/2,y:c+p/2,textAnchor:"middle",verticalAnchor:"middle"},q)},$us=function(s){return"cx"in s&&ln(s.cx)};function Yu(t){var s=t.offset,r=s===void 0?5:s,n=Eus(t,kus),a=hu({offset:r},n),o=a.viewBox,l=a.position,i=a.value,c=a.children,u=a.content,p=a.className,f=p===void 0?"":p,g=a.textBreakAll;if(!o||$i(i)&&$i(c)&&!k.isValidElement(u)&&!Mi(u))return null;if(k.isValidElement(u))return k.cloneElement(u,a);var b;if(Mi(u)){if(b=k.createElement(u,a),k.isValidElement(b))return b}else b=Ous(a);var _=$us(o),j=ai(a,!0);if(_&&(l==="insideStart"||l==="insideEnd"||l==="end"))return Fus(a,b,j);var w=_?zus(a):Bus(a);return ht.createElement(sC,qD({className:Vi("recharts-label",f)},j,w,{breakAll:g}),b)}Yu.displayName="Label";var lnt=function(s){var r=s.cx,n=s.cy,a=s.angle,o=s.startAngle,l=s.endAngle,i=s.r,c=s.radius,u=s.innerRadius,p=s.outerRadius,f=s.x,g=s.y,b=s.top,_=s.left,j=s.width,w=s.height,N=s.clockWise,S=s.labelViewBox;if(S)return S;if(ln(j)&&ln(w)){if(ln(f)&&ln(g))return{x:f,y:g,width:j,height:w};if(ln(b)&&ln(_))return{x:b,y:_,width:j,height:w}}return ln(f)&&ln(g)?{x:f,y:g,width:0,height:0}:ln(r)&&ln(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||c||i||0,clockWise:N}:s.viewBox?s.viewBox:{}},qus=function(s,r){return s?s===!0?ht.createElement(Yu,{key:"label-implicit",viewBox:r}):ju(s)?ht.createElement(Yu,{key:"label-implicit",viewBox:r,value:s}):k.isValidElement(s)?s.type===Yu?k.cloneElement(s,{key:"label-implicit",viewBox:r}):ht.createElement(Yu,{key:"label-implicit",content:s,viewBox:r}):Mi(s)?ht.createElement(Yu,{key:"label-implicit",content:s,viewBox:r}):pE(s)?ht.createElement(Yu,qD({viewBox:r},s,{key:"label-implicit"})):null:null},Uus=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!s||!s.children&&n&&!s.label)return null;var a=s.children,o=lnt(s),l=Nf(a,Yu).map(function(c,u){return k.cloneElement(c,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=qus(s.label,r||o);return[i].concat(Sus(l))};Yu.parseViewBox=lnt;Yu.renderCallByParent=Uus;function Vus(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var Hus=Vus;const Wus=Po(Hus);function UD(t){"@babel/helpers - typeof";return UD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},UD(t)}var Gus=["valueAccessor"],Kus=["data","dataKey","clockWise","id","textBreakAll"];function Zus(t){return Jus(t)||Qus(t)||Xus(t)||Yus()}function Yus(){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 Xus(t,s){if(t){if(typeof t=="string")return t_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return t_e(t,s)}}function Qus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Jus(t){if(Array.isArray(t))return t_e(t)}function t_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function rhs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var nhs=function(s){return Array.isArray(s.value)?Wus(s.value):s.value};function b1(t){var s=t.valueAccessor,r=s===void 0?nhs:s,n=iRe(t,Gus),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,c=n.textBreakAll,u=iRe(n,Kus);return!a||!a.length?null:ht.createElement(Zo,{className:"recharts-label-list"},a.map(function(p,f){var g=$i(o)?r(p,f):_u(p&&p.payload,o),b=$i(i)?{}:{id:"".concat(i,"-").concat(f)};return ht.createElement(Yu,wce({},ai(p,!0),u,b,{parentViewBox:p.parentViewBox,value:g,textBreakAll:c,viewBox:Yu.parseViewBox($i(l)?p:aRe(aRe({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}b1.displayName="LabelList";function ahs(t,s){return t?t===!0?ht.createElement(b1,{key:"labelList-implicit",data:s}):ht.isValidElement(t)||Mi(t)?ht.createElement(b1,{key:"labelList-implicit",data:s,content:t}):pE(t)?ht.createElement(b1,wce({data:s},t,{key:"labelList-implicit"})):null:null}function ihs(t,s){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&r&&!t.label)return null;var n=t.children,a=Nf(n,b1).map(function(l,i){return k.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=ahs(t.label,s);return[o].concat(Zus(a))}b1.renderCallByParent=ihs;function VD(t){"@babel/helpers - typeof";return VD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},VD(t)}function s_e(){return s_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s180),",").concat(+(l>u),`, `).concat(f.x,",").concat(f.y,` `);if(a>0){var b=nc(r,n,a,l),_=nc(r,n,a,u);g+="L ".concat(_.x,",").concat(_.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(c)>180),",").concat(+(l<=u),`, `).concat(b.x,",").concat(b.y," Z")}else g+="L ".concat(r,",").concat(n," Z");return g},uhs=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,o=s.outerRadius,l=s.cornerRadius,i=s.forceCornerRadius,c=s.cornerIsExternal,u=s.startAngle,p=s.endAngle,f=Tm(p-u),g=zz({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:c}),b=g.circleTangency,_=g.lineTangency,j=g.theta,w=zz({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:c}),N=w.circleTangency,S=w.lineTangency,M=w.theta,L=c?Math.abs(u-p):Math.abs(u-p)-j-M;if(L<0)return i?"M ".concat(_.x,",").concat(_.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 `):cnt({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:p});var I="M ".concat(_.x,",").concat(_.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(b.x,",").concat(b.y,` A`).concat(o,",").concat(o,",0,").concat(+(L>180),",").concat(+(f<0),",").concat(N.x,",").concat(N.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(S.x,",").concat(S.y,` `);if(a>0){var O=zz({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),q=O.circleTangency,U=O.lineTangency,B=O.theta,V=zz({cx:r,cy:n,radius:a,angle:p,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),Y=V.circleTangency,Q=V.lineTangency,ee=V.theta,X=c?Math.abs(u-p):Math.abs(u-p)-B-ee;if(X<0&&l===0)return"".concat(I,"L").concat(r,",").concat(n,"Z");I+="L".concat(Q.x,",").concat(Q.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(Y.x,",").concat(Y.y,` A`).concat(a,",").concat(a,",0,").concat(+(X>180),",").concat(+(f>0),",").concat(q.x,",").concat(q.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(U.x,",").concat(U.y,"Z")}else I+="L".concat(r,",").concat(n,"Z");return I},hhs={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},dnt=function(s){var r=lRe(lRe({},hhs),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,c=r.forceCornerRadius,u=r.cornerIsExternal,p=r.startAngle,f=r.endAngle,g=r.className;if(l0&&Math.abs(p-f)<360?w=uhs({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(j,_/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:p,endAngle:f}):w=cnt({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:f}),ht.createElement("path",s_e({},ai(r,!0),{className:b,d:w,role:"img"}))};function HD(t){"@babel/helpers - typeof";return HD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},HD(t)}function r_e(){return r_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s0;)if(!r.equals(t[n],s[n],n,n,t,s,r))return!1;return!0}function Ehs(t,s){return SC(t.getTime(),s.getTime())}function Phs(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function Ihs(t,s){return t===s}function xRe(t,s,r){var n=t.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),o=t.entries(),l,i,c=0;(l=o.next())&&!l.done;){for(var u=s.entries(),p=!1,f=0;(i=u.next())&&!i.done;){if(a[f]){f++;continue}var g=l.value,b=i.value;if(r.equals(g[0],b[0],c,f,t,s,r)&&r.equals(g[1],b[1],g[0],b[0],t,s,r)){p=a[f]=!0;break}f++}if(!p)return!1;c++}return!0}var Lhs=SC;function Dhs(t,s,r){var n=fRe(t),a=n.length;if(fRe(s).length!==a)return!1;for(;a-- >0;)if(!pnt(t,s,r,n[a]))return!1;return!0}function oI(t,s,r){var n=mRe(t),a=n.length;if(mRe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!pnt(t,s,r,o)||(l=pRe(t,o),i=pRe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function Ohs(t,s){return SC(t.valueOf(),s.valueOf())}function Rhs(t,s){return t.source===s.source&&t.flags===s.flags}function gRe(t,s,r){var n=t.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),o=t.values(),l,i;(l=o.next())&&!l.done;){for(var c=s.values(),u=!1,p=0;(i=c.next())&&!i.done;){if(!a[p]&&r.equals(l.value,i.value,l.value,i.value,t,s,r)){u=a[p]=!0;break}p++}if(!u)return!1}return!0}function Fhs(t,s){var r=t.length;if(s.length!==r)return!1;for(;r-- >0;)if(t[r]!==s[r])return!1;return!0}function zhs(t,s){return t.hostname===s.hostname&&t.pathname===s.pathname&&t.protocol===s.protocol&&t.port===s.port&&t.hash===s.hash&&t.username===s.username&&t.password===s.password}function pnt(t,s,r,n){return(n===Ths||n===Mhs||n===Chs)&&(t.$$typeof||s.$$typeof)?!0:Shs(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var Bhs="[object Arguments]",$hs="[object Boolean]",qhs="[object Date]",Uhs="[object Error]",Vhs="[object Map]",Hhs="[object Number]",Whs="[object Object]",Ghs="[object RegExp]",Khs="[object Set]",Zhs="[object String]",Yhs="[object URL]",Xhs=Array.isArray,yRe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,vRe=Object.assign,Qhs=Object.prototype.toString.call.bind(Object.prototype.toString);function Jhs(t){var s=t.areArraysEqual,r=t.areDatesEqual,n=t.areErrorsEqual,a=t.areFunctionsEqual,o=t.areMapsEqual,l=t.areNumbersEqual,i=t.areObjectsEqual,c=t.arePrimitiveWrappersEqual,u=t.areRegExpsEqual,p=t.areSetsEqual,f=t.areTypedArraysEqual,g=t.areUrlsEqual;return function(_,j,w){if(_===j)return!0;if(_==null||j==null)return!1;var N=typeof _;if(N!==typeof j)return!1;if(N!=="object")return N==="number"?l(_,j,w):N==="function"?a(_,j,w):!1;var S=_.constructor;if(S!==j.constructor)return!1;if(S===Object)return i(_,j,w);if(Xhs(_))return s(_,j,w);if(yRe!=null&&yRe(_))return f(_,j,w);if(S===Date)return r(_,j,w);if(S===RegExp)return u(_,j,w);if(S===Map)return o(_,j,w);if(S===Set)return p(_,j,w);var M=Qhs(_);return M===qhs?r(_,j,w):M===Ghs?u(_,j,w):M===Vhs?o(_,j,w):M===Khs?p(_,j,w):M===Whs?typeof _.then!="function"&&typeof j.then!="function"&&i(_,j,w):M===Yhs?g(_,j,w):M===Uhs?n(_,j,w):M===Bhs?i(_,j,w):M===$hs||M===Hhs||M===Zhs?c(_,j,w):!1}}function ems(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?oI:Ahs,areDatesEqual:Ehs,areErrorsEqual:Phs,areFunctionsEqual:Ihs,areMapsEqual:n?hRe(xRe,oI):xRe,areNumbersEqual:Lhs,areObjectsEqual:n?oI:Dhs,arePrimitiveWrappersEqual:Ohs,areRegExpsEqual:Rhs,areSetsEqual:n?hRe(gRe,oI):gRe,areTypedArraysEqual:n?oI:Fhs,areUrlsEqual:zhs};if(r&&(a=vRe({},a,r(a))),s){var o=$z(a.areArraysEqual),l=$z(a.areMapsEqual),i=$z(a.areObjectsEqual),c=$z(a.areSetsEqual);a=vRe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:c})}return a}function tms(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function sms(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(c,u){var p=n(),f=p.cache,g=f===void 0?s?new WeakMap:void 0:f,b=p.meta;return r(c,u,{cache:g,equals:a,meta:b,strict:o})};if(s)return function(c,u){return r(c,u,{cache:new WeakMap,equals:a,meta:void 0,strict:o})};var l={cache:void 0,equals:a,meta:void 0,strict:o};return function(c,u){return r(c,u,l)}}var rms=qw();qw({strict:!0});qw({circular:!0});qw({circular:!0,strict:!0});qw({createInternalComparator:function(){return SC}});qw({strict:!0,createInternalComparator:function(){return SC}});qw({circular:!0,createInternalComparator:function(){return SC}});qw({circular:!0,createInternalComparator:function(){return SC},strict:!0});function qw(t){t===void 0&&(t={});var s=t.circular,r=s===void 0?!1:s,n=t.createInternalComparator,a=t.createState,o=t.strict,l=o===void 0?!1:o,i=ems(t),c=Jhs(i),u=n?n(c):tms(c);return sms({circular:r,comparator:c,createState:a,equals:u,strict:l})}function nms(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function bRe(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,n=function a(o){r<0&&(r=o),o-r>s?(t(o),r=-1):nms(a)};requestAnimationFrame(n)}function n_e(t){"@babel/helpers - typeof";return n_e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},n_e(t)}function ams(t){return cms(t)||lms(t)||oms(t)||ims()}function ims(){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 oms(t,s){if(t){if(typeof t=="string")return _Re(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _Re(t,s)}}function _Re(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1?1:N<0?0:N},j=function(N){for(var S=N>1?1:N,M=S,L=0;L<8;++L){var I=f(M)-S,O=b(M);if(Math.abs(I-S)0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,o=a===void 0?8:a,l=s.dt,i=l===void 0?17:l,c=function(p,f,g){var b=-(p-f)*n,_=g*o,j=g+(b-_)*i/1e3,w=g*i/1e3+p;return Math.abs(w-f)t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Bms(t,s){if(t==null)return{};var r={},n=Object.keys(t),a,o;for(o=0;o=0)&&(r[a]=t[a]);return r}function oye(t){return Vms(t)||Ums(t)||qms(t)||$ms()}function $ms(){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 qms(t,s){if(t){if(typeof t=="string")return c_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c_e(t,s)}}function Ums(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Vms(t){if(Array.isArray(t))return c_e(t)}function c_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Sce(t){return Sce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Sce(t)}var D0=function(t){Zms(r,t);var s=Yms(r);function r(n,a){var o;Hms(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,c=l.attributeName,u=l.from,p=l.to,f=l.steps,g=l.children,b=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(h_e(o)),o.changeStyle=o.changeStyle.bind(h_e(o)),!i||b<=0)return o.state={style:{}},typeof g=="function"&&(o.state={style:p}),u_e(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof g=="function")return o.state={style:u},u_e(o);o.state={style:c?TI({},c,u):u}}else o.state={style:{}};return o}return Gms(r,[{key:"componentDidMount",value:function(){var a=this.props,o=a.isActive,l=a.canBegin;this.mounted=!0,!(!o||!l)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var o=this.props,l=o.isActive,i=o.canBegin,c=o.attributeName,u=o.shouldReAnimate,p=o.to,f=o.from,g=this.state.style;if(i){if(!l){var b={style:c?TI({},c,p):p};this.state&&g&&(c&&g[c]!==p||!c&&g!==p)&&this.setState(b);return}if(!(rms(a.to,p)&&a.canBegin&&a.isActive)){var _=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var j=_||u?f:a.to;if(this.state&&g){var w={style:c?TI({},c,j):j};(c&&g[c]!==j||!c&&g!==j)&&this.setState(w)}this.runAnimation(Sg(Sg({},this.props),{},{from:j,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,c=a.duration,u=a.easing,p=a.begin,f=a.onAnimationEnd,g=a.onAnimationStart,b=Rms(l,i,Sms(u),c,this.changeStyle),_=function(){o.stopJSAnimation=b()};this.manager.start([g,p,_,c,f])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,c=a.onAnimationStart,u=l[0],p=u.style,f=u.duration,g=f===void 0?0:f,b=function(j,w,N){if(N===0)return j;var S=w.duration,M=w.easing,L=M===void 0?"ease":M,I=w.style,O=w.properties,q=w.onAnimationEnd,U=N>0?l[N-1]:w,B=O||Object.keys(I);if(typeof L=="function"||L==="spring")return[].concat(oye(j),[o.runJSAnimation.bind(o,{from:U.style,to:I,duration:S,easing:L}),S]);var V=NRe(B,S,L),Y=Sg(Sg(Sg({},U.style),I),{},{transition:V});return[].concat(oye(j),[Y,S,q]).filter(pms)};return this.manager.start([c].concat(oye(l.reduce(b,[p,Math.max(g,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=dms());var o=a.begin,l=a.duration,i=a.attributeName,c=a.to,u=a.easing,p=a.onAnimationStart,f=a.onAnimationEnd,g=a.steps,b=a.children,_=this.manager;if(this.unSubscribe=_.subscribe(this.handleStyleChange),typeof u=="function"||typeof b=="function"||u==="spring"){this.runJSAnimation(a);return}if(g.length>1){this.runStepAnimation(a);return}var j=i?TI({},i,c):c,w=NRe(Object.keys(j),l,u);_.start([p,o,Sg(Sg({},j),{},{transition:w}),l,f])}},{key:"render",value:function(){var a=this.props,o=a.children;a.begin;var l=a.duration;a.attributeName,a.easing;var i=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var c=zms(a,Fms),u=k.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var f=function(b){var _=b.props,j=_.style,w=j===void 0?{}:j,N=_.className,S=k.cloneElement(b,Sg(Sg({},c),{},{style:Sg(Sg({},w),p),className:N}));return S};return u===1?f(k.Children.only(o)):ht.createElement("div",null,k.Children.map(o,function(g){return f(g)}))}}]),r}(k.PureComponent);D0.displayName="Animate";D0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};D0.propTypes={from:ol.oneOfType([ol.object,ol.string]),to:ol.oneOfType([ol.object,ol.string]),attributeName:ol.string,duration:ol.number,begin:ol.number,easing:ol.oneOfType([ol.string,ol.func]),steps:ol.arrayOf(ol.shape({duration:ol.number.isRequired,style:ol.object.isRequired,easing:ol.oneOfType([ol.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),ol.func]),properties:ol.arrayOf("string"),onAnimationEnd:ol.func})),children:ol.oneOfType([ol.node,ol.func]),isActive:ol.bool,canBegin:ol.bool,onAnimationEnd:ol.func,shouldReAnimate:ol.bool,onAnimationStart:ol.func,onAnimationReStart:ol.func};function KD(t){"@babel/helpers - typeof";return KD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},KD(t)}function Cce(){return Cce=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0?1:-1,c=n>=0?1:-1,u=a>=0&&n>=0||a<0&&n<0?1:0,p;if(l>0&&o instanceof Array){for(var f=[0,0,0,0],g=0,b=4;gl?l:o[g];p="M".concat(s,",").concat(r+i*f[0]),f[0]>0&&(p+="A ".concat(f[0],",").concat(f[0],",0,0,").concat(u,",").concat(s+c*f[0],",").concat(r)),p+="L ".concat(s+n-c*f[1],",").concat(r),f[1]>0&&(p+="A ".concat(f[1],",").concat(f[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*f[1])),p+="L ".concat(s+n,",").concat(r+a-i*f[2]),f[2]>0&&(p+="A ".concat(f[2],",").concat(f[2],",0,0,").concat(u,`, `).concat(s+n-c*f[2],",").concat(r+a)),p+="L ".concat(s+c*f[3],",").concat(r+a),f[3]>0&&(p+="A ".concat(f[3],",").concat(f[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*f[3])),p+="Z"}else if(l>0&&o===+o&&o>0){var _=Math.min(l,o);p="M ".concat(s,",").concat(r+i*_,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s+c*_,",").concat(r,` L `).concat(s+n-c*_,",").concat(r,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s+n,",").concat(r+i*_,` L `).concat(s+n,",").concat(r+a-i*_,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s+n-c*_,",").concat(r+a,` L `).concat(s+c*_,",").concat(r+a,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s,",").concat(r+a-i*_," Z")}else p="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return p},ips=function(s,r){if(!s||!r)return!1;var n=s.x,a=s.y,o=r.x,l=r.y,i=r.width,c=r.height;if(Math.abs(i)>0&&Math.abs(c)>0){var u=Math.min(o,o+i),p=Math.max(o,o+i),f=Math.min(l,l+c),g=Math.max(l,l+c);return n>=u&&n<=p&&a>=f&&a<=g}return!1},ops={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},G4e=function(s){var r=PRe(PRe({},ops),s),n=k.useRef(),a=k.useState(-1),o=Qms(a,2),l=o[0],i=o[1];k.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var L=n.current.getTotalLength();L&&i(L)}catch{}},[]);var c=r.x,u=r.y,p=r.width,f=r.height,g=r.radius,b=r.className,_=r.animationEasing,j=r.animationDuration,w=r.animationBegin,N=r.isAnimationActive,S=r.isUpdateAnimationActive;if(c!==+c||u!==+u||p!==+p||f!==+f||p===0||f===0)return null;var M=Vi("recharts-rectangle",b);return S?ht.createElement(D0,{canBegin:l>0,from:{width:p,height:f,x:c,y:u},to:{width:p,height:f,x:c,y:u},duration:j,animationEasing:_,isActive:S},function(L){var I=L.width,O=L.height,q=L.x,U=L.y;return ht.createElement(D0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,isActive:N,easing:_},ht.createElement("path",Cce({},ai(r,!0),{className:M,d:IRe(q,U,I,O,g),ref:n})))}):ht.createElement("path",Cce({},ai(r,!0),{className:M,d:IRe(c,u,p,f,g)}))},lps=["points","className","baseLinePoints","connectNulls"];function mM(){return mM=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function dps(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function LRe(t){return pps(t)||mps(t)||hps(t)||ups()}function ups(){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 hps(t,s){if(t){if(typeof t=="string")return m_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m_e(t,s)}}function mps(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function pps(t){if(Array.isArray(t))return m_e(t)}function m_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return s.forEach(function(n){DRe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),DRe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},y8=function(s,r){var n=fps(s);r&&(n=[n.reduce(function(o,l){return[].concat(LRe(o),LRe(l))},[])]);var a=n.map(function(o){return o.reduce(function(l,i,c){return"".concat(l).concat(c===0?"M":"L").concat(i.x,",").concat(i.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},xps=function(s,r,n){var a=y8(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(y8(r.reverse(),n).slice(1))},gps=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=cps(s,lps);if(!r||!r.length)return null;var i=Vi("recharts-polygon",n);if(a&&a.length){var c=l.stroke&&l.stroke!=="none",u=xps(r,a,o);return ht.createElement("g",{className:i},ht.createElement("path",mM({},ai(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),c?ht.createElement("path",mM({},ai(l,!0),{fill:"none",d:y8(r,o)})):null,c?ht.createElement("path",mM({},ai(l,!0),{fill:"none",d:y8(a,o)})):null)}var p=y8(r,o);return ht.createElement("path",mM({},ai(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function p_e(){return p_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Nps(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var kps=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},Sps=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.top,i=l===void 0?0:l,c=s.left,u=c===void 0?0:c,p=s.width,f=p===void 0?0:p,g=s.height,b=g===void 0?0:g,_=s.className,j=jps(s,yps),w=vps({x:n,y:o,top:i,left:u,width:f,height:b},j);return!ln(n)||!ln(o)||!ln(f)||!ln(b)||!ln(i)||!ln(u)?null:ht.createElement("path",f_e({},ai(w,!0),{className:Vi("recharts-cross",_),d:kps(n,o,f,b,i,u)}))},Cps=khe,Mps=Prt,Tps=U0;function Aps(t,s){return t&&t.length?Cps(t,Tps(s),Mps):void 0}var Eps=Aps;const Pps=Po(Eps);var Ips=khe,Lps=U0,Dps=Irt;function Ops(t,s){return t&&t.length?Ips(t,Lps(s),Dps):void 0}var Rps=Ops;const Fps=Po(Rps);var zps=["cx","cy","angle","ticks","axisLine"],Bps=["ticks","tick","angle","tickFormatter","stroke"];function oA(t){"@babel/helpers - typeof";return oA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},oA(t)}function v8(){return v8=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function $ps(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function qps(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function zRe(t,s){for(var r=0;rqRe?l=a==="outer"?"start":"end":o<-qRe?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,c=n.axisLineType,u=U2(U2({},ai(this.props,!1)),{},{fill:"none"},ai(i,!1));if(c==="circle")return ht.createElement(Ahe,m4({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,f=p.map(function(g){return nc(a,o,l,g.coordinate)});return ht.createElement(gps,m4({className:"recharts-polar-angle-axis-line"},u,{points:f}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,o=a.ticks,l=a.tick,i=a.tickLine,c=a.tickFormatter,u=a.stroke,p=ai(this.props,!1),f=ai(l,!1),g=U2(U2({},p),{},{fill:"none"},ai(i,!1)),b=o.map(function(_,j){var w=n.getTickLineCoord(_),N=n.getTickTextAnchor(_),S=U2(U2(U2({textAnchor:N},p),{},{stroke:"none",fill:u},f),{},{index:j,payload:_,x:w.x2,y:w.y2});return ht.createElement(Zo,m4({className:Vi("recharts-polar-angle-axis-tick",ont(l)),key:"tick-".concat(_.coordinate)},tC(n.props,_,j)),i&&ht.createElement("line",m4({className:"recharts-polar-angle-axis-tick-line"},g,w)),l&&s.renderTickItem(l,S,c?c(_.value,j):_.value))});return ht.createElement(Zo,{className:"recharts-polar-angle-axis-ticks"},b)}},{key:"render",value:function(){var n=this.props,a=n.ticks,o=n.radius,l=n.axisLine;return o<=0||!a||!a.length?null:ht.createElement(Zo,{className:Vi("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return ht.isValidElement(n)?l=ht.cloneElement(n,a):Mi(n)?l=n(a):l=ht.createElement(sC,m4({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(k.PureComponent);Ihe(Lhe,"displayName","PolarAngleAxis");Ihe(Lhe,"axisType","angleAxis");Ihe(Lhe,"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 rfs=Mst,nfs=rfs(Object.getPrototypeOf,Object),afs=nfs,ifs=q1,ofs=afs,lfs=U1,cfs="[object Object]",dfs=Function.prototype,ufs=Object.prototype,knt=dfs.toString,hfs=ufs.hasOwnProperty,mfs=knt.call(Object);function pfs(t){if(!lfs(t)||ifs(t)!=cfs)return!1;var s=ofs(t);if(s===null)return!0;var r=hfs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&knt.call(r)==mfs}var ffs=pfs;const xfs=Po(ffs);var gfs=q1,yfs=U1,vfs="[object Boolean]";function bfs(t){return t===!0||t===!1||yfs(t)&&gfs(t)==vfs}var _fs=bfs;const wfs=Po(_fs);function YD(t){"@babel/helpers - typeof";return YD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},YD(t)}function Ace(){return Ace=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0,from:{upperWidth:0,lowerWidth:0,height:g,x:c,y:u},to:{upperWidth:p,lowerWidth:f,height:g,x:c,y:u},duration:j,animationEasing:_,isActive:N},function(M){var L=M.upperWidth,I=M.lowerWidth,O=M.height,q=M.x,U=M.y;return ht.createElement(D0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,easing:_},ht.createElement("path",Ace({},ai(r,!0),{className:S,d:WRe(q,U,L,I,O),ref:n})))}):ht.createElement("g",null,ht.createElement("path",Ace({},ai(r,!0),{className:S,d:WRe(c,u,p,f,g)})))},Ifs=["option","shapeType","propTransformer","activeClassName","isActive"];function XD(t){"@babel/helpers - typeof";return XD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},XD(t)}function Lfs(t,s){if(t==null)return{};var r=Dfs(t,s),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Dfs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function GRe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Ece(t){for(var s=1;s0?jf(M,"paddingAngle",0):0;if(I){var q=af(I.endAngle-I.startAngle,M.endAngle-M.startAngle),U=Gl(Gl({},M),{},{startAngle:S+O,endAngle:S+q(j)+O});w.push(U),S=U.endAngle}else{var B=M.endAngle,V=M.startAngle,Y=af(0,B-V),Q=Y(j),ee=Gl(Gl({},M),{},{startAngle:S+O,endAngle:S+Q+O});w.push(ee),S=ee.endAngle}}),ht.createElement(Zo,null,n.renderSectorsStatically(w))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var l=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"ArrowRight":{var i=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,o=n.isAnimationActive,l=this.state.prevSectors;return o&&a&&a.length&&(!l||!mR(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,c=a.label,u=a.cx,p=a.cy,f=a.innerRadius,g=a.outerRadius,b=a.isAnimationActive,_=this.state.isAnimationFinished;if(o||!l||!l.length||!ln(u)||!ln(p)||!ln(f)||!ln(g))return null;var j=Vi("recharts-pie",i);return ht.createElement(Zo,{tabIndex:this.props.rootTabIndex,className:j,ref:function(N){n.pieRef=N}},this.renderSectors(),c&&this.renderLabels(l),Yu.renderCallByParent(this.props,null,!1),(!b||_)&&b1.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?S:S-1)*c,L=w-S*b-M,I=a.reduce(function(U,B){var V=_u(B,N,0);return U+(ln(V)?V:0)},0),O;if(I>0){var q;O=a.map(function(U,B){var V=_u(U,N,0),Y=_u(U,p,B),Q=(ln(V)?V:0)/I,ee;B?ee=q.endAngle+Tm(j)*c*(V!==0?1:0):ee=l;var X=ee+Tm(j)*((V!==0?b:0)+Q*L),ie=(ee+X)/2,re=(_.innerRadius+_.outerRadius)/2,oe=[{name:Y,value:V,payload:U,dataKey:N,type:g}],ce=nc(_.cx,_.cy,re,ie);return q=Gl(Gl(Gl({percent:Q,cornerRadius:o,name:Y,tooltipPayload:oe,midAngle:ie,middleRadius:re,tooltipPosition:ce},U),_),{},{value:_u(U,N),startAngle:ee,endAngle:X,payload:U,paddingAngle:Tm(j)*c}),q})}return Gl(Gl({},_),{},{sectors:O,data:a})});var sxs=Math.ceil,rxs=Math.max;function nxs(t,s,r,n){for(var a=-1,o=rxs(sxs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var axs=nxs,ixs=Gst,XRe=1/0,oxs=17976931348623157e292;function lxs(t){if(!t)return t===0?t:0;if(t=ixs(t),t===XRe||t===-XRe){var s=t<0?-1:1;return s*oxs}return t===t?t:0}var Tnt=lxs,cxs=axs,dxs=yhe,lye=Tnt;function uxs(t){return function(s,r,n){return n&&typeof n!="number"&&dxs(s,r,n)&&(r=n=void 0),s=lye(s),r===void 0?(r=s,s=0):r=lye(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),ef(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()}),ef(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),ef(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),ef(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),ef(n,"handleSlideDragStart",function(a){var o=sFe(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 kxs(s,t),_xs(s,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,o=n.endX,l=this.state.scaleValues,i=this.props,c=i.gap,u=i.data,p=u.length-1,f=Math.min(a,o),g=Math.max(a,o),b=s.getIndexInRange(l,f),_=s.getIndexInRange(l,g);return{startIndex:b-b%c,endIndex:_===p?p:_-_%c}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,c=_u(o[n],i,n);return Mi(l)?l(c,n):c}},{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,c=this.props,u=c.x,p=c.width,f=c.travellerWidth,g=c.startIndex,b=c.endIndex,_=c.onChange,j=n.pageX-o;j>0?j=Math.min(j,u+p-f-i,u+p-f-l):j<0&&(j=Math.max(j,u-l,u-i));var w=this.getIndex({startX:l+j,endX:i+j});(w.startIndex!==g||w.endIndex!==b)&&_&&_(w),this.setState({startX:l+j,endX:i+j,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=sFe(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,c=a.startX,u=this.state[l],p=this.props,f=p.x,g=p.width,b=p.travellerWidth,_=p.onChange,j=p.gap,w=p.data,N={startX:this.state.startX,endX:this.state.endX},S=n.pageX-o;S>0?S=Math.min(S,f+g-b-u):S<0&&(S=Math.max(S,f-u)),N[l]=u+S;var M=this.getIndex(N),L=M.startIndex,I=M.endIndex,O=function(){var U=w.length-1;return l==="startX"&&(i>c?L%j===0:I%j===0)||ic?I%j===0:L%j===0)||i>c&&I===U};this.setState(ef(ef({},l,u+S),"brushMoveStartX",n.pageX),function(){_&&O()&&_(M)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,c=l.startX,u=l.endX,p=this.state[a],f=i.indexOf(p);if(f!==-1){var g=f+n;if(!(g===-1||g>=i.length)){var b=i[g];a==="startX"&&b>=u||a==="endX"&&b<=c||this.setState(ef({},a,b),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,c=n.fill,u=n.stroke;return ht.createElement("rect",{stroke:u,fill:c,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,c=n.data,u=n.children,p=n.padding,f=k.Children.only(u);return f?ht.cloneElement(f,{x:a,y:o,width:l,height:i,margin:p,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,c=this.props,u=c.y,p=c.travellerWidth,f=c.height,g=c.traveller,b=c.ariaLabel,_=c.data,j=c.startIndex,w=c.endIndex,N=Math.max(n,this.props.x),S=cye(cye({},ai(this.props,!1)),{},{x:N,y:u,width:p,height:f}),M=b||"Min value: ".concat((o=_[j])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=_[w])===null||l===void 0?void 0:l.name);return ht.createElement(Zo,{tabIndex:0,role:"slider","aria-label":M,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(I){["ArrowLeft","ArrowRight"].includes(I.key)&&(I.preventDefault(),I.stopPropagation(),i.handleTravellerMoveKeyboard(I.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(g,S))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,c=o.stroke,u=o.travellerWidth,p=Math.min(n,a)+u,f=Math.max(Math.abs(a-n)-u,0);return ht.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:p,y:l,width:f,height:i})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,o=n.endIndex,l=n.y,i=n.height,c=n.travellerWidth,u=n.stroke,p=this.state,f=p.startX,g=p.endX,b=5,_={pointerEvents:"none",fill:u};return ht.createElement(Zo,{className:"recharts-brush-texts"},ht.createElement(sC,Lce({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,g)-b,y:l+i/2},_),this.getTextOfTick(a)),ht.createElement(sC,Lce({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,g)+c+b,y:l+i/2},_),this.getTextOfTick(o)))}},{key:"render",value:function(){var n=this.props,a=n.data,o=n.className,l=n.children,i=n.x,c=n.y,u=n.width,p=n.height,f=n.alwaysShowText,g=this.state,b=g.startX,_=g.endX,j=g.isTextActive,w=g.isSlideMoving,N=g.isTravellerMoving,S=g.isTravellerFocused;if(!a||!a.length||!ln(i)||!ln(c)||!ln(u)||!ln(p)||u<=0||p<=0)return null;var M=Vi("recharts-brush",o),L=ht.Children.count(l)===1,I=vxs("userSelect","none");return ht.createElement(Zo,{className:M,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:I},this.renderBackground(),L&&this.renderPanorama(),this.renderSlide(b,_),this.renderTravellerLayer(b,"startX"),this.renderTravellerLayer(_,"endX"),(j||w||N||S||f)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,c=n.stroke,u=Math.floor(o+i/2)-1;return ht.createElement(ht.Fragment,null,ht.createElement("rect",{x:a,y:o,width:l,height:i,fill:c,stroke:"none"}),ht.createElement("line",{x1:a+1,y1:u,x2:a+l-1,y2:u,fill:"none",stroke:"#fff"}),ht.createElement("line",{x1:a+1,y1:u+2,x2:a+l-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var o;return ht.isValidElement(n)?o=ht.cloneElement(n,a):Mi(n)?o=n(a):o=s.renderDefaultTraveller(a),o}},{key:"getDerivedStateFromProps",value:function(n,a){var o=n.data,l=n.width,i=n.x,c=n.travellerWidth,u=n.updateId,p=n.startIndex,f=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return cye({prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?Cxs({data:o,width:l,x:i,travellerWidth:c,startIndex:p,endIndex:f}):{scale:null,scaleValues:null});if(a.scale&&(l!==a.prevWidth||i!==a.prevX||c!==a.prevTravellerWidth)){a.scale.range([i,i+l-c]);var g=a.scale.domain().map(function(b){return a.scale(b)});return{prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:g}}return null}},{key:"getIndexInRange",value:function(n,a){for(var o=n.length,l=0,i=o-1;i-l>1;){var c=Math.floor((l+i)/2);n[c]>a?i=c:l=c}return a>=n[i]?i:l}}])}(k.PureComponent);ef(uA,"displayName","Brush");ef(uA,"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 Mxs=v4e;function Txs(t,s){var r;return Mxs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Axs=Txs,Exs=bst,Pxs=U0,Ixs=Axs,Lxs=Ip,Dxs=yhe;function Oxs(t,s,r){var n=Lxs(t)?Exs:Ixs;return r&&Dxs(t,s,r)&&(s=void 0),n(t,Pxs(s))}var Rxs=Oxs;const Fxs=Po(Rxs);var S0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},rFe=qst;function zxs(t,s,r){s=="__proto__"&&rFe?rFe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Bxs=zxs,$xs=Bxs,qxs=Bst,Uxs=U0;function Vxs(t,s){var r={};return s=Uxs(s),qxs(t,function(n,a,o){$xs(r,a,s(n,a,o))}),r}var Hxs=Vxs;const Wxs=Po(Hxs);function Gxs(t,s){for(var r=-1,n=t==null?0:t.length;++r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function dgs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function ugs(t,s){var r=t.x,n=t.y,a=cgs(t,ags),o="".concat(r),l=parseInt(o,10),i="".concat(n),c=parseInt(i,10),u="".concat(s.height||a.height),p=parseInt(u,10),f="".concat(s.width||a.width),g=parseInt(f,10);return lI(lI(lI(lI(lI({},s),a),l?{x:l}:{}),c?{y:c}:{}),{},{height:p,width:g,name:s.name,radius:s.radius})}function aFe(t){return ht.createElement(Snt,b_e({shapeType:"rectangle",propTransformer:ugs,activeClassName:"recharts-active-bar"},t))}var hgs=function(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof s=="number")return s;var o=ln(n)||RZt(n);return o?s(n,a):(o||nC(),r)}},mgs=["value","background"],Lnt;function hA(t){"@babel/helpers - typeof";return hA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},hA(t)}function pgs(t,s){if(t==null)return{};var r=fgs(t,s),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function fgs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Oce(){return Oce=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ie)0&&Math.abs(X)0&&(ee=Math.min(($e||0)-(X[Ae-1]||0),ee))}),Number.isFinite(ee)){var ie=ee/Q,re=j.layout==="vertical"?n.height:n.width;if(j.padding==="gap"&&(q=ie*re/2),j.padding==="no-gap"){var oe=Am(s.barCategoryGap,ie*re),ce=ie*re/2;q=ce-oe-(ce-oe)/re*oe}}}a==="xAxis"?U=[n.left+(M.left||0)+(q||0),n.left+n.width-(M.right||0)-(q||0)]:a==="yAxis"?U=c==="horizontal"?[n.top+n.height-(M.bottom||0),n.top+(M.top||0)]:[n.top+(M.top||0)+(q||0),n.top+n.height-(M.bottom||0)-(q||0)]:U=j.range,I&&(U=[U[1],U[0]]);var ge=ent(j,o,g),ye=ge.scale,ue=ge.realScaleType;ye.domain(N).range(U),tnt(ye);var pe=snt(ye,zg(zg({},j),{},{realScaleType:ue}));a==="xAxis"?(Y=w==="top"&&!L||w==="bottom"&&L,B=n.left,V=f[O]-Y*j.height):a==="yAxis"&&(Y=w==="left"&&!L||w==="right"&&L,B=f[O]-Y*j.width,V=n.top);var _e=zg(zg(zg({},j),pe),{},{realScaleType:ue,x:B,y:V,scale:ye,width:a==="xAxis"?n.width:j.width,height:a==="yAxis"?n.height:j.height});return _e.bandSize=bce(_e,pe),!j.hide&&a==="xAxis"?f[O]+=(Y?-1:1)*_e.height:j.hide||(f[O]+=(Y?-1:1)*_e.width),zg(zg({},b),{},Rhe({},_,_e))},{})},znt=function(s,r){var n=s.x,a=s.y,o=r.x,l=r.y;return{x:Math.min(n,o),y:Math.min(a,l),width:Math.abs(o-n),height:Math.abs(l-a)}},Sgs=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return znt({x:r,y:n},{x:a,y:o})},Bnt=function(){function t(s){jgs(this,t),this.scale=s}return Ngs(t,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,o=n.position;if(r!==void 0){if(o)switch(o){case"start":return this.scale(r);case"middle":{var l=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+l}case"end":{var i=this.bandwidth?this.bandwidth():0;return this.scale(r)+i}default:return this.scale(r)}if(a){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+c}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),a=n[0],o=n[n.length-1];return a<=o?r>=a&&r<=o:r>=o&&r<=a}}],[{key:"create",value:function(r){return new t(r)}}])}();Rhe(Bnt,"EPS",1e-4);var K4e=function(s){var r=Object.keys(s).reduce(function(n,a){return zg(zg({},n),{},Rhe({},a,Bnt.create(s[a])))},{});return zg(zg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return Wxs(a,function(c,u){return r[u].apply(c,{bandAware:l,position:i})})},isInRange:function(a){return Int(a,function(o,l){return r[l].isInRange(o)})}})};function Cgs(t){return(t%180+180)%180}var Mgs=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Cgs(a),l=o*Math.PI/180,i=Math.atan(n/r),c=l>i&&l-1?a[o?s[l]:l]:void 0}}var Igs=Pgs,Lgs=Tnt;function Dgs(t){var s=Lgs(t),r=s%1;return s===s?r?s-r:s:0}var Ogs=Dgs,Rgs=Lst,Fgs=U0,zgs=Ogs,Bgs=Math.max;function $gs(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:zgs(r);return a<0&&(a=Bgs(n+a,0)),Rgs(t,Fgs(s),a)}var qgs=$gs,Ugs=Igs,Vgs=qgs,Hgs=Ugs(Vgs),Wgs=Hgs;const Ggs=Po(Wgs);var Kgs=UKt(function(t){return{x:t.left,y:t.top,width:t.width,height:t.height}},function(t){return["l",t.left,"t",t.top,"w",t.width,"h",t.height].join("")}),Z4e=k.createContext(void 0),Y4e=k.createContext(void 0),$nt=k.createContext(void 0),qnt=k.createContext({}),Unt=k.createContext(void 0),Vnt=k.createContext(0),Hnt=k.createContext(0),dFe=function(s){var r=s.state,n=r.xAxisMap,a=r.yAxisMap,o=r.offset,l=s.clipPathId,i=s.children,c=s.width,u=s.height,p=Kgs(o);return ht.createElement(Z4e.Provider,{value:n},ht.createElement(Y4e.Provider,{value:a},ht.createElement(qnt.Provider,{value:o},ht.createElement($nt.Provider,{value:p},ht.createElement(Unt.Provider,{value:l},ht.createElement(Vnt.Provider,{value:u},ht.createElement(Hnt.Provider,{value:c},i)))))))},Zgs=function(){return k.useContext(Unt)},Wnt=function(s){var r=k.useContext(Z4e);r==null&&nC();var n=r[s];return n==null&&nC(),n},Ygs=function(){var s=k.useContext(Z4e);return l_(s)},Xgs=function(){var s=k.useContext(Y4e),r=Ggs(s,function(n){return Int(n.domain,Number.isFinite)});return r||l_(s)},Gnt=function(s){var r=k.useContext(Y4e);r==null&&nC();var n=r[s];return n==null&&nC(),n},Qgs=function(){var s=k.useContext($nt);return s},Jgs=function(){return k.useContext(qnt)},X4e=function(){return k.useContext(Hnt)},Q4e=function(){return k.useContext(Vnt)};function mA(t){"@babel/helpers - typeof";return mA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},mA(t)}function eys(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function tys(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);rt*a)return!1;var o=r();return t*(s-t*o/2-n)>=0&&t*(s+t*o/2-a)<=0}function Oys(t,s){return eat(t,s+1)}function Rys(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,c=0,u=1,p=l,f=function(){var _=n==null?void 0:n[c];if(_===void 0)return{v:eat(n,u)};var j=c,w,N=function(){return w===void 0&&(w=r(_,j)),w},S=_.coordinate,M=c===0||$ce(t,S,N,p,i);M||(c=0,p=l,u+=1),M&&(p=S+t*(N()/2+a),c+=u)},g;u<=o.length;)if(g=f(),g)return g.v;return[]}function sO(t){"@babel/helpers - typeof";return sO=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},sO(t)}function yFe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function $h(t){for(var s=1;s0?b.coordinate-w*t:b.coordinate})}else o[g]=b=$h($h({},b),{},{tickCoord:b.coordinate});var N=$ce(t,b.tickCoord,j,i,c);N&&(c=b.tickCoord-t*(j()/2+a),o[g]=$h($h({},b),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function qys(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,c=s.start,u=s.end;if(o){var p=n[i-1],f=r(p,i-1),g=t*(p.coordinate+t*f/2-u);l[i-1]=p=$h($h({},p),{},{tickCoord:g>0?p.coordinate-g*t:p.coordinate});var b=$ce(t,p.tickCoord,function(){return f},c,u);b&&(u=p.tickCoord-t*(f/2+a),l[i-1]=$h($h({},p),{},{isShow:!0}))}for(var _=o?i-1:i,j=function(S){var M=l[S],L,I=function(){return L===void 0&&(L=r(M,S)),L};if(S===0){var O=t*(M.coordinate-t*I()/2-c);l[S]=M=$h($h({},M),{},{tickCoord:O<0?M.coordinate-O*t:M.coordinate})}else l[S]=M=$h($h({},M),{},{tickCoord:M.coordinate});var q=$ce(t,M.tickCoord,I,c,u);q&&(c=M.tickCoord+t*(I()/2+a),l[S]=$h($h({},M),{},{isShow:!0}))},w=0;w<_;w++)j(w);return l}function tSe(t,s,r){var n=t.tick,a=t.ticks,o=t.viewBox,l=t.minTickGap,i=t.orientation,c=t.interval,u=t.tickFormatter,p=t.unit,f=t.angle;if(!a||!a.length||!n)return[];if(ln(c)||jC.isSsr)return Oys(a,typeof c=="number"&&ln(c)?c:0);var g=[],b=i==="top"||i==="bottom"?"width":"height",_=p&&b==="width"?p8(p,{fontSize:s,letterSpacing:r}):{width:0,height:0},j=function(M,L){var I=Mi(u)?u(M.value,L):M.value;return b==="width"?Lys(p8(I,{fontSize:s,letterSpacing:r}),_,f):p8(I,{fontSize:s,letterSpacing:r})[b]},w=a.length>=2?Tm(a[1].coordinate-a[0].coordinate):1,N=Dys(o,w,b);return c==="equidistantPreserveStart"?Rys(w,N,j,a,l):(c==="preserveStart"||c==="preserveStartEnd"?g=qys(w,N,j,a,l,c==="preserveStartEnd"):g=$ys(w,N,j,a,l),g.filter(function(S){return S.isShow}))}var Uys=["viewBox"],Vys=["viewBox"],Hys=["ticks"];function xA(t){"@babel/helpers - typeof";return xA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},xA(t)}function fM(){return fM=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Wys(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Gys(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function bFe(t,s){for(var r=0;r0?c(this.props):c(b)),l<=0||i<=0||!_||!_.length?null:ht.createElement(Zo,{className:Vi("recharts-cartesian-axis",u),ref:function(w){n.layerReference=w}},o&&this.renderAxisLine(),this.renderTicks(_,this.state.fontSize,this.state.letterSpacing),Yu.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=Vi(a.className,"recharts-cartesian-axis-tick-value");return ht.isValidElement(n)?l=ht.cloneElement(n,uu(uu({},a),{},{className:i})):Mi(n)?l=n(uu(uu({},a),{},{className:i})):l=ht.createElement(sC,fM({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(k.Component);sSe(kE,"displayName","CartesianAxis");sSe(kE,"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 e0s=["x1","y1","x2","y2","key"],t0s=["offset"];function aC(t){"@babel/helpers - typeof";return aC=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},aC(t)}function _Fe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Vh(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function a0s(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var i0s=function(s){var r=s.fill;if(!r||r==="none")return null;var n=s.fillOpacity,a=s.x,o=s.y,l=s.width,i=s.height,c=s.ry;return ht.createElement("rect",{x:a,y:o,ry:c,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function rat(t,s){var r;if(ht.isValidElement(t))r=ht.cloneElement(t,s);else if(Mi(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,c=wFe(s,e0s),u=ai(c,!1);u.offset;var p=wFe(u,t0s);r=ht.createElement("line",A4({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function o0s(t){var s=t.x,r=t.width,n=t.horizontal,a=n===void 0?!0:n,o=t.horizontalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,c){var u=Vh(Vh({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(c),index:c});return rat(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function l0s(t){var s=t.y,r=t.height,n=t.vertical,a=n===void 0?!0:n,o=t.verticalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,c){var u=Vh(Vh({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(c),index:c});return rat(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function c0s(t){var s=t.horizontalFill,r=t.fillOpacity,n=t.x,a=t.y,o=t.width,l=t.height,i=t.horizontalPoints,c=t.horizontal,u=c===void 0?!0:c;if(!u||!s||!s.length)return null;var p=i.map(function(g){return Math.round(g+a-a)}).sort(function(g,b){return g-b});a!==p[0]&&p.unshift(0);var f=p.map(function(g,b){var _=!p[b+1],j=_?a+l-g:p[b+1]-g;if(j<=0)return null;var w=b%s.length;return ht.createElement("rect",{key:"react-".concat(b),y:g,x:n,height:j,width:o,stroke:"none",fill:s[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function d0s(t){var s=t.vertical,r=s===void 0?!0:s,n=t.verticalFill,a=t.fillOpacity,o=t.x,l=t.y,i=t.width,c=t.height,u=t.verticalPoints;if(!r||!n||!n.length)return null;var p=u.map(function(g){return Math.round(g+o-o)}).sort(function(g,b){return g-b});o!==p[0]&&p.unshift(0);var f=p.map(function(g,b){var _=!p[b+1],j=_?o+i-g:p[b+1]-g;if(j<=0)return null;var w=b%n.length;return ht.createElement("rect",{key:"react-".concat(b),x:g,y:l,width:j,height:c,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var u0s=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return Jrt(tSe(Vh(Vh(Vh({},kE.defaultProps),n),{},{ticks:e1(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},h0s=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return Jrt(tSe(Vh(Vh(Vh({},kE.defaultProps),n),{},{ticks:e1(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},E5={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function nat(t){var s,r,n,a,o,l,i=X4e(),c=Q4e(),u=Jgs(),p=Vh(Vh({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:E5.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:E5.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:E5.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:E5.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:E5.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:E5.verticalFill,x:ln(t.x)?t.x:u.left,y:ln(t.y)?t.y:u.top,width:ln(t.width)?t.width:u.width,height:ln(t.height)?t.height:u.height}),f=p.x,g=p.y,b=p.width,_=p.height,j=p.syncWithTicks,w=p.horizontalValues,N=p.verticalValues,S=Ygs(),M=Xgs();if(!ln(b)||b<=0||!ln(_)||_<=0||!ln(f)||f!==+f||!ln(g)||g!==+g)return null;var L=p.verticalCoordinatesGenerator||u0s,I=p.horizontalCoordinatesGenerator||h0s,O=p.horizontalPoints,q=p.verticalPoints;if((!O||!O.length)&&Mi(I)){var U=w&&w.length,B=I({yAxis:M?Vh(Vh({},M),{},{ticks:U?w:M.ticks}):void 0,width:i,height:c,offset:u},U?!0:j);ry(Array.isArray(B),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(aC(B),"]")),Array.isArray(B)&&(O=B)}if((!q||!q.length)&&Mi(L)){var V=N&&N.length,Y=L({xAxis:S?Vh(Vh({},S),{},{ticks:V?N:S.ticks}):void 0,width:i,height:c,offset:u},V?!0:j);ry(Array.isArray(Y),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(aC(Y),"]")),Array.isArray(Y)&&(q=Y)}return ht.createElement("g",{className:"recharts-cartesian-grid"},ht.createElement(i0s,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),ht.createElement(o0s,A4({},p,{offset:u,horizontalPoints:O,xAxis:S,yAxis:M})),ht.createElement(l0s,A4({},p,{offset:u,verticalPoints:q,xAxis:S,yAxis:M})),ht.createElement(c0s,A4({},p,{horizontalPoints:O})),ht.createElement(d0s,A4({},p,{verticalPoints:q})))}nat.displayName="CartesianGrid";var m0s=["type","layout","connectNulls","ref"],p0s=["key"];function gA(t){"@babel/helpers - typeof";return gA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},gA(t)}function jFe(t,s){if(t==null)return{};var r=f0s(t,s),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function f0s(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function b8(){return b8=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);rf){b=[].concat(P5(c.slice(0,_)),[f-j]);break}var w=b.length%2===0?[0,g]:[g];return[].concat(P5(s.repeat(c,p)),P5(b),w).map(function(N){return"".concat(N,"px")}).join(", ")}),Bg(r,"id",yE("recharts-line-")),Bg(r,"pathRef",function(l){r.mainCurve=l}),Bg(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Bg(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return k0s(s,t),_0s(s,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,l=o.points,i=o.xAxis,c=o.yAxis,u=o.layout,p=o.children,f=Nf(p,pR);if(!f)return null;var g=function(j,w){return{x:j.x,y:j.y,value:j.value,errorVal:_u(j.payload,w)}},b={clipPath:n?"url(#clipPath-".concat(a,")"):null};return ht.createElement(Zo,b,f.map(function(_){return ht.cloneElement(_,{key:"bar-".concat(_.props.dataKey),data:l,xAxis:i,yAxis:c,layout:u,dataPointFormatter:g})}))}},{key:"renderDots",value:function(n,a,o){var l=this.props.isAnimationActive;if(l&&!this.state.isAnimationFinished)return null;var i=this.props,c=i.dot,u=i.points,p=i.dataKey,f=ai(this.props,!1),g=ai(c,!0),b=u.map(function(j,w){var N=Qp(Qp(Qp({key:"dot-".concat(w),r:3},f),g),{},{index:w,cx:j.x,cy:j.y,value:j.value,dataKey:p,payload:j.payload,points:u});return s.renderDotItem(c,N)}),_={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return ht.createElement(Zo,b8({className:"recharts-line-dots",key:"dots"},_),b)}},{key:"renderCurveStatically",value:function(n,a,o,l){var i=this.props,c=i.type,u=i.layout,p=i.connectNulls;i.ref;var f=jFe(i,m0s),g=Qp(Qp(Qp({},ai(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:c,layout:u,connectNulls:p});return ht.createElement(jce,b8({},g,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var o=this,l=this.props,i=l.points,c=l.strokeDasharray,u=l.isAnimationActive,p=l.animationBegin,f=l.animationDuration,g=l.animationEasing,b=l.animationId,_=l.animateNewValues,j=l.width,w=l.height,N=this.state,S=N.prevPoints,M=N.totalLength;return ht.createElement(D0,{begin:p,duration:f,isActive:u,easing:g,from:{t:0},to:{t:1},key:"line-".concat(b),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(L){var I=L.t;if(S){var O=S.length/i.length,q=i.map(function(Q,ee){var X=Math.floor(ee*O);if(S[X]){var ie=S[X],re=af(ie.x,Q.x),oe=af(ie.y,Q.y);return Qp(Qp({},Q),{},{x:re(I),y:oe(I)})}if(_){var ce=af(j*2,Q.x),ge=af(w/2,Q.y);return Qp(Qp({},Q),{},{x:ce(I),y:ge(I)})}return Qp(Qp({},Q),{},{x:Q.x,y:Q.y})});return o.renderCurveStatically(q,n,a)}var U=af(0,M),B=U(I),V;if(c){var Y="".concat(c).split(/[,\s]+/gim).map(function(Q){return parseFloat(Q)});V=o.getStrokeDasharray(B,M,Y)}else V=o.generateSimpleStrokeDasharray(M,B);return o.renderCurveStatically(i,n,a,{strokeDasharray:V})})}},{key:"renderCurve",value:function(n,a){var o=this.props,l=o.points,i=o.isAnimationActive,c=this.state,u=c.prevPoints,p=c.totalLength;return i&&l&&l.length&&(!u&&p>0||!mR(u,l))?this.renderCurveWithAnimation(n,a):this.renderCurveStatically(l,n,a)}},{key:"render",value:function(){var n,a=this.props,o=a.hide,l=a.dot,i=a.points,c=a.className,u=a.xAxis,p=a.yAxis,f=a.top,g=a.left,b=a.width,_=a.height,j=a.isAnimationActive,w=a.id;if(o||!i||!i.length)return null;var N=this.state.isAnimationFinished,S=i.length===1,M=Vi("recharts-line",c),L=u&&u.allowDataOverflow,I=p&&p.allowDataOverflow,O=L||I,q=$i(w)?this.id:w,U=(n=ai(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},B=U.r,V=B===void 0?3:B,Y=U.strokeWidth,Q=Y===void 0?2:Y,ee=ZZt(l)?l:{},X=ee.clipDot,ie=X===void 0?!0:X,re=V*2+Q;return ht.createElement(Zo,{className:M},L||I?ht.createElement("defs",null,ht.createElement("clipPath",{id:"clipPath-".concat(q)},ht.createElement("rect",{x:L?g:g-b/2,y:I?f:f-_/2,width:L?b:b*2,height:I?_:_*2})),!ie&&ht.createElement("clipPath",{id:"clipPath-dots-".concat(q)},ht.createElement("rect",{x:g-re/2,y:f-re/2,width:b+re,height:_+re}))):null,!S&&this.renderCurve(O,q),this.renderErrorBar(O,q),(S||l)&&this.renderDots(O,ie,q),(!j||N)&&b1.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,a){for(var o=n.length%2!==0?[].concat(P5(n),[0]):n,l=[],i=0;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function pvs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function fvs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function xvs(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&ln(a)&&ln(o)?s.slice(a,o+1):[]};function bat(t){return t==="number"?[0,"auto"]:void 0}var z_e=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=qhe(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(c,u){var p,f=(p=u.props.data)!==null&&p!==void 0?p:r;f&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(f=f.slice(s.dataStartIndex,s.dataEndIndex+1));var g;if(l.dataKey&&!l.allowDuplicatedCategory){var b=f===void 0?i:f;g=Wle(b,l.dataKey,a)}else g=f&&f[n]||i[n];return g?[].concat(_A(c),[nnt(u,g)]):c},[])},EFe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=Mvs(o,n),i=s.orderedTooltipTicks,c=s.tooltipAxis,u=s.tooltipTicks,p=Yds(l,i,u,c);if(p>=0&&u){var f=u[p]&&u[p].value,g=z_e(s,r,p,f),b=Tvs(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:g,activeCoordinate:b}}return null},Avs=function(s,r){var n=r.axes,a=r.graphicalItems,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,g=s.stackOffset,b=Qrt(p,o);return n.reduce(function(_,j){var w,N=j.type.defaultProps!==void 0?wr(wr({},j.type.defaultProps),j.props):j.props,S=N.type,M=N.dataKey,L=N.allowDataOverflow,I=N.allowDuplicatedCategory,O=N.scale,q=N.ticks,U=N.includeHidden,B=N[l];if(_[B])return _;var V=qhe(s.data,{graphicalItems:a.filter(function(pe){var _e,$e=l in pe.props?pe.props[l]:(_e=pe.type.defaultProps)===null||_e===void 0?void 0:_e[l];return $e===B}),dataStartIndex:c,dataEndIndex:u}),Y=V.length,Q,ee,X;svs(N.domain,L,S)&&(Q=Jbe(N.domain,null,L),b&&(S==="number"||O!=="auto")&&(X=x8(V,M,"category")));var ie=bat(S);if(!Q||Q.length===0){var re,oe=(re=N.domain)!==null&&re!==void 0?re:ie;if(M){if(Q=x8(V,M,S),S==="category"&&b){var ce=zZt(Q);I&&ce?(ee=Q,Q=Ice(0,Y)):I||(Q=JOe(oe,Q,j).reduce(function(pe,_e){return pe.indexOf(_e)>=0?pe:[].concat(_A(pe),[_e])},[]))}else if(S==="category")I?Q=Q.filter(function(pe){return pe!==""&&!$i(pe)}):Q=JOe(oe,Q,j).reduce(function(pe,_e){return pe.indexOf(_e)>=0||_e===""||$i(_e)?pe:[].concat(_A(pe),[_e])},[]);else if(S==="number"){var ge=tus(V,a.filter(function(pe){var _e,$e,Ae=l in pe.props?pe.props[l]:(_e=pe.type.defaultProps)===null||_e===void 0?void 0:_e[l],Ie="hide"in pe.props?pe.props.hide:($e=pe.type.defaultProps)===null||$e===void 0?void 0:$e.hide;return Ae===B&&(U||!Ie)}),M,o,p);ge&&(Q=ge)}b&&(S==="number"||O!=="auto")&&(X=x8(V,M,"category"))}else b?Q=Ice(0,Y):i&&i[B]&&i[B].hasStack&&S==="number"?Q=g==="expand"?[0,1]:rnt(i[B].stackGroups,c,u):Q=Xrt(V,a.filter(function(pe){var _e=l in pe.props?pe.props[l]:pe.type.defaultProps[l],$e="hide"in pe.props?pe.props.hide:pe.type.defaultProps.hide;return _e===B&&(U||!$e)}),S,p,!0);if(S==="number")Q=O_e(f,Q,B,o,q),oe&&(Q=Jbe(oe,Q,L));else if(S==="category"&&oe){var ye=oe,ue=Q.every(function(pe){return ye.indexOf(pe)>=0});ue&&(Q=ye)}}return wr(wr({},_),{},mi({},B,wr(wr({},N),{},{axisType:o,domain:Q,categoricalDomain:X,duplicateDomain:ee,originalDomain:(w=N.domain)!==null&&w!==void 0?w:ie,isCategorical:b,layout:p})))},{})},Evs=function(s,r){var n=r.graphicalItems,a=r.Axis,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,g=qhe(s.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:u}),b=g.length,_=Qrt(p,o),j=-1;return n.reduce(function(w,N){var S=N.type.defaultProps!==void 0?wr(wr({},N.type.defaultProps),N.props):N.props,M=S[l],L=bat("number");if(!w[M]){j++;var I;return _?I=Ice(0,b):i&&i[M]&&i[M].hasStack?(I=rnt(i[M].stackGroups,c,u),I=O_e(f,I,M,o)):(I=Jbe(L,Xrt(g,n.filter(function(O){var q,U,B=l in O.props?O.props[l]:(q=O.type.defaultProps)===null||q===void 0?void 0:q[l],V="hide"in O.props?O.props.hide:(U=O.type.defaultProps)===null||U===void 0?void 0:U.hide;return B===M&&!V}),"number",p),a.defaultProps.allowDataOverflow),I=O_e(f,I,M,o)),wr(wr({},w),{},mi({},M,wr(wr({axisType:o},a.defaultProps),{},{hide:!0,orientation:jf(Svs,"".concat(o,".").concat(j%2),null),domain:I,originalDomain:L,isCategorical:_,layout:p})))}return w},{})},Pvs=function(s,r){var n=r.axisType,a=n===void 0?"xAxis":n,o=r.AxisComp,l=r.graphicalItems,i=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,p=s.children,f="".concat(a,"Id"),g=Nf(p,o),b={};return g&&g.length?b=Avs(s,{axes:g,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u}):l&&l.length&&(b=Evs(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u})),b},Ivs=function(s){var r=l_(s),n=e1(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:b4e(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:bce(r,n)}},PFe=function(s){var r=s.children,n=s.defaultShowTooltip,a=sf(r,uA),o=0,l=0;return s.data&&s.data.length!==0&&(l=s.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(o=a.props.startIndex),a.props.endIndex>=0&&(l=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:o,dataEndIndex:l,activeTooltipIndex:-1,isTooltipActive:!!n}},Lvs=function(s){return!s||!s.length?!1:s.some(function(r){var n=y1(r&&r.type);return n&&n.indexOf("Bar")>=0})},IFe=function(s){return s==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:s==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:s==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},Dvs=function(s,r){var n=s.props,a=s.graphicalItems,o=s.xAxisMap,l=o===void 0?{}:o,i=s.yAxisMap,c=i===void 0?{}:i,u=n.width,p=n.height,f=n.children,g=n.margin||{},b=sf(f,uA),_=sf(f,aT),j=Object.keys(c).reduce(function(I,O){var q=c[O],U=q.orientation;return!q.mirror&&!q.hide?wr(wr({},I),{},mi({},U,I[U]+q.width)):I},{left:g.left||0,right:g.right||0}),w=Object.keys(l).reduce(function(I,O){var q=l[O],U=q.orientation;return!q.mirror&&!q.hide?wr(wr({},I),{},mi({},U,jf(I,"".concat(U))+q.height)):I},{top:g.top||0,bottom:g.bottom||0}),N=wr(wr({},w),j),S=N.bottom;b&&(N.bottom+=b.props.height||uA.defaultProps.height),_&&r&&(N=Jds(N,a,n,r));var M=u-N.left-N.right,L=p-N.top-N.bottom;return wr(wr({brushBottom:S},N),{},{width:Math.max(M,0),height:Math.max(L,0)})},Ovs=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},rSe=function(s){var r=s.chartName,n=s.GraphicalChild,a=s.defaultTooltipEventType,o=a===void 0?"axis":a,l=s.validateTooltipEventTypes,i=l===void 0?["axis"]:l,c=s.axisComponents,u=s.legendContent,p=s.formatAxisMap,f=s.defaultProps,g=function(N,S){var M=S.graphicalItems,L=S.stackGroups,I=S.offset,O=S.updateId,q=S.dataStartIndex,U=S.dataEndIndex,B=N.barSize,V=N.layout,Y=N.barGap,Q=N.barCategoryGap,ee=N.maxBarSize,X=IFe(V),ie=X.numericAxisName,re=X.cateAxisName,oe=Lvs(M),ce=[];return M.forEach(function(ge,ye){var ue=qhe(N.data,{graphicalItems:[ge],dataStartIndex:q,dataEndIndex:U}),pe=ge.type.defaultProps!==void 0?wr(wr({},ge.type.defaultProps),ge.props):ge.props,_e=pe.dataKey,$e=pe.maxBarSize,Ae=pe["".concat(ie,"Id")],Ie=pe["".concat(re,"Id")],Ce={},xe=c.reduce(function(ct,Ue){var Ze=S["".concat(Ue.axisType,"Map")],Qe=pe["".concat(Ue.axisType,"Id")];Ze&&Ze[Qe]||Ue.axisType==="zAxis"||nC();var We=Ze[Qe];return wr(wr({},ct),{},mi(mi({},Ue.axisType,We),"".concat(Ue.axisType,"Ticks"),e1(We)))},Ce),we=xe[re],Le=xe["".concat(re,"Ticks")],tt=L&&L[Ae]&&L[Ae].hasStack&&dus(ge,L[Ae].stackGroups),Te=y1(ge.type).indexOf("Bar")>=0,pt=bce(we,Le),fe=[],qe=oe&&Xds({barSize:B,stackGroups:L,totalSize:Ovs(xe,re)});if(Te){var at,et,Me=$i($e)?ee:$e,rt=(at=(et=bce(we,Le,!0))!==null&&et!==void 0?et:Me)!==null&&at!==void 0?at:0;fe=Qds({barGap:Y,barCategoryGap:Q,bandSize:rt!==pt?rt:pt,sizeList:qe[Ie],maxBarSize:Me}),rt!==pt&&(fe=fe.map(function(ct){return wr(wr({},ct),{},{position:wr(wr({},ct.position),{},{offset:ct.position.offset-rt/2})})}))}var He=ge&&ge.type&&ge.type.getComposedData;He&&ce.push({props:wr(wr({},He(wr(wr({},xe),{},{displayedData:ue,props:N,dataKey:_e,item:ge,bandSize:pt,barPosition:fe,offset:I,stackedData:tt,layout:V,dataStartIndex:q,dataEndIndex:U}))),{},mi(mi(mi({key:ge.key||"item-".concat(ye)},ie,xe[ie]),re,xe[re]),"animationId",O)),childIndex:QZt(ge,N.children),item:ge})}),ce},b=function(N,S){var M=N.props,L=N.dataStartIndex,I=N.dataEndIndex,O=N.updateId;if(!W8e({props:M}))return null;var q=M.children,U=M.layout,B=M.stackOffset,V=M.data,Y=M.reverseStackOrder,Q=IFe(U),ee=Q.numericAxisName,X=Q.cateAxisName,ie=Nf(q,n),re=lus(V,ie,"".concat(ee,"Id"),"".concat(X,"Id"),B,Y),oe=c.reduce(function(pe,_e){var $e="".concat(_e.axisType,"Map");return wr(wr({},pe),{},mi({},$e,Pvs(M,wr(wr({},_e),{},{graphicalItems:ie,stackGroups:_e.axisType===ee&&re,dataStartIndex:L,dataEndIndex:I}))))},{}),ce=Dvs(wr(wr({},oe),{},{props:M,graphicalItems:ie}),S==null?void 0:S.legendBBox);Object.keys(oe).forEach(function(pe){oe[pe]=p(M,oe[pe],ce,pe.replace("Map",""),r)});var ge=oe["".concat(X,"Map")],ye=Ivs(ge),ue=g(M,wr(wr({},oe),{},{dataStartIndex:L,dataEndIndex:I,updateId:O,graphicalItems:ie,stackGroups:re,offset:ce}));return wr(wr({formattedGraphicalItems:ue,graphicalItems:ie,offset:ce,stackGroups:re},ye),oe)},_=function(w){function N(S){var M,L,I;return fvs(this,N),I=yvs(this,N,[S]),mi(I,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),mi(I,"accessibilityManager",new tvs),mi(I,"handleLegendBBoxUpdate",function(O){if(O){var q=I.state,U=q.dataStartIndex,B=q.dataEndIndex,V=q.updateId;I.setState(wr({legendBBox:O},b({props:I.props,dataStartIndex:U,dataEndIndex:B,updateId:V},wr(wr({},I.state),{},{legendBBox:O}))))}}),mi(I,"handleReceiveSyncEvent",function(O,q,U){if(I.props.syncId===O){if(U===I.eventEmitterSymbol&&typeof I.props.syncMethod!="function")return;I.applySyncEvent(q)}}),mi(I,"handleBrushChange",function(O){var q=O.startIndex,U=O.endIndex;if(q!==I.state.dataStartIndex||U!==I.state.dataEndIndex){var B=I.state.updateId;I.setState(function(){return wr({dataStartIndex:q,dataEndIndex:U},b({props:I.props,dataStartIndex:q,dataEndIndex:U,updateId:B},I.state))}),I.triggerSyncEvent({dataStartIndex:q,dataEndIndex:U})}}),mi(I,"handleMouseEnter",function(O){var q=I.getMouseInfo(O);if(q){var U=wr(wr({},q),{},{isTooltipActive:!0});I.setState(U),I.triggerSyncEvent(U);var B=I.props.onMouseEnter;Mi(B)&&B(U,O)}}),mi(I,"triggeredAfterMouseMove",function(O){var q=I.getMouseInfo(O),U=q?wr(wr({},q),{},{isTooltipActive:!0}):{isTooltipActive:!1};I.setState(U),I.triggerSyncEvent(U);var B=I.props.onMouseMove;Mi(B)&&B(U,O)}),mi(I,"handleItemMouseEnter",function(O){I.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),mi(I,"handleItemMouseLeave",function(){I.setState(function(){return{isTooltipActive:!1}})}),mi(I,"handleMouseMove",function(O){O.persist(),I.throttleTriggeredAfterMouseMove(O)}),mi(I,"handleMouseLeave",function(O){I.throttleTriggeredAfterMouseMove.cancel();var q={isTooltipActive:!1};I.setState(q),I.triggerSyncEvent(q);var U=I.props.onMouseLeave;Mi(U)&&U(q,O)}),mi(I,"handleOuterEvent",function(O){var q=XZt(O),U=jf(I.props,"".concat(q));if(q&&Mi(U)){var B,V;/.*touch.*/i.test(q)?V=I.getMouseInfo(O.changedTouches[0]):V=I.getMouseInfo(O),U((B=V)!==null&&B!==void 0?B:{},O)}}),mi(I,"handleClick",function(O){var q=I.getMouseInfo(O);if(q){var U=wr(wr({},q),{},{isTooltipActive:!0});I.setState(U),I.triggerSyncEvent(U);var B=I.props.onClick;Mi(B)&&B(U,O)}}),mi(I,"handleMouseDown",function(O){var q=I.props.onMouseDown;if(Mi(q)){var U=I.getMouseInfo(O);q(U,O)}}),mi(I,"handleMouseUp",function(O){var q=I.props.onMouseUp;if(Mi(q)){var U=I.getMouseInfo(O);q(U,O)}}),mi(I,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&I.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),mi(I,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&I.handleMouseDown(O.changedTouches[0])}),mi(I,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&I.handleMouseUp(O.changedTouches[0])}),mi(I,"handleDoubleClick",function(O){var q=I.props.onDoubleClick;if(Mi(q)){var U=I.getMouseInfo(O);q(U,O)}}),mi(I,"handleContextMenu",function(O){var q=I.props.onContextMenu;if(Mi(q)){var U=I.getMouseInfo(O);q(U,O)}}),mi(I,"triggerSyncEvent",function(O){I.props.syncId!==void 0&&uye.emit(hye,I.props.syncId,O,I.eventEmitterSymbol)}),mi(I,"applySyncEvent",function(O){var q=I.props,U=q.layout,B=q.syncMethod,V=I.state.updateId,Y=O.dataStartIndex,Q=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)I.setState(wr({dataStartIndex:Y,dataEndIndex:Q},b({props:I.props,dataStartIndex:Y,dataEndIndex:Q,updateId:V},I.state)));else if(O.activeTooltipIndex!==void 0){var ee=O.chartX,X=O.chartY,ie=O.activeTooltipIndex,re=I.state,oe=re.offset,ce=re.tooltipTicks;if(!oe)return;if(typeof B=="function")ie=B(ce,O);else if(B==="value"){ie=-1;for(var ge=0;ge=0){var tt,Te;if(ee.dataKey&&!ee.allowDuplicatedCategory){var pt=typeof ee.dataKey=="function"?Le:"payload.".concat(ee.dataKey.toString());tt=Wle(ge,pt,ie),Te=ye&&ue&&Wle(ue,pt,ie)}else tt=ge==null?void 0:ge[X],Te=ye&&ue&&ue[X];if(Ie||Ae){var fe=O.props.activeIndex!==void 0?O.props.activeIndex:X;return[k.cloneElement(O,wr(wr(wr({},B.props),xe),{},{activeIndex:fe})),null,null]}if(!$i(tt))return[we].concat(_A(I.renderActivePoints({item:B,activePoint:tt,basePoint:Te,childIndex:X,isRange:ye})))}else{var qe,at=(qe=I.getItemByXY(I.state.activeCoordinate))!==null&&qe!==void 0?qe:{graphicalItem:we},et=at.graphicalItem,Me=et.item,rt=Me===void 0?O:Me,He=et.childIndex,ct=wr(wr(wr({},B.props),xe),{},{activeIndex:He});return[k.cloneElement(rt,ct),null,null]}return ye?[we,null,null]:[we,null]}),mi(I,"renderCustomized",function(O,q,U){return k.cloneElement(O,wr(wr({key:"recharts-customized-".concat(U)},I.props),I.state))}),mi(I,"renderMap",{CartesianGrid:{handler:Uz,once:!0},ReferenceArea:{handler:I.renderReferenceElement},ReferenceLine:{handler:Uz},ReferenceDot:{handler:I.renderReferenceElement},XAxis:{handler:Uz},YAxis:{handler:Uz},Brush:{handler:I.renderBrush,once:!0},Bar:{handler:I.renderGraphicChild},Line:{handler:I.renderGraphicChild},Area:{handler:I.renderGraphicChild},Radar:{handler:I.renderGraphicChild},RadialBar:{handler:I.renderGraphicChild},Scatter:{handler:I.renderGraphicChild},Pie:{handler:I.renderGraphicChild},Funnel:{handler:I.renderGraphicChild},Tooltip:{handler:I.renderCursor,once:!0},PolarGrid:{handler:I.renderPolarGrid,once:!0},PolarAngleAxis:{handler:I.renderPolarAxis},PolarRadiusAxis:{handler:I.renderPolarAxis},Customized:{handler:I.renderCustomized}}),I.clipPathId="".concat((M=S.id)!==null&&M!==void 0?M:yE("recharts"),"-clip"),I.throttleTriggeredAfterMouseMove=Kst(I.triggeredAfterMouseMove,(L=S.throttleDelay)!==null&&L!==void 0?L:1e3/60),I.state={},I}return _vs(N,w),gvs(N,[{key:"componentDidMount",value:function(){var M,L;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(M=this.props.margin.left)!==null&&M!==void 0?M:0,top:(L=this.props.margin.top)!==null&&L!==void 0?L:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var M=this.props,L=M.children,I=M.data,O=M.height,q=M.layout,U=sf(L,hp);if(U){var B=U.props.defaultIndex;if(!(typeof B!="number"||B<0||B>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[B]&&this.state.tooltipTicks[B].value,Y=z_e(this.state,I,B,V),Q=this.state.tooltipTicks[B].coordinate,ee=(this.state.offset.top+O)/2,X=q==="horizontal",ie=X?{x:Q,y:ee}:{y:Q,x:ee},re=this.state.formattedGraphicalItems.find(function(ce){var ge=ce.item;return ge.type.name==="Scatter"});re&&(ie=wr(wr({},ie),re.props.points[B].tooltipPosition),Y=re.props.points[B].tooltipPayload);var oe={activeTooltipIndex:B,isTooltipActive:!0,activeLabel:V,activePayload:Y,activeCoordinate:ie};this.setState(oe),this.renderCursor(U),this.accessibilityManager.setIndex(B)}}}},{key:"getSnapshotBeforeUpdate",value:function(M,L){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==L.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==M.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==M.margin){var I,O;this.accessibilityManager.setDetails({offset:{left:(I=this.props.margin.left)!==null&&I!==void 0?I:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(M){pbe([sf(M.children,hp)],[sf(this.props.children,hp)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var M=sf(this.props.children,hp);if(M&&typeof M.props.shared=="boolean"){var L=M.props.shared?"axis":"item";return i.indexOf(L)>=0?L:o}return o}},{key:"getMouseInfo",value:function(M){if(!this.container)return null;var L=this.container,I=L.getBoundingClientRect(),O=Nis(I),q={chartX:Math.round(M.pageX-O.left),chartY:Math.round(M.pageY-O.top)},U=I.width/L.offsetWidth||1,B=this.inRange(q.chartX,q.chartY,U);if(!B)return null;var V=this.state,Y=V.xAxisMap,Q=V.yAxisMap,ee=this.getTooltipEventType(),X=EFe(this.state,this.props.data,this.props.layout,B);if(ee!=="axis"&&Y&&Q){var ie=l_(Y).scale,re=l_(Q).scale,oe=ie&&ie.invert?ie.invert(q.chartX):null,ce=re&&re.invert?re.invert(q.chartY):null;return wr(wr({},q),{},{xValue:oe,yValue:ce},X)}return X?wr(wr({},q),X):null}},{key:"inRange",value:function(M,L){var I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,q=M/I,U=L/I;if(O==="horizontal"||O==="vertical"){var B=this.state.offset,V=q>=B.left&&q<=B.left+B.width&&U>=B.top&&U<=B.top+B.height;return V?{x:q,y:U}:null}var Y=this.state,Q=Y.angleAxisMap,ee=Y.radiusAxisMap;if(Q&&ee){var X=l_(Q);return sRe({x:q,y:U},X)}return null}},{key:"parseEventsOfWrapper",value:function(){var M=this.props.children,L=this.getTooltipEventType(),I=sf(M,hp),O={};I&&L==="axis"&&(I.props.trigger==="click"?O={onClick:this.handleClick}:O={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 q=Gle(this.props,this.handleOuterEvent);return wr(wr({},q),O)}},{key:"addListener",value:function(){uye.on(hye,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){uye.removeListener(hye,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(M,L,I){for(var O=this.state.formattedGraphicalItems,q=0,U=O.length;q{const{data:S,error:M}=await H.from("email_campaigns").select("*").eq("status","sent").order("sent_at",{ascending:!0});if(M)throw M;return S}}),{data:n}=mt({queryKey:["campaign-agent-profiles"],queryFn:async()=>{const{data:S,error:M}=await H.from("profiles").select("id, name, email");if(M)throw M;return S}});if(r)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading analytics..."});const a=s||[],o=new Map((n||[]).map(S=>[S.id,S])),l=a.reduce((S,M)=>S+(M.sent_count||0),0),i=a.reduce((S,M)=>S+(M.open_count||0),0),c=a.reduce((S,M)=>S+(M.click_count||0),0),u=a.reduce((S,M)=>S+(M.bounce_count||0),0),p=a.reduce((S,M)=>S+(M.complaint_count||0),0),f=l>0?(i/l*100).toFixed(1):"0.0",g=l>0?(c/l*100).toFixed(1):"0.0",b=[{label:"Campaigns Sent",value:a.length,icon:Bn,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:pr,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:Ln,color:"text-blue-600"},{label:"Avg Click Rate",value:`${g}%`,icon:wh,color:"text-purple-600"},{label:"Total Bounces",value:u,icon:Ku,color:"text-orange-600"},{label:"Complaints",value:p,icon:ul,color:"text-destructive"}],_=new Map;a.forEach(S=>{var I,O;const M=S.user_id,L=_.get(M)||{name:((I=o.get(M))==null?void 0:I.name)||((O=o.get(M))==null?void 0:O.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};L.campaigns++,L.sent+=S.sent_count||0,L.opens+=S.open_count||0,L.clicks+=S.click_count||0,_.set(M,L)});const j=[..._.entries()].map(([S,M])=>({id:S,...M,openRate:M.sent>0?+(M.opens/M.sent*100).toFixed(1):0})).sort((S,M)=>M.sent-S.sent),w=j.slice(0,6).map(S=>({name:S.name,value:S.sent})),N=a.map(S=>{var M;return{name:S.name.length>20?S.name.slice(0,20)+"…":S.name,agent:((M=o.get(S.user_id))==null?void 0:M.name)||"Unknown",openRate:S.sent_count>0?+(S.open_count/S.sent_count*100).toFixed(1):0,clickRate:S.sent_count>0?+(S.click_count/S.sent_count*100).toFixed(1):0,sent:S.sent_count,date:S.sent_at?ms(new Date(S.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Bn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No campaigns sent yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Campaign analytics will appear here after the first send."})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:b.map(S=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx(S.icon,{className:`h-5 w-5 mx-auto mb-1 ${S.color}`}),e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})},S.label))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(iT,{width:"100%",height:"100%",children:e.jsxs(_at,{data:N,children:[e.jsx(iC,{dataKey:"date",fontSize:11}),e.jsx(oC,{fontSize:11,unit:"%"}),e.jsx(hp,{formatter:S=>`${S}%`}),e.jsx(L1,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(L1,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(iT,{width:"100%",height:"100%",children:e.jsxs(wat,{children:[e.jsx(V0,{data:w,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:S,percent:M})=>`${S} (${(M*100).toFixed(0)}%)`,fontSize:11,children:w.map((S,M)=>e.jsx(lR,{fill:LFe[M%LFe.length]},M))}),e.jsx(hp,{})]})})})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(iT,{width:"100%",height:"100%",children:e.jsxs(Rvs,{data:N,children:[e.jsx(iC,{dataKey:"date",fontSize:11}),e.jsx(oC,{fontSize:11}),e.jsx(hp,{}),e.jsx(fR,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Agent Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-2 font-medium",children:"Agent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Campaigns"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Sent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Opens"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Clicks"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Open Rate"})]})}),e.jsx("tbody",{children:j.map(S=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5 font-medium",children:S.name}),e.jsx("td",{className:"py-2.5 text-center",children:S.campaigns}),e.jsx("td",{className:"py-2.5 text-center",children:S.sent}),e.jsx("td",{className:"py-2.5 text-center",children:S.opens}),e.jsx("td",{className:"py-2.5 text-center",children:S.clicks}),e.jsx("td",{className:"py-2.5 text-center",children:e.jsxs(st,{variant:"outline",children:[S.openRate,"%"]})})]},S.id))})]})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((S,M)=>{const L=S.sent_count>0?S.open_count/S.sent_count:0;return(M.sent_count>0?M.open_count/M.sent_count:0)-L}).slice(0,10).map((S,M)=>{const L=S.sent_count>0?(S.open_count/S.sent_count*100).toFixed(1):"0.0",I=S.sent_count>0?(S.click_count/S.sent_count*100).toFixed(1):"0.0",O=o.get(S.user_id);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/30 cursor-pointer",onClick:()=>t(`/admin/email-campaigns/${S.id}`),children:[e.jsxs("span",{className:"text-lg font-bold text-muted-foreground w-6",children:["#",M+1]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:S.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(O==null?void 0:O.name)||"Unknown"," · ",S.sent_at?ms(new Date(S.sent_at),"MMM d, yyyy"):""," · ",S.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(Ln,{className:"h-3 w-3"})," ",L,"%"]}),e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(wh,{className:"h-3 w-3"})," ",I,"%"]})]})]},S.id)})})})]})]})})}const zvs=()=>e.jsx(Ms,{title:"Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Analytics & Activity"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Platform-wide usage statistics and user activity"})]}),e.jsxs(ba,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"analytics",children:"Analytics"}),e.jsx(ns,{value:"content",children:"Content"}),e.jsx(ns,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(ns,{value:"activity",children:"Activity"}),e.jsx(ns,{value:"shares",children:"Shares"})]}),e.jsx(bs,{value:"analytics",className:"space-y-4",children:e.jsx(nWt,{})}),e.jsx(bs,{value:"content",className:"space-y-4",children:e.jsx(iWt,{})}),e.jsx(bs,{value:"email-campaigns",className:"space-y-4",children:e.jsx(Fvs,{})}),e.jsx(bs,{value:"activity",className:"space-y-4",children:e.jsx(rWt,{})}),e.jsx(bs,{value:"shares",className:"space-y-4",children:e.jsx(Itt,{})})]})]})});function Bvs(){const t=Qt(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,c]=k.useState(null),[u,p]=k.useState(""),[f,g]=k.useState([]),[b,_]=k.useState([]),[j,w]=k.useState([]),[N,S]=k.useState(!1),[M,L]=k.useState(null),[I,O]=k.useState(""),{data:q,isLoading:U}=mt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(pt)throw pt;return Te}}),{data:B}=mt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(pt)throw pt;return Te}}),{data:V}=mt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(pt)throw pt;return Te}}),{data:Y}=mt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(pt)throw pt;return Te}}),{data:Q,isLoading:ee}=mt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(pt)throw pt;return Te}}),X=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),c(null),p(""),g([]),_([]),w([]),a(null),O("")},ie=Te=>{a(Te),l({title:Te.title,description:Te.description||"",publish_date:Te.publish_date.split("T")[0],is_published:Te.is_published,category_id:Te.category_id||""}),p(Te.preview_image_url||""),O("");const pt=(B==null?void 0:B.filter(at=>at.resource_id===Te.id))||[];g(pt.map(at=>({id:at.id,name:at.name,file_url:at.file_url,file_size:at.file_size,sort_order:at.sort_order})));const fe=(V==null?void 0:V.filter(at=>at.resource_id===Te.id))||[];_(fe.map(at=>({id:at.id,title:at.title,video_url:at.video_url,sort_order:at.sort_order})));const qe=(Y==null?void 0:Y.filter(at=>at.resource_id===Te.id))||[];w(qe.map(at=>({id:at.id,title:at.title,canva_share_link:at.canva_share_link,sort_order:at.sort_order}))),r(!0)},re=Te=>{var fe;const pt=(fe=Te.target.files)==null?void 0:fe[0];pt&&(c(pt),p(URL.createObjectURL(pt)))},oe=()=>{g([...f,{name:"",file_url:"",sort_order:f.length}])},ce=Te=>{g(f.filter((pt,fe)=>fe!==Te))},ge=(Te,pt,fe)=>{const qe=[...f];if(pt==="file"&&fe instanceof File){const at=fe.name.replace(/\.[^/.]+$/,"");qe[Te]={...qe[Te],file:fe,file_size:fe.size,name:qe[Te].name||at}}else qe[Te]={...qe[Te],[pt]:fe};g(qe)},ye=()=>{_([...b,{title:"",video_url:"",sort_order:b.length}])},ue=Te=>{_(b.filter((pt,fe)=>fe!==Te))},pe=(Te,pt,fe)=>{const qe=[...b];pt==="file"&&fe instanceof File?qe[Te]={...qe[Te],file:fe}:qe[Te]={...qe[Te],[pt]:fe},_(qe)},_e=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},$e=Te=>{w(j.filter((pt,fe)=>fe!==Te))},Ae=(Te,pt,fe)=>{const qe=[...j];qe[Te]={...qe[Te],[pt]:fe},w(qe)},Ie=async(Te,pt)=>{try{const fe=await H.functions.invoke("bunny-upload",{body:{action:"create",title:Te.name}});if(fe.error)throw fe.error;const{videoId:qe,uploadUrl:at,libraryId:et}=fe.data,Me=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:qe,libraryId:et}});if(Me.error)throw Me.error;const{uploadUrl:rt,apiKey:He}=Me.data,ct=new XMLHttpRequest;return ct.open("PUT",rt,!0),ct.setRequestHeader("AccessKey",He),ct.upload.onprogress=Ue=>{if(Ue.lengthComputable){const Ze=Math.round(Ue.loaded/Ue.total*100),Qe=[...b];Qe[pt]={...Qe[pt],uploadProgress:Ze},_(Qe)}},await new Promise((Ue,Ze)=>{ct.onload=()=>ct.status>=200&&ct.status<300?Ue():Ze(new Error("Upload failed")),ct.onerror=()=>Ze(new Error("Upload failed")),ct.send(Te)}),`https://iframe.mediadelivery.net/embed/${et}/${qe}`}catch(fe){throw console.error("Bunny upload error:",fe),fe}},Ce=Lt({mutationFn:async Te=>{const{data:pt,error:fe}=await H.from("brokerage_resource_categories").insert({name:Te,sort_order:(Q==null?void 0:Q.length)||0}).select().single();if(fe)throw fe;return pt},onSuccess:Te=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:Te.id}),O(""),me.success("Category created")},onError:Te=>{me.error("Failed to create category: "+Te.message)}}),xe=Lt({mutationFn:async()=>{S(!0);let Te=(n==null?void 0:n.preview_image_url)||null;if(i){const qe=i.name.split(".").pop(),at=`${Date.now()}.${qe}`,{error:et}=await H.storage.from("brokerage-resources").upload(`previews/${at}`,i);if(et)throw et;const{data:Me}=H.storage.from("brokerage-resources").getPublicUrl(`previews/${at}`);Te=Me.publicUrl}const pt={title:o.title,description:o.description||null,preview_image_url:Te,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let fe;if(n){const{error:qe}=await H.from("brokerage_resources").update(pt).eq("id",n.id);if(qe)throw qe;fe=n.id;const at=(B==null?void 0:B.filter(We=>We.resource_id===n.id).map(We=>We.id))||[],et=f.filter(We=>We.id).map(We=>We.id),Me=at.filter(We=>!et.includes(We));Me.length>0&&await H.from("brokerage_resource_pdfs").delete().in("id",Me);const rt=(V==null?void 0:V.filter(We=>We.resource_id===n.id).map(We=>We.id))||[],He=b.filter(We=>We.id).map(We=>We.id),ct=rt.filter(We=>!He.includes(We));ct.length>0&&await H.from("brokerage_resource_videos").delete().in("id",ct);const Ue=(Y==null?void 0:Y.filter(We=>We.resource_id===n.id).map(We=>We.id))||[],Ze=j.filter(We=>We.id).map(We=>We.id),Qe=Ue.filter(We=>!Ze.includes(We));Qe.length>0&&await H.from("brokerage_resource_links").delete().in("id",Qe)}else{const{data:qe,error:at}=await H.from("brokerage_resources").insert(pt).select().single();if(at)throw at;fe=qe.id}for(let qe=0;qe{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success(n?"Resource updated":"Resource created"),r(!1),X(),S(!1)},onError:Te=>{me.error("Failed to save resource: "+Te.message),S(!1)}}),we=Lt({mutationFn:async Te=>{const{error:pt}=await H.from("brokerage_resources").delete().eq("id",Te);if(pt)throw pt},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success("Resource deleted")},onError:Te=>{me.error("Failed to delete: "+Te.message)}}),Le=Te=>{if(Te.preventDefault(),!o.title){me.error("Please enter a title");return}xe.mutate()},tt=Te=>{const pt=(B==null?void 0:B.filter(at=>at.resource_id===Te).length)||0,fe=(V==null?void 0:V.filter(at=>at.resource_id===Te).length)||0,qe=(Y==null?void 0:Y.filter(at=>at.resource_id===Te).length)||0;return{pdfCount:pt,videoCount:fe,linkCount:qe}};return e.jsx(Ms,{title:"Brokerage Resources Management",description:"Create and manage resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(q==null?void 0:q.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(q==null?void 0:q.filter(Te=>Te.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{X(),r(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Content"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:U?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):(q==null?void 0:q.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):q==null?void 0:q.map(Te=>{const{pdfCount:pt,videoCount:fe,linkCount:qe}=tt(Te.id),at=Q==null?void 0:Q.find(et=>et.id===Te.category_id);return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Te.preview_image_url?e.jsx("img",{src:Te.preview_image_url,alt:Te.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(Gh,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Te.title}),Te.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Te.description})]})]})}),e.jsx(dt,{children:at?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:at.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3.5 w-3.5"}),pt]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(An,{className:"h-3.5 w-3.5"}),fe]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bo,{className:"h-3.5 w-3.5"}),qe]})]})}),e.jsx(dt,{children:ms(new Date(Te.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Te.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Te.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const et=(B==null?void 0:B.filter(He=>He.resource_id===Te.id))||[],Me=(V==null?void 0:V.filter(He=>He.resource_id===Te.id))||[],rt=(Y==null?void 0:Y.filter(He=>He.resource_id===Te.id))||[];L({...Te,pdfs:et,videos:Me,links:rt})},children:e.jsx(Ln,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ie(Te),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&we.mutate(Te.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Te.id)})})]})})}),e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:Le,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[u?e.jsx("img",{src:u,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):e.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:e.jsx(Gh,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(ze,{type:"file",accept:"image/*",onChange:re})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:o.title,onChange:Te=>l({...o,title:Te.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Fm,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:o.category_id,onValueChange:Te=>l({...o,category_id:Te}),children:[e.jsx(Hs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select a category"})}),e.jsx(Ws,{children:Q==null?void 0:Q.map(Te=>e.jsx(Mt,{value:Te.id,children:Te.name},Te.id))})]}),o.category_id&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Or create new category...",value:I,onChange:Te=>O(Te.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!I.trim()||Ce.isPending,onClick:()=>Ce.mutate(I.trim()),children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(py,{content:o.description,onChange:Te=>l({...o,description:Te}),placeholder:"Brief description of this resource",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:o.publish_date,onChange:Te=>l({...o,publish_date:Te.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(qr,{checked:o.is_published,onCheckedChange:Te=>l({...o,is_published:Te})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:o.is_published?"Visible to brokerage managers":"Hidden from brokerage managers"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:oe,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((Te,pt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(ze,{placeholder:"PDF Name",value:Te.name,onChange:fe=>ge(pt,"name",fe.target.value),className:"flex-1"}),e.jsx(ze,{type:"file",accept:".pdf",onChange:fe=>{var at;const qe=(at=fe.target.files)==null?void 0:at[0];qe&&ge(pt,"file",qe)},className:"flex-1"}),Te.file_url&&!Te.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>ce(pt),children:e.jsx(Rr,{className:"h-4 w-4"})})]},pt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(An,{className:"h-4 w-4"}),"Videos (",b.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ye,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),b.map((Te,pt)=>e.jsxs("div",{className:"space-y-2 p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{placeholder:"Video Title",value:Te.title,onChange:fe=>pe(pt,"title",fe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>ue(pt),children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsx(ze,{type:"file",accept:"video/*",onChange:fe=>{var at;const qe=(at=fe.target.files)==null?void 0:at[0];qe&&pe(pt,"file",qe)}}),Te.uploadProgress!==void 0&&Te.uploadProgress>0&&e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${Te.uploadProgress}%`}})}),Te.video_url&&!Te.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},pt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4"}),"Canva Links (",j.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),j.map((Te,pt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(ze,{placeholder:"Link Title",value:Te.title,onChange:fe=>Ae(pt,"title",fe.target.value),className:"flex-1"}),e.jsx(ze,{placeholder:"Canva Share Link",value:Te.canva_share_link,onChange:fe=>Ae(pt,"canva_share_link",fe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>$e(pt),children:e.jsx(Rr,{className:"h-4 w-4"})})]},pt))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:xe.isPending||N,children:xe.isPending||N?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!M,onOpenChange:()=>L(null),children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:M==null?void 0:M.title})}),M&&e.jsxs("div",{className:"space-y-4",children:[M.preview_image_url&&e.jsx("img",{src:M.preview_image_url,alt:M.title,className:"w-full h-48 object-cover rounded-lg"}),M.description&&e.jsx("p",{className:"text-muted-foreground",children:M.description}),M.pdfs&&M.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"}),"PDF Documents (",M.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:M.pdfs.map(Te=>e.jsx("a",{href:Te.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Te.name},Te.id))})]}),M.videos&&M.videos.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(An,{className:"h-4 w-4"}),"Videos (",M.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:M.videos.map(Te=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:Te.title})},Te.id))})]}),M.links&&M.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4"}),"Canva Links (",M.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:M.links.map(Te=>e.jsx("a",{href:Te.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Te.title},Te.id))})]})]})]})})]})})}const jat=[{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 $vs(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(null),[p,f]=k.useState(!1),[g,b]=k.useState(!1),[_,j]=k.useState(""),[w,N]=k.useState(""),[S,M]=k.useState(""),[L,I]=k.useState(""),[O,q]=k.useState("Learn More"),[U,B]=k.useState("top"),[V,Y]=k.useState(""),[Q,ee]=k.useState(!0),[X,ie]=k.useState(""),[re,oe]=k.useState("");k.useEffect(()=>{ce()},[]);const ce=async()=>{try{const{data:Ce,error:xe}=await H.from("dashboard_banners").select("*").order("placement").order("sort_order");if(xe)throw xe;s(Ce||[])}catch(Ce){me.error("Failed to load banners: "+Ce.message)}finally{n(!1)}},ge=()=>{j(""),N(""),M(""),I(""),q("Learn More"),B("top"),Y(""),ee(!0),ie(""),oe(""),u(null)},ye=Ce=>{u(Ce),j(Ce.title),N(Ce.description||""),M(Ce.image_url),I(Ce.link_url||""),q(Ce.link_text||"Learn More"),B(Ce.placement),Y(Ce.section_after||""),ee(Ce.is_active),ie(Ce.start_date?ms(new Date(Ce.start_date),"yyyy-MM-dd'T'HH:mm"):""),oe(Ce.end_date?ms(new Date(Ce.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},ue=async Ce=>{var we;const xe=(we=Ce.target.files)==null?void 0:we[0];if(xe){f(!0);try{const Le=xe.name.split(".").pop(),tt=`${Date.now()}.${Le}`,{error:Te}=await H.storage.from("banner-images").upload(tt,xe);if(Te)throw Te;const{data:{publicUrl:pt}}=H.storage.from("banner-images").getPublicUrl(tt);M(pt),me.success("Image uploaded successfully")}catch(Le){me.error("Failed to upload image: "+Le.message)}finally{f(!1)}}},pe=async()=>{if(!_.trim()||!S){me.error("Please fill in required fields (title and image)");return}b(!0);try{const Ce={title:_.trim(),description:w.trim()||null,image_url:S,link_url:L.trim()||null,link_text:O.trim()||"Learn More",placement:U,section_after:U==="between"?V:null,is_active:Q,start_date:X?new Date(X).toISOString():null,end_date:re?new Date(re).toISOString():null};if(c){const{error:xe}=await H.from("dashboard_banners").update(Ce).eq("id",c.id);if(xe)throw xe;me.success("Banner updated successfully")}else{const xe=t.filter(Le=>Le.placement===U).length,{error:we}=await H.from("dashboard_banners").insert({...Ce,sort_order:xe});if(we)throw we;me.success("Banner created successfully")}o(!1),ge(),ce()}catch(Ce){me.error("Failed to save banner: "+Ce.message)}finally{b(!1)}},_e=async()=>{if(c)try{const{error:Ce}=await H.from("dashboard_banners").delete().eq("id",c.id);if(Ce)throw Ce;me.success("Banner deleted successfully"),i(!1),u(null),ce()}catch(Ce){me.error("Failed to delete banner: "+Ce.message)}},$e=async Ce=>{try{const{error:xe}=await H.from("dashboard_banners").update({is_active:!Ce.is_active}).eq("id",Ce.id);if(xe)throw xe;me.success(Ce.is_active?"Banner deactivated":"Banner activated"),ce()}catch(xe){me.error("Failed to update banner: "+xe.message)}},Ae=t.filter(Ce=>Ce.placement==="top"),Ie=t.filter(Ce=>Ce.placement==="between");return r?e.jsx(Ms,{title:"Dashboard Management",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):e.jsxs(Ms,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(gl,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(gr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(fs,{open:a&&U==="top",onOpenChange:Ce=>{Ce||ge(),o(Ce),Ce&&B("top")},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{ge(),B("top")},children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[c?"Edit":"Create"," Banner"]}),e.jsx(Gr,{children:"Configure the banner's content and display settings"})]}),e.jsx(DFe,{title:_,setTitle:j,description:w,setDescription:N,imageUrl:S,linkUrl:L,setLinkUrl:I,linkText:O,setLinkText:q,placement:U,setPlacement:B,sectionAfter:V,setSectionAfter:Y,isActive:Q,setIsActive:ee,startDate:X,setStartDate:ie,endDate:re,setEndDate:oe,handleImageUpload:ue,uploading:p,showPlacementOptions:!1}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),ge()},children:"Cancel"}),e.jsx(K,{onClick:pe,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:Ae.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No hero banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Ae.map(Ce=>e.jsx(OFe,{banner:Ce,onEdit:()=>ye(Ce),onDelete:()=>{u(Ce),i(!0)},onToggleActive:()=>$e(Ce)},Ce.id))})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(gl,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(gr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(fs,{open:a&&U==="between",onOpenChange:Ce=>{Ce||ge(),o(Ce),Ce&&B("between")},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{ge(),B("between")},children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[c?"Edit":"Create"," Section Banner"]}),e.jsx(Gr,{children:"Configure where this banner appears between sections"})]}),e.jsx(DFe,{title:_,setTitle:j,description:w,setDescription:N,imageUrl:S,linkUrl:L,setLinkUrl:I,linkText:O,setLinkText:q,placement:U,setPlacement:B,sectionAfter:V,setSectionAfter:Y,isActive:Q,setIsActive:ee,startDate:X,setStartDate:ie,endDate:re,setEndDate:oe,handleImageUpload:ue,uploading:p,showPlacementOptions:!0}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),ge()},children:"Cancel"}),e.jsx(K,{onClick:pe,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:Ie.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No section banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Ie.map(Ce=>e.jsx(OFe,{banner:Ce,onEdit:()=>ye(Ce),onDelete:()=>{u(Ce),i(!0)},onToggleActive:()=>$e(Ce),showSection:!0},Ce.id))})})]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Delete Banner"}),e.jsxs(Gr,{children:['Are you sure you want to delete "',c==null?void 0:c.title,'"? This action cannot be undone.']})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:_e,children:"Delete"})]})]})})]})}function DFe({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:c,placement:u,setPlacement:p,sectionAfter:f,setSectionAfter:g,isActive:b,setIsActive:_,startDate:j,setStartDate:w,endDate:N,setEndDate:S,handleImageUpload:M,uploading:L,showPlacementOptions:I}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",placeholder:"Banner headline...",value:t,onChange:O=>s(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",placeholder:"Optional banner description...",value:r,onChange:O=>n(O.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:M,disabled:L,className:"flex-1"}),L&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&e.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:e.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(ze,{id:"linkUrl",placeholder:"https://...",value:o,onChange:O=>l(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"linkText",children:"Button Text"}),e.jsx(ze,{id:"linkText",placeholder:"Learn More",value:i,onChange:O=>c(O.target.value)})]})]}),I&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Placement"}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select section placement..."})}),e.jsx(Ws,{children:jat.map(O=>e.jsx(Mt,{value:O.value,children:O.label},O.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(ze,{id:"startDate",type:"datetime-local",value:j,onChange:O=>w(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(ze,{id:"endDate",type:"datetime-local",value:N,onChange:O=>S(O.target.value)})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"isActive",checked:b,onCheckedChange:_}),e.jsx(be,{htmlFor:"isActive",children:"Active"})]})})]})}function OFe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var l;const o=(l=jat.find(i=>i.value===t.section_after))==null?void 0:l.label;return e.jsxs("div",{className:"flex items-center gap-4 p-3 border rounded-lg bg-card hover:bg-accent/50 transition-colors",children:[e.jsx(Cu,{className:"h-5 w-5 text-muted-foreground cursor-grab"}),e.jsx("img",{src:t.image_url,alt:t.title,className:"w-24 h-14 object-cover rounded"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium truncate",children:t.title}),!t.is_active&&e.jsx(st,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(st,{variant:"outline",children:"Scheduled"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:t.description}),a&&o&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.link_url&&e.jsx("a",{href:t.link_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(tn,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(Ln,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]})}const Vz={open:{label:"Open",icon:un,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:$c,color:"bg-blue-500"},resolved:{label:"Resolved",icon:xi,color:"bg-green-500"},closed:{label:"Closed",icon:vc,color:"bg-muted-foreground"}},RFe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function qvs(){var O,q;const{user:t}=Ds(),s=Qt(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState("all"),[c,u]=k.useState("all"),[p,f]=k.useState(!1),{data:g=[],isLoading:b}=mt({queryKey:["admin-support-tickets",l,c],queryFn:async()=>{let U=H.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(U=U.eq("status",l)),c!=="all"&&(U=U.eq("category",c));const{data:B,error:V}=await U;if(V)throw V;return B}}),{data:_=[]}=mt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:U,error:B}=await H.from("user_roles").select("user_id").eq("role","admin");if(B)throw B;const V=U.map(re=>re.user_id),{data:Y,error:Q}=await H.from("profiles").select("id, name, email").in("id",V);if(Q)throw Q;const{data:ee,error:X}=await H.from("support_notification_settings").select("user_id, receive_notifications");if(X)throw X;const ie=new Map((ee==null?void 0:ee.map(re=>[re.user_id,re.receive_notifications]))||[]);return Y.map(re=>({...re,receives_notifications:ie.get(re.id)||!1}))}}),{data:j=[]}=mt({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:U,error:B}=await H.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(B)throw B;return U},enabled:!!r}),w=Lt({mutationFn:async({userId:U,enabled:B})=>{const{data:V}=await H.from("support_notification_settings").select("id").eq("user_id",U).maybeSingle();if(V){const{error:Y}=await H.from("support_notification_settings").update({receive_notifications:B}).eq("user_id",U);if(Y)throw Y}else{const{error:Y}=await H.from("support_notification_settings").insert({user_id:U,receive_notifications:B});if(Y)throw Y}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),me.success("Notification settings updated")},onError:()=>{me.error("Failed to update settings")}}),N=Lt({mutationFn:async({ticketId:U,status:B})=>{const{error:V}=await H.from("support_tickets").update({status:B}).eq("id",U);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),me.success("Status updated")},onError:()=>{me.error("Failed to update status")}}),S=Lt({mutationFn:async({ticketId:U,assignedTo:B})=>{const{error:V}=await H.from("support_tickets").update({assigned_to:B}).eq("id",U);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),me.success("Ticket assigned")},onError:()=>{me.error("Failed to assign ticket")}}),M=Lt({mutationFn:async U=>{var V,Y;if(!r||!t)throw new Error("Missing data");const{error:B}=await H.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:U,is_admin_reply:!0});if(B)throw B;try{await H.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:U,userEmail:(V=r.profiles)==null?void 0:V.email,userName:(Y=r.profiles)==null?void 0:Y.name}})}catch(Q){console.error("Failed to send reply notification:",Q)}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-ticket-replies",r==null?void 0:r.id]}),o(""),me.success("Reply sent!")},onError:()=>{me.error("Failed to send reply")}}),L=()=>{a.trim()&&M.mutate(a)};k.useEffect(()=>{const U=H.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{H.removeChannel(U)}},[s]);const I=g.filter(U=>U.status==="open").length;return r?(Vz[r.status].icon,e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"secondary",children:RFe[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((O=r.profiles)==null?void 0:O.name)||"Unknown"," (",(q=r.profiles)==null?void 0:q.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm",children:"Status"})}),e.jsx(Oe,{children:e.jsxs(Ks,{value:r.status,onValueChange:U=>{N.mutate({ticketId:r.id,status:U}),n({...r,status:U})},children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"open",children:"Open"}),e.jsx(Mt,{value:"in_progress",children:"In Progress"}),e.jsx(Mt,{value:"resolved",children:"Resolved"}),e.jsx(Mt,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm",children:"Assigned To"})}),e.jsx(Oe,{children:e.jsxs(Ks,{value:r.assigned_to||"unassigned",onValueChange:U=>{const B=U==="unassigned"?null:U;S.mutate({ticketId:r.id,assignedTo:B}),n({...r,assigned_to:B})},children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Unassigned"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"unassigned",children:"Unassigned"}),_.map(U=>e.jsx(Mt,{value:U.id,children:U.name},U.id))]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(gr,{children:["Created on ",ms(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Gi,{className:"h-[300px] pr-4",children:j.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:j.map(U=>{var B,V;return e.jsxs("div",{className:`p-4 rounded-lg ${U.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:U.is_admin_reply?`${((B=U.profiles)==null?void 0:B.name)||"Admin"} (Support)`:((V=U.profiles)==null?void 0:V.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(U.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:U.content})]},U.id)})})}),e.jsx(rl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Type your reply...",value:a,onChange:U=>o(U.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:L,disabled:!a.trim()||M.isPending,className:"self-end",children:e.jsx(Bn,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Support Tickets"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage support requests from agents",I>0&&e.jsxs(st,{variant:"destructive",className:"ml-2",children:[I," open"]})]})]}),e.jsxs(fs,{open:p,onOpenChange:f,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Xo,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Email Notification Settings"}),e.jsx(Gr,{children:"Choose which admins receive email notifications for new support tickets."})]}),e.jsx("div",{className:"space-y-4 mt-4",children:_.map(U=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:U.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:U.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[U.receives_notifications?e.jsx(Lm,{className:"h-4 w-4 text-primary"}):e.jsx(r1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(qr,{checked:U.receives_notifications,onCheckedChange:B=>w.mutate({userId:U.id,enabled:B})})]})]},U.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(ba,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(pa,{children:[e.jsx(ns,{value:"all",children:"All"}),e.jsx(ns,{value:"open",children:"Open"}),e.jsx(ns,{value:"in_progress",children:"In Progress"}),e.jsx(ns,{value:"resolved",children:"Resolved"}),e.jsx(ns,{value:"closed",children:"Closed"})]})}),e.jsxs(Ks,{value:c,onValueChange:u,children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"All Categories"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Categories"}),e.jsx(Mt,{value:"general",children:"General Support"}),e.jsx(Mt,{value:"technology",children:"Technology Support"}),e.jsx(Mt,{value:"crm",children:"CRM Support"}),e.jsx(Mt,{value:"marketing",children:"Marketing Support"})]})]})]}),e.jsx("div",{className:"mt-4",children:b?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):g.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx($c,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets found"}),e.jsx("p",{className:"text-muted-foreground",children:"No support tickets match the current filters."})]})}):e.jsx("div",{className:"space-y-3",children:g.map(U=>{var V,Y;const B=Vz[U.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(U),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:U.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(st,{variant:"outline",className:"text-xs",children:RFe[U.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(V=U.profiles)==null?void 0:V.name," • ",ms(new Date(U.created_at),"MMM d, yyyy")]}),U.assigned_to&&e.jsxs(st,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(to,{className:"h-3 w-3"}),((Y=_.find(Q=>Q.id===U.assigned_to))==null?void 0:Y.name)||"Assigned"]})]})]}),e.jsxs(st,{className:Vz[U.status].color,children:[e.jsx(B,{className:"h-3 w-3 mr-1"}),Vz[U.status].label]})]})})},U.id)})})})]})]})})}const Nat=Ih.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var s;return(s=t.style.color)===null||s===void 0?void 0:s.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:s})=>s().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});function Uvs({content:t,onChange:s,variables:r}){const n=ake({extensions:[oke,gke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),yke.configure({types:["heading","paragraph"]}),vke,Nat],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});k.useEffect(()=>{n&&t!==n.getHTML()&&n.commands.setContent(t)},[t,n]);const a=l=>{n&&n.chain().focus().insertContent(`{{${l.key}}}`).run()},o=()=>{if(!n)return;const l=n.getAttributes("link").href,i=window.prompt("URL",l);if(i!==null){if(i===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}n.chain().focus().extendMarkRange("link").setLink({href:i}).run()}};return n?e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(Y4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:e.jsx(sS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:e.jsx(Mh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:e.jsx(p0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(G4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(W4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:e.jsx(K4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(Bo,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(Q4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(xS,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:e.jsx(mS,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(VM,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(Bd,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Ma,{onClick:()=>a(l),className:"flex flex-col items-start",children:[e.jsx("span",{className:"font-medium",children:l.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:`{{${l.key}}}`}),l.description&&e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:l.description})]},l.key))})]})]}),e.jsx(rke,{editor:n,className:"prose prose-sm max-w-none p-4 min-h-[300px] focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[280px]"}),r.length>0&&e.jsxs("div",{className:"border-t p-3 bg-muted/20",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Available variables (click to copy):"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(l=>e.jsx(st,{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 Vvs(){const t=Qt(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(""),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(!0),[b,_]=k.useState("visual"),{data:j,isLoading:w}=mt({queryKey:["email-templates"],queryFn:async()=>{const{data:I,error:O}=await H.from("email_templates").select("*").order("name");if(O)throw O;return I.map(q=>({...q,available_variables:q.available_variables||[]}))}}),N=Lt({mutationFn:async I=>{const{error:O}=await H.from("email_templates").update({subject:I.subject,body_html:I.body_html,description:I.description,is_active:I.is_active}).eq("id",I.id);if(O)throw O},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),me.success("Email template updated successfully"),r(null)},onError:I=>{me.error("Failed to update template: "+I.message)}}),S=I=>{r(I),l(I.subject),c(I.body_html),p(I.description||""),g(I.is_active),_("visual")},M=()=>{s&&N.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},L=(I,O)=>{let q=I;return O.forEach(U=>{const B=`{{${U.key}}}`,V=`[${U.label}]`;q=q.replace(new RegExp(B.replace(/[{}]/g,"\\$&"),"g"),V)}),q};return s?e.jsxs(Ms,{title:"Edit Email Template",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{variant:"outline",onClick:()=>a(s),children:[e.jsx(Ln,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:M,disabled:N.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),N.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),s.name]}),e.jsxs(gr,{className:"mt-1",children:["Template slug: ",e.jsx("code",{className:"bg-muted px-1 rounded",children:s.slug})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{htmlFor:"active-toggle",children:"Active"}),e.jsx(qr,{id:"active-toggle",checked:f,onCheckedChange:g})]})]})}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:u,onChange:I=>p(I.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"subject",children:"Email Subject"}),e.jsx(ze,{id:"subject",value:o,onChange:I=>l(I.target.value),placeholder:"Email subject line"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["You can use variables like ","{{name}}"," in the subject"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Email Body"}),e.jsx(ba,{value:b,onValueChange:I=>_(I),children:e.jsxs(pa,{className:"h-8",children:[e.jsxs(ns,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(dS,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(ns,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(Q4,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),b==="visual"?e.jsx(Uvs,{content:i,onChange:c,variables:s.available_variables}):e.jsx(Er,{value:i,onChange:I=>c(I.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Email Preview"}),e.jsxs(Gr,{children:["Subject: ",o.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:L(i,s.available_variables)}})})]})})]}):e.jsx(Ms,{title:"Email Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),w?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((I,O)=>e.jsx(Ee,{children:e.jsxs(Pt,{children:[e.jsx(ys,{className:"h-5 w-48"}),e.jsx(ys,{className:"h-4 w-96"})]})},O))}):e.jsx("div",{className:"grid gap-4",children:j==null?void 0:j.map(I=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Rt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(cr,{className:"h-5 w-5 text-muted-foreground"}),I.name,!I.is_active&&e.jsx(st,{variant:"secondary",children:"Inactive"})]}),e.jsx(gr,{children:I.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(I),children:[e.jsx(Ln,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>S(I),children:[e.jsx(hd,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subject:"}),e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-sm",children:I.subject})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Variables:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:I.available_variables.map(O=>e.jsx(st,{variant:"outline",className:"font-mono text-xs",children:`{{${O.key}}}`},O.key))})]})]})})]},I.id))}),e.jsx(fs,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:["Email Preview: ",n==null?void 0:n.name]}),e.jsxs(Gr,{children:["Subject: ",n==null?void 0:n.subject.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),n&&e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:L(n.body_html,n.available_variables)}})})]})})]})})}function Hvs(){const t=Qt(),[s,r]=k.useState("templates"),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(!1),[u,p]=k.useState(!1),[f,g]=k.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[b,_]=k.useState({name:"",description:"",icon:"📧"}),{data:j=[]}=mt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:V,error:Y}=await H.from("email_template_categories").select("*").order("sort_order");if(Y)throw Y;return V}}),{data:w=[],isLoading:N}=mt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:V,error:Y}=await H.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(Y)throw Y;return V}}),S=Lt({mutationFn:async V=>{const Y={title:V.title,subject:V.subject,body:V.body,description:V.description||null,tone:V.tone||null,category_id:V.category_id||null,is_active:V.is_active};if(V.id){const{error:Q}=await H.from("agent_email_templates").update(Y).eq("id",V.id);if(Q)throw Q}else{const{error:Q}=await H.from("agent_email_templates").insert(Y);if(Q)throw Q}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),c(!1),me.success(n?"Template updated":"Template created")},onError:()=>me.error("Failed to save template")}),M=Lt({mutationFn:async V=>{const{error:Y}=await H.from("agent_email_templates").delete().eq("id",V);if(Y)throw Y},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),me.success("Template deleted")}}),L=Lt({mutationFn:async V=>{const Y={name:V.name,description:V.description||null,icon:V.icon};if(V.id){const{error:Q}=await H.from("email_template_categories").update(Y).eq("id",V.id);if(Q)throw Q}else{const Q=j.length>0?Math.max(...j.map(X=>X.sort_order))+1:0,{error:ee}=await H.from("email_template_categories").insert({...Y,sort_order:Q});if(ee)throw ee}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),p(!1),me.success(o?"Category updated":"Category created")},onError:()=>me.error("Failed to save category")}),I=Lt({mutationFn:async V=>{const{error:Y}=await H.from("email_template_categories").delete().eq("id",V);if(Y)throw Y},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),me.success("Category deleted")}}),O=()=>{a(null),g({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),c(!0)},q=V=>{a(V),g({title:V.title,subject:V.subject,body:V.body,description:V.description||"",tone:V.tone||"",category_id:V.category_id||"",is_active:V.is_active}),c(!0)},U=()=>{l(null),_({name:"",description:"",icon:"📧"}),p(!0)},B=V=>{l(V),_({name:V.name,description:V.description||"",icon:V.icon}),p(!0)};return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(oh,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(ba,{value:s,onValueChange:r,children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"templates",className:"gap-2",children:[e.jsx(cr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(ns,{value:"categories",className:"gap-2",children:[e.jsx(Om,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(bs,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Template"}),e.jsx(St,{className:"hidden md:table-cell",children:"Category"}),e.jsx(St,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:N?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin mx-auto"})})}):w.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):w.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:V.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:V.subject})]})}),e.jsx(dt,{className:"hidden md:table-cell",children:V.category?e.jsxs(st,{variant:"outline",className:"gap-1",children:[V.category.icon," ",V.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:V.tone?e.jsx(st,{variant:"secondary",children:V.tone}):"—"}),e.jsx(dt,{children:e.jsx(st,{variant:V.is_active?"default":"secondary",children:V.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q(V),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&M.mutate(V.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},V.id))})]})})})]}),e.jsxs(bs,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:U,className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"})," Add Category"]})}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:j.map(V=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:V.icon})," ",V.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>B(V),children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&I.mutate(V.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:V.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[w.filter(Y=>Y.category_id===V.id).length," templates"]})]})]},V.id))})]})]}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:n?"Edit Template":"New Template"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:f.title,onChange:V=>g(Y=>({...Y,title:V.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Category"}),e.jsxs(Ks,{value:f.category_id,onValueChange:V=>g(Y=>({...Y,category_id:V})),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:j.map(V=>e.jsxs(Mt,{value:V.id,children:[V.icon," ",V.name]},V.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Subject Line"}),e.jsx(ze,{value:f.subject,onChange:V=>g(Y=>({...Y,subject:V.target.value})),placeholder:"e.g. Hey {{first_name}}, just checking in!"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}",", ","{{full_name}}"," for merge variables"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Email Body"}),e.jsx(Er,{value:f.body,onChange:V=>g(Y=>({...Y,body:V.target.value})),rows:12,placeholder:"Write your email template...",className:"resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Description (internal)"}),e.jsx(ze,{value:f.description,onChange:V=>g(Y=>({...Y,description:V.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Tone"}),e.jsx(ze,{value:f.tone,onChange:V=>g(Y=>({...Y,tone:V.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:f.is_active,onCheckedChange:V=>g(Y=>({...Y,is_active:V}))}),e.jsx(be,{children:"Active"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>S.mutate({...f,id:n==null?void 0:n.id}),disabled:S.isPending||!f.title||!f.subject||!f.body,children:[S.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ps,{className:"sm:max-w-[450px]",children:[e.jsx(_s,{children:e.jsx(vs,{children:o?"Edit Category":"New Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-[60px_1fr] gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Icon"}),e.jsx(ze,{value:b.icon,onChange:V=>_(Y=>({...Y,icon:V.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Name"}),e.jsx(ze,{value:b.name,onChange:V=>_(Y=>({...Y,name:V.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Description"}),e.jsx(ze,{value:b.description,onChange:V=>_(Y=>({...Y,description:V.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>L.mutate({...b,id:o==null?void 0:o.id}),disabled:L.isPending||!b.name,children:[L.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const Wvs=({brokerageId:t})=>{var Fo,$t;const{toast:s}=Ua(),r=fr(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,c]=k.useState(""),[u,p]=k.useState("all"),[f,g]=k.useState(new Set),[b,_]=k.useState(!1),[j,w]=k.useState({}),[N,S]=k.useState(!1),[M,L]=k.useState(!1),[I,O]=k.useState({email:"",name:"",password:"",phone:""}),[q,U]=k.useState(!1),[B,V]=k.useState(null),[Y,Q]=k.useState(!1),[ee,X]=k.useState(!1),[ie,re]=k.useState(!1),[oe,ce]=k.useState(""),[ge,ye]=k.useState(!1),[ue,pe]=k.useState([]),[_e,$e]=k.useState(!1),[Ae,Ie]=k.useState(!1),[Ce,xe]=k.useState(null),[we,Le]=k.useState({name:"",phone:"",email:""}),[tt,Te]=k.useState(!1),[pt,fe]=k.useState(!1),[qe,at]=k.useState(null),[et,Me]=k.useState("asc"),[rt,He]=k.useState(!1),[ct,Ue]=k.useState(null),[Ze,Qe]=k.useState(!1),[We,Je]=k.useState(null),[it,Dt]=k.useState(""),[Vt,hs]=k.useState(!1),[Ts,Cs]=k.useState(null);k.useEffect(()=>{er(),cs()},[t]);const cs=async()=>{try{const{data:ke,error:Be}=await H.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(Be)throw Be;pe((ke==null?void 0:ke.map(Ye=>Ye.user_id))||[])}catch(ke){console.error("Error loading brokerage managers:",ke)}},er=async()=>{try{l(!0);const{data:ke,error:Be}=await H.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(Be)throw Be;const Ye=ke.agents||[];if(a(Ye),Ye.length>0){const bt=Ye.map(Ft=>Ft.id),{data:gt}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",bt);if(gt&>.length>0){const Ft=gt.map(Xt=>Xt.assistant_id),{data:Zt}=await H.from("profiles").select("id, name, email").in("id",Ft),Ut={};for(const Xt of gt){const Ps=Zt==null?void 0:Zt.find(gs=>gs.id===Xt.assistant_id);Ps&&(Ut[Xt.agent_id]={name:Ps.name||"",email:Ps.email||""})}w(Ut)}else w({})}}catch(ke){console.error("Error loading agents:",ke),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},xt=async()=>{if(!I.email||!I.name||!I.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}L(!0);try{const{data:{session:ke}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ke==null?void 0:ke.access_token}`},body:JSON.stringify({...I,brokerageId:t})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to create agent");s({title:"Success",description:`Agent ${I.email} created successfully`}),O({email:"",name:"",password:"",phone:""}),S(!1),er()}catch(ke){console.error("Error creating agent:",ke),s({title:"Error",description:ke.message||"Failed to create agent",variant:"destructive"})}finally{L(!1)}},Es=async ke=>{try{const{data:{session:Be}}=await H.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Be==null?void 0:Be.access_token}`},body:JSON.stringify({userId:ke})}),bt=await Ye.json();if(!Ye.ok)throw new Error(bt.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(Be){console.error("Error resending welcome email:",Be),s({title:"Error",description:Be.message||"Failed to resend welcome email",variant:"destructive"})}},ur=async(ke,Be)=>{try{const{error:Ye}=await H.functions.invoke("send-password-reset",{body:{email:ke,redirectTo:window.location.origin}});if(Ye)throw Ye;s({title:"Password Reset Sent",description:`Password reset email sent to ${Be}`})}catch(Ye){console.error("Error sending password reset:",Ye),s({title:"Error",description:Ye.message||"Failed to send password reset email",variant:"destructive"})}},Mr=ke=>{V(ke),U(!0)},Lr=ke=>{xe(ke),Le({name:ke.name,phone:ke.phone||"",email:ke.email}),Ie(!0)},fn=async()=>{if(!Ce)return;if(!we.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const ke=we.email.trim().toLowerCase()!==Ce.email.toLowerCase();Te(!0);try{if(ke){if(!we.email.trim())throw new Error("Email is required");fe(!0);const{data:{session:Ye}}=await H.auth.getSession(),bt=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:Ce.id,newEmail:we.email.trim(),brokerageId:t})}),gt=await bt.json();if(fe(!1),!bt.ok)throw new Error(gt.error||"Failed to update email")}const{error:Be}=await H.from("profiles").update({name:we.name.trim(),phone:we.phone.trim()||null}).eq("id",Ce.id);if(Be)throw Be;s({title:"Success",description:"Agent profile updated successfully"}),Ie(!1),xe(null),er()}catch(Be){console.error("Error updating agent:",Be),s({title:"Error",description:Be.message||"Failed to update agent",variant:"destructive"})}finally{Te(!1),fe(!1)}},ki=async()=>{if(!oe){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}ye(!0);try{const{data:{session:ke}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ke==null?void 0:ke.access_token}`},body:JSON.stringify({userId:oe,role:"brokerage_manager",action:"add",brokerageId:t})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),re(!1),ce(""),cs()}catch(ke){console.error("Error adding brokerage manager:",ke),s({title:"Error",description:ke.message||"Failed to add brokerage manager",variant:"destructive"})}finally{ye(!1)}},Ea=async ke=>{try{const{data:{session:Be}}=await H.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Be==null?void 0:Be.access_token}`},body:JSON.stringify({userId:ke,role:"brokerage_manager",action:"remove",brokerageId:t})}),bt=await Ye.json();if(!Ye.ok)throw new Error(bt.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),cs()}catch(Be){console.error("Error removing brokerage manager:",Be),s({title:"Error",description:Be.message||"Failed to remove brokerage manager",variant:"destructive"})}},dr=ke=>ue.includes(ke),Jr=ke=>{Je(ke),Dt(""),Qe(!0)},Wr=async()=>{if(!(!We||!it)){if(it.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}hs(!0);try{const{data:{session:ke}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ke==null?void 0:ke.access_token}`},body:JSON.stringify({agentId:We.id,brokerageId:t,action:"set_password",newPassword:it})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to set password");s({title:"Success",description:`Password set for ${We.name}`}),Qe(!1),Je(null),Dt("")}catch(ke){console.error("Error setting password:",ke),s({title:"Error",description:ke.message||"Failed to set password",variant:"destructive"})}finally{hs(!1)}}},dn=async ke=>{Cs(ke.id);try{const{data:{session:Be}}=await H.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Be==null?void 0:Be.access_token}`},body:JSON.stringify({agentId:ke.id,brokerageId:t,action:"claim_account"})}),bt=await Ye.json();if(!Ye.ok)throw new Error(bt.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${ke.name}`}),er()}catch(Be){console.error("Error claiming account:",Be),s({title:"Error",description:Be.message||"Failed to claim account",variant:"destructive"})}finally{Cs(null)}},Yr=async()=>{if(B){Q(!0);try{const{data:{session:ke}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ke==null?void 0:ke.access_token}`},body:JSON.stringify({userId:B.id,brokerageId:t})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to remove agent");s({title:"Success",description:`${B.name} has been removed from your brokerage`}),U(!1),V(null),er()}catch(ke){console.error("Error removing agent:",ke),s({title:"Error",description:ke.message||"Failed to remove agent",variant:"destructive"})}finally{Q(!1)}}},vi=ke=>{const Be=ke.trim().split(" ");return Be.length>1?Be[Be.length-1].toLowerCase():ke.toLowerCase()},ft=ke=>{qe===ke?Me(et==="asc"?"desc":"asc"):(at(ke),Me("asc"))},ir=ke=>qe!==ke?e.jsx(bd,{className:"ml-1 h-4 w-4"}):et==="asc"?e.jsx(ku,{className:"ml-1 h-4 w-4"}):e.jsx(Wh,{className:"ml-1 h-4 w-4"}),Vn=n.filter(ke=>{if(u==="active"&&!ke.claimed||u==="pending"&&ke.claimed)return!1;if(!i)return!0;const Be=i.toLowerCase();return ke.name.toLowerCase().includes(Be)||ke.email.toLowerCase().includes(Be)}),Sr=[...Vn].sort((ke,Be)=>{if(!qe)return 0;let Ye=0;return qe==="name"?Ye=vi(ke.name).localeCompare(vi(Be.name)):qe==="status"&&(Ye=ke.claimed===Be.claimed?0:ke.claimed?-1:1),et==="asc"?Ye:-Ye});Vn.filter(ke=>ke.claimed&&!dr(ke.id));const jr=ke=>{g(Be=>{const Ye=new Set(Be);return Ye.has(ke)?Ye.delete(ke):Ye.add(ke),Ye})},ea=()=>{f.size===Sr.length?g(new Set):g(new Set(Sr.map(ke=>ke.id)))},Pa=()=>{g(new Set)},Ii=async()=>{const ke=Array.from(f);if(ke.length===0)return;_(!0);let Be=0,Ye=0;try{const{data:{session:bt}}=await H.auth.getSession();for(const gt of ke)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${bt==null?void 0:bt.access_token}`},body:JSON.stringify({userId:gt})})).ok?Be++:Ye++}catch{Ye++}Be>0?s({title:"Success",description:`Welcome emails sent to ${Be} agent${Be>1?"s":""}${Ye>0?` (${Ye} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),Pa()}catch(bt){console.error("Error bulk sending welcome emails:",bt),s({title:"Error",description:bt.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!1)}};return o?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Agents"}),e.jsx(gr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>re(!0),children:[e.jsx(th,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>X(!0),children:[e.jsx(a1,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>S(!0),children:[e.jsx(Tl,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-4 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:i,onChange:ke=>c(ke.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:u,onValueChange:ke=>p(ke),children:[e.jsx(Hs,{className:"w-[160px]",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Agents"}),e.jsx(Mt,{value:"active",children:"Active"}),e.jsx(Mt,{value:"pending",children:"Pending"})]})]})]}),f.size>0&&e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/50 p-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[f.size," agent",f.size>1?"s":""," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const Be=n.filter(Ye=>f.has(Ye.id)&&Ye.email).map(Ye=>({email:Ye.email,name:Ye.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify(Be)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:Be}})},disabled:b,children:[e.jsx(Ah,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:Ii,disabled:b,children:[e.jsx(cr,{className:"mr-2 h-4 w-4"}),b?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:Pa,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:Sr.length>0&&f.size===Sr.length,onCheckedChange:ea,"aria-label":"Select all"})}),e.jsx(St,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ft("name"),children:["Name (Last)",ir("name")]})}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ft("status"),children:["Status",ir("status")]})}),e.jsx(St,{children:"Actions"})]})}),e.jsx(zn,{children:Sr.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):Sr.map(ke=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(Oo,{checked:f.has(ke.id),onCheckedChange:()=>jr(ke.id),"aria-label":`Select ${ke.name}`})}),e.jsx(dt,{className:"font-medium",children:ke.name}),e.jsx(dt,{children:ke.email}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[ke.claimed?e.jsx(st,{variant:"default",children:"Active"}):e.jsx(st,{variant:"secondary",children:"Pending"}),dr(ke.id)&&e.jsxs(st,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(AL,{className:"mr-1 h-3 w-3"}),"Manager"]}),j[ke.id]&&e.jsxs(st,{variant:"outline",className:"text-xs",children:[e.jsx(pr,{className:"mr-1 h-3 w-3"}),"Asst: ",j[ke.id].name||j[ke.id].email]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{Ue(ke),He(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(ru,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Lr(ke),title:"Edit agent",children:e.jsx(Ra,{className:"h-4 w-4"})}),!ke.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Es(ke.id),title:"Resend welcome email",children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>dn(ke),title:"Claim account for agent",disabled:Ts===ke.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(G_,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Jr(ke),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(Th,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>ur(ke.email,ke.name),title:"Send password reset email",children:e.jsx(rS,{className:"h-4 w-4"})}),dr(ke.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Ea(ke.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(th,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Mr(ke),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},ke.id))})]})})]})]}),e.jsx(fs,{open:N,onOpenChange:S,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add New Agent"}),e.jsx(Gr,{children:"Create a new agent account. They'll receive an email to set up their account."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:I.name,onChange:ke=>O({...I,name:ke.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:I.email,onChange:ke=>O({...I,email:ke.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(ze,{id:"phone",type:"tel",value:I.phone,onChange:ke=>O({...I,phone:ke.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"password",children:"Temporary Password"}),e.jsx(ze,{id:"password",type:"password",value:I.password,onChange:ke=>O({...I,password:ke.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:xt,disabled:M,children:M?"Creating...":"Create Agent"})]})]})}),e.jsx(fs,{open:q,onOpenChange:U,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Remove Agent"}),e.jsxs(Gr,{children:["Are you sure you want to remove ",e.jsx("strong",{children:B==null?void 0:B.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Yr,disabled:Y,children:Y?"Removing...":"Remove Agent"})]})]})}),e.jsx(rtt,{open:ee,onOpenChange:X,fixedBrokerageId:t,onSuccess:er}),e.jsx(fs,{open:ie,onOpenChange:re,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add Brokerage Manager"}),e.jsx(Gr,{children:"Promote an existing active agent to brokerage manager. They will be able to manage agents and view analytics."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(be,{children:"Select Agent"}),e.jsxs($o,{open:_e,onOpenChange:$e,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":_e,className:"w-full justify-between",children:[oe?((Fo=n.find(ke=>ke.id===oe))==null?void 0:Fo.name)+" ("+(($t=n.find(ke=>ke.id===oe))==null?void 0:$t.email)+")":"Select an agent to promote...",e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-full p-0",align:"start",children:e.jsxs(Dx,{children:[e.jsx(Ox,{placeholder:"Search by name or email..."}),e.jsxs(Rx,{className:"max-h-[200px]",children:[e.jsx(Fx,{children:"No eligible agents found."}),e.jsx(zx,{children:n.filter(ke=>!dr(ke.id)).map(ke=>e.jsxs(bp,{value:`${ke.name} ${ke.email}`,onSelect:()=>{ce(ke.id),$e(!1)},children:[e.jsx(va,{className:`mr-2 h-4 w-4 ${oe===ke.id?"opacity-100":"opacity-0"}`}),ke.name," (",ke.email,")"]},ke.id))})]})]})})]}),n.filter(ke=>!dr(ke.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsx(K,{onClick:ki,disabled:ge||!oe,children:ge?"Adding...":"Add as Manager"})]})]})}),e.jsx(fs,{open:Ae,onOpenChange:Ie,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Agent"}),e.jsxs(Gr,{children:["Update profile information for ",Ce==null?void 0:Ce.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"edit-name",children:"Name"}),e.jsx(ze,{id:"edit-name",value:we.name,onChange:ke=>Le({...we,name:ke.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"edit-email",children:"Email"}),e.jsx(ze,{id:"edit-email",type:"email",value:we.email,onChange:ke=>Le({...we,email:ke.target.value}),placeholder:"agent@example.com"}),we.email.trim().toLowerCase()!==(Ce==null?void 0:Ce.email.toLowerCase())&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing email will update their login credentials"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(ze,{id:"edit-phone",type:"tel",value:we.phone,onChange:ke=>Le({...we,phone:ke.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ie(!1),children:"Cancel"}),e.jsx(K,{onClick:fn,disabled:tt||pt,children:pt?"Updating email...":tt?"Saving...":"Save Changes"})]})]})}),ct&&e.jsx(ntt,{open:rt,onOpenChange:ke=>{He(ke),ke||Ue(null)},userId:ct.id,userName:ct.name}),e.jsx(fs,{open:Ze,onOpenChange:Qe,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Set Password"}),e.jsxs(Gr,{children:["Set a new password for ",We==null?void 0:We.name,". They will be able to log in with this password immediately."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"new-password",children:"New Password"}),e.jsx(ze,{id:"new-password",type:"password",value:it,onChange:ke=>Dt(ke.target.value),placeholder:"Enter new password (min 6 characters)"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Make sure to communicate this password to the agent through a secure channel."})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Qe(!1),children:"Cancel"}),e.jsx(K,{onClick:Wr,disabled:Vt||!it||it.length<6,children:Vt?"Setting...":"Set Password"})]})]})})]})},Gvs={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},Kvs={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},Zvs=t=>{switch(t){case"academy_video":return e.jsx(An,{className:"h-4 w-4"});case"template":return e.jsx(Sn,{className:"h-4 w-4"});case"toolbox":return e.jsx(Sn,{className:"h-4 w-4"});case"newsletter":return e.jsx(d1,{className:"h-4 w-4"});case"social_swag":return e.jsx(pn,{className:"h-4 w-4"});case"event":return e.jsx(hn,{className:"h-4 w-4"});default:return e.jsx(tn,{className:"h-4 w-4"})}},Yvs=({brokerageId:t})=>{const{toast:s}=Ua(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState([]),[c,u]=k.useState(!0),[p,f]=k.useState(null);k.useEffect(()=>{g()},[t]);const g=async()=>{try{u(!0);const{data:j,error:w}=await H.from("profiles").select("id, name, email").eq("brokerage_id",t);if(w)throw w;const N=j.map(Y=>Y.id),S=new Map(j.map(Y=>[Y.id,Y]));if(N.length===0){n([]),o([]),i([]);return}const{data:M,error:L}=await H.from("activity_logs").select("*").in("user_id",N).order("launched_at",{ascending:!1});if(L)throw L;const I=M.map(Y=>{var Q,ee;return{id:Y.id,user_id:Y.user_id,app_name:Y.app_name,launched_at:Y.launched_at,user_name:((Q=S.get(Y.user_id))==null?void 0:Q.name)||"Unknown",user_email:((ee=S.get(Y.user_id))==null?void 0:ee.email)||"Unknown"}});n(I);const{data:O,error:q}=await H.from("content_engagement_logs").select("*").in("user_id",N).order("created_at",{ascending:!1});if(q)throw q;const U=(O||[]).map(Y=>{var Q,ee;return{id:Y.id,user_id:Y.user_id,resource_type:Y.resource_type,resource_id:Y.resource_id,resource_title:Y.resource_title,action_type:Y.action_type,created_at:Y.created_at,user_name:((Q=S.get(Y.user_id))==null?void 0:Q.name)||"Unknown",user_email:((ee=S.get(Y.user_id))==null?void 0:ee.email)||"Unknown"}});o(U);const B=new Map;j.forEach(Y=>{B.set(Y.id,{user_id:Y.id,user_name:Y.name,user_email:Y.email,app_launches:0,content_views:0,last_activity:""})}),I.forEach(Y=>{const Q=B.get(Y.user_id);Q&&(Q.app_launches++,(!Q.last_activity||new Date(Y.launched_at)>new Date(Q.last_activity))&&(Q.last_activity=Y.launched_at))}),U.forEach(Y=>{const Q=B.get(Y.user_id);Q&&(Q.content_views++,(!Q.last_activity||new Date(Y.created_at)>new Date(Q.last_activity))&&(Q.last_activity=Y.created_at))});const V=Array.from(B.values()).filter(Y=>Y.app_launches>0||Y.content_views>0).sort((Y,Q)=>new Date(Q.last_activity).getTime()-new Date(Y.last_activity).getTime());i(V)}catch(j){console.error("Error loading activity:",j),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},b=j=>r.filter(w=>w.user_id===j),_=j=>a.filter(w=>w.user_id===j);return c?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Agent Activity"}),e.jsx(gr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"App Launches"}),e.jsx(St,{className:"text-center",children:"Content Views"}),e.jsx(St,{children:"Last Active"})]})}),e.jsx(zn,{children:l.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(j=>e.jsxs(Ss,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:j.user_id,name:j.user_name,email:j.user_email}),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:j.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:j.user_email})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(nl,{className:"h-3 w-3"}),j.app_launches]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),j.content_views]})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:j.last_activity&&Uc(new Date(j.last_activity),{addSuffix:!0})})]},j.user_id))})]})})})]}),e.jsx(fs,{open:!!p,onOpenChange:j=>!j&&f(null),children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Gr,{children:p==null?void 0:p.email})]}),e.jsxs(ba,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsx(ns,{value:"content",children:"Content Engagement"}),e.jsx(ns,{value:"apps",children:"App Launches"})]}),e.jsx(bs,{value:"content",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Resource"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Time"})]})}),e.jsx(zn,{children:p&&_(p.id).length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&_(p.id).map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"max-w-[200px] truncate font-medium",children:j.resource_title}),e.jsx(dt,{children:e.jsxs(st,{variant:"outline",className:"gap-1",children:[Zvs(j.resource_type),Gvs[j.resource_type]||j.resource_type]})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Kvs[j.action_type]||j.action_type})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(j.created_at),{addSuffix:!0})})]},j.id))})]})})}),e.jsx(bs,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"App"}),e.jsx(St,{children:"Time"})]})}),e.jsx(zn,{children:p&&b(p.id).length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&b(p.id).map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(st,{variant:"outline",children:j.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Uc(new Date(j.launched_at),{addSuffix:!0})})]},j.id))})]})})})]})]})})]})},Xvs=({brokerageId:t})=>{const{toast:s}=Ua(),[r,n]=k.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=k.useState(!0);k.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:c}=await H.from("profiles").select("id").eq("brokerage_id",t);if(c)throw c;const u=i.map(I=>I.id),p=u.length;if(u.length===0){o(!1);return}const{data:f,error:g}=await H.from("profiles").select("id, email").in("id",u);if(g)throw g;const{count:b}=await H.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),_=b||0,j=p-_,{count:w}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),N=new Date;N.setDate(N.getDate()-7);const{count:S}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",N.toISOString()),M=new Date;M.setMonth(M.getMonth()-1);const{count:L}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",M.toISOString());n({totalAgents:p,activeAgents:_,pendingAgents:j,totalLaunches:w||0,launchesThisWeek:S||0,launchesThisMonth:L||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalAgents}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.activeAgents," active, ",r.pendingAgents," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.activeAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.totalAgents>0?`${Math.round(r.activeAgents/r.totalAgents*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.pendingAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]})]})},Qvs=({brokerageId:t})=>{const[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState({description:"",maxUses:""});k.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:N,error:S}=await H.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(S)throw S;r(N||[])}catch(N){console.error("Error loading invite codes:",N),me.error("Failed to load invite links")}finally{a(!1)}},g=()=>Math.random().toString(36).substring(2,8).toUpperCase(),b=async()=>{l(!0);try{const N=g(),{error:S}=await H.from("invite_codes").insert({code:N,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(S)throw S;me.success("Invite link created!"),c(!1),p({description:"",maxUses:""}),f()}catch(N){console.error("Error creating invite code:",N),me.error("Failed to create invite link")}finally{l(!1)}},_=async N=>{try{const{error:S}=await H.from("invite_codes").delete().eq("id",N);if(S)throw S;me.success("Invite link deleted"),r(s.filter(M=>M.id!==N))}catch(S){console.error("Error deleting invite code:",S),me.error("Failed to delete invite link")}},j=async(N,S)=>{try{const{error:M}=await H.from("invite_codes").update({is_active:!S}).eq("id",N);if(M)throw M;r(s.map(L=>L.id===N?{...L,is_active:!S}:L)),me.success(`Invite link ${S?"deactivated":"activated"}`)}catch(M){console.error("Error toggling invite code:",M),me.error("Failed to update invite link")}},w=N=>{const S=`${window.location.origin}/join?code=${N}`;navigator.clipboard.writeText(S),me.success("Link copied to clipboard!")};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(gr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(fs,{open:i,onOpenChange:c,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create Invite Link"}),e.jsx(Gr,{children:"Create a new invite link for agents to join your brokerage"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description (optional)"}),e.jsx(ze,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:N=>p({...u,description:N.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(ze,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:N=>p({...u,maxUses:N.target.value})})]}),e.jsx(K,{onClick:b,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(Oe,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Bo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No invite links yet"}),e.jsx("p",{className:"text-sm",children:"Create one to start inviting agents"})]}):e.jsx("div",{className:"space-y-3",children:s.map(N=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono bg-muted px-2 py-0.5 rounded",children:N.code}),e.jsx(st,{variant:N.is_active?"default":"secondary",children:N.is_active?"Active":"Inactive"})]}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:N.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[N.uses_count," uses",N.max_uses&&` / ${N.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(N.code),title:"Copy link",children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>j(N.id,N.is_active),title:N.is_active?"Deactivate":"Activate",children:N.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(N.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},N.id))})})]})},Jvs=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,c]=k.useState(""),[u,p]=k.useState([]),[f,g]=k.useState(""),[b,_]=k.useState(!1),j=L=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(L),w=()=>{const L=i.trim().toLowerCase();if(L&&j(L)&&!u.includes(L)){if(u.length>=10){me.error("Maximum 10 emails per invite");return}p([...u,L]),c("")}else L&&!j(L)?me.error("Please enter a valid email address"):u.includes(L)&&me.error("Email already added")},N=L=>{p(u.filter(I=>I!==L))},S=L=>{(L.key==="Enter"||L.key===",")&&(L.preventDefault(),w())},M=async()=>{if(u.length===0){me.error("Please add at least one email address");return}_(!0);try{const{data:L,error:I}=await H.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:f.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(I)throw I;L.successCount===L.totalCount?me.success(`${L.successCount} invite${L.successCount>1?"s":""} sent successfully!`):me.warning(`${L.successCount} of ${L.totalCount} invites sent. Some failed.`),p([]),g(""),s(!1),l==null||l()}catch(L){console.error("Error sending invites:",L),me.error("Failed to send invites. Please try again.")}finally{_(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[550px]",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(Gr,{children:"Send a personalized email invitation to broker owners you know. They'll receive a beautiful email highlighting LevelUp's features."})]}),e.jsxs("div",{className:"bg-gradient-to-r from-primary/10 to-primary/5 border border-primary/20 rounded-lg p-4 flex items-center gap-3",children:[e.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:e.jsx(ko,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:"Earn $25/month for each referral!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"When they sign up and stay for 30 days, you save on your membership forever."})]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email Addresses (up to 10)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:L=>c(L.target.value),onKeyDown:S,onBlur:w}),e.jsx(K,{type:"button",variant:"secondary",onClick:w,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(L=>e.jsxs(st,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[L,e.jsx("button",{type:"button",onClick:()=>N(L),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Rr,{className:"h-3 w-3"})})]},L))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Er,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:f,onChange:L=>g(L.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/500 characters"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),"What they'll receive:"]}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Beautiful branded email from you"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Your personal message (if added)"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Key LevelUp features for brokerages"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Direct signup link with your referral code"]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:M,disabled:u.length===0||b,children:b?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent mr-2"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},e1s=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=k.useState([]),[a,o]=k.useState(!0);k.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:c,error:u}=await H.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(u)throw u;n(c||[])}catch(c){console.error("Error fetching invites:",c)}finally{o(!1)}},i=c=>{switch(c){case"signed_up":return e.jsxs(st,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(xi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(st,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(vc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Pending"]})}};return a?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):r.length===0?e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(cr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No invites sent yet"}),e.jsx("p",{className:"text-xs",children:"Start inviting broker friends to earn rewards!"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Recent Invites"}),r.map(c=>e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:c.recipient_email}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sent ",ms(new Date(c.sent_at),"MMM d, yyyy")]})]}),i(c.status)]},c.id))]})},t1s=()=>{const{brokerageId:t,user:s}=Ds(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState([]),[p,f]=k.useState(!0),[g,b]=k.useState(!1),[_,j]=k.useState(0);k.useEffect(()=>{t&&w()},[t]);const w=async()=>{try{const[O,q]=await Promise.all([H.from("brokerages").select("name").eq("id",t).single(),s?H.from("profiles").select("name").eq("id",s.id).single():Promise.resolve({data:null})]);O.data&&o(O.data.name),q.data&&i(q.data.name||"A LevelUp Member");const{data:U}=await H.from("referral_codes").select("code").eq("brokerage_id",t).single();if(U)n(U.code);else{const V=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await H.from("referral_codes").insert({brokerage_id:t,code:V}),n(V)}const{data:B}=await H.from("referrals").select(` *, referred_user:profiles!referred_user_id(name, email), referred_brokerage:brokerages!referred_brokerage_id(name) `).eq("referrer_brokerage_id",t).order("created_at",{ascending:!1});u(B||[])}catch(O){console.error("Error fetching referral data:",O)}finally{f(!1)}},N=()=>{const O=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(O),me.success("Referral link copied to clipboard!")},S=c.filter(O=>O.status==="qualified").length,M=c.filter(O=>O.status==="pending").length,L=S*25,I=Math.max(0,Math.ceil((299-L)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-primary/10 via-primary/5 to-background border-b",children:e.jsxs("div",{className:"px-6 py-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:e.jsx(ko,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold",children:"Referral Rewards Program"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Earn $25/month off your membership for every broker you refer"})]})]}),e.jsx("div",{className:"mt-4 bg-background/80 rounded-lg p-4 border",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",L]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),L>0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(xi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),I>0&&L<299&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Refer ",I," more = ",e.jsx("span",{className:"text-primary",children:"FREE membership!"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your membership could cost $0/month"})]}),L>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(pn,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Oe,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(K,{onClick:()=>b(!0),className:"w-full",size:"lg",children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:N,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Referral Link"]})]}),e.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Your Referral Link"}),e.jsxs("code",{className:"block px-3 py-2 bg-background rounded border text-sm break-all",children:["https://dashboard.relevelup.com/?ref=",r]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"text-center p-4 bg-green-50 dark:bg-green-950/20 rounded-lg border border-green-200 dark:border-green-900",children:[e.jsx(ac,{className:"h-5 w-5 mx-auto text-green-600 mb-1"}),e.jsxs("p",{className:"text-2xl font-bold text-green-700 dark:text-green-400",children:["$",L]}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-500",children:"Monthly Savings"})]}),e.jsxs("div",{className:"text-center p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(pr,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(un,{className:"h-5 w-5 mx-auto text-amber-600 mb-1"}),e.jsx("p",{className:"text-2xl font-bold text-amber-700 dark:text-amber-400",children:M}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:"Pending (30 days)"})]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4",children:[e.jsx("h4",{className:"font-semibold text-sm mb-3",children:"How It Works"}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"1"}),e.jsx("p",{children:"Share your referral link or send an invite email to broker friends"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"2"}),e.jsx("p",{children:"They sign up and subscribe to LevelUp"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"3"}),e.jsx("p",{children:"After 30 days, you get $25/month off your membership - forever!"})]})]})]}),e.jsx(e1s,{brokerageId:t,refreshTrigger:_}),c.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your Referrals"}),c.slice(0,5).map(O=>{var q,U;return e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsx("span",{className:"text-sm truncate",children:((q=O.referred_brokerage)==null?void 0:q.name)||((U=O.referred_user)==null?void 0:U.email)||"Pending setup"}),e.jsxs(st,{variant:O.status==="qualified"?"default":O.status==="pending"?"secondary":"destructive",className:O.status==="qualified"?"bg-green-600":"",children:[O.status==="qualified"&&e.jsx(xi,{className:"h-3 w-3 mr-1"}),O.status]})]},O.id)})]})]})]}),e.jsx(Jvs,{open:g,onOpenChange:b,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>j(O=>O+1)})]})},s1s=({brokerageId:t})=>{const s=fr(),{teams:r,isLoading:n}=_C(t),{data:a,isLoading:o}=mt({queryKey:["team-aggregate-stats",t,r.map(p=>p.id)],queryFn:async()=>{if(r.length===0)return[];const p=r.map(O=>O.id),{data:f}=await H.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!f||f.length===0)return r.map(O=>({team_id:O.id,team_name:O.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const g=f.map(O=>O.user_id),b=f.filter(O=>O.role==="team_leader").map(O=>O.user_id),{data:_}=await H.from("profiles").select("id, name, avatar_url").in("id",b),j=new Map((_||[]).map(O=>[O.id,O])),{data:w}=await H.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",g),{data:N}=await H.from("deal_pipeline").select("owner_user_id").in("owner_user_id",g),{data:S}=await H.from("agent_videos").select("owner_user_id").in("owner_user_id",g).eq("is_deleted",!1),M=new Map;(w||[]).forEach(O=>{M.set(O.owner_user_id,(M.get(O.owner_user_id)||0)+1)});const L=new Map;(N||[]).forEach(O=>{L.set(O.owner_user_id,(L.get(O.owner_user_id)||0)+1)});const I=new Map;return(S||[]).forEach(O=>{I.set(O.owner_user_id,(I.get(O.owner_user_id)||0)+1)}),r.map(O=>{const q=f.filter(X=>X.team_id===O.id),U=q.find(X=>X.role==="team_leader"),B=U?j.get(U.user_id):null,V=q.map(X=>X.user_id),Y=V.reduce((X,ie)=>X+(M.get(ie)||0),0),Q=V.reduce((X,ie)=>X+(L.get(ie)||0),0),ee=V.reduce((X,ie)=>X+(I.get(ie)||0),0);return{team_id:O.id,team_name:O.name,member_count:q.length,leader_name:(B==null?void 0:B.name)||null,leader_avatar:(B==null?void 0:B.avatar_url)||null,total_contacts:Y,total_deals:Q,total_videos:ee}})},enabled:r.length>0});if(n||o)return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(p=>e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(ys,{className:"h-5 w-32"})}),e.jsx(Oe,{children:e.jsx(ys,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create teams to organize your agents and track their performance."}),e.jsx(K,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,f)=>p+f.member_count,0),c=(a||[]).reduce((p,f)=>p+f.total_contacts,0),u=(a||[]).reduce((p,f)=>p+f.total_deals,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(eS,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:c.toLocaleString()})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Gh,{className:"h-4 w-4"})," Total Deals"]}),e.jsx("p",{className:"text-2xl font-bold",children:u.toLocaleString()})]})})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:(a||[]).map(p=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-lg",children:p.team_name}),e.jsxs(st,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:p.leader_avatar||""}),e.jsx(kn,{className:"text-xs",children:p.leader_name.charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Dm,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_contacts.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_deals.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},p.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},r1s=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Ds(),i=fr(),{toast:c}=Ua(),[u,p]=k.useState(""),[f,g]=k.useState(!0),b=o||(a.length>0?a[0].id:r);k.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),b?_():a.length===0&&!r&&g(!1)},[t,s,n,b,i,a,o]);const _=async()=>{if(!b){g(!1);return}try{const{data:j,error:w}=await H.from("brokerages").select("name").eq("id",b).single();if(w)throw w;p(j.name)}catch(j){console.error("Error loading brokerage info:",j),c({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{g(!1)}};return f?e.jsx(Ms,{title:"Manage Brokerages",description:"Loading brokerage information...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):b?e.jsx(Ms,{title:u||"Manage Brokerages",description:"Brokerage Management Dashboard",children:e.jsxs("div",{className:"space-y-6",children:[a.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Managing:"}),e.jsxs(Ks,{value:o||"",onValueChange:l,children:[e.jsxs(Hs,{className:"w-[280px]",children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),e.jsx(Ys,{placeholder:"Select brokerage"})]}),e.jsx(Ws,{children:a.map(j=>e.jsx(Mt,{value:j.id,children:j.name},j.id))})]})]}),e.jsxs(ba,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(pa,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(ns,{value:"agents",children:"Agents"}),e.jsx(ns,{value:"teams",children:"Teams"}),e.jsx(ns,{value:"invite",children:"Invite Links"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"leaderboard",children:"Leaderboard"}),e.jsx(ns,{value:"activity",children:"Activity"}),e.jsx(ns,{value:"analytics",children:"Analytics"}),e.jsx(ns,{value:"shares",children:"Shares"})]}),e.jsx(bs,{value:"agents",className:"space-y-4",children:e.jsx(Wvs,{brokerageId:b})}),e.jsx(bs,{value:"teams",className:"space-y-4",children:e.jsx(s1s,{brokerageId:b})}),e.jsx(bs,{value:"invite",className:"space-y-4",children:e.jsx(Qvs,{brokerageId:b})}),e.jsx(bs,{value:"referrals",className:"space-y-4",children:e.jsx(t1s,{})}),e.jsx(bs,{value:"leaderboard",className:"space-y-4",children:e.jsx(_et,{brokerageId:b,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(bs,{value:"activity",className:"space-y-4",children:e.jsx(Yvs,{brokerageId:b})}),e.jsx(bs,{value:"analytics",className:"space-y-4",children:e.jsx(Xvs,{brokerageId:b})}),e.jsx(bs,{value:"shares",className:"space-y-4",children:e.jsx(Itt,{brokerageOnly:!0,brokerageId:b})})]})]})}):e.jsx(Ms,{title:"Manage Brokerages",description:"Brokerage Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ka,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You don't have any brokerages to manage."})]})})};function n1s({brokerageId:t,canManage:s}){const{user:r}=Ds(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,c]=k.useState(!1),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(!1),[j,w]=k.useState(""),[N,S]=k.useState(""),[M,L]=k.useState(!1),I=async()=>{try{const{data:V,error:Y}=await H.from("brokerage_announcements").select("*").eq("brokerage_id",t).order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1});if(Y)throw Y;const Q=V;if(Q&&Q.length>0){const ee=[...new Set(Q.map(oe=>oe.created_by))],{data:X}=await H.from("profiles").select("id, name, avatar_url").in("id",ee),ie=new Map((X==null?void 0:X.map(oe=>[oe.id,oe]))||[]),re=Q.map(oe=>({...oe,author:ie.get(oe.created_by)||{name:"Unknown",avatar_url:null}}));a(re)}else a([])}catch(V){console.error("Error fetching announcements:",V)}finally{l(!1)}};k.useEffect(()=>{I()},[t]);const O=()=>{w(""),S(""),L(!1),p(null)},q=V=>{V?(p(V),w(V.title),S(V.content),L(V.is_pinned)):O(),c(!0)},U=async()=>{if(!j.trim()||!N.trim()){me.error("Please fill in all fields");return}_(!0);try{if(u){const{error:V}=await H.from("brokerage_announcements").update({title:j.trim(),content:N.trim(),is_pinned:M,pinned_at:M?new Date().toISOString():null}).eq("id",u.id);if(V)throw V;me.success("Announcement updated")}else{const{error:V}=await H.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:j.trim(),content:N.trim(),is_pinned:M,pinned_at:M?new Date().toISOString():null});if(V)throw V;me.success("Announcement created")}c(!1),O(),I()}catch(V){console.error("Error saving announcement:",V),me.error("Failed to save announcement")}finally{_(!1)}},B=async()=>{if(f)try{const{error:V}=await H.from("brokerage_announcements").delete().eq("id",f);if(V)throw V;me.success("Announcement deleted"),I()}catch(V){console.error("Error deleting announcement:",V),me.error("Failed to delete announcement")}finally{g(null)}};return o?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Ah,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:e.jsx("div",{className:"h-20 bg-muted rounded"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Ah,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>q(),className:"gap-1",children:[e.jsx($s,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Oe,{children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):e.jsx("div",{className:"space-y-4",children:n.map(V=>{var Y,Q,ee,X;return e.jsx("div",{className:`p-4 rounded-lg border ${V.is_pinned?"bg-primary/5 border-primary/20":"bg-muted/30"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[V.is_pinned&&e.jsx(V_,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold truncate",children:V.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:V.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-muted-foreground",children:[e.jsxs(Nn,{className:"h-5 w-5",children:[e.jsx($a,{src:((Y=V.author)==null?void 0:Y.avatar_url)||void 0}),e.jsx(kn,{className:"text-[10px]",children:((ee=(Q=V.author)==null?void 0:Q.name)==null?void 0:ee.charAt(0))||"?"})]}),e.jsx("span",{children:(X=V.author)==null?void 0:X.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ms(new Date(V.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>q(V),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>g(V.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})},V.id)})})})]}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:u?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",value:j,onChange:V=>w(V.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"content",children:"Content"}),e.jsx(Er,{id:"content",value:N,onChange:V=>S(V.target.value),placeholder:"Write your announcement...",rows:4})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"pinned",checked:M,onCheckedChange:L}),e.jsxs(be,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(V_,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:U,disabled:b,children:b?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(kc,{open:!!f,onOpenChange:()=>g(null),children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete Announcement"}),e.jsx(sc,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function a1s({brokerageId:t,canManage:s=!1}){const{startImpersonation:r,isLoading:n}=Ide(),{user:a}=Ds(),[o,l]=k.useState([]),[i,c]=k.useState(!0),[u,p]=k.useState(""),[f,g]=k.useState(new Set);k.useEffect(()=>{(async()=>{try{const{data:j,error:w}=await H.from("profiles").select("id, name, email, phone, avatar_url, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url").eq("brokerage_id",t).order("name");if(w)throw w;if(l(j||[]),j&&j.length>0){const N=j.map(M=>M.id),{data:S}=await H.from("agent_assistant_assignments").select("agent_id").in("agent_id",N);S&&g(new Set(S.map(M=>M.agent_id)))}}catch(j){console.error("Error fetching agents:",j)}finally{c(!1)}})()},[t]);const b=o.filter(_=>{var j,w;return _.name.toLowerCase().includes(u.toLowerCase())||_.email.toLowerCase().includes(u.toLowerCase())||((j=_.title)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))||((w=_.areas_served)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))});return i?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(_=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},_))})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5 text-primary"}),"Agent Roster",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",o.length,")"]})]}),e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:u,onChange:_=>p(_.target.value),className:"pl-9"})]})]}),e.jsx(Oe,{children:b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:u?"No agents match your search":"No agents in this brokerage yet"}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:b.map(_=>e.jsx(i1s,{agent:_,hasAssistant:f.has(_.id),canImpersonate:s&&_.id!==(a==null?void 0:a.id),onImpersonate:()=>r(_.id,"/my-brokerage"),impersonationLoading:n},_.id))})})]})}function i1s({agent:t,hasAssistant:s,canImpersonate:r,onImpersonate:n,impersonationLoading:a}){const o=t.name.split(" ").map(l=>l[0]).join("").toUpperCase().slice(0,2);return e.jsxs("div",{className:"group relative bg-card border rounded-xl p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-3",children:[e.jsxs(Nn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx($a,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(kn,{className:"text-lg bg-primary/10 text-primary",children:o})]}),e.jsx("h3",{className:"font-semibold text-sm leading-tight",children:t.name}),t.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.title}),s&&e.jsx(st,{variant:"outline",className:"text-[10px] mt-1",children:"Has Assistant"})]}),t.bio&&e.jsx("p",{className:"text-xs text-muted-foreground text-center line-clamp-2 mb-3",children:t.bio}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[t.areas_served&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ma,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.areas_served})]}),t.years_experience&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:[t.years_experience," ",t.years_experience===1?"year":"years"," experience"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r&&e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:n,disabled:a,children:e.jsx(iS,{className:"h-4 w-4"})})}),e.jsxs(Xl,{children:["Login as ",t.name]})]}),t.phone&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`tel:${t.phone}`,title:`Call ${t.name}`,children:e.jsx(Un,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`mailto:${t.email}`,title:`Email ${t.name}`,children:e.jsx(cr,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:"LinkedIn",children:e.jsx(Mp,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.instagram_url,target:"_blank",rel:"noopener noreferrer",title:"Instagram",children:e.jsx(Mu,{className:"h-4 w-4"})})})]})]})}function o1s({brokerageId:t}){const[s,r]=k.useState([]),[n,a]=k.useState(!0);if(k.useEffect(()=>{(async()=>{try{const{data:c,error:u}=await H.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!c||c.length===0){r([]),a(!1);return}const p=c.map(j=>j.id),{data:f,error:g}=await H.from("agent_attendance_stats").select("user_id, total_points").in("user_id",p).order("total_points",{ascending:!1});if(g)throw g;const b=new Map(c.map(j=>[j.id,j])),_=(f||[]).filter(j=>j.total_points>0).map(j=>{const w=b.get(j.user_id);return{user_id:j.user_id,total_points:j.total_points,name:(w==null?void 0:w.name)||"Unknown",avatar_url:(w==null?void 0:w.avatar_url)||null}});r(_)}catch(c){console.error("Error fetching leaderboard:",c)}finally{a(!1)}})()},[t]),n)return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:[1,2,3].map(i=>e.jsx("div",{className:"h-12 bg-muted rounded"},i))})})]});const o=i=>i===1?"text-yellow-500":i===2?"text-gray-400":i===3?"text-amber-600":"text-muted-foreground",l=i=>i<=3?e.jsx(c1,{className:It("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No points earned yet. Attend events to earn points!"}):e.jsx("div",{className:"space-y-2",children:s.slice(0,10).map((i,c)=>{const u=i.name.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),p=c+1;return e.jsxs("div",{className:It("flex items-center gap-3 p-2 rounded-lg",p<=3&&"bg-muted/50"),children:[e.jsx("div",{className:"w-6 flex justify-center",children:l(p)}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:i.avatar_url||void 0}),e.jsx(kn,{className:"text-xs",children:u})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:i.name}),e.jsxs("span",{className:"text-sm font-semibold text-primary",children:[i.total_points.toLocaleString()," pts"]})]},i.user_id)})})})]})}function l1s({brokerageId:t}){const s=fr(),[r,n]=k.useState([]),[a,o]=k.useState(!0);k.useEffect(()=>{(async()=>{try{const{data:c,error:u}=await H.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!c||c.length===0){n([]),o(!1);return}const p=c.map(j=>j.id),f=new Map(c.map(j=>[j.id,j])),{data:g,error:b}=await H.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(b)throw b;const _=(g||[]).map(j=>({id:j.id,slug:j.slug,property_address:j.property_address,city:j.city,price:j.price,property_type:j.property_type,agent_id:j.agent_id,agent:f.get(j.agent_id)||null,photos:j.listing_photos||[]}));n(_)}catch(c){console.error("Error fetching listings:",c)}finally{o(!1)}})()},[t]);const l=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i);return a?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2].map(i=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-32 bg-muted rounded-lg"})},i))})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>s("/mission-control/listings"),className:"gap-1",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(Oe,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(bn,{className:"h-10 w-10 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No active listings from your brokerage yet"}),e.jsxs(K,{size:"sm",onClick:()=>s("/mission-control/listings/new"),className:"gap-1",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Your First Listing"]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:r.map(i=>e.jsxs("div",{onClick:()=>window.open(`https://listings.relevelup.com/${i.slug||i.id}`,"_blank"),className:"group cursor-pointer border rounded-lg overflow-hidden hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"relative h-24 bg-muted",children:[i.photos&&i.photos.length>0?e.jsx("img",{src:i.photos[0].photo_url,alt:i.property_address||"Listing",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(bn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:"text-[10px] font-medium bg-primary text-primary-foreground px-1.5 py-0.5 rounded uppercase",children:i.property_type.replace("_"," ")})})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("p",{className:"font-semibold text-sm text-primary",children:l(i.price)}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:i.property_address||"Address not available"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.city}),i.agent&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1.5 truncate",children:["Listed by ",i.agent.name]})]})]},i.id))}),r.length>0&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>s("/mission-control/listings"),children:["View All Listings",e.jsx(tn,{className:"h-3 w-3 ml-1"})]})]})]})}function c1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Ds(),n=fr(),[a,o]=k.useState(!0),[l,i]=k.useState(null),[c,u]=k.useState(""),[p,f]=k.useState(0),[g,b]=k.useState(!1),[_,j]=k.useState(!1);return k.useEffect(()=>{(async()=>{if(t)try{const{data:N}=await H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(N!=null&&N.brokerage_id)){o(!1);return}i(N.brokerage_id);const{data:S}=await H.from("brokerages").select("name").eq("id",N.brokerage_id).maybeSingle();S&&u(S.name);const{count:M}=await H.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",N.brokerage_id);if(f(M||0),s)b(!0),j(!0);else if(r){const{data:L}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",N.brokerage_id).maybeSingle();b(!!L),j(!!L)}}catch(N){console.error("Error fetching brokerage info:",N)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Ms,{title:"My Brokerage",description:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):l?e.jsx(Ms,{title:c||"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-4 py-2",children:[e.jsx(pr,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[p," ",p===1?"Agent":"Agents"]})]}),_&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(Sh,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(n1s,{brokerageId:l,canManage:g}),e.jsx(a1s,{brokerageId:l,canManage:g}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(o1s,{brokerageId:l}),e.jsx(l1s,{brokerageId:l})]})]})}):e.jsx(Ms,{title:"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ka,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You're not currently part of a brokerage team."})]})})}function d1s(t){if(!t)return null;try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}function u1s(t){if(!t)return!1;try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}const FFe={video:{icon:nl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:Sn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:dl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:hn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:ic,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function h1s({item:t,canManage:s}){const[r,n]=k.useState(!1),[a,o]=k.useState(null),l=_Lt(),i=fr(),c=FFe[t.content_type]||FFe.link,u=c.icon,p=k.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?d1s(t.url):null,[t]);k.useEffect(()=>{p||!t.url||t.content_type!=="video"||!u1s(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(_=>_.ok?_.json():null).then(_=>{_!=null&&_.thumbnail_url&&o(_.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,p]);const f=p||a,g=()=>{i(`/brokerage-content/${t.id}`)},b=async()=>{try{await l.mutateAsync(t.id),me.success("Content deleted")}catch{me.error("Failed to delete")}n(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"group overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",onClick:g,children:[f?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:f,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/30 flex items-center justify-center",children:e.jsx(u,{className:"h-12 w-12 text-muted-foreground/30"})}),e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs(st,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${c.color}`,children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),c.label]}),t.category&&e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[t.category.icon," ",t.category.name]})]}),e.jsx("h3",{className:"font-semibold text-sm text-foreground group-hover:text-primary transition-colors truncate",children:t.title}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:t.description}),t.content_type==="event"&&t.event_date&&e.jsxs("p",{className:"text-xs text-primary mt-2 font-medium",children:["📅 ",ms(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ms(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,onClick:_=>_.stopPropagation(),children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsx(Bd,{align:"end",children:e.jsxs(Ma,{onClick:_=>{_.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(kc,{open:r,onOpenChange:n,children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete Content"}),e.jsxs(sc,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:b,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function m1s(t){try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}const zFe=[{value:"video",label:"🎥 Video",hint:"YouTube, Vimeo, or video URL"},{value:"pdf",label:"📄 Document / PDF",hint:"Upload a PDF or document"},{value:"link",label:"🔗 Link / Resource",hint:"External URL"},{value:"event",label:"📅 Event",hint:"Brokerage event with date"},{value:"graphic",label:"🎨 Graphic / Canva",hint:"Image, Canva share link, or social post"}];function p1s({brokerageId:t,categories:s}){var pe;const{user:r}=Ds(),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(""),[u,p]=k.useState("📁"),[f,g]=k.useState(!1);k.useRef(null);const[b,_]=k.useState("video"),[j,w]=k.useState(""),[N,S]=k.useState(""),[M,L]=k.useState(""),[I,O]=k.useState(""),[q,U]=k.useState(""),[B,V]=k.useState(""),[Y,Q]=k.useState(""),ee=bLt(),X=wLt(t),ie=jLt(),re=NLt(t),oe=()=>{_("video"),w(""),S(""),L(""),O(""),U(""),V(""),Q("")},ce=async(_e,$e)=>{var Ie;const Ae=(Ie=_e.target.files)==null?void 0:Ie[0];if(Ae){g(!0);try{const Ce=Ae.name.split(".").pop(),xe=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Ce}`,{error:we}=await H.storage.from("brokerage-content").upload(xe,Ae);if(we)throw we;const{data:{publicUrl:Le}}=H.storage.from("brokerage-content").getPublicUrl(xe);$e==="file"?(O(Le),b==="graphic"&&!q&&U(Le)):U(Le),me.success("File uploaded")}catch(Ce){me.error(Ce.message||"Upload failed")}finally{g(!1)}}},ge=async()=>{if(!j.trim()){me.error("Title is required");return}if(r)try{await ee.mutateAsync({brokerage_id:t,category_id:Y||null,content_type:b,title:j.trim(),description:N.trim()||null,url:M.trim()||null,file_url:I.trim()||null,thumbnail_url:q.trim()||null,event_date:B?new Date(B).toISOString():null,created_by:r.id}),me.success("Content added!"),oe(),a(!1)}catch(_e){me.error(_e.message||"Failed to add content")}},ye=async()=>{if(i.trim())try{await X.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),c(""),p("📁"),me.success("Category created")}catch(_e){me.error(_e.message||"Failed to create category")}},ue=async()=>{try{await re.mutateAsync(),me.success("Default categories created")}catch{me.error("Failed to create defaults")}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(fs,{open:n,onOpenChange:a,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add Brokerage Content"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Content Type"}),e.jsxs(Ks,{value:b,onValueChange:_,children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:zFe.map(_e=>e.jsx(Mt,{value:_e.value,children:_e.label},_e.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(pe=zFe.find(_e=>_e.value===b))==null?void 0:pe.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Category"}),e.jsxs(Ks,{value:Y,onValueChange:Q,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select category (optional)"})}),e.jsx(Ws,{children:s.map(_e=>e.jsxs(Mt,{value:_e.id,children:[_e.icon," ",_e.name]},_e.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Title *"}),e.jsx(ze,{value:j,onChange:_e=>w(_e.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{value:N,onChange:_e=>S(_e.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(b)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:b==="video"?"Video URL":b==="graphic"?"Canva / Image URL":b==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(ze,{value:M,onChange:_e=>{const $e=_e.target.value;if(L($e),b==="video"&&!q){const Ae=m1s($e);Ae&&U(Ae)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(b)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:b==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"file",accept:b==="pdf"?".pdf,.doc,.docx":"image/*",onChange:_e=>ce(_e,"file"),disabled:f}),f&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]}),I&&e.jsx("p",{className:"text-xs text-green-600",children:"✓ File uploaded"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Thumbnail Image (optional)"}),e.jsx(ze,{type:"file",accept:"image/*",onChange:_e=>ce(_e,"thumbnail"),disabled:f}),q&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:q,className:"w-full h-full object-cover",alt:"thumb"}),e.jsx("button",{onClick:()=>U(""),className:"absolute top-0 right-0 bg-background/80 rounded-bl p-0.5",children:e.jsx(Rr,{className:"h-3 w-3"})})]})]}),b==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Event Date & Time"}),e.jsx(ze,{type:"datetime-local",value:B,onChange:_e=>V(_e.target.value)})]}),e.jsxs(K,{onClick:ge,disabled:ee.isPending||!j.trim(),className:"w-full",children:[ee.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx(Xo,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Manage Categories"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[s.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No categories yet"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ue,disabled:re.isPending,children:[re.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(_e=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[_e.icon," ",_e.name]}),!_e.is_default&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ie.mutateAsync(_e.id),me.success("Category deleted")},children:e.jsx(Rr,{className:"h-4 w-4"})})]},_e.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(ze,{value:u,onChange:_e=>p(_e.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(ze,{value:i,onChange:_e=>c(_e.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:_e=>_e.key==="Enter"&&ye()}),e.jsx(K,{size:"sm",onClick:ye,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function f1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Ds(),[n,a]=k.useState(!0),[o,l]=k.useState(null),[i,c]=k.useState(""),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState("");k.useEffect(()=>{(async()=>{if(t)try{const{data:L}=await H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(L!=null&&L.brokerage_id)){a(!1);return}l(L.brokerage_id);const{data:I}=await H.from("brokerages").select("name").eq("id",L.brokerage_id).maybeSingle();if(I&&c(I.name),s)p(!0);else if(r){const{data:O}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",L.brokerage_id).maybeSingle();p(!!O)}}catch(L){console.error("Error fetching brokerage info:",L)}finally{a(!1)}})()},[t,s,r]);const{data:j=[]}=gLt(o),{data:w=[],isLoading:N}=yLt(o,f),S=k.useMemo(()=>{if(!b.trim())return w;const M=b.toLowerCase();return w.filter(L=>{var I;return L.title.toLowerCase().includes(M)||((I=L.description)==null?void 0:I.toLowerCase().includes(M))||L.content_type.toLowerCase().includes(M)})},[w,b]);return n?e.jsx(Ms,{title:"Brokerage Content",description:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):o?e.jsx(Ms,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(p1s,{brokerageId:o,categories:j}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search content...",value:b,onChange:M=>_(M.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{variant:f===null?"default":"outline",size:"sm",onClick:()=>g(null),children:"All"}),j.map(M=>e.jsxs(K,{variant:f===M.id?"default":"outline",size:"sm",onClick:()=>g(M.id),children:[e.jsx("span",{className:"mr-1",children:M.icon}),M.name]},M.id))]})]}),N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):S.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Om,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:b.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:b.trim()?"Try a different search term or category.":u?"Add your first piece of content above.":"Your brokerage hasn't added content yet."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:S.map(M=>e.jsx(h1s,{item:M,canManage:u},M.id))})]})}):e.jsx(Ms,{title:"Brokerage Content",description:"Content Hub",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ka,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You're not currently part of a brokerage team."})]})})}const BFe={video:{icon:nl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:Sn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:dl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:hn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:ic,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function x1s(t){try{const s=new URL(t),r=s.hostname.replace("www.","");if(s.pathname==="/playlist"){const n=s.searchParams.get("list");if(n)return`https://www.youtube.com/embed/videoseries?list=${n}`}if(r==="youtube.com"||r==="m.youtube.com"){const n=s.searchParams.get("v");if(n){const a=s.searchParams.get("list");let o=`https://www.youtube.com/embed/${n}`;return a&&(o+=`?list=${a}`),o}}if(r==="youtu.be"){const n=s.pathname.slice(1);if(n){const a=s.searchParams.get("list");let o=`https://www.youtube.com/embed/${n}`;return a&&(o+=`?list=${a}`),o}}if(r==="youtube.com"&&s.pathname.startsWith("/embed/"))return t}catch{}return null}function g1s(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function y1s(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function v1s(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function b1s(){const{contentId:t}=yo(),{data:s,isLoading:r}=mt({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:p}=await H.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(p)throw p;return u},enabled:!!t});if(r)return e.jsx(Ms,{title:"Brokerage Content",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})});if(!s)return e.jsx(Ms,{title:"Brokerage Content",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ka,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Content not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This content may have been removed."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(Pi,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=BFe[s.content_type]||BFe.link,a=n.icon,o=s.url||s.file_url,l=o&&g1s(o)?x1s(o):null,i=o&&y1s(o)?v1s(o):null,c=l||i;return e.jsx(Ms,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Pi,{to:"/brokerage-content",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(st,{variant:"secondary",className:`text-xs px-2 py-0.5 ${n.color}`,children:[e.jsx(a,{className:"h-3 w-3 mr-1"}),n.label]}),s.category&&e.jsxs(st,{variant:"outline",className:"text-xs px-2 py-0.5",children:[s.category.icon," ",s.category.name]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["Added ",ms(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),c&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative w-full bg-black",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:c,className:"absolute top-0 left-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:s.title})})}),s.content_type==="graphic"&&s.file_url&&!c&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.file_url,alt:s.title,className:"w-full max-h-[600px] object-contain bg-muted"})}),!c&&s.content_type!=="graphic"&&s.thumbnail_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.thumbnail_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),s.description&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})})}),s.content_type==="event"&&s.event_date&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(hn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Event Date"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ms(new Date(s.event_date),"EEEE, MMMM d, yyyy · h:mm a")})]})]})}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.file_url&&e.jsx(K,{asChild:!0,size:"lg",children:e.jsxs("a",{href:s.file_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),s.content_type==="pdf"?"Download Document":"Download File"]})}),s.url&&e.jsx(K,{variant:s.file_url?"outline":"default",asChild:!0,size:"lg",children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),c?"Open on YouTube":s.content_type==="event"?"Join Event":s.content_type==="graphic"?"Open in Canva":"Open Link"]})})]})]})})}function _1s(){const t=fr(),[s,r]=k.useState(""),[n,a]=k.useState("grid"),{data:o,isLoading:l}=mt({queryKey:["newsletters"],queryFn:async()=>{const{data:M,error:L}=await H.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(L)throw L;return M}}),{data:i}=mt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:M}=await H.from("newsletter_likes").select("newsletter_id");return M||[]}}),{data:c}=mt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:M}=await H.from("newsletter_comments").select("newsletter_id");return M||[]}}),{data:u}=mt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[M,L,I,O]=await Promise.all([H.from("newsletter_canva_links").select("newsletter_id"),H.from("newsletter_pdfs").select("newsletter_id"),H.from("newsletter_videos").select("newsletter_id"),H.from("newsletter_drive_links").select("newsletter_id")]);return{canva:M.data||[],pdfs:L.data||[],videos:I.data||[],drives:O.data||[]}}}),p=M=>(i==null?void 0:i.filter(L=>L.newsletter_id===M).length)||0,f=M=>(c==null?void 0:c.filter(L=>L.newsletter_id===M).length)||0,g=M=>{var L;return((L=u==null?void 0:u.canva)==null?void 0:L.filter(I=>I.newsletter_id===M).length)||0},b=M=>{var L;return((L=u==null?void 0:u.pdfs)==null?void 0:L.filter(I=>I.newsletter_id===M).length)||0},_=M=>{var L;return((L=u==null?void 0:u.videos)==null?void 0:L.filter(I=>I.newsletter_id===M).length)||0},j=M=>{var L;return((L=u==null?void 0:u.drives)==null?void 0:L.filter(I=>I.newsletter_id===M).length)||0},w=M=>g(M)+b(M)+_(M)+j(M),N=o==null?void 0:o.filter(M=>{var L;return M.title.toLowerCase().includes(s.toLowerCase())||((L=M.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase()))}),S=M=>{t(`/newsletters/${M}`)};return e.jsx(Ms,{title:"Newsletter Content",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Newsletter Content"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Monthly newsletter templates and resources"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search newsletters...",value:s,onChange:M=>r(M.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Mh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(N==null?void 0:N.length)||0," item",(N==null?void 0:N.length)!==1?"s":""," found"]}),l&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((M,L)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-0",children:[e.jsx(ys,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-full"})]})]})},L))}),!l&&(N==null?void 0:N.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Sn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No newsletters match your search":"No newsletters available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&N&&N.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-3",children:N.map(M=>{const L=w(M.id),I=g(M.id),O=b(M.id),q=_(M.id);return n==="grid"?e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(M.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:M.preview_image_url?e.jsx("img",{src:M.preview_image_url,alt:M.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(Sn,{className:"h-16 w-16"})})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:M.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(M.publish_date),"MMM d, yyyy")]})]}),M.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:M.description.replace(/<[^>]*>/g,"")}),L>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[I>0&&e.jsxs(st,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(ic,{className:"h-3 w-3"})," ",I," Template",I>1?"s":""]}),O>0&&e.jsxs(st,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(yi,{className:"h-3 w-3"})," ",O," PDF",O>1?"s":""]}),q>0&&e.jsxs(st,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(nl,{className:"h-3 w-3"})," ",q," Video",q>1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground pt-1 border-t border-border/50",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3"})," ",p(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]},M.id):e.jsx(Ee,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(M.id),children:e.jsxs("div",{className:"flex flex-row",children:[e.jsx("div",{className:"relative overflow-hidden bg-muted w-40 sm:w-48 shrink-0",children:M.preview_image_url?e.jsx("img",{src:M.preview_image_url,alt:M.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground min-h-[100px]",children:e.jsx(Sn,{className:"h-10 w-10"})})}),e.jsxs(Oe,{className:"p-4 flex-1 flex flex-col justify-center gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:M.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(M.publish_date),"MMM d, yyyy")]})]}),M.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:M.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[L>0&&e.jsxs("span",{children:[L," resource",L>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3"})," ",p(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]})},M.id)})})]})})}function w1s({rows:t}){if(!t||t.length===0)return null;const s=t.filter(r=>r.columns.some(n=>n.title||n.description||n.image_url));return s.length===0?null:e.jsx("div",{className:"space-y-6",children:s.map((r,n)=>{const a=r.columns.filter(o=>o.title||o.description||o.image_url);return a.length===0?null:e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},children:a.map((o,l)=>e.jsxs(Ee,{className:"overflow-hidden border-border/50",children:[o.image_url&&e.jsx("img",{src:o.image_url,alt:o.title||"",className:"w-full h-40 object-cover"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[o.title&&e.jsx("h4",{className:"font-semibold text-foreground",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})]},l))},n)})})}function j1s(){const{id:t}=yo(),s=fr(),{user:r}=Ds(),{toast:n}=Ua(),a=Qt(),{trackEngagement:o}=GO(),[l,i]=k.useState(""),{data:c,isLoading:u}=mt({queryKey:["newsletter",t],queryFn:async()=>{const{data:I,error:O}=await H.from("newsletter_content").select("*").eq("id",t).single();if(O)throw O;return I},enabled:!!t});k.useEffect(()=>{c&&o("newsletter",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:p}=mt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:f}=mt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:g}=mt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:b}=mt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:_}=mt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_likes").select("*").eq("newsletter_id",t);return I||[]},enabled:!!t}),{data:j}=mt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:I}=await H.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return I||[]},enabled:!!t}),w=_==null?void 0:_.some(I=>I.user_id===(r==null?void 0:r.id)),N=Lt({mutationFn:async()=>{w?await H.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await H.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),S=Lt({mutationFn:async I=>{const{error:O}=await H.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:I});if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),M=Lt({mutationFn:async I=>{const{error:O}=await H.from("newsletter_comments").delete().eq("id",I);if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),L=I=>{if(I.includes("player.mediadelivery.net")||I.includes("iframe.mediadelivery.net")){const O=I.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${O[1]}/${O[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(I.includes("youtube.com")||I.includes("youtu.be")){const O=I.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${O[1]}`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}return e.jsxs("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(nl,{className:"h-4 w-4"})," Watch Video"]})};return u?e.jsx(Ms,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-32"}),e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-32 w-full"})]})}):c?e.jsx(Ms,{title:"",description:"",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(Ja,{className:"mr-2 h-4 w-4"})," Back to Newsletters"]}),c.preview_image_url&&e.jsx("img",{src:c.preview_image_url,alt:c.title,className:"w-full h-64 md:h-80 object-cover rounded-lg"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:c.title}),e.jsx("p",{className:"text-muted-foreground mt-1",children:ms(new Date(c.publish_date),"MMMM d, yyyy")})]}),c.description&&e.jsx("div",{className:"text-lg text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&_p]:mb-4 [&_p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:c.description}}),e.jsx(w1s,{rows:c.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(lE,{resourceType:"newsletter",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:w?"default":"outline",size:"sm",onClick:()=>N.mutate(),children:[e.jsx(ni,{className:`h-4 w-4 mr-1 ${w?"fill-current":""}`}),(_==null?void 0:_.length)||0," ",(_==null?void 0:_.length)===1?"Like":"Likes"]})]}),b&&b.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Oe,{className:"space-y-2",children:b.map(I=>e.jsxs("a",{href:I.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_canva"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(ic,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:I.title}),e.jsx(tn,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},I.id))})]}),p&&p.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Oe,{className:"space-y-2",children:p.map(I=>e.jsxs("a",{href:I.drive_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_link"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(tn,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:I.title})]},I.id))})]}),f&&f.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Oe,{className:"space-y-2",children:f.map(I=>e.jsxs("a",{href:I.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_pdf"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(Sn,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:I.name}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]}),g&&g.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Videos"})}),e.jsx(Oe,{className:"space-y-6",children:g.map(I=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:I.title}),L(I.video_url)]},I.id))})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg",children:["Comments (",(j==null?void 0:j.length)||0,")"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Er,{placeholder:"Write a comment...",value:l,onChange:I=>i(I.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&S.mutate(l),disabled:!l.trim()||S.isPending,children:e.jsx(Bn,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:j==null?void 0:j.map(I=>{var O,q,U;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{children:((q=(O=I.profiles)==null?void 0:O.name)==null?void 0:q[0])||"U"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-sm",children:((U=I.profiles)==null?void 0:U.name)||"User"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(I.created_at),"MMM d, yyyy")}),I.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>M.mutate(I.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:I.content})]})]},I.id)})})]})]})]})}):e.jsx(Ms,{title:"Not Found",description:"",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Newsletter not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function N1s({rows:t,onChange:s}){const[r,n]=k.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((p,f)=>f!==u))},l=(u,p,f,g)=>{const b=[...t];b[u]={...b[u],columns:b[u].columns.map((_,j)=>j===p?{..._,[f]:g}:_)},s(b)},i=async(u,p,f)=>{var _;const g=(_=f.target.files)==null?void 0:_[0];if(!g)return;const b=`${u}-${p}`;n(b);try{const j=`content-blocks/${Date.now()}-${g.name}`,{error:w}=await H.storage.from("newsletter-content").upload(j,g);if(!w){const{data:N}=H.storage.from("newsletter-content").getPublicUrl(j);l(u,p,"image_url",N.publicUrl)}}finally{n(null)}},c=(u,p)=>{l(u,p,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:a,children:[e.jsx($s,{className:"mr-1 h-3 w-3"})," Add Row"]})]}),t.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No content block rows yet. Add a row to create a 3-column layout."}),t.map((u,p)=>e.jsxs(Ee,{className:"relative",children:[e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(p),children:e.jsx(Rr,{className:"h-4 w-4"})}),e.jsxs(Oe,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",p+1]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:u.columns.map((f,g)=>{const b=`${p}-${g}`;return e.jsxs("div",{className:"space-y-2 border border-border/50 rounded-md p-3 bg-muted/20",children:[e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:["Column ",g+1]}),f.image_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:f.image_url,alt:"",className:"w-full h-20 object-cover rounded"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(p,g),children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${b}`,onChange:_=>i(p,g,_)}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:r===b,asChild:!0,children:e.jsx("label",{htmlFor:`block-img-${b}`,className:"cursor-pointer",children:r===b?"Uploading...":e.jsxs(e.Fragment,{children:[e.jsx(gl,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(ze,{placeholder:"Title",value:f.title,onChange:_=>l(p,g,"title",_.target.value),className:"h-8 text-sm"}),e.jsx(Er,{placeholder:"Description",value:f.description,onChange:_=>l(p,g,"description",_.target.value),className:"text-sm min-h-[60px] resize-none"})]},g)})})]})]},p))]})}function k1s(){const{toast:t}=Ua(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState({title:"",description:"",publish_date:ms(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[c,u]=k.useState(null),[p,f]=k.useState(null),[g,b]=k.useState([]),[_,j]=k.useState([]),[w,N]=k.useState([]),[S,M]=k.useState([]),[L,I]=k.useState([]),[O,q]=k.useState([]),[U,B]=k.useState(!1),{data:V,isLoading:Y}=mt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Ae,error:Ie}=await H.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Ie)throw Ie;return Ae}}),Q=Lt({mutationFn:async Ae=>{const{data:Ie,error:Ce}=await H.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(Ce)throw Ce;return Ie},onSuccess:async Ae=>{await ie(Ae.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Ae.is_published&&cVt(Ae.title,Ae.id),ce()},onError:Ae=>{t({title:"Error creating newsletter",description:Ae.message,variant:"destructive"})}}),ee=Lt({mutationFn:async Ae=>{const{error:Ie}=await H.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(Ie)throw Ie;return Ae.id},onSuccess:async Ae=>{await ie(Ae),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),ce()},onError:Ae=>{t({title:"Error updating newsletter",description:Ae.message,variant:"destructive"})}}),X=Lt({mutationFn:async Ae=>{const{error:Ie}=await H.from("newsletter_content").delete().eq("id",Ae);if(Ie)throw Ie},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:Ae=>{t({title:"Error deleting newsletter",description:Ae.message,variant:"destructive"})}}),ie=async Ae=>{await H.from("newsletter_drive_links").delete().eq("newsletter_id",Ae),await H.from("newsletter_pdfs").delete().eq("newsletter_id",Ae),await H.from("newsletter_videos").delete().eq("newsletter_id",Ae),await H.from("newsletter_canva_links").delete().eq("newsletter_id",Ae);for(const Ie of O){const Ce=`${Ae}/${Date.now()}-${Ie.file.name}`,{error:xe}=await H.storage.from("newsletter-content").upload(Ce,Ie.file);if(!xe){const{data:we}=H.storage.from("newsletter-content").getPublicUrl(Ce);_.push({name:Ie.name,file_url:we.publicUrl,file_size:Ie.file.size,sort_order:_.length})}}g.length>0&&await H.from("newsletter_drive_links").insert(g.map((Ie,Ce)=>({newsletter_id:Ae,title:Ie.title,drive_url:Ie.drive_url,sort_order:Ce}))),_.length>0&&await H.from("newsletter_pdfs").insert(_.map((Ie,Ce)=>({newsletter_id:Ae,name:Ie.name,file_url:Ie.file_url,file_size:Ie.file_size||null,sort_order:Ce}))),w.length>0&&await H.from("newsletter_videos").insert(w.map((Ie,Ce)=>({newsletter_id:Ae,title:Ie.title,video_url:Ie.video_url,sort_order:Ce}))),S.length>0&&await H.from("newsletter_canva_links").insert(S.map((Ie,Ce)=>({newsletter_id:Ae,title:Ie.title,canva_share_link:Ie.canva_share_link,sort_order:Ce})))},re=async Ae=>{o(Ae),i({title:Ae.title,description:Ae.description||"",publish_date:ms(new Date(Ae.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Ae.is_published}),f(Ae.preview_image_url),I(Ae.content_blocks||[]);const[Ie,Ce,xe,we]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Ae.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Ae.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Ae.id).order("sort_order"),H.from("newsletter_canva_links").select("*").eq("newsletter_id",Ae.id).order("sort_order")]);b(Ie.data||[]),j(Ce.data||[]),N(xe.data||[]),M(we.data||[]),q([]),n(!0)},oe=async Ae=>{const[Ie,Ce,xe,we]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Ae.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Ae.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Ae.id).order("sort_order"),H.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:ms(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(Ae.preview_image_url),I(Ae.content_blocks||[]),b((Ie.data||[]).map(({id:Le,...tt})=>tt)),j((Ce.data||[]).map(({id:Le,...tt})=>tt)),N((xe.data||[]).map(({id:Le,...tt})=>tt)),M((we.data||[]).map(({id:Le,...tt})=>tt)),q([]),n(!0)},ce=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ms(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),b([]),j([]),N([]),M([]),I([]),q([])},ge=async Ae=>{var Ce;const Ie=(Ce=Ae.target.files)==null?void 0:Ce[0];Ie&&(u(Ie),f(URL.createObjectURL(Ie)))},ye=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}B(!0);let Ae=p;if(c){const Ie=`previews/${Date.now()}-${c.name}`,{error:Ce}=await H.storage.from("newsletter-content").upload(Ie,c);if(!Ce){const{data:xe}=H.storage.from("newsletter-content").getPublicUrl(Ie);Ae=xe.publicUrl}}a?ee.mutate({id:a.id,...l,preview_image_url:Ae,content_blocks:L}):Q.mutate({...l,preview_image_url:Ae,content_blocks:L}),B(!1)},ue=()=>b([...g,{title:"",drive_url:"",sort_order:g.length}]),pe=()=>N([...w,{title:"",video_url:"",sort_order:w.length}]),_e=()=>M([...S,{title:"",canva_share_link:"",sort_order:S.length}]),$e=Ae=>{const Ie=Ae.target.files;if(!Ie)return;const Ce=Array.from(Ie).map(xe=>({file:xe,name:xe.name.replace(/\.[^/.]+$/,"")}));q([...O,...Ce])};return e.jsx(Ms,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources"}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(Ae=>Ae.is_published).length)||0})})]})]}),e.jsxs(fs,{open:r,onOpenChange:Ae=>!Ae&&ce(),children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx($s,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:a?"Edit Newsletter":"Add Newsletter"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Title *"}),e.jsx(ze,{value:l.title,onChange:Ae=>i({...l,title:Ae.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Publish Date"}),e.jsx(ze,{type:"datetime-local",value:l.publish_date,onChange:Ae=>i({...l,publish_date:Ae.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(py,{content:l.description,onChange:Ae=>i({...l,description:Ae}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[p&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:p,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute -top-2 -right-2 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{u(null),f(null)},children:e.jsx(Rr,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:ge,className:"hidden",id:"preview-upload"}),e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx(li,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:l.is_published,onCheckedChange:Ae=>i({...l,is_published:Ae})}),e.jsx(be,{children:"Published"})]}),e.jsx(N1s,{rows:L,onChange:I}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[e.jsx($s,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),S.map((Ae,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Link title",value:Ae.title,onChange:Ce=>{const xe=[...S];xe[Ie].title=Ce.target.value,M(xe)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Canva share link",value:Ae.canva_share_link,onChange:Ce=>{const xe=[...S];xe[Ie].canva_share_link=Ce.target.value,M(xe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>M(S.filter((Ce,xe)=>xe!==Ie)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},Ie))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ue,children:[e.jsx($s,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),g.map((Ae,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Link title",value:Ae.title,onChange:Ce=>{const xe=[...g];xe[Ie].title=Ce.target.value,b(xe)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Google Drive URL",value:Ae.drive_url,onChange:Ce=>{const xe=[...g];xe[Ie].drive_url=Ce.target.value,b(xe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>b(g.filter((Ce,xe)=>xe!==Ie)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},Ie))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:".pdf",multiple:!0,onChange:$e,className:"hidden",id:"pdf-upload"}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[e.jsx(li,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),_.map((Ae,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Ae.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>j(_.filter((Ce,xe)=>xe!==Ie)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},`existing-${Ie}`)),O.map((Ae,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:Ae.name,onChange:Ce=>{const xe=[...O];xe[Ie].name=Ce.target.value,q(xe)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>q(O.filter((Ce,xe)=>xe!==Ie)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},`pending-${Ie}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:pe,children:[e.jsx($s,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),w.map((Ae,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Video title",value:Ae.title,onChange:Ce=>{const xe=[...w];xe[Ie].title=Ce.target.value,N(xe)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Video URL",value:Ae.video_url,onChange:Ce=>{const xe=[...w];xe[Ie].video_url=Ce.target.value,N(xe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(w.filter((Ce,xe)=>xe!==Ie)),children:e.jsx(Rr,{className:"h-4 w-4"})})]},Ie))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:ce,children:"Cancel"}),e.jsx(K,{onClick:ye,disabled:U||Q.isPending||ee.isPending,children:U?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:Y?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):V==null?void 0:V.map(Ae=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ae.preview_image_url?e.jsx("img",{src:Ae.preview_image_url,alt:Ae.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(Sn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ae.title}),Ae.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ae.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(dt,{children:ms(new Date(Ae.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ae.is_published?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"}`,children:Ae.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>re(Ae),title:"Edit",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>oe(Ae),title:"Duplicate",children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&X.mutate(Ae.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Ae.id))})]})})})]})})}const $Fe={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 S1s(){const{user:t}=Ds(),{toast:s}=Ua(),r=fr(),n=Qt(),[a,o]=k.useState(""),[l,i]=k.useState("popular"),[c,u]=k.useState(!1),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(!1),{data:w=[],isLoading:N}=mt({queryKey:["wishlist-items",l,_],queryFn:async()=>{let O=H.from("wishlist_items").select("*");_&&t&&(O=O.eq("user_id",t.id)),l==="latest"?O=O.order("created_at",{ascending:!1}):l==="popular"?O=O.order("vote_count",{ascending:!1}):l==="trending"&&(O=O.order("vote_count",{ascending:!1}));const{data:q,error:U}=await O;if(U)throw U;const B=[...new Set((q==null?void 0:q.map(re=>re.user_id))||[])],{data:V}=await H.from("profiles").select("id, name").in("id",B),Y=new Map((V==null?void 0:V.map(re=>[re.id,re]))||[]);let Q=[];if(t){const{data:re}=await H.from("wishlist_votes").select("item_id").eq("user_id",t.id);Q=(re==null?void 0:re.map(oe=>oe.item_id))||[]}const ee=(q==null?void 0:q.map(re=>re.id))||[],{data:X}=await H.from("wishlist_comments").select("item_id").in("item_id",ee),ie=new Map;return X==null||X.forEach(re=>{ie.set(re.item_id,(ie.get(re.item_id)||0)+1)}),q==null?void 0:q.map(re=>{const oe=Y.get(re.user_id),ce=(oe==null?void 0:oe.name)||"Unknown";return{...re,user_name:ce,user_initials:ce.split(" ").map(ge=>ge[0]).join("").toUpperCase().slice(0,2),has_voted:Q.includes(re.id),comment_count:ie.get(re.id)||0}})}}),S=Lt({mutationFn:async({title:O,description:q})=>{const{error:U}=await H.from("wishlist_items").insert({user_id:t.id,title:O,description:q});if(U)throw U},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),f(""),b(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),M=Lt({mutationFn:async({itemId:O,hasVoted:q})=>{if(q){const{error:U}=await H.from("wishlist_votes").delete().eq("item_id",O).eq("user_id",t.id);if(U)throw U;return{itemId:O,wasAdded:!1}}else{const{error:U}=await H.from("wishlist_votes").insert({item_id:O,user_id:t.id});if(U)throw U;return{itemId:O,wasAdded:!0}}},onSuccess:async O=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),O!=null&&O.wasAdded){const q=w.find(B=>B.id===O.itemId),U=((q==null?void 0:q.vote_count)||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:O.itemId,voteCount:U}}).catch(console.error)}},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),L=w.filter(O=>O.title.toLowerCase().includes(a.toLowerCase())||O.description.toLowerCase().includes(a.toLowerCase())),I=()=>{if(!p.trim()||!g.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}S.mutate({title:p.trim(),description:g.trim()})};return e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(q_,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold",children:"Wishlist"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Share ideas and vote on what we build next"})]})]}),e.jsxs(fs,{open:c,onOpenChange:u,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Submit a New Idea"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:g,onChange:O=>b(O.target.value),rows:4})]}),e.jsx(K,{onClick:I,className:"w-full",disabled:S.isPending,children:S.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Idea"})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search ideas...",value:a,onChange:O=>o(O.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ba,{value:l,onValueChange:O=>i(O),children:e.jsxs(pa,{children:[e.jsx(ns,{value:"popular",children:"Most Popular"}),e.jsx(ns,{value:"latest",children:"Latest"}),e.jsx(ns,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(K,{variant:_?"default":"outline",size:"sm",onClick:()=>j(!_),children:_?"Show All Ideas":"My Ideas"})}),N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):L.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx(q_,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No ideas yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to submit an idea!"}),e.jsxs(K,{onClick:()=>u(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:L.map(O=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${O.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:q=>{q.stopPropagation(),M.mutate({itemId:O.id,hasVoted:O.has_voted||!1})},className:It("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",O.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(ku,{className:It("h-4 w-4",O.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:O.vote_count})]}),e.jsx(Nn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(kn,{className:"bg-primary/20 text-primary text-sm font-medium",children:O.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:O.title}),e.jsx(st,{className:It("text-xs",$Fe[O.status].color),children:$Fe[O.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:O.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:O.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(O.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(so,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:O.comment_count})]})]})},O.id))})]})})}const qFe={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 C1s(){const{itemId:t}=yo(),s=fr(),{user:r}=Ds(),{toast:n}=Ua(),a=Qt(),[o,l]=k.useState(""),{data:i=!1}=mt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:w,error:N}=await H.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!N&&!!w},enabled:!!r}),{data:c,isLoading:u}=mt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:w,error:N}=await H.from("wishlist_items").select("*").eq("id",t).single();if(N)throw N;const{data:S}=await H.from("profiles").select("name").eq("id",w.user_id).single();let M=!1;if(r){const{data:L}=await H.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();M=!!L}return{...w,user_name:(S==null?void 0:S.name)||"Unknown",user_initials:((S==null?void 0:S.name)||"U").split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),has_voted:M}}}),{data:p=[],isLoading:f}=mt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:w,error:N}=await H.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(N)throw N;const S=[...new Set((w==null?void 0:w.map(I=>I.user_id))||[])],{data:M}=await H.from("profiles").select("id, name").in("id",S),L=new Map((M==null?void 0:M.map(I=>[I.id,I]))||[]);return w==null?void 0:w.map(I=>{const O=L.get(I.user_id),q=(O==null?void 0:O.name)||"Unknown";return{...I,user_name:q,user_initials:q.split(" ").map(U=>U[0]).join("").toUpperCase().slice(0,2)}})}}),g=Lt({mutationFn:async w=>{if(w){const{error:N}=await H.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(N)throw N;return{wasAdded:!1}}else{const{error:N}=await H.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(N)throw N;return{wasAdded:!0}}},onSuccess:async w=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),w!=null&&w.wasAdded&&c){const N=(c.vote_count||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:N}}).catch(console.error)}},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),b=Lt({mutationFn:async w=>{const{error:N}=await H.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:w});if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),_=Lt({mutationFn:async w=>{const{error:N}=await H.from("wishlist_comments").delete().eq("id",w);if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),j=()=>{o.trim()&&b.mutate(o.trim())};return u?e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(ys,{className:"h-8 w-32 mb-6"}),e.jsx(ys,{className:"h-48 w-full mb-6"}),e.jsx(ys,{className:"h-32 w-full"})]})}):c?e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Back to Wishlist"]}),e.jsx("div",{className:"bg-card border rounded-lg p-6 mb-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:()=>g.mutate(c.has_voted),className:It("flex flex-col items-center justify-center min-w-[60px] py-3 px-4 rounded-lg border transition-colors",c.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(ku,{className:It("h-5 w-5",c.has_voted&&"fill-current")}),e.jsx("span",{className:"text-lg font-bold",children:c.vote_count}),e.jsx("span",{className:"text-xs",children:"votes"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:c.title}),e.jsx(st,{className:It("text-xs",qFe[c.status].color),children:qFe[c.status].label})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap mb-4",children:c.description}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Nn,{className:"h-6 w-6",children:e.jsx(kn,{className:"bg-primary/20 text-primary text-xs",children:c.user_initials})}),e.jsx("span",{children:c.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(c.created_at).toLocaleDateString()})]})]})]})}),e.jsxs("div",{className:"bg-card border rounded-lg p-6",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Comments (",p.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(Ble,{placeholder:i?"Share your thoughts... Use # to link templates":"Share your thoughts on this idea...",value:o,onChange:l,minHeight:"60px",mentionFormat:"encoded",enableTemplateMentions:i}),e.jsx(K,{onClick:j,disabled:!o.trim()||b.isPending,size:"icon",className:"h-auto",children:b.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(w=>e.jsx(ys,{className:"h-20 w-full"},w))}):p.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No comments yet. Be the first to share your thoughts!"}):e.jsx("div",{className:"space-y-4",children:p.map(w=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"bg-primary/20 text-primary text-xs",children:w.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:w.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(w.created_at).toLocaleDateString()})]}),e.jsx(Dke,{content:w.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===w.user_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>_.mutate(w.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]},w.id))})]})]})}):e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Item not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const UFe={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"}},VFe=["open","under_review","planned","in_progress","launched","declined"];function M1s(){const{toast:t}=Ua(),s=fr(),r=Qt(),[n,a]=k.useState(""),[o,l]=k.useState("all"),[i,c]=k.useState(!1),[u,p]=k.useState(null),{data:f=[],isLoading:g}=mt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:N,error:S}=await H.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(S)throw S;const M=[...new Set((N==null?void 0:N.map(B=>B.user_id))||[])],{data:L}=await H.from("profiles").select("id, name, email").in("id",M),I=new Map((L==null?void 0:L.map(B=>[B.id,B]))||[]),O=(N==null?void 0:N.map(B=>B.id))||[],{data:q}=await H.from("wishlist_comments").select("item_id").in("item_id",O),U=new Map;return q==null||q.forEach(B=>{U.set(B.item_id,(U.get(B.item_id)||0)+1)}),N==null?void 0:N.map(B=>{const V=I.get(B.user_id);return{...B,user_name:(V==null?void 0:V.name)||"Unknown",user_email:(V==null?void 0:V.email)||"",comment_count:U.get(B.id)||0}})}}),b=Lt({mutationFn:async({itemId:N,status:S})=>{const{error:M}=await H.from("wishlist_items").update({status:S}).eq("id",N);if(M)throw M},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),_=Lt({mutationFn:async N=>{const{error:S}=await H.from("wishlist_items").delete().eq("id",N);if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),c(!1),p(null),t({title:"Item deleted!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),j=f.filter(N=>{const S=N.title.toLowerCase().includes(n.toLowerCase())||N.description.toLowerCase().includes(n.toLowerCase())||N.user_name.toLowerCase().includes(n.toLowerCase()),M=o==="all"||N.status===o;return S&&M}),w={total:f.length,open:f.filter(N=>N.status==="open").length,inProgress:f.filter(N=>N.status==="in_progress").length,launched:f.filter(N=>N.status==="launched").length,highVotes:f.filter(N=>N.vote_count>=10).length};return e.jsx(Ms,{title:"Admin - Wishlist",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),e.jsx("p",{className:"text-2xl font-bold",children:w.total})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:w.open})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:w.inProgress})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:w.launched})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:w.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search ideas, users...",value:n,onChange:N=>a(N.target.value),className:"pl-10"})]}),e.jsxs(Ks,{value:o,onValueChange:N=>l(N),children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),VFe.map(N=>e.jsx(Mt,{value:N,children:UFe[N].label},N))]})]})]}),g?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(N=>e.jsx(ys,{className:"h-16 w-full"},N))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[60px]",children:"Votes"}),e.jsx(St,{children:"Title"}),e.jsx(St,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(St,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(zn,{children:j.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):j.map(N=>e.jsxs(Ss,{className:It(N.vote_count>=10&&"bg-primary/5"),children:[e.jsx(dt,{children:e.jsx(st,{variant:N.vote_count>=10?"default":"secondary",children:N.vote_count})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:N.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:N.description})]})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:N.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N.user_email})]})}),e.jsx(dt,{className:"hidden sm:table-cell",children:N.comment_count}),e.jsx(dt,{children:e.jsxs(Ks,{value:N.status,onValueChange:S=>b.mutate({itemId:N.id,status:S}),children:[e.jsx(Hs,{className:"w-[140px] h-8",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:VFe.map(S=>e.jsx(Mt,{value:S,children:UFe[S].label},S))})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${N.id}`,"_blank"),children:e.jsx(tn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(N.id),c(!0)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},N.id))})]})}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Delete Wishlist Item"})}),e.jsx("p",{className:"text-muted-foreground",children:"Are you sure you want to delete this idea? This will also delete all votes and comments."}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:()=>u&&_.mutate(u),disabled:_.isPending,children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function T1s(){const{user:t}=Ds(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState(""),[j,w]=k.useState(""),[N,S]=k.useState(""),[M,L]=k.useState(""),[I,O]=k.useState(""),[q,U]=k.useState(!1),[B,V]=k.useState(""),[Y,Q]=k.useState("once"),[ee,X]=k.useState([]),[ie,re]=k.useState([]),[oe,ce]=k.useState(!1),[ge,ye]=k.useState(!1),[ue,pe]=k.useState([]),[_e,$e]=k.useState({total:0,dismissed:0});k.useEffect(()=>{Ae()},[]);const Ae=async()=>{const{data:Ze,error:Qe}=await H.from("levelup_briefs").select("*").order("created_at",{ascending:!1});Qe?(me.error("Failed to fetch briefs"),console.error(Qe)):r(Ze||[]),a(!1)},Ie=()=>{_(""),w(""),S(""),L(""),O(""),U(!1),V(new Date().toISOString().slice(0,16)),Q("once"),X([]),re([]),c(null)},Ce=()=>{Ie(),l(!0)},xe=async Ze=>{c(Ze),_(Ze.title),w(Ze.description||""),S(Ze.video_url||""),L(Ze.graphic_url||""),O(Ze.graphic_link_url||""),U(Ze.is_published),V(Ze.publish_date.slice(0,16)),Q(Ze.show_frequency);const{data:Qe}=await H.from("levelup_brief_links").select("*").eq("brief_id",Ze.id).order("sort_order");X((Qe==null?void 0:Qe.map(Je=>({title:Je.title,url:Je.url})))||[]);const{data:We}=await H.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(We){const Je=[];for(const it of We){const{data:Dt}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",it.id).order("sort_order");Je.push({question:it.question,poll_type:it.poll_type,options:(Dt==null?void 0:Dt.map(Vt=>Vt.option_text))||[]})}re(Je)}l(!0)},we=async Ze=>{var We;const Qe=(We=Ze.target.files)==null?void 0:We[0];if(Qe){ce(!0);try{const Je=await H.functions.invoke("bunny-upload",{body:{action:"create",title:Qe.name.replace(/\.[^/.]+$/,"")}});if(Je.error)throw Je.error;const{videoId:it,libraryId:Dt}=Je.data,Vt=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:it}});if(Vt.error)throw Vt.error;const{uploadUrl:hs,apiKey:Ts}=Vt.data,Cs=new XMLHttpRequest;await new Promise((er,xt)=>{Cs.upload.addEventListener("progress",Es=>{if(Es.lengthComputable){const ur=Math.round(Es.loaded/Es.total*100);console.log("Upload progress:",ur)}}),Cs.addEventListener("load",()=>{Cs.status>=200&&Cs.status<300?er():xt(new Error(`Upload failed with status ${Cs.status}`))}),Cs.addEventListener("error",()=>xt(new Error("Upload failed"))),Cs.open("PUT",hs),Cs.setRequestHeader("AccessKey",Ts),Cs.send(Qe)});const cs=`https://player.mediadelivery.net/embed/${Dt}/${it}`;S(cs),me.success("Video uploaded successfully! It may take a few minutes to process.")}catch(Je){console.error("Upload error:",Je),me.error("Failed to upload video")}finally{ce(!1)}}},Le=async()=>{if(!b.trim()){me.error("Title is required");return}try{let Ze;if(i){const{error:Qe}=await H.from("levelup_briefs").update({title:b,description:j||null,video_url:N||null,graphic_url:M||null,graphic_link_url:I||null,is_published:q,publish_date:B,show_frequency:Y}).eq("id",i.id);if(Qe)throw Qe;Ze=i.id,await H.from("levelup_brief_links").delete().eq("brief_id",Ze);const{data:We}=await H.from("levelup_brief_polls").select("id").eq("brief_id",Ze);if(We)for(const Je of We)await H.from("levelup_brief_poll_options").delete().eq("poll_id",Je.id);await H.from("levelup_brief_polls").delete().eq("brief_id",Ze)}else{const{data:Qe,error:We}=await H.from("levelup_briefs").insert({title:b,description:j||null,video_url:N||null,graphic_url:M||null,graphic_link_url:I||null,is_published:q,publish_date:B,show_frequency:Y,created_by:t==null?void 0:t.id}).select().single();if(We)throw We;Ze=Qe.id}if(ee.length>0){const Qe=ee.map((We,Je)=>({brief_id:Ze,title:We.title,url:We.url,sort_order:Je}));await H.from("levelup_brief_links").insert(Qe)}for(let Qe=0;Qe0){const Dt=We.options.map((Vt,hs)=>({poll_id:Je.id,option_text:Vt,sort_order:hs}));await H.from("levelup_brief_poll_options").insert(Dt)}}me.success(i?"Brief updated":"Brief created"),l(!1),Ie(),Ae()}catch(Ze){console.error("Error saving brief:",Ze),me.error("Failed to save brief")}},tt=async Ze=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:Qe}=await H.from("levelup_briefs").delete().eq("id",Ze);if(Qe)throw Qe;me.success("Brief deleted"),Ae()}catch(Qe){console.error("Error deleting brief:",Qe),me.error("Failed to delete brief")}},Te=async Ze=>{g(Ze);const{count:Qe}=await H.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id),{count:We}=await H.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id).not("dismissed_at","is",null);$e({total:Qe||0,dismissed:We||0});const{data:Je}=await H.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(Je){const it=[];for(const Dt of Je){const{data:Vt}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",Dt.id).order("sort_order"),{data:hs}=await H.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Dt.id),Ts=[...new Set((hs==null?void 0:hs.map(Es=>Es.user_id))||[])];let Cs={};if(Ts.length>0){const{data:Es}=await H.from("profiles").select("id, name, email").in("id",Ts);Es&&Es.forEach(ur=>{Cs[ur.id]=ur.name||ur.email||"Unknown"})}const cs=(hs||[]).map(Es=>({optionId:Es.option_id,userName:Cs[Es.user_id]||"Unknown",userId:Es.user_id})),er={};let xt=0;Vt&&Vt.forEach(Es=>{const ur=(hs==null?void 0:hs.filter(Mr=>Mr.option_id===Es.id).length)||0;er[Es.id]=ur,xt+=ur}),it.push({...Dt,options:Vt||[],results:er,respondents:cs,totalResponses:Dt.poll_type==="single"?new Set(hs==null?void 0:hs.map(Es=>Es.user_id)).size:xt})}pe(it)}p(!0)},pt=()=>{X([...ee,{title:"",url:""}])},fe=(Ze,Qe,We)=>{const Je=[...ee];Je[Ze][Qe]=We,X(Je)},qe=Ze=>{X(ee.filter((Qe,We)=>We!==Ze))},at=()=>{re([...ie,{question:"",poll_type:"single",options:["",""]}])},et=(Ze,Qe)=>{const We=[...ie];We[Ze].question=Qe,re(We)},Me=(Ze,Qe)=>{const We=[...ie];We[Ze].poll_type=Qe,re(We)},rt=Ze=>{const Qe=[...ie];Qe[Ze].options.push(""),re(Qe)},He=(Ze,Qe,We)=>{const Je=[...ie];Je[Ze].options[Qe]=We,re(Je)},ct=(Ze,Qe)=>{const We=[...ie];We[Ze].options=We[Ze].options.filter((Je,it)=>it!==Qe),re(We)},Ue=Ze=>{re(ie.filter((Qe,We)=>We!==Ze))};return e.jsxs(Ms,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(K,{onClick:Ce,children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Frequency"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:n?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Ze=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:Ze.title}),e.jsx(dt,{children:e.jsx(st,{variant:Ze.is_published?"default":"secondary",children:Ze.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"capitalize",children:Ze.show_frequency.replace("_"," ")}),e.jsx(dt,{children:ms(new Date(Ze.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Te(Ze),children:e.jsx(No,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>xe(Ze),children:e.jsx(hd,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>tt(Ze.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ze.id))})]})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(ba,{defaultValue:"content",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-4",children:[e.jsx(ns,{value:"content",children:"Content"}),e.jsx(ns,{value:"media",children:"Media"}),e.jsx(ns,{value:"links",children:"Links"}),e.jsx(ns,{value:"polls",children:"Polls"})]}),e.jsxs(bs,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Title *"}),e.jsx(ze,{value:b,onChange:Ze=>_(Ze.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(py,{content:j,onChange:Ze=>w(Ze),placeholder:"Brief overview for agents...",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Publish Date"}),e.jsx(ze,{type:"datetime-local",value:B,onChange:Ze=>V(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Show Frequency"}),e.jsxs(Ks,{value:Y,onValueChange:Q,children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"once",children:"Once (until dismissed)"}),e.jsx(Mt,{value:"every_login",children:"Every login"}),e.jsx(Mt,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qr,{checked:q,onCheckedChange:U}),e.jsx(be,{children:"Publish immediately"})]})]}),e.jsxs(bs,{value:"media",className:"space-y-6 mt-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Video (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ze,{type:"file",accept:"video/*",onChange:we,disabled:oe})}),oe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Or paste embed URL"}),e.jsx(ze,{value:N,onChange:Ze=>S(Ze.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),N&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:N,className:"w-full h-full",allow:"autoplay; fullscreen",allowFullScreen:!0})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Graphic / Image (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ze,{type:"file",accept:"image/*",onChange:async Ze=>{var We;const Qe=(We=Ze.target.files)==null?void 0:We[0];if(Qe){ye(!0);try{const Je=Qe.name.split(".").pop(),it=`brief-graphics/${Date.now()}.${Je}`,{error:Dt}=await H.storage.from("banner-images").upload(it,Qe,{upsert:!0});if(Dt)throw Dt;const{data:Vt}=H.storage.from("banner-images").getPublicUrl(it);L(Vt.publicUrl),me.success("Image uploaded!")}catch(Je){console.error(Je),me.error("Failed to upload image")}finally{ye(!1)}}},disabled:ge})}),ge&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Or paste Image URL"}),e.jsx(ze,{value:M,onChange:Ze=>L(Ze.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Click-through Link (optional)"}),e.jsx(ze,{value:I,onChange:Ze=>O(Ze.target.value),placeholder:"https://example.com/landing-page"})]}),M&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:M,alt:"Brief graphic preview",className:"w-full object-contain max-h-64"})})]})]}),e.jsxs(bs,{value:"links",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(be,{children:"Quick Links"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:pt,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),ee.map((Ze,Qe)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(ze,{value:Ze.title,onChange:We=>fe(Qe,"title",We.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(ze,{value:Ze.url,onChange:We=>fe(Qe,"url",We.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>qe(Qe),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]},Qe)),ee.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(bs,{value:"polls",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(be,{children:"Polls"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:at,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ie.map((Ze,Qe)=>e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ze,{value:Ze.question,onChange:We=>et(Qe,We.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(Ks,{value:Ze.poll_type,onValueChange:We=>Me(Qe,We),children:[e.jsx(Hs,{className:"w-32",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"single",children:"Single"}),e.jsx(Mt,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ue(Qe),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Ze.options.map((We,Je)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:We,onChange:it=>He(Qe,Je,it.target.value),placeholder:`Option ${Je+1}`}),Ze.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ct(Qe,Je),children:e.jsx(Nr,{className:"h-4 w-4 text-muted-foreground"})})]},Je)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>rt(Qe),children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},Qe)),ie.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls added yet"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Le,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Results: ",f==null?void 0:f.title]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:_e.total})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:_e.dismissed})})]})]}),ue.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),ue.map(Ze=>e.jsxs(Ee,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Ze.question}),e.jsx("div",{className:"space-y-2",children:Ze.options.map(Qe=>{const We=Ze.results[Qe.id]||0,Je=Ze.totalResponses>0?Math.round(We/Ze.totalResponses*100):0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:Qe.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[We," (",Je,"%)"]})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Je}%`}})}),We>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Ze.respondents||[]).filter(it=>it.optionId===Qe.id).map((it,Dt)=>e.jsx(st,{variant:"secondary",className:"text-xs font-normal",children:it.userName},Dt))})]},Qe.id)})})]},Ze.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const A1s=()=>{const{user:t}=Ds(),{toast:s}=Ua(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=k.useState(null),[f,g]=k.useState(""),{data:b=[],isLoading:_}=mt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:I,error:O}=await H.from("additional_services").select("*").order("publish_date",{ascending:!1});if(O)throw O;return I}}),j=Lt({mutationFn:async I=>{let O=I.existingImageUrl;if(I.image){const U=I.image.name.split(".").pop(),B=`${Date.now()}-${Math.random().toString(36).substring(7)}.${U}`,{error:V}=await H.storage.from("service-images").upload(B,I.image);if(V)throw V;const{data:Y}=H.storage.from("service-images").getPublicUrl(B);O=Y.publicUrl}const q={name:I.item.name,description:I.item.description||null,preview_image_url:O,signup_link_url:I.item.signup_link_url,publish_date:I.item.publish_date?new Date(I.item.publish_date).toISOString():new Date().toISOString(),is_published:I.item.is_published,created_by:t==null?void 0:t.id};if(I.itemId){const{error:U}=await H.from("additional_services").update(q).eq("id",I.itemId);if(U)throw U}else{const{error:U}=await H.from("additional_services").insert(q);if(U)throw U}},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:o?"Service updated":"Service created"}),a(!1),N()},onError:I=>{s({title:"Error saving service",description:I.message,variant:"destructive"})}}),w=Lt({mutationFn:async I=>{const{error:O}=await H.from("additional_services").delete().eq("id",I);if(O)throw O},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:I=>{s({title:"Error deleting service",description:I.message,variant:"destructive"})}}),N=()=>{c({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),g(""),l(null)},S=I=>{l(I),c({name:I.name,description:I.description||"",signup_link_url:I.signup_link_url,publish_date:I.publish_date?new Date(I.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:I.is_published}),g(I.preview_image_url||""),a(!0)},M=I=>{var q;const O=(q=I.target.files)==null?void 0:q[0];O&&(p(O),g(URL.createObjectURL(O)))},L=I=>{if(I.preventDefault(),!i.name.trim()){s({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){s({title:"Signup link URL is required",variant:"destructive"});return}j.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ms,{title:"Manage Additional Services",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.filter(I=>I.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:I=>{a(I),I||N()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:o?"Edit Service":"Add New Service"})}),e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:i.name,onChange:I=>c({...i,name:I.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(py,{content:i.description,onChange:I=>c({...i,description:I}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(ze,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:I=>c({...i,signup_link_url:I.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:I=>c({...i,publish_date:I.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:I=>c({...i,is_published:I})}),e.jsx(be,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),g("")},children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(gl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(ze,{type:"file",accept:"image/*",onChange:M,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:j.isPending,children:j.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):b.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No services yet. Click "Add Service" to create your first one.'}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-16",children:"Preview"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Signup Link"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:b.map(I=>e.jsxs(Ss,{children:[e.jsx(dt,{children:I.preview_image_url?e.jsx("img",{src:I.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(gl,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:I.name}),e.jsx(dt,{children:e.jsxs("a",{href:I.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(tn,{className:"h-3 w-3"}),"Link"]})}),e.jsx(dt,{children:new Date(I.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(st,{variant:I.is_published?"default":"secondary",children:I.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(I),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&w.mutate(I.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},I.id))})]})})})]})})};function E1s(){const{toast:t}=Ua(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:w,error:N}=await H.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(N)throw N;r(w.coupons||[])}catch(w){console.error("Error fetching coupons:",w),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},g=async()=>{if(!u.name){t({title:"Error",description:"Please enter a coupon name",variant:"destructive"});return}if(u.discountType==="percent"&&!u.percentOff){t({title:"Error",description:"Please enter a percent off value",variant:"destructive"});return}if(u.discountType==="amount"&&!u.amountOff){t({title:"Error",description:"Please enter an amount off value",variant:"destructive"});return}if(u.duration==="repeating"&&!u.durationInMonths){t({title:"Error",description:"Please enter duration in months",variant:"destructive"});return}l(!0);try{const w={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?w.percent_off=parseFloat(u.percentOff):(w.amount_off=Math.round(parseFloat(u.amountOff)*100),w.currency="usd"),u.duration==="repeating"&&(w.duration_in_months=parseInt(u.durationInMonths));const{data:N,error:S}=await H.functions.invoke("stripe-manage-coupons",{body:w});if(S)throw S;t({title:"Success",description:"Coupon created successfully"}),c(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(w){console.error("Error creating coupon:",w),t({title:"Error",description:w.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},b=async w=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:N}=await H.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:w}});if(N)throw N;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(N){console.error("Error deleting coupon:",N),t({title:"Error",description:N.message||"Failed to delete coupon",variant:"destructive"})}},_=w=>w.percent_off?`${w.percent_off}% off`:w.amount_off?`$${(w.amount_off/100).toFixed(2)} off`:"N/A",j=w=>{switch(w.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${w.duration_in_months} months`;default:return w.duration}};return e.jsx(Ms,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(fs,{open:i,onOpenChange:c,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New Coupon"}),e.jsx(Gr,{children:"Create a discount coupon that can be applied to subscriptions"})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Promotion Code (what users will type)"}),e.jsx(ze,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:w=>p({...u,promotionCode:w.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Coupon Name (internal label)"}),e.jsx(ze,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:w=>p({...u,name:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Discount Type"}),e.jsxs(Ks,{value:u.discountType,onValueChange:w=>{const N=w==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:w,duration:N})},children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(hS,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(Mt,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(ac,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:w=>p({...u,percentOff:w.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Amount Off (USD)"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx(ze,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:u.amountOff,onChange:w=>p({...u,amountOff:w.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Duration"}),e.jsxs(Ks,{value:u.duration,onValueChange:w=>p({...u,duration:w}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"once",children:"Once (first payment only)"}),e.jsx(Mt,{value:"repeating",children:"Multiple months"}),e.jsxs(Mt,{value:"forever",disabled:u.discountType==="amount",children:["Forever ",u.discountType==="amount"&&"(% discounts only)"]})]})]}),u.discountType==="amount"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'Note: "Forever" duration is only available for percentage-based discounts.'})]}),u.duration==="repeating"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Number of Months"}),e.jsx(ze,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:w=>p({...u,durationInMonths:w.target.value})})]}),e.jsx(K,{onClick:g,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Active Coupons"}),e.jsx(gr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No coupons created yet. Create your first coupon to get started."}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Promo Code"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Discount"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Redemptions"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:s.map(w=>{var N;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono font-medium",children:((N=w.promotion_codes)==null?void 0:N.length)>0?w.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(dt,{children:w.name||"-"}),e.jsx(dt,{children:_(w)}),e.jsx(dt,{children:j(w)}),e.jsx(dt,{children:w.times_redeemed}),e.jsx(dt,{children:e.jsx(st,{variant:w.valid?"default":"secondary",children:w.valid?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(w.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})})]},w.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"How to Use Coupons"})}),e.jsxs(Oe,{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"1. Create a coupon above with your desired discount."}),e.jsx("p",{children:'2. Share the coupon code (shown in the "Code" column) with users.'}),e.jsx("p",{children:"3. Users can enter the code during checkout to receive the discount."}),e.jsx("p",{children:"4. Alternatively, you can create a promotion code in Stripe dashboard for public-facing promotions."})]})]})]})})}const pye={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 P1s(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState(null),{data:l,isLoading:i,refetch:c}=mt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:_,error:j}=await H.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(j)throw j;return _}}),{data:u}=mt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:_,error:j}=await H.from("brokerages").select("*").order("name");if(j)throw j;return await Promise.all((_||[]).map(async N=>{const{data:S}=await H.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",N.id),{data:M}=await H.from("user_roles").select("user_id").eq("role","brokerage_manager"),L=(M==null?void 0:M.map(q=>q.user_id))||[],I=(S==null?void 0:S.filter(q=>L.includes(q.id)))||[],O=(S==null?void 0:S.length)||0;return{...N,managers:I,agentCount:O}}))}}),p=_=>{if(_.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(_.brokerage_id&&!_.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(_.is_trial&&_.trial_expires_at)return new Date(_.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(_.subscription_status==="active"||_.subscription_status==="trialing"){const j=pye[_.subscription_product_id];return{status:(j==null?void 0:j.name)||"Active",badge:_.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return _.subscription_status==="canceled"||_.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},f=l==null?void 0:l.filter(_=>{var w,N;if(!(((w=_.name)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||((N=_.email)==null?void 0:N.toLowerCase().includes(t.toLowerCase()))))return!1;switch(p(_),r){case"active":return _.subscription_status==="active";case"trialing":return _.subscription_status==="trialing"||_.is_trial&&new Date(_.trial_expires_at)>new Date;case"grandfathered":return _.is_grandfathered;case"brokerage":return _.brokerage_id&&!_.subscription_product_id&&!_.is_grandfathered;case"expired":return _.subscription_status==="canceled"||_.subscription_status==="past_due"||_.is_trial&&new Date(_.trial_expires_at)<=new Date;case"none":return!_.subscription_status||_.subscription_status==="none";default:return!0}}),g={totalUsers:(l==null?void 0:l.length)||0,activeSubscriptions:(l==null?void 0:l.filter(_=>_.subscription_status==="active").length)||0,trials:(l==null?void 0:l.filter(_=>_.subscription_status==="trialing"||_.is_trial&&new Date(_.trial_expires_at)>new Date).length)||0,grandfathered:(l==null?void 0:l.filter(_=>_.is_grandfathered).length)||0,brokerageMembers:(l==null?void 0:l.filter(_=>_.brokerage_id&&!_.subscription_product_id&&!_.is_grandfathered).length)||0,individualSubscribers:(l==null?void 0:l.filter(_=>_.subscription_status==="active"&&_.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(l==null?void 0:l.filter(_=>_.subscription_status==="active"&&(_.subscription_product_id==="prod_Tc08MupgoVySDG"||_.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},b=_=>{window.open(`https://dashboard.stripe.com/customers/${_}`,"_blank")};return e.jsx(Ms,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(K,{onClick:()=>c(),variant:"outline",size:"sm",children:[e.jsx(Go,{className:"h-4 w-4 mr-2"}),"Refresh"]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Users"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:g.totalUsers})]})}),e.jsx(Ee,{className:"border-green-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mx,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Active Paid"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-green-600",children:g.activeSubscriptions})]})}),e.jsx(Ee,{className:"border-blue-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Trials"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-blue-600",children:g.trials})]})}),e.jsx(Ee,{className:"border-purple-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dm,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Grandfathered"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-purple-600",children:g.grandfathered})]})}),e.jsx(Ee,{className:"border-orange-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Members"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-orange-600",children:g.brokerageMembers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Individual"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:g.individualSubscribers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Subs"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:g.brokerageSubscribers})]})})]}),e.jsxs(ba,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"users",children:"All Users"}),e.jsx(ns,{value:"brokerages",children:"Brokerages"})]}),e.jsxs(bs,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:r,onValueChange:_=>n(_),children:[e.jsx(Hs,{className:"w-[200px]",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Users"}),e.jsx(Mt,{value:"active",children:"Active Subscriptions"}),e.jsx(Mt,{value:"trialing",children:"Trials"}),e.jsx(Mt,{value:"grandfathered",children:"Grandfathered"}),e.jsx(Mt,{value:"brokerage",children:"Brokerage Members"}),e.jsx(Mt,{value:"expired",children:"Expired/Canceled"}),e.jsx(Mt,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"User"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Plan"}),e.jsx(St,{children:"Brokerage"}),e.jsx(St,{children:"End Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:i?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(f==null?void 0:f.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):f==null?void 0:f.map(_=>{var N,S;const j=p(_),w=pye[_.subscription_product_id];return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:_.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:_.email})]})}),e.jsx(dt,{children:e.jsx(st,{variant:j.variant,children:j.badge})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm",children:_.is_grandfathered?"Legacy Access":_.brokerage_id&&!_.subscription_product_id?"Brokerage Subscription":(w==null?void 0:w.name)||j.status})}),e.jsx(dt,{children:(N=_.brokerages)!=null&&N.name?e.jsx("span",{className:"text-sm",children:_.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(dt,{children:_.subscription_end_date?e.jsx("span",{className:"text-sm",children:ms(new Date(_.subscription_end_date),"MMM d, yyyy")}):_.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ms(new Date(_.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[_.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(_.stripe_customer_id),children:e.jsx(tn,{className:"h-4 w-4"})}),e.jsxs(fs,{children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>o(_),children:"Details"})}),e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Subscription Details"}),e.jsxs(Gr,{children:[_.name," (",_.email,")"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Status"}),e.jsx(st,{variant:j.variant,className:"mt-1",children:j.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:_.is_grandfathered?"Grandfathered (Legacy)":_.brokerage_id&&!_.subscription_product_id?"Brokerage Subscription":(w==null?void 0:w.name)||"None"})]}),_.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((S=_.brokerages)==null?void 0:S.name)||"Unknown"})]}),_.subscription_end_date&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Current Period End"}),e.jsx("p",{className:"font-medium",children:ms(new Date(_.subscription_end_date),"MMMM d, yyyy")})]}),_.trial_expires_at&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Trial Expires"}),e.jsx("p",{className:"font-medium",children:ms(new Date(_.trial_expires_at),"MMMM d, yyyy")})]}),_.stripe_customer_id&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Stripe Customer ID"}),e.jsx("p",{className:"font-mono text-sm",children:_.stripe_customer_id})]})]}),_.stripe_customer_id&&e.jsxs(K,{className:"w-full",onClick:()=>b(_.stripe_customer_id),children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},_.id)})})]})})})]}),e.jsx(bs,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:u==null?void 0:u.map(_=>{var w,N;const j=(w=_.managers)==null?void 0:w.some(S=>S.subscription_status==="active"&&(S.subscription_product_id==="prod_Tc08MupgoVySDG"||S.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(ka,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:_.name}),e.jsxs(gr,{children:[_.agentCount," agents"]})]})]}),e.jsx(st,{variant:j?"default":"outline",children:j?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Oe,{children:((N=_.managers)==null?void 0:N.length)>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),_.managers.map(S=>{const M=pye[S.subscription_product_id];return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.email})]}),e.jsx("div",{className:"text-right",children:M?e.jsxs("div",{children:[e.jsx(st,{variant:"default",children:M.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:M.price})]}):e.jsx(st,{variant:"outline",children:"No Subscription"})})]},S.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},_.id)})})})]})]})})}function I1s(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(""),[l,i]=k.useState("all"),[c,u]=k.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});k.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:_,error:j}=await H.from("referrals").select(` *, referrer_brokerage:brokerages!referrer_brokerage_id(name), referred_brokerage:brokerages!referred_brokerage_id(name), referred_user:profiles!referred_user_id(name, email) `).order("created_at",{ascending:!1});if(j)throw j;s(_||[]);const w=(_==null?void 0:_.filter(M=>M.status==="qualified").length)||0,N=(_==null?void 0:_.filter(M=>M.status==="pending").length)||0,S=(_==null?void 0:_.filter(M=>M.status==="cancelled").length)||0;u({total:(_==null?void 0:_.length)||0,qualified:w,pending:N,cancelled:S,totalDiscounts:w*25})}catch(_){console.error("Error fetching referrals:",_),me.error("Failed to load referrals")}finally{n(!1)}},f=async()=>{try{me.loading("Processing qualifications...");const{error:_}=await H.functions.invoke("process-referral-qualifications");if(_)throw _;me.dismiss(),me.success("Qualifications processed successfully"),p()}catch(_){me.dismiss(),console.error("Error processing qualifications:",_),me.error("Failed to process qualifications")}},g=t.filter(_=>{var N,S,M,L,I,O;const j=((S=(N=_.referrer_brokerage)==null?void 0:N.name)==null?void 0:S.toLowerCase().includes(a.toLowerCase()))||((L=(M=_.referred_brokerage)==null?void 0:M.name)==null?void 0:L.toLowerCase().includes(a.toLowerCase()))||((O=(I=_.referred_user)==null?void 0:I.email)==null?void 0:O.toLowerCase().includes(a.toLowerCase())),w=l==="all"||_.status===l;return j&&w}),b=_=>{switch(_){case"qualified":return e.jsxs(st,{className:"bg-green-100 text-green-800",children:[e.jsx(xi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(st,{variant:"secondary",children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(st,{variant:"destructive",children:[e.jsx(vc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(st,{children:_})}};return e.jsx(Ms,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(K,{onClick:f,variant:"outline",children:[e.jsx(Go,{className:"h-4 w-4 mr-2"}),"Process Qualifications"]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xi,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.qualified}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.pending}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vc,{className:"h-5 w-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.cancelled}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ac,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",c.totalDiscounts]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Discounts"})]})]})})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"All Referrals"}),e.jsx(gr,{children:"View and manage all referral relationships"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by brokerage or email...",value:a,onChange:_=>o(_.target.value),className:"pl-10"})]}),e.jsxs(Ks,{value:l,onValueChange:i,children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),e.jsx(Mt,{value:"pending",children:"Pending"}),e.jsx(Mt,{value:"qualified",children:"Qualified"}),e.jsx(Mt,{value:"cancelled",children:"Cancelled"})]})]})]}),r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Referrer"}),e.jsx(St,{children:"Referred"}),e.jsx(St,{children:"Signup Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Qualified Date"}),e.jsx(St,{children:"Discount"})]})}),e.jsx(zn,{children:g.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):g.map(_=>{var j,w,N,S;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:((j=_.referrer_brokerage)==null?void 0:j.name)||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{children:((w=_.referred_brokerage)==null?void 0:w.name)||((N=_.referred_user)==null?void 0:N.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(S=_.referred_user)==null?void 0:S.email})]})}),e.jsx(dt,{children:ms(new Date(_.signup_date),"MMM d, yyyy")}),e.jsx(dt,{children:b(_.status)}),e.jsx(dt,{children:_.qualified_date?ms(new Date(_.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(dt,{children:_.discount_applied?e.jsx(st,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},_.id)})})]})]})]})]})})}const fye=[{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"}],L1s=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function D1s(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(null),[c,u]=k.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});k.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:S,error:M}=await H.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(M)throw M;s(S||[])}catch(S){console.error("Error fetching checklist items:",S),me.error("Failed to load checklist items")}finally{n(!1)}},f=()=>{i(null),u({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0}),o(!0)},g=S=>{i(S),u({title:S.title,description:S.description||"",action_type:S.action_type,target_role:S.target_role,is_active:S.is_active}),o(!0)},b=async()=>{if(!c.title.trim()){me.error("Title is required");return}try{if(l){const{error:S}=await H.from("onboarding_checklist_items").update({title:c.title,description:c.description||null,action_type:c.action_type,target_role:c.target_role,is_active:c.is_active}).eq("id",l.id);if(S)throw S;me.success("Checklist item updated")}else{const S=t.filter(L=>L.target_role===c.target_role).reduce((L,I)=>Math.max(L,I.sort_order),-1),{error:M}=await H.from("onboarding_checklist_items").insert({title:c.title,description:c.description||null,action_type:c.action_type,target_role:c.target_role,is_active:c.is_active,sort_order:S+1});if(M)throw M;me.success("Checklist item created")}o(!1),p()}catch(S){console.error("Error saving checklist item:",S),me.error("Failed to save checklist item")}},_=async S=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:M}=await H.from("onboarding_checklist_items").delete().eq("id",S);if(M)throw M;me.success("Checklist item deleted"),p()}catch(M){console.error("Error deleting checklist item:",M),me.error("Failed to delete checklist item")}},j=async S=>{try{const{error:M}=await H.from("onboarding_checklist_items").update({is_active:!S.is_active}).eq("id",S.id);if(M)throw M;me.success(S.is_active?"Item deactivated":"Item activated"),p()}catch(M){console.error("Error toggling item:",M),me.error("Failed to update item")}},w=t.filter(S=>S.target_role==="brokerage_manager"),N=t.filter(S=>S.target_role==="agent");return e.jsxs(Ms,{title:"Onboarding Checklist",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Onboarding Checklist"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage checklist items shown to new users on their dashboard"})]}),e.jsxs(K,{onClick:f,className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(st,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Oe,{children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:w.map((S,M)=>{var L;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-muted-foreground",children:M+1}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",children:((L=fye.find(I=>I.value===S.action_type))==null?void 0:L.label)||S.action_type})}),e.jsx(dt,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>j(S)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(S),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(S.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(st,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Oe,{children:N.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:N.map((S,M)=>{var L;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-muted-foreground",children:M+1}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",children:((L=fye.find(I=>I.value===S.action_type))==null?void 0:L.label)||S.action_type})}),e.jsx(dt,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>j(S)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(S),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(S.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:l?"Edit Checklist Item":"Add Checklist Item"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:c.title,onChange:S=>u({...c,title:S.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:c.description,onChange:S=>u({...c,description:S.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Target Role"}),e.jsxs(Ks,{value:c.target_role,onValueChange:S=>u({...c,target_role:S}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:L1s.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Action Type"}),e.jsxs(Ks,{value:c.action_type,onValueChange:S=>u({...c,action_type:S}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:fye.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:c.is_active,onCheckedChange:S=>u({...c,is_active:S})}),e.jsx(be,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:b,children:l?"Save Changes":"Create Item"})]})]})})]})}function O1s(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("name"),[l,i]=k.useState("asc"),[c,u]=k.useState(""),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(""),{data:w}=mt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:V,error:Y}=await H.from("brokerages").select("id, name").order("name");if(Y)throw Y;return V}}),N=async V=>{let Q=[],ee=0,X=!0;for(;X;){const{data:ie,error:re}=await V(ee,ee+1e3-1);if(re)throw re;ie&&ie.length>0?(Q=[...Q,...ie],ee+=1e3,X=ie.length===1e3):X=!1}return Q},{data:S,isLoading:M}=mt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const V=await N((xe,we)=>H.from("profiles").select("id, name, email, brokerage_id, created_at").range(xe,we)),{data:Y}=await H.from("brokerages").select("id, name"),Q=new Map((Y==null?void 0:Y.map(xe=>[xe.id,xe.name]))||[]),[{data:ee},{data:X},{data:ie},{data:re},{data:oe},{data:ce},{data:ge}]=await Promise.all([H.rpc("get_admin_contact_counts"),H.rpc("get_admin_video_counts"),H.rpc("get_admin_popby_counts"),H.rpc("get_admin_listing_counts"),H.rpc("get_admin_deal_counts"),H.rpc("get_admin_portal_counts"),H.rpc("get_admin_sendable_card_counts")]),ye=new Map;ee==null||ee.forEach(xe=>ye.set(xe.owner_user_id,xe.contact_count));const ue=new Map;X==null||X.forEach(xe=>ue.set(xe.owner_user_id,xe.video_count));const pe=new Map;ie==null||ie.forEach(xe=>pe.set(xe.owner_user_id,xe.popby_count));const _e=new Map;re==null||re.forEach(xe=>_e.set(xe.agent_id,xe.listing_count));const $e=new Map;oe==null||oe.forEach(xe=>$e.set(xe.owner_user_id,xe.deal_count));const Ae=new Map;ce==null||ce.forEach(xe=>Ae.set(xe.owner_user_id,{total:xe.portal_count,active:xe.active_portal_count}));const Ie=new Map;return ge==null||ge.forEach(xe=>Ie.set(xe.owner_user_id,{total:xe.card_count,sent:xe.sent_card_count,views:xe.total_card_views})),V.map(xe=>{const we=Ae.get(xe.id),Le=Ie.get(xe.id);return{id:xe.id,name:xe.name||"Unknown",email:xe.email||"",brokerage_id:xe.brokerage_id,brokerage_name:xe.brokerage_id&&Q.get(xe.brokerage_id)||null,contact_count:ye.get(xe.id)||0,video_count:ue.get(xe.id)||0,popby_count:pe.get(xe.id)||0,listing_count:_e.get(xe.id)||0,deal_count:$e.get(xe.id)||0,portal_count:(we==null?void 0:we.total)||0,active_portal_count:(we==null?void 0:we.active)||0,card_count:(Le==null?void 0:Le.total)||0,sent_card_count:(Le==null?void 0:Le.sent)||0,total_card_views:(Le==null?void 0:Le.views)||0,created_at:xe.created_at}})}}),L=k.useMemo(()=>{if(!S)return[];let V=S.filter(Y=>{const Q=t.toLowerCase(),ee=!t||Y.name.toLowerCase().includes(Q)||Y.email.toLowerCase().includes(Q),X=r==="all"||r==="none"&&!Y.brokerage_id||Y.brokerage_id===r,ie=parseInt(c)||0,re=parseInt(p)||0,oe=parseInt(g)||0,ce=parseInt(_)||0,ge=Y.contact_count>=ie&&Y.video_count>=re&&Y.popby_count>=oe&&Y.listing_count>=ce;return ee&&X&&ge});return V.sort((Y,Q)=>{let ee=0;return a==="name"?ee=Y.name.localeCompare(Q.name):ee=Y[a]-Q[a],l==="asc"?ee:-ee}),V},[S,t,r,a,l,c,p,g,_]),I=V=>{a===V?i(l==="asc"?"desc":"asc"):(o(V),i("desc"))},O=()=>{const V=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],Y=L.map(re=>[re.name,re.email,re.brokerage_name||"None",re.contact_count,re.video_count,re.popby_count,re.listing_count,re.deal_count,`${re.portal_count} (${re.active_portal_count})`,re.card_count,re.sent_card_count,re.total_card_views]),Q=[V.join(","),...Y.map(re=>re.map(oe=>`"${oe}"`).join(","))].join(` `),ee=new Blob([Q],{type:"text/csv"}),X=URL.createObjectURL(ee),ie=document.createElement("a");ie.href=X,ie.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,ie.click(),URL.revokeObjectURL(X)},q=k.useMemo(()=>L.length?L.reduce((V,Y)=>({contacts:V.contacts+Y.contact_count,videos:V.videos+Y.video_count,popbys:V.popbys+Y.popby_count,listings:V.listings+Y.listing_count,deals:V.deals+Y.deal_count,portals:V.portals+Y.portal_count,activePortals:V.activePortals+Y.active_portal_count,cards:V.cards+Y.card_count,sentCards:V.sentCards+Y.sent_card_count,cardViews:V.cardViews+Y.total_card_views}),{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0}):{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0},[L]),U=k.useMemo(()=>L.length?{portals:L.filter(V=>V.portal_count>0).length,cards:L.filter(V=>V.card_count>0).length}:{portals:0,cards:0},[L]),B=({field:V,children:Y})=>e.jsx(St,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>I(V),children:e.jsxs("div",{className:"flex items-center gap-1",children:[Y,e.jsx(bd,{className:`h-3 w-3 ${a===V?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(B1,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(n1,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:U.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Portals"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:q.activePortals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),e.jsxs(Ee,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-4 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:U.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Created"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:q.sentCards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Sent"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:q.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(gr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:O,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-6",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:t,onChange:V=>s(V.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(Ks,{value:r,onValueChange:n,children:[e.jsxs(Hs,{children:[e.jsx(ka,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Ys,{placeholder:"Brokerage"})]}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Brokerages"}),e.jsx(Mt,{value:"none",children:"No Brokerage"}),w==null?void 0:w.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))]})]})}),e.jsx("div",{children:e.jsx(ze,{type:"number",placeholder:"Min contacts",value:c,onChange:V=>u(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(ze,{type:"number",placeholder:"Min videos",value:p,onChange:V=>f(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(ze,{type:"number",placeholder:"Min popbys",value:g,onChange:V=>b(V.target.value),min:"0"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-8 text-sm",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:L.length}),e.jsx("div",{className:"text-muted-foreground",children:"Users"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.contacts.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.videos.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Videos"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.popbys.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Popbys"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.listings.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Listings"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.deals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{className:"bg-blue-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.portals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Portals"})]}),e.jsxs("div",{className:"bg-violet-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),M?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(B,{field:"name",children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Brokerage"}),e.jsx(B,{field:"contact_count",children:"Contacts"}),e.jsx(B,{field:"video_count",children:"Videos"}),e.jsx(B,{field:"popby_count",children:"Popbys"}),e.jsx(B,{field:"listing_count",children:"Listings"}),e.jsx(B,{field:"deal_count",children:"Deals"}),e.jsx(B,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(n1,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(B,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(zn,{children:L.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):L.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:V.name}),e.jsx(dt,{className:"text-muted-foreground",children:V.email}),e.jsx(dt,{children:V.brokerage_name?e.jsx(st,{variant:"secondary",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(st,{variant:V.contact_count>0?"default":"outline",children:V.contact_count})}),e.jsx(dt,{children:e.jsx(st,{variant:V.video_count>0?"default":"outline",children:V.video_count})}),e.jsx(dt,{children:e.jsx(st,{variant:V.popby_count>0?"default":"outline",children:V.popby_count})}),e.jsx(dt,{children:e.jsx(st,{variant:V.listing_count>0?"default":"outline",children:V.listing_count})}),e.jsx(dt,{children:e.jsx(st,{variant:V.deal_count>0?"default":"outline",children:V.deal_count})}),e.jsx(dt,{children:V.portal_count>0?e.jsxs(bc,{children:[e.jsx(_c,{children:e.jsxs(st,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[V.portal_count,V.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",V.active_portal_count," active)"]})]})}),e.jsxs(Xl,{children:[e.jsxs("p",{children:[V.portal_count," total portals"]}),e.jsxs("p",{children:[V.active_portal_count," currently active"]})]})]}):e.jsx(st,{variant:"outline",children:"0"})}),e.jsx(dt,{children:V.card_count>0?e.jsxs(bc,{children:[e.jsx(_c,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(st,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:V.card_count}),V.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx(Bn,{className:"h-3 w-3"}),V.sent_card_count]}),V.total_card_views>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(Ln,{className:"h-3 w-3"}),V.total_card_views]})]})}),e.jsxs(Xl,{children:[e.jsxs("p",{children:[V.card_count," cards created"]}),e.jsxs("p",{children:[V.sent_card_count," sent"]}),e.jsxs("p",{children:[V.total_card_views," total views"]})]})]}):e.jsx(st,{variant:"outline",children:"0"})})]},V.id))})]})})]})]})]})})}function R1s(){Ua(),Qt();const[t,s]=k.useState("user-analytics"),{data:r}=mt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:b,error:_}=await H.from("feature_flags").select("*").order("key");if(_)throw _;return b}}),{data:n,isLoading:a}=mt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:b,error:_}=await H.from("relationship_types").select("*").order("sort_order");if(_)throw _;return b}}),{data:o,isLoading:l}=mt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:b,error:_}=await H.from("action_types").select("*").order("sort_order");if(_)throw _;return b}}),{data:i,isLoading:c}=mt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:b,error:_}=await H.from("action_scripts").select("*, action_type:action_types(*)");if(_)throw _;return b}}),{data:u,isLoading:p}=mt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:b,error:_}=await H.from("touchpoint_plans").select("*").order("name");if(_)throw _;return b}}),{data:f,isLoading:g}=mt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:b,error:_}=await H.from("popby_items").select("*").is("owner_user_id",null).order("name");if(_)throw _;return b}});return e.jsx(Ms,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(ba,{value:t,onValueChange:s,children:[e.jsxs(pa,{className:"grid w-full grid-cols-9",children:[e.jsxs(ns,{value:"user-analytics",className:"gap-2",children:[e.jsx(No,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(ns,{value:"relationship-types",className:"gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(ns,{value:"action-types",className:"gap-2",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(ns,{value:"scripts",className:"gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(ns,{value:"video-scripts",className:"gap-2",children:[e.jsx(gu,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(ns,{value:"plans",className:"gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(ns,{value:"popbys",className:"gap-2",children:[e.jsx(ko,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(ns,{value:"settings",className:"gap-2",children:[e.jsx(Xo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(ns,{value:"feature-flags",className:"gap-2",children:[e.jsx(i1,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx(bs,{value:"user-analytics",className:"mt-6",children:e.jsx(O1s,{})}),e.jsx(bs,{value:"relationship-types",className:"mt-6",children:e.jsx(F1s,{types:n||[],isLoading:a})}),e.jsx(bs,{value:"action-types",className:"mt-6",children:e.jsx(z1s,{types:o||[],isLoading:l})}),e.jsx(bs,{value:"scripts",className:"mt-6",children:e.jsx(B1s,{scripts:i||[],actionTypes:o||[],isLoading:c})}),e.jsx(bs,{value:"video-scripts",className:"mt-6",children:e.jsx(V1s,{})}),e.jsx(bs,{value:"plans",className:"mt-6",children:e.jsx($1s,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(bs,{value:"popbys",className:"mt-6",children:e.jsx(U1s,{items:f||[],isLoading:g})}),e.jsx(bs,{value:"settings",className:"mt-6",children:e.jsx(H1s,{})}),e.jsx(bs,{value:"feature-flags",className:"mt-6",children:e.jsx(q1s,{flags:r||[]})})]})]})})}function F1s({types:t,isLoading:s}){const{toast:r}=Ua(),n=Qt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),c=Lt({mutationFn:async p=>{if(p.id){const{error:f}=await H.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(f)throw f}else{const{error:f}=await H.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-relationship-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await H.from("relationship_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Relationship Types"}),e.jsx(gr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-12"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(p=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(dt,{className:"font-medium",children:p.name}),e.jsx(dt,{className:"text-muted-foreground",children:p.description}),e.jsx(dt,{children:e.jsx(qr,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);c.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"icon",children:"Icon"}),e.jsx(ze,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function z1s({types:t,isLoading:s}){const{toast:r}=Ua(),n=Qt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),c=Lt({mutationFn:async p=>{if(p.id){const{error:f}=await H.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(f)throw f}else{const{error:f}=await H.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-action-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await H.from("action_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Action Types"}),e.jsx(gr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Color"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(p=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:p.name}),e.jsx(dt,{className:"text-muted-foreground",children:p.description}),e.jsx(dt,{children:p.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:p.color}})}),e.jsx(dt,{children:e.jsx(qr,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);c.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon"),color:f.get("color")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"icon",children:"Icon"}),e.jsx(ze,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"color",children:"Color"}),e.jsx(ze,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function B1s({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=Ua(),a=Qt(),[o,l]=k.useState(null),[i,c]=k.useState(!1),u=Lt({mutationFn:async f=>{if(f.id){const{error:g}=await H.from("action_scripts").update({title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:f.active}).eq("id",f.id);if(g)throw g}else{const{error:g}=await H.from("action_scripts").insert([{title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:!0}]);if(g)throw g}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),c(!1),l(null),n({title:"Saved successfully"})},onError:f=>{n({title:"Error",description:f.message,variant:"destructive"})}}),p=Lt({mutationFn:async f=>{const{error:g}=await H.from("action_scripts").delete().eq("id",f);if(g)throw g},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Script Library"}),e.jsx(gr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(K,{onClick:()=>{l(null),c(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Tone"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(f=>{var g;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:f.title}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",children:((g=f.action_type)==null?void 0:g.name)||"Unknown"})}),e.jsx(dt,{className:"text-muted-foreground",children:f.tone}),e.jsx(dt,{children:e.jsx(st,{variant:f.active?"default":"secondary",children:f.active?"Active":"Inactive"})}),e.jsxs(dt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{l(f),c(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(f.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]},f.id)})})]})}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.currentTarget);u.mutate({id:o==null?void 0:o.id,title:g.get("title"),action_type_id:g.get("action_type_id"),tone:g.get("tone"),script_body:g.get("script_body"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(Ks,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select action type"})}),e.jsx(Ws,{children:s.map(f=>e.jsx(Mt,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(ze,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Er,{id:"script_body",name:"script_body",defaultValue:o==null?void 0:o.script_body,rows:8,required:!0,placeholder:`Use {{FirstName}}, {{LastName}}, and {{AgentName}} as placeholders. Example: Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in...`})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function $1s({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=Ua(),o=Qt(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(null),[g,b]=k.useState(!1),[_,j]=k.useState(null),[w,N]=k.useState(null),{data:S}=mt({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:B,error:V}=await H.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(V)throw V;return B},enabled:!!p}),M=Lt({mutationFn:async B=>{if(B.id){const{error:V}=await H.from("touchpoint_plans").update({name:B.name,description:B.description,active:B.active}).eq("id",B.id);if(V)throw V}else{const{error:V}=await H.from("touchpoint_plans").insert([{name:B.name,description:B.description,active:!0}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:B=>{a({title:"Error",description:B.message,variant:"destructive"})}}),L=Lt({mutationFn:async B=>{if(B.id){const{error:V}=await H.from("touchpoint_plan_items").update({action_type_id:B.action_type_id,default_script_id:B.default_script_id,notes:B.notes}).eq("id",B.id);if(V)throw V}else{const{error:V}=await H.from("touchpoint_plan_items").insert([{plan_id:B.plan_id,month_number:B.month_number,action_type_id:B.action_type_id,default_script_id:B.default_script_id,notes:B.notes}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),I=Lt({mutationFn:async B=>{const{error:V}=await H.from("touchpoint_plan_items").delete().eq("id",B);if(V)throw V},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),O=Lt({mutationFn:async B=>{const{data:V,error:Y}=await H.from("action_scripts").insert([{...B,active:!0}]).select().single();if(Y)throw Y;return V},onSuccess:async B=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),_&&await L.mutateAsync({id:_.itemId,plan_id:p,month_number:_.month,action_type_id:_.actionTypeId,default_script_id:B.id}),b(!1),j(null),a({title:"Script created and assigned"})},onError:B=>{a({title:"Error",description:B.message,variant:"destructive"})}}),q=(B,V,Y)=>{j({month:B,actionTypeId:V,itemId:Y}),b(!0)},U=B=>r.find(V=>V.id===B);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Touchpoint Plans"}),e.jsx(gr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(K,{onClick:()=>{i(null),u(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(B=>e.jsxs(Ee,{className:`cursor-pointer transition-colors ${p===B.id?"border-primary":""}`,onClick:()=>f(B.id),children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:B.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:V=>{V.stopPropagation(),i(B),u(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:B.description}),e.jsx(st,{variant:B.active?"default":"secondary",className:"mt-2",children:B.active?"Active":"Inactive"})]})]},B.id))})})]}),p&&e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Plan Schedule"}),e.jsx(gr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(B,V)=>V+1).map(B=>{const V=S==null?void 0:S.find(ee=>ee.month_number===B),Y=V!=null&&V.default_script_id?U(V.default_script_id):null,Q=r.filter(ee=>ee.action_type_id===(V==null?void 0:V.action_type_id)&&ee.active);return e.jsxs("div",{className:"p-4 border rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"w-20 font-medium text-sm",children:["Month ",B]}),e.jsxs(Ks,{value:(V==null?void 0:V.action_type_id)||"none",onValueChange:ee=>{ee==="none"&&V?I.mutate(V.id):ee!=="none"&&L.mutate({id:V==null?void 0:V.id,plan_id:p,month_number:B,action_type_id:ee,default_script_id:null})},children:[e.jsx(Hs,{className:"w-40",children:e.jsx(Ys,{placeholder:"No action"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No action"}),s.filter(ee=>ee.active).map(ee=>e.jsx(Mt,{value:ee.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[ee.color&&e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ee.color}}),ee.name]})},ee.id))]})]}),V&&e.jsxs(e.Fragment,{children:[e.jsxs(Ks,{value:V.default_script_id||"none",onValueChange:ee=>{N(null),L.mutate({id:V.id,default_script_id:ee==="none"?null:ee})},children:[e.jsx(Hs,{className:"w-56",children:e.jsx(Ys,{placeholder:"Select script"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No default script"}),Q.map(ee=>e.jsxs(Mt,{value:ee.id,children:[ee.title," ",ee.tone&&`(${ee.tone})`]},ee.id))]})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>q(B,V.action_type_id,V.id),children:[e.jsx($s,{className:"h-3 w-3 mr-1"}),"New Script"]}),Y&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N((w==null?void 0:w.id)===Y.id?null:Y),children:(w==null?void 0:w.id)===Y.id?"Hide":"Preview"})]})]}),w&&(V==null?void 0:V.default_script_id)===w.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(st,{variant:"outline",children:w.title}),w.tone&&e.jsx(st,{variant:"secondary",children:w.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:w.script_body})]})]},B)})})})]}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:B=>{B.preventDefault();const V=new FormData(B.currentTarget);M.mutate({id:l==null?void 0:l.id,name:V.get("name"),description:V.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:M.isPending,children:[M.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(fs,{open:g,onOpenChange:b,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New Script"}),e.jsxs(Gr,{children:["Create a script for Month ",_==null?void 0:_.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),e.jsxs("form",{onSubmit:B=>{B.preventDefault();const V=new FormData(B.currentTarget);O.mutate({title:V.get("title"),action_type_id:_.actionTypeId,tone:V.get("tone"),script_body:V.get("script_body")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_title",children:"Title"}),e.jsx(ze,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_tone",children:"Tone"}),e.jsx(ze,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Er,{id:"script_body",name:"script_body",rows:6,required:!0,placeholder:"Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in..."})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:O.isPending,children:[O.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function q1s({flags:t}){const{toast:s}=Ua(),r=Qt(),n=async(a,o)=>{const{error:l}=await H.from("feature_flags").update({...o,updated_at:new Date().toISOString()}).eq("id",a.id);l?s({title:"Error",description:l.message,variant:"destructive"}):(r.invalidateQueries({queryKey:["admin-feature-flags"]}),s({title:"Flag updated"}))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Feature Flags"}),e.jsx(gr,{children:"Control which features are enabled for members"})]}),e.jsx(Oe,{children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Flag"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Notes"}),e.jsx(St,{children:"Last Updated"})]})}),e.jsx(zn,{children:t.map(a=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono text-sm",children:a.key}),e.jsx(dt,{children:e.jsx(qr,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(dt,{children:e.jsx(ze,{defaultValue:a.notes||"",placeholder:"Add notes...",className:"max-w-xs",onBlur:o=>{o.target.value!==a.notes&&n(a,{notes:o.target.value})}})}),e.jsx(dt,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function U1s({items:t,isLoading:s}){const{toast:r}=Ua(),n=Qt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),c=Lt({mutationFn:async f=>{if(f.id){const{error:g}=await H.from("popby_items").update({name:f.name,description:f.description}).eq("id",f.id);if(g)throw g}else{const{error:g}=await H.from("popby_items").insert([{name:f.name,description:f.description,owner_user_id:null}]);if(g)throw g}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),u=async f=>{await H.from("popby_items").update({is_active:!f.is_active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async f=>{await H.from("popby_items").delete().eq("id",f),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),r({title:"Deleted successfully"})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Popby Ideas"}),e.jsx(gr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ko,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No popby ideas yet. Add your first one!"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:t.map(f=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:f.name}),e.jsx(dt,{className:"text-muted-foreground",children:f.description}),e.jsx(dt,{children:e.jsx(qr,{checked:f.is_active,onCheckedChange:()=>u(f)})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(f.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.currentTarget);c.mutate({id:a==null?void 0:a.id,name:g.get("name"),description:g.get("description")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function V1s(){var b;const{toast:t}=Ua(),s=Qt(),[r,n]=k.useState(null),[a,o]=k.useState(!1),{data:l,isLoading:i}=mt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:_,error:j}=await H.from("video_script_categories").select("*").order("sort_order");if(j)throw j;return _}}),{data:c,isLoading:u}=mt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:_,error:j}=await H.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(j)throw j;return _}}),p=Lt({mutationFn:async _=>{var j,w;if(_.id){const{error:N}=await H.from("video_scripts").update({title:_.title,script_text:_.script_text,category_id:_.category_id,tags:((j=_.tags)==null?void 0:j.split(",").map(S=>S.trim()).filter(Boolean))||[]}).eq("id",_.id);if(N)throw N}else{const{error:N}=await H.from("video_scripts").insert([{title:_.title,script_text:_.script_text,category_id:_.category_id||null,tags:((w=_.tags)==null?void 0:w.split(",").map(S=>S.trim()).filter(Boolean))||[]}]);if(N)throw N}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),t({title:"Video script saved!"})},onError:_=>t({title:"Error",description:_.message,variant:"destructive"})}),f=async _=>{await H.from("video_scripts").update({is_active:!_.is_active}).eq("id",_.id),s.invalidateQueries({queryKey:["admin-video-scripts"]})},g=async _=>{confirm("Delete this video script?")&&(await H.from("video_scripts").delete().eq("id",_),s.invalidateQueries({queryKey:["admin-video-scripts"]}),t({title:"Script deleted"}))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Video Scripts"}),e.jsx(gr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(K,{onClick:()=>{n(null),o(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(zn,{children:c==null?void 0:c.map(_=>{var j;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:_.title}),e.jsx(dt,{className:"text-muted-foreground",children:((j=_.category)==null?void 0:j.name)||"Uncategorized"}),e.jsx(dt,{children:e.jsx(qr,{checked:_.is_active,onCheckedChange:()=>f(_)})}),e.jsxs(dt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{n(_),o(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(_.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},_.id)})})]})}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:_=>{_.preventDefault();const j=new FormData(_.currentTarget);p.mutate({id:r==null?void 0:r.id,title:j.get("title"),script_text:j.get("script_text"),category_id:j.get("category_id")||null,tags:j.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"category_id",children:"Category"}),e.jsxs(Ks,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:l==null?void 0:l.map(_=>e.jsx(Mt,{value:_.id,children:_.name},_.id))})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Er,{id:"script_text",name:"script_text",defaultValue:r==null?void 0:r.script_text,rows:6,required:!0,placeholder:"Enter the teleprompter script..."})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(ze,{id:"tags",name:"tags",defaultValue:((b=r==null?void 0:r.tags)==null?void 0:b.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(qn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[p.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function H1s(){const{toast:t}=Ua(),[s,r]=k.useState(""),[n,a]=k.useState(!0),[o,l]=k.useState(!1);k.useEffect(()=>{(async()=>{a(!0);try{const{data:u}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();u!=null&&u.value&&r(u.value)}catch(u){console.error("Error fetching settings:",u)}a(!1)})()},[]);const i=async()=>{l(!0);try{await H.from("settings").upsert({key:"mapbox_public_token",value:s.trim()}),t({title:"Mapbox token saved!"})}catch{t({title:"Error saving token",variant:"destructive"})}l(!1)};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ma,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(gr,{children:"Configure the map feature for popbys"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(ze,{id:"mapbox-token",placeholder:"pk.eyJ1I...",value:s,onChange:c=>r(c.target.value)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token at"," ",e.jsx("a",{href:"https://mapbox.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"mapbox.com"}),". This token will be used by all agents for the popby map feature."]})]}),e.jsxs(K,{onClick:i,disabled:o,children:[o&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(st,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const W1s=()=>{const[t,s]=k.useState(""),[r,n]=k.useState("grid"),a=fr(),{data:o=[],isLoading:l}=mt({queryKey:["additional-services"],queryFn:async()=>{const{data:c,error:u}=await H.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(u)throw u;return c}}),i=o.filter(c=>{var p;return c.name.toLowerCase().includes(t.toLowerCase())||((p=c.description)==null?void 0:p.toLowerCase().includes(t.toLowerCase()))});return e.jsx(Ms,{title:"Additional Services",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Additional Services"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Explore our additional services and offerings"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search services...",value:t,onChange:c=>s(c.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[t&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(Mh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," service",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(4)].map((c,u)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"})]})},u))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:t?"No services match your search":"No additional services available yet"}),t&&e.jsx(K,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(c=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${r==="list"?"flex flex-row":""}`,onClick:()=>a(`/additional-services/${c.id}`),children:[e.jsx("div",{className:`relative overflow-hidden bg-muted ${r==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:c.preview_image_url?e.jsx("img",{src:c.preview_image_url,alt:c.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(pn,{className:"h-8 w-8"})})}),e.jsxs(Oe,{className:`p-4 flex flex-col ${r==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:c.name}),c.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 flex-1",children:jde(c.description)})]})]},c.id))})]})})},G1s=()=>{const{serviceId:t}=yo(),s=fr(),{data:r,isLoading:n}=mt({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await H.from("additional_services").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!t});return n?e.jsx(Ms,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(ys,{className:"h-8 w-48"}),e.jsx(ys,{className:"h-64 w-full rounded-lg"}),e.jsx(ys,{className:"h-24 w-full"})]})}):r?e.jsx(Ms,{title:r.name,children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative bg-muted",children:r.preview_image_url?e.jsx("img",{src:r.preview_image_url,alt:r.name,className:"w-full h-auto max-h-[500px] object-contain mx-auto"}):e.jsx("div",{className:"w-full h-64 flex items-center justify-center text-muted-foreground",children:e.jsx(pn,{className:"h-16 w-16"})})})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4 mr-1"}),"Published ",ms(new Date(r.publish_date),"MMMM d, yyyy")]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:r.description}}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs(K,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(tn,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Ms,{title:"Not Found",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center py-12",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-4",children:"Service Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"The service you're looking for doesn't exist or has been removed."}),e.jsxs(K,{onClick:()=>s("/additional-services"),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},cI=[{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 K1s(){const[t,s]=k.useState(cI[0].id),r=cI.find(n=>n.id===t)||cI[0];return e.jsx(Ms,{title:"AI Toolkit",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(SM,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"AI Toolkit"}),e.jsx("p",{className:"text-muted-foreground",children:"Powerful AI tools to boost your real estate business"})]})]}),e.jsx("div",{className:"md:hidden",children:e.jsxs(Ks,{value:t,onValueChange:s,children:[e.jsx(Hs,{className:"w-full",children:e.jsx(Ys,{placeholder:"Select a tool"})}),e.jsx(Ws,{children:cI.map(n=>e.jsx(Mt,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(ba,{value:t,onValueChange:s,className:"w-full",children:e.jsx(pa,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:cI.map(n=>e.jsx(ns,{value:n.id,className:"flex-1 min-w-[150px] text-xs lg:text-sm whitespace-normal h-auto py-2",children:n.name},n.id))})})}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-full max-w-[700px]",dangerouslySetInnerHTML:{__html:r.iframe}})})]})})}const HFe="agent-os-onboarding-completed",Hz=[{icon:x0,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:Zh,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:pr,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:Od,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:ko,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:No,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"]}],Z1s=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(0),[a,o]=k.useState(!1);k.useEffect(()=>{if(!localStorage.getItem(HFe)){const _=setTimeout(()=>s(!0),500);return()=>clearTimeout(_)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):c()},i=()=>{c()},c=()=>{localStorage.setItem(HFe,"true"),s(!1)},u=Hz[r],p=u.icon,f=r===Hz.length-1,g=b=>{b||c(),s(b)};return e.jsx(fs,{open:t,onOpenChange:g,children:e.jsxs(ps,{className:"sm:max-w-lg overflow-hidden p-0 gap-0",children:[e.jsxs("div",{className:`relative bg-gradient-to-br ${u.bgGradient} p-8 pb-12 transition-all duration-500`,children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-4 -right-4 w-32 h-32 bg-white/10 rounded-full blur-2xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-8 -left-8 w-40 h-40 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl"})]}),e.jsxs("div",{className:`relative mx-auto flex h-20 w-20 items-center justify-center transition-all duration-300 ${a?"scale-75 opacity-0":"scale-100 opacity-100"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-white/20 rounded-2xl blur-xl"}),e.jsx("div",{className:"relative flex h-20 w-20 items-center justify-center rounded-2xl bg-white/20 backdrop-blur-sm border border-white/30 shadow-2xl",children:e.jsx(p,{className:`h-10 w-10 ${u.iconColor} drop-shadow-lg`})})]}),r===0&&e.jsxs("div",{className:"absolute top-4 right-4 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm border border-white/30 text-white text-xs font-medium flex items-center gap-1.5",children:[e.jsx(pn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(_s,{className:"text-center sm:text-center pb-2",children:[e.jsx(vs,{className:`text-2xl font-bold transition-all duration-300 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.title}),e.jsx(Gr,{className:`text-base pt-2 transition-all duration-300 delay-75 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.description})]}),u.highlights&&e.jsx("div",{className:`space-y-2.5 py-4 transition-all duration-300 delay-100 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.highlights.map((b,_)=>e.jsxs("div",{className:"flex items-center gap-3 group",style:{transitionDelay:`${150+_*50}ms`},children:[e.jsx("div",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${u.bgGradient} shadow-sm`,children:e.jsx(va,{className:"h-3.5 w-3.5 text-white"})}),e.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground transition-colors",children:b})]},_))}),e.jsx("div",{className:"flex justify-center gap-2 py-4",children:Hz.map((b,_)=>e.jsx("button",{onClick:()=>{_!==r&&(o(!0),setTimeout(()=>{n(_),o(!1)},150))},className:`h-2 rounded-full transition-all duration-300 ${_===r?"w-8 bg-gradient-to-r "+u.bgGradient:_{const{user:t}=Ds();return mt({queryKey:["contact-snoozes",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(r)throw r;return s},enabled:!!t})},X1s=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=Pl(new Date,n);await H.from("contact_snoozes").delete().eq("contact_id",r);const{error:o}=await H.from("contact_snoozes").insert({contact_id:r,owner_user_id:s.id,snoozed_until:a.toISOString()});if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),t.invalidateQueries({queryKey:["today-actions"]}),t.invalidateQueries({queryKey:["popby-logs"]}),wn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{wn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},Q1s=()=>{const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("contact_snoozes").delete().eq("contact_id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),wn({title:"Snooze cancelled"})},onError:s=>{wn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},J1s=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function Uhe({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=k.useState(null),l=X1s(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},c=u=>ms(Pl(new Date,u),"MMM d, yyyy");return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(Gr,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:J1s.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:It("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===u.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:u.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Until ",c(u.days)]})]},u.days))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const ebs={Crown:Dm,FileText:Sn,Users:pr,Globe:su,Star:Jn,Phone:Un,MessageSquare:so,PenTool:U_,Video:An,Gift:ko};function tbs({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=fr(),[c,u]=k.useState("name"),[p,f]=k.useState("asc"),[g,b]=k.useState(null),[_,j]=k.useState(""),w=I=>{c===I?f(O=>O==="asc"?"desc":"asc"):(u(I),f("asc"))},N=k.useMemo(()=>[...t].sort((I,O)=>{var U,B;let q=0;switch(c){case"name":{const V=`${I.contact.first_name} ${I.contact.last_name||""}`.toLowerCase(),Y=`${O.contact.first_name} ${O.contact.last_name||""}`.toLowerCase();q=V.localeCompare(Y);break}case"relationship_type":q=(I.relationshipTypeName||"").localeCompare(O.relationshipTypeName||"");break;case"action_type":q=(((U=I.actionType)==null?void 0:U.name)||"").localeCompare(((B=O.actionType)==null?void 0:B.name)||"");break;case"last_touch":q=(I.monthNumber||0)-(O.monthNumber||0);break}return p==="asc"?q:-q}),[t,c,p]),S=I=>ebs[I||"Phone"]||Un,M=({field:I,children:O})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>w(I),children:[O,c===I?p==="asc"?e.jsx(ku,{className:"ml-2 h-4 w-4"}):e.jsx(Wh,{className:"ml-2 h-4 w-4"}):e.jsx(bd,{className:"ml-2 h-4 w-4 opacity-50"})]}),L=(I,O,q)=>{b(I),j(`${O} ${q||""}`.trim())};return t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/50",children:[e.jsx(St,{className:"w-[180px]",children:e.jsx(M,{field:"name",children:"Contact"})}),e.jsx(St,{className:"w-[130px]",children:e.jsx(M,{field:"relationship_type",children:"Type"})}),e.jsx(St,{className:"w-[120px]",children:e.jsx(M,{field:"action_type",children:"Action"})}),e.jsx(St,{className:"w-[130px]",children:"Phone"}),e.jsx(St,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(zn,{children:N.map((I,O)=>{var Q,ee,X,ie,re,oe;const q=I.isSpecialDate,U=I.specialDateType,B=q?U==="birthday"?Ch:bn:S(((Q=I.actionType)==null?void 0:Q.icon)||null),V=I.contact.phone,Y=I.contact.email;return e.jsxs(Ss,{className:It("hover:bg-muted/50 transition-colors",q&&U==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",q&&U==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(dt,{className:"font-medium",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>i(`/mission-control/contacts/${I.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[I.contact.first_name," ",I.contact.last_name]})})}),e.jsx(dt,{children:I.relationshipTypeName?e.jsx(st,{variant:"secondary",className:"text-xs",children:I.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:q?e.jsx(st,{className:It("gap-1",U==="birthday"&&"bg-pink-500 hover:bg-pink-600",U==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:U==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Ch,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(bn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(B,{className:"h-3 w-3"}),(ee=I.actionType)==null?void 0:ee.name]})})}),e.jsx(dt,{children:V?e.jsx("span",{className:"text-sm font-mono",children:I.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[V&&e.jsx("a",{href:`tel:${I.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(Un,{className:"h-3.5 w-3.5"})}),V&&e.jsx("a",{href:a(I.contact.phone,(X=I.script)==null?void 0:X.script_body,I.contact),className:"p-1.5 rounded bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 transition-colors",title:"Text",children:e.jsx(so,{className:"h-3.5 w-3.5"})}),Y&&(l?e.jsx("button",{onClick:()=>l({id:I.contact.id,first_name:I.contact.first_name,last_name:I.contact.last_name,email:I.contact.email}),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Compose Email",children:e.jsx(cr,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(I.contact.email,(ie=I.script)==null?void 0:ie.script_body,(re=I.script)==null?void 0:re.email_subject,(oe=I.actionType)==null?void 0:oe.name,I.contact),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Email",children:e.jsx(cr,{className:"h-3.5 w-3.5"})})),q&&e.jsxs("button",{onClick:()=>{const ce=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,ge=U==="birthday"?"birthday":"home_anniversary",ye=new URLSearchParams({cardType:ge,contactId:I.contact.id,name:ce,...I.contact.address?{address:I.contact.address}:{},...U==="anniversary"&&I.contact.home_anniversary?{date:I.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${ye.toString()}`)},className:It("h-7 px-2 rounded text-xs font-semibold flex items-center gap-1 transition-colors",U==="birthday"?"bg-pink-500/15 hover:bg-pink-500/25 text-pink-600 dark:text-pink-400":"bg-purple-500/15 hover:bg-purple-500/25 text-purple-600 dark:text-purple-400"),title:`Send ${U==="birthday"?"Birthday":"Anniversary"} Card`,children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>L(I.contact.id,I.contact.first_name,I.contact.last_name),title:"Snooze",children:e.jsx(Rm,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var ce;return s(I.contact.id,I.actionType.id,(ce=I.script)==null?void 0:ce.id)},disabled:n,children:[e.jsx(sa,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${I.contact.id}-${O}`)})})]})}),e.jsx(Uhe,{open:!!g,onOpenChange:I=>!I&&b(null),contactId:g||"",contactName:_})]})}function Gx(){const{data:t,isLoading:s}=mt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await H.from("gmail_integrations").select("*").maybeSingle();if(o)throw o;return a}}),r=!!(t!=null&&t.is_active),n=(t==null?void 0:t.gmail_email)||null;return{isGmailConnected:r,gmailEmail:n,isLoading:s}}function sbs({onSelect:t}){const[s,r]=k.useState(null),{data:n=[],isLoading:a}=mt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:c,error:u}=await H.from("email_template_categories").select("*").order("sort_order");if(u)throw u;return c}}),{data:o=[],isLoading:l}=mt({queryKey:["agent-email-templates",s],queryFn:async()=>{let c=H.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");s&&(c=c.eq("category_id",s));const{data:u,error:p}=await c;if(p)throw p;return u}}),i=n.find(c=>c.id===s);return a?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>r(null),className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(cl,{className:"h-3.5 w-3.5"}),"Back to categories"]}),e.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx("span",{children:i==null?void 0:i.icon})," ",i==null?void 0:i.name]}),l?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No templates in this category"}):e.jsx(Gi,{className:"max-h-[280px]",children:e.jsx("div",{className:"space-y-1",children:o.map(c=>e.jsxs("button",{onClick:()=>t(c),className:"w-full p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium text-sm",children:c.title}),c.tone&&e.jsx(st,{variant:"secondary",className:"text-[10px] shrink-0",children:c.tone})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:c.subject})]},c.id))})})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1 mb-2",children:"Select a category"}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-1 pr-1",children:n.map(c=>e.jsxs("button",{onClick:()=>r(c.id),className:"w-full flex items-center justify-between p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:c.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:c.name}),c.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:c.description})]})]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},c.id))})]})}function nSe(){var a;const{user:t}=Ds(),{data:s,isLoading:r}=mt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,staleTime:60*1e3,queryFn:async()=>{var u,p,f,g;const[o,l]=await Promise.all([H.from("mass_email_settings").select("reply_to_email, display_name").eq("user_id",t.id).maybeSingle(),H.from("profiles").select("email, name").eq("id",t.id).maybeSingle()]),i=o.data,c=l.data;return{reply_to_email:((u=i==null?void 0:i.reply_to_email)==null?void 0:u.trim())||((p=c==null?void 0:c.email)==null?void 0:p.trim())||t.email||null,display_name:((f=i==null?void 0:i.display_name)==null?void 0:f.trim())||((g=c==null?void 0:c.name)==null?void 0:g.trim())||null}}});return{isReady:!!((a=s==null?void 0:s.reply_to_email)!=null&&a.trim()),isLoading:r,settings:s}}const rbs=5*1024*1024,Mv=50,nbs=["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 abs(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function ibs(t){return new Promise((s,r)=>{const n=new FileReader;n.onload=()=>{const a=n.result;s(a.split(",")[1])},n.onerror=r,n.readAsDataURL(t)})}function Ob(t,s){let r=t.replace(/\{\{first_name\}\}/gi,s.first_name).replace(/\{\{last_name\}\}/gi,s.last_name||"").replace(/\{\{full_name\}\}/gi,`${s.first_name} ${s.last_name||""}`.trim());return s.updateLink&&(r=r.replace(/\{\{update_link\}\}/gi,s.updateLink)),r}function Uw({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:c}=Ds(),u=Qt(),{isReady:p,settings:f}=nSe(),g=!!n&&n.length>0,b=g&&p,_=g?n:r?[r]:[],j=_[0],w=g?Math.ceil(_.length/Mv):1,N=g&&_.length>Mv,[S,M]=k.useState((j==null?void 0:j.email)||""),[L,I]=k.useState(a),[O,q]=k.useState(o),[U,B]=k.useState(!1),[V,Y]=k.useState(!1),[Q,ee]=k.useState([]),[X,ie]=k.useState(a),[re,oe]=k.useState(o),[ce,ge]=k.useState("composing"),[ye,ue]=k.useState(0),[pe,_e]=k.useState(0),[$e,Ae]=k.useState(0),[Ie,Ce]=k.useState(0),xe=k.useRef(!1),[we,Le]=k.useState(null);k.useEffect(()=>{t&&(M((j==null?void 0:j.email)||""),ie(a),oe(o),I(Ob(a,j||{first_name:""})),q(Ob(o,j||{first_name:""})),Y(!a&&!o),ee([]),ge("composing"),ue(0),_e(0),Ae(0),Ce(0),xe.current=!1,Le(null))},[t,j,a,o]);const tt=async Qe=>{const We=Qe.target.files;if(!We)return;const Je=Q.reduce((Dt,Vt)=>Dt+Vt.size,0),it=[];for(const Dt of Array.from(We)){if(!nbs.includes(Dt.type)){me.error(`${Dt.name}: Unsupported file type`);continue}if(Je+Dt.size>rbs){me.error("Total attachments exceed 5MB limit");break}try{const Vt=await ibs(Dt);it.push({name:Dt.name,type:Dt.type,size:Dt.size,data:Vt})}catch{me.error(`Failed to read ${Dt.name}`)}}ee(Dt=>[...Dt,...it]),Qe.target.value=""},Te=Qe=>{ee(We=>We.filter((Je,it)=>it!==Qe))},pt=Qe=>{ie(Qe.subject),oe(Qe.body),I(Ob(Qe.subject,j||{first_name:""})),q(Ob(Qe.body,j||{first_name:""})),Y(!1)},fe=Qe=>Qe.split(/\n\n+/).map(We=>`

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

`).join(""),qe=async Qe=>{const We=Ob(X,Qe),Je=Ob(re,Qe),it=fe(Je);try{if(b){const Dt=(f==null?void 0:f.display_name)||"ReLevelUp",Vt=`${Dt.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,hs=`${Dt} <${Vt}>`,{data:Ts,error:Cs}=await H.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:Qe.email,from_email:hs,subject:We,body_html:it,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(Cs)throw Cs;if(!(Ts!=null&&Ts.success))throw new Error((Ts==null?void 0:Ts.error)||"Failed to send")}else{const{data:Dt,error:Vt}=await H.functions.invoke("gmail-send",{body:{to:Qe.email,subject:We,body:it,contactId:Qe.id,attachments:Q.map(({name:hs,type:Ts,data:Cs})=>({name:hs,type:Ts,data:Cs}))}});if(Vt)throw Vt;if(!(Dt!=null&&Dt.success))throw new Error((Dt==null?void 0:Dt.error)||"Failed to send")}return c&&await H.from("bulk_email_sends").insert({user_id:c.id,contact_id:Qe.id,contact_email:Qe.email,subject:We,source:b?"ses_bulk":"sphere_gaps"}),!0}catch(Dt){return console.error("Send error:",Dt),me.error("Failed to send to "+Qe.first_name+": "+(Dt instanceof Error?Dt.message:"Unknown error")),!1}},at=()=>{const Qe=ye*Mv;return _.slice(Qe,Qe+Mv)},et=async()=>{if(!L||!O){me.error("Please fill in subject and message");return}const Qe=at();B(!0),ge("sending");let We=0,Je=0;for(let Dt=0;DtsetTimeout(hs,150));_e(Dt=>Dt+We),Ae(Dt=>Dt+Je),B(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),ye>=w-1||xe.current?ge("all_done"):ge("batch_complete")},Me=async()=>{if(!L||!O){me.error("Please fill in subject and message");return}if(!g){B(!0);const Qe=await qe(j);B(!1),Qe&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),me.success("Email sent successfully!"),s(!1),i==null||i());return}await et()},rt=async()=>{ue(Qe=>Qe+1),Ce(0),await new Promise(Qe=>setTimeout(Qe,50)),await et()};k.useEffect(()=>{},[ye]);const He=()=>{if(U){xe.current=!0;return}s(!1),i==null||i()},ct=ye*Mv,Ue=Math.min(ct+Mv,_.length),Ze=g&&_.length>0?Math.round((pe+$e)/_.length*100):0;return e.jsx(fs,{open:t,onOpenChange:He,children:e.jsxs(ps,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:`h-5 w-5 ${b?"text-orange-500":"text-red-500"}`}),g?`Send to ${_.length} Contacts`:"Compose Email"]}),b?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending via ",e.jsx("span",{className:"font-medium",children:"Mass Email"})," (reply-to: ",f==null?void 0:f.reply_to_email,")"]}):l?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:l})]}):null,g&&ce==="composing"&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Composing email for ",e.jsxs("span",{className:"font-medium",children:[_.length," contacts"]}),". You'll review each personalized email before sending."]})]}),ce==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(ws,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",ye+1," of ",w,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Ie," of ",at().length," in this batch"]})]}),e.jsx(Bi,{value:Ie/at().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",pe+$e," / ",_.length]}),e.jsxs("span",{children:[pe," sent • ",$e," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{xe.current=!0},children:"Stop Sending"})]}),ce==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(sa,{className:"h-8 w-8 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"font-medium",children:["Batch ",ye+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[pe," sent, ",$e," failed so far"]})]}),e.jsx(Bi,{value:Ze,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[_.length-pe-$e," contacts remaining (",w-ye-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:He,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:rt,children:[e.jsx(Bn,{className:"h-4 w-4"}),"Send Next ",Math.min(Mv,_.length-Ue)," Contacts"]})]})]}),ce==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(sa,{className:"h-10 w-10 text-emerald-500 mx-auto"}),e.jsx("p",{className:"font-semibold text-lg",children:"All Done!"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[pe," emails sent successfully",$e>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",$e," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:He,children:"Close"})]}),ce==="composing"&&e.jsxs("div",{className:"space-y-4",children:[V?e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 max-h-[50vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(Sn,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Y(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Rr,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(sbs,{onSelect:pt})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>Y(!0),children:[e.jsx(Sn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(rl,{}),!g&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"gmail-to",children:"To"}),e.jsx(ze,{id:"gmail-to",value:S,onChange:Qe=>M(Qe.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(ze,{id:"gmail-subject",value:L,onChange:Qe=>{I(Qe.target.value),ie(Qe.target.value)},placeholder:"Enter subject..."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(st,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{q(Qe=>Qe+"{{first_name}}"),oe(Qe=>Qe+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(st,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{q(Qe=>Qe+"{{last_name}}"),oe(Qe=>Qe+"{{last_name}}")},children:"{{last_name}}"})]})]}),e.jsx(Er,{id:"gmail-body",value:O,onChange:Qe=>{q(Qe.target.value),oe(Qe.target.value)},placeholder:"Write your message...",rows:10,className:"resize-y"}),g&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}"," to personalize. You'll preview each recipient's email in the next step."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var Qe;return(Qe=document.getElementById("gmail-attachments"))==null?void 0:Qe.click()},disabled:U,children:[e.jsx(uS,{className:"h-4 w-4"}),"Attach Files"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"PDF, images, Word, Excel (max 5MB total)"}),e.jsx("input",{id:"gmail-attachments",type:"file",multiple:!0,accept:".pdf,.jpg,.jpeg,.png,.gif,.webp,.doc,.docx,.xls,.xlsx,.csv",className:"hidden",onChange:tt})]}),Q.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Q.map((Qe,We)=>e.jsxs(st,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(uS,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:Qe.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",abs(Qe.size),")"]}),e.jsx("button",{type:"button",onClick:()=>Te(We),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Rr,{className:"h-3 w-3"})})]},We))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),g?e.jsxs(K,{onClick:()=>{Le(_[0]||null),ge("reviewing")},disabled:!L||!O,className:"gap-2",children:["Review Emails",e.jsx(Qa,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:Me,disabled:U||!L||!O,className:"gap-2",children:[U?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),U?"Sending...":"Send Email"]})]})]}),ce==="reviewing"&&g&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-xs text-primary bg-primary/10 rounded-md px-2.5 py-1.5",children:["✉️ Click any recipient below to preview the ",e.jsx("span",{className:"font-semibold",children:"exact personalized email"})," they will receive."]}),N&&e.jsxs("p",{className:"text-xs text-amber-600 bg-amber-500/10 rounded-md px-2.5 py-1.5",children:["📦 ",_.length," contacts will be sent in ",w," batches of up to ",Mv,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(be,{children:["Recipients (",_.length,")"]}),e.jsx("div",{className:"bg-muted p-1.5 rounded-md space-y-0.5 max-h-32 overflow-y-auto",children:_.map(Qe=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(we==null?void 0:we.id)===Qe.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>Le(Qe),children:[Qe.first_name," ",Qe.last_name," — ",Qe.email]},Qe.id))})]}),we&&e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 space-y-2 animate-in fade-in slide-in-from-top-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"text-xs font-semibold text-primary flex items-center gap-1.5",children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),"Preview for ",we.first_name," ",we.last_name]})}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"To:"})," ",we.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",Ob(X,we)]})]}),e.jsx(rl,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:Ob(re,we)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{ge("composing"),Le(null)},children:[e.jsx(Ja,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:Me,disabled:U,className:"gap-2",children:[U?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),N?`Send First ${Mv}`:`Send to ${_.length}`]})]})]})]})})}function obs(){const t=fr(),{data:s}=Gm(),{data:r}=qO(),n=NNe(),{isGmailConnected:a,gmailEmail:o}=Gx(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(new Set),g=$m(new Date),b=Pl(g,30),_=L=>{if(!L)return null;const I=L.split(/[-/T]/);if(I.length<3)return null;const O=parseInt(I[1],10)-1,q=parseInt(I[2],10);return isNaN(O)||isNaN(q)?null:new Date(g.getFullYear(),O,q)},j=k.useMemo(()=>{if(!s)return[];const L=[];for(const I of s){if(I.birthday){const O=_(I.birthday);O&&(Cl(O,g)||US(O,g)&&VS(O,b))&&L.push({contact:I,type:"birthday",date:O,daysUntil:mf(O,g),dateStr:I.birthday})}if(I.home_anniversary){const O=_(I.home_anniversary);O&&(Cl(O,g)||US(O,g)&&VS(O,b))&&L.push({contact:I,type:"anniversary",date:O,daysUntil:mf(O,g),dateStr:I.home_anniversary})}}return L.sort((I,O)=>I.daysUntil-O.daysUntil),L},[s]),w=async L=>{const I=(r==null?void 0:r.find(O=>O.name==="Call"))||(r==null?void 0:r[0]);if(I)try{await n.mutateAsync({contactId:L.contact.id,actionTypeId:I.id,notes:`${L.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),f(O=>new Set(O).add(`${L.contact.id}-${L.type}`)),wn({title:"Touch logged!",description:`Logged outreach for ${L.contact.first_name}`})}catch{wn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},N=L=>{const I=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,O=L.type==="birthday"?"birthday":"home_anniversary",q=new URLSearchParams({cardType:O,contactId:L.contact.id,name:I,...L.contact.address?{address:L.contact.address}:{},...L.type==="anniversary"&&L.dateStr?{date:L.dateStr}:{}});t(`/mission-control/card-studio?${q.toString()}`)},S=L=>L===0?"Today!":L===1?"Tomorrow":`${L} days`,M=L=>L===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":L<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":L<=7?"bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30":"bg-muted text-muted-foreground border-border";return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Od,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(st,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[j.length," event",j.length!==1?"s":""]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[j.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ch,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No birthdays or anniversaries in the next 30 days."}),e.jsx("p",{className:"text-xs mt-1",children:"Add dates to your contacts to see upcoming milestones here."})]}),j.map((L,I)=>{var B,V;const O=`${L.contact.id}-${L.type}`,q=p.has(O),U=`${((B=L.contact.first_name)==null?void 0:B[0])||""}${((V=L.contact.last_name)==null?void 0:V[0])||""}`.toUpperCase();return e.jsxs("div",{className:It("p-3 rounded-lg border transition-colors",L.daysUntil===0&&L.type==="birthday"?"bg-pink-500/10 border-pink-500/30 dark:bg-pink-900/20 dark:border-pink-800/40":L.daysUntil===0&&L.type==="anniversary"?"bg-blue-500/10 border-blue-500/30 dark:bg-blue-900/20 dark:border-blue-800/40":L.type==="birthday"?"bg-pink-50/60 border-pink-200/60 hover:bg-pink-100/60 dark:bg-pink-950/20 dark:border-pink-900/30 dark:hover:bg-pink-950/30":"bg-blue-50/60 border-blue-200/60 hover:bg-blue-100/60 dark:bg-blue-950/20 dark:border-blue-900/30 dark:hover:bg-blue-950/30"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(Nn,{className:It("h-10 w-10",L.type==="birthday"?"ring-2 ring-pink-300/50 dark:ring-pink-700/50":"ring-2 ring-blue-300/50 dark:ring-blue-700/50"),children:e.jsx(kn,{className:It("text-xs font-medium",L.type==="birthday"?"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"),children:U})}),e.jsx("span",{className:"absolute -bottom-1.5 -right-1.5 text-base leading-none drop-shadow-sm",children:L.type==="birthday"?"🎂":"🏠"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[L.contact.first_name," ",L.contact.last_name||""]}),e.jsx(st,{variant:"outline",className:It("text-[10px] shrink-0 whitespace-nowrap",M(L.daysUntil)),children:S(L.daysUntil)})]}),e.jsxs("div",{className:It("text-xs flex items-center gap-1.5 mt-0.5",L.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[L.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Ch,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(bn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ms(L.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[L.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Call",asChild:!0,children:e.jsx("a",{href:`tel:${L.contact.phone}`,children:e.jsx(Un,{className:"h-3.5 w-3.5"})})}),L.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Text",asChild:!0,children:e.jsx("a",{href:`sms:${L.contact.phone}`,children:e.jsx(so,{className:"h-3.5 w-3.5"})})}),L.contact.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Email",onClick:()=>{a?(i({id:L.contact.id,first_name:L.contact.first_name,last_name:L.contact.last_name,email:L.contact.email}),u(!0)):window.location.href=`mailto:${L.contact.email}`},children:e.jsx(cr,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Record video",onClick:()=>t(`/mission-control/video/record?contactId=${L.contact.id}`),children:e.jsx(An,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("h-7 px-2 gap-1 text-xs",L.type==="birthday"?"text-pink-600 hover:text-pink-700 dark:text-pink-400":"text-blue-600 hover:text-blue-700 dark:text-blue-400"),title:`Send ${L.type==="birthday"?"birthday":"anniversary"} card`,onClick:()=>N(L),children:[e.jsx(pn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:It("h-7 w-7",q&&"text-green-600"),title:"Log a touch",disabled:q||n.isPending,onClick:()=>w(L),children:e.jsx(sa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${L.contact.id}`),children:e.jsx(Ln,{className:"h-3.5 w-3.5"})})]})]},`${O}-${I}`)})]})]}),a&&l&&e.jsx(Uw,{open:c,onOpenChange:u,contact:l,gmailEmail:o})]})}function lbs(t){const[s,r]=k.useState([]),[n,a]=k.useState(!1),{data:o,isLoading:l}=mt({queryKey:["active-visitors",t],queryFn:async()=>{if(!t)return[];try{await H.rpc("cleanup_stale_visitors")}catch{}const{data:p}=await H.from("lead_site_active_visitors").select("*").eq("lead_site_id",t).gte("last_seen_at",new Date(Date.now()-2*60*1e3).toISOString()).order("last_seen_at",{ascending:!1});if(!p)return[];const f=p.map(_=>_.contact_id).filter(Boolean);let g={};if(f.length>0){const{data:_}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",f);(_||[]).forEach(j=>{g[j.id]=j})}const b=p.map(_=>_.auth_user_id).filter(Boolean);if(b.length>0){const{data:_}=await H.from("lead_site_consumer_profiles").select("user_id, name, phone, contact_id").eq("lead_site_id",t).in("user_id",b);(_||[]).forEach(j=>{const w=p.find(N=>N.auth_user_id===j.user_id);w&&!w.contact_id&&j.contact_id&&(w.contact_id=j.contact_id),w&&!g[w.contact_id||""]&&j.name&&(g[w.contact_id||w.auth_user_id||""]={first_name:j.name.split(" ")[0],last_name:j.name.split(" ").slice(1).join(" ")||null,email:null,phone:j.phone})})}return p.map(_=>{var j,w;return{..._,contact_name:g[_.contact_id||_.auth_user_id||""]?`${g[_.contact_id||_.auth_user_id||""].first_name} ${g[_.contact_id||_.auth_user_id||""].last_name||""}`.trim():null,contact_email:((j=g[_.contact_id||_.auth_user_id||""])==null?void 0:j.email)||null,contact_phone:((w=g[_.contact_id||_.auth_user_id||""])==null?void 0:w.phone)||null}})},enabled:!!t,refetchInterval:6e4});k.useEffect(()=>{if(!t)return;const p=H.channel(`active-visitors-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"lead_site_active_visitors",filter:`lead_site_id=eq.${t}`},f=>{f.eventType==="INSERT"?r(g=>g.find(_=>_.id===f.new.id)?g:[f.new,...g]):f.eventType==="UPDATE"?r(g=>g.map(b=>b.id===f.new.id?{...b,...f.new}:b)):f.eventType==="DELETE"&&r(g=>g.filter(b=>b.id!==f.old.id))}).subscribe(f=>{f==="SUBSCRIBED"&&a(!0)});return()=>{H.removeChannel(p)}},[t]);const i=n&&s.length>0?cbs([...s,...o||[]]):o||[],c=Date.now(),u=i.filter(p=>c-new Date(p.last_seen_at).getTime()<2*60*1e3);return{activeVisitors:u,isLoading:l,count:u.length}}function cbs(t){const s=new Set;return t.filter(r=>s.has(r.id)?!1:(s.add(r.id),!0))}const dbs={property_view:{label:"Viewed",icon:Ln,color:"text-blue-500",bgColor:"bg-blue-500/10"},new_lead:{label:"New Lead",icon:Tl,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},saved_listing:{label:"Saved",icon:ni,color:"text-rose-500",bgColor:"bg-rose-500/10"}};function ubs(){const{user:t}=Ds(),s=fr(),{isGmailConnected:r,gmailEmail:n}=Gx(),{leadSite:a}=rE(),{count:o}=lbs(a==null?void 0:a.id),[l,i]=k.useState(!1),[c,u]=k.useState(null),{data:p,isLoading:f}=mt({queryKey:["lead-site-activity",t==null?void 0:t.id],queryFn:async()=>{const{data:N,error:S}=await H.rpc("get_lead_site_activity",{_user_id:t.id});if(S)throw S;return N},enabled:!!t,refetchInterval:6e4});if(f||!(p!=null&&p.has_site))return null;const g=(p.activities||[]).filter(N=>N.visitor_name&&N.visitor_name!=="Site Visitor"),b=g.filter(N=>N.activity_type==="new_lead"),_=(p.activities||[]).filter(N=>N.activity_type==="property_view").length,j=(p.activities||[]).filter(N=>N.activity_type==="saved_listing").length,w=N=>{if(N.visitor_email)if(r){const S=(N.visitor_name||"").split(" ");u({id:N.contact_id||"",first_name:S[0]||"",last_name:S.slice(1).join(" ")||null,email:N.visitor_email}),i(!0)}else window.location.href=`mailto:${N.visitor_email}`};return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-primary/10 rounded-lg",children:e.jsx(su,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Website Activity"}),o>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 text-[11px] font-semibold",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-emerald-500"})]}),o," Live"]})]})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"text-primary gap-1",onClick:()=>s("/mission-control/website-activity"),children:["View All",e.jsx(Qa,{className:"h-4 w-4"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-emerald-500/5 border border-emerald-200 dark:border-emerald-800",children:[e.jsx(Tl,{className:"h-4 w-4 text-emerald-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:b.length}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"New Leads"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-blue-500/5 border border-blue-200 dark:border-blue-800",children:[e.jsx(Ln,{className:"h-4 w-4 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-blue-600 dark:text-blue-400",children:_}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Views"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-rose-500/5 border border-rose-200 dark:border-rose-800",children:[e.jsx(ni,{className:"h-4 w-4 text-rose-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-rose-600 dark:text-rose-400",children:j}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Saved"})]})]})]}),g.length>0?e.jsxs("div",{className:"space-y-2",children:[g.slice(0,5).map((N,S)=>{const M=dbs[N.activity_type],L=M.icon,I=Uc(new Date(N.occurred_at),{addSuffix:!0});return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:shadow-sm transition-shadow",children:[e.jsx("div",{className:`p-1.5 rounded-md ${M.bgColor}`,children:e.jsx(L,{className:`h-3.5 w-3.5 ${M.color}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{className:"font-medium text-sm text-primary hover:underline text-left truncate block",onClick:()=>{N.contact_id&&s(`/mission-control/contacts/${N.contact_id}`)},children:N.visitor_name}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:M.label}),N.mls_number&&e.jsxs("span",{children:["· MLS# ",N.mls_number]}),N.lead_type&&e.jsxs("span",{children:["· ",N.lead_type]}),e.jsxs("span",{children:["· ",I]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[N.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>w(N),children:e.jsx(cr,{className:"h-3.5 w-3.5"})}),N.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`tel:${N.visitor_phone}`,children:e.jsx(Un,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`sms:${N.visitor_phone}`,children:e.jsx(so,{className:"h-3.5 w-3.5"})})]}),N.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>s(`/mission-control/contacts/${N.contact_id}`),children:e.jsx(da,{className:"h-3.5 w-3.5"})})]})]},`${N.activity_type}-${N.occurred_at}-${S}`)}),g.length>5&&e.jsxs(K,{variant:"outline",className:"w-full text-xs",onClick:()=>s("/mission-control/website-activity"),children:["View ",g.length-5," more activities",e.jsx(Qa,{className:"h-3.5 w-3.5 ml-1"})]})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 text-center",children:[e.jsx(kh,{className:"h-8 w-8 text-muted-foreground/30 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No actionable website activity yet."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:_>0?`${_} anonymous listing views recorded.`:"Lead engagement will appear here as visitors interact with your site."}),e.jsxs(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>s("/mission-control/website-activity"),children:["View Full Activity",e.jsx(Qa,{className:"h-3.5 w-3.5 ml-1"})]})]})}),r&&c&&e.jsx(Uw,{open:l,onOpenChange:i,contact:c,gmailEmail:n})]})}const WFe={Crown:Dm,FileText:Sn,Users:pr,Globe:su,Star:Jn,Phone:Un,MessageSquare:so,PenTool:U_,Video:An,Gift:ko},hbs={"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 mbs(){var He,ct,Ue,Ze,Qe,We;const t=fr(),{user:s}=Ds(),{data:r}=Vx(),{data:n}=GYe(),{data:a}=Gm(),{data:o}=qO(),{data:l}=QYe(),i=fLt(),c=kNe(),u=mLt(90),p=NNe(),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(!1),[N,S]=k.useState(""),[M,L]=k.useState(!1),[I,O]=k.useState(""),[q,U]=k.useState(Zoe()),[B,V]=k.useState("cards"),[Y,Q]=k.useState(!1),[ee,X]=k.useState(null),[ie,re]=k.useState(null),[oe,ce]=k.useState(""),{isGmailConnected:ge,gmailEmail:ye}=Gx(),ue=()=>{const Je=parseInt(I,10);if(isNaN(Je)||Je<1){wn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}U(Je),XYe(Je),L(!1),wn({title:"Goal updated",description:`Weekly touch goal set to ${Je}`})},pe=()=>{O(q.toString()),L(!0)};k.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:it}=await H.from("profiles").select("name").eq("id",s.id).single();it!=null&&it.name&&S(it.name.split(" ")[0])})()},[s==null?void 0:s.id]),k.useEffect(()=>{i.mutate()},[]);const _e=$m(new Date),$e=Pl(_e,7),Ae=Je=>{if(!Je)return null;const it=Je.split(/[-/T]/);if(it.length<3)return null;const Dt=parseInt(it[1],10)-1,Vt=parseInt(it[2],10);return isNaN(Dt)||isNaN(Vt)?null:new Date(_e.getFullYear(),Dt,Vt)},Ie=(a==null?void 0:a.filter(Je=>{const it=Ae(Je.birthday),Dt=Ae(Je.home_anniversary);return it&&Cl(it,_e)||Dt&&Cl(Dt,_e)}))||[];a!=null&&a.filter(Je=>{if(!Je.birthday&&!Je.home_anniversary)return!1;const it=Dt=>{if(!Dt)return!1;const Vt=Ae(Dt);return Vt?US(Vt,_e)&&VS(Vt,$e):!1};return it(Je.birthday)||it(Je.home_anniversary)}).slice(0,5);const Ce=[],xe=(o==null?void 0:o.find(Je=>Je.name==="Call"))||(o==null?void 0:o[0]);for(const Je of Ie){const it=Ae(Je.birthday),Dt=Ae(Je.home_anniversary),Vt=it&&Cl(it,_e),hs=Dt&&Cl(Dt,_e);Vt&&Ce.push({contact:Je,actionType:xe||{id:"special-date-birthday",name:"Birthday Call",icon:"Cake",color:"#EC4899",description:"Wish them happy birthday!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:"🎂 Birthday Today!",relationshipTypeName:((Ue=(ct=(He=Je.tags)==null?void 0:He[0])==null?void 0:ct.relationship_type)==null?void 0:Ue.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),hs&&Ce.push({contact:Je,actionType:xe||{id:"special-date-anniversary",name:"Anniversary Call",icon:"Home",color:"#8B5CF6",description:"Celebrate their home anniversary!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:"🏠 Home Anniversary!",relationshipTypeName:((We=(Qe=(Ze=Je.tags)==null?void 0:Ze[0])==null?void 0:Qe.relationship_type)==null?void 0:We.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const Le=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((Je,it)=>{var Vt,hs,Ts;const Dt=o==null?void 0:o[it%((o==null?void 0:o.length)||1)];return Dt?{contact:Je,actionType:Dt,planName:"Quick Touch",relationshipTypeName:((Ts=(hs=(Vt=Je.tags)==null?void 0:Vt[0])==null?void 0:hs.relationship_type)==null?void 0:Ts.name)||"",monthNumber:0}:null}).filter(Boolean))||[],tt=[...Ce,...Le],Te=async(Je,it,Dt)=>{await p.mutateAsync({contactId:Je,actionTypeId:it,scriptUsedId:Dt}),w(!1),_(null)},pt=Je=>{Je.script?(_(Je),w(!0)):Te(Je.contact.id,Je.actionType.id)},fe=Je=>WFe[Je||"Phone"]||Un,qe=Je=>WFe[Je||"Users"]||pr,at=(Je,it)=>Je.replace(/\{\{FirstName\}\}/g,it.first_name).replace(/\{\{LastName\}\}/g,it.last_name||"").replace(/\{\{AgentName\}\}/g,N||"there"),et=(Je,it)=>({Call:`Thinking of you, ${it}!`,Text:`Quick hello, ${it}`,Email:`Checking in, ${it}`,"Handwritten Note":`A note for ${it}`,Video:`Video message for ${it}`,Gift:`Something special for you, ${it}`})[Je]||`Hello ${it}!`,Me=(Je,it,Dt)=>{const Vt=`sms:${Je}`;if(it&&Dt){const hs=at(it,Dt);return`${Vt}?body=${encodeURIComponent(hs)}`}return Vt},rt=(Je,it,Dt,Vt,hs)=>{const Ts=`mailto:${Je}`,Cs=[];if(hs){const cs=Dt||et(Vt||"Email",hs.first_name);if(Cs.push(`subject=${encodeURIComponent(cs)}`),it){const er=at(it,hs);Cs.push(`body=${encodeURIComponent(er)}`)}}return Cs.length>0?`${Ts}?${Cs.join("&")}`:Ts};return e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{title:"Mission Control",description:"Your relationship-first contact system",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Mission Control"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsx(ubs,{}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Your Sphere"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:r==null?void 0:r.filter(Je=>Je.active).map(Je=>{const it=qe(Je.icon),Dt=(n==null?void 0:n[Je.id])||0,Vt=f===Je.id,hs=hbs[Je.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Vt?(g(null),t("/mission-control/contacts")):(g(Je.id),t(`/mission-control/contacts?type=${Je.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${Vt?hs:"bg-card hover:bg-accent"} `,children:[e.jsx(it,{className:"h-5 w-5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:Je.name}),e.jsxs("div",{className:`text-sm ${Vt?"opacity-90":"text-muted-foreground"}`,children:[Dt," Contacts"]})]})]},Je.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(gu,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",e.jsx(da,{className:"h-4 w-4 ml-1"})]}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/plans"),className:"w-full",children:"Manage Plans"})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Today in Your InnerCircle"}),l!==void 0&&e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(pn,{className:"h-3 w-3"}),"Plan-based"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 border rounded-lg p-0.5",children:[e.jsx(K,{variant:B==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("cards"),title:"Card view",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:B==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("table"),title:"Table view",children:e.jsx(Mh,{className:"h-4 w-4"})})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:tt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."}),e.jsx(K,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):B==="table"?e.jsx(tbs,{actions:tt,onMarkComplete:Te,onViewScript:pt,isLoading:p.isPending,buildSmsLink:Me,buildEmailLink:rt,onGmailCompose:ge?Je=>{X(Je),Q(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[tt.map((Je,it)=>{var xt,Es,ur,Mr,Lr,fn,ki;const Dt=Je.isSpecialDate,Vt=Je.specialDateType,hs=Dt?Vt==="birthday"?Ch:bn:fe(((xt=Je.actionType)==null?void 0:xt.icon)||null),Ts=Je.contact.phone,Cs=Je.contact.email,cs=Dt?Vt==="birthday"?"#EC4899":"#8B5CF6":((Es=Je.actionType)==null?void 0:Es.color)||"#3B82F6",er=Dt?Vt==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(ur=Je.actionType)==null?void 0:ur.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Dt?"ring-2 ring-offset-2":""}`,style:Dt?{"--tw-ring-color":cs}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:cs},children:[e.jsx(hs,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:er})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${Je.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[Je.contact.first_name," ",Je.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[Ts&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${Je.contact.phone}`,className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-primary/10 hover:bg-primary/20 text-primary rounded text-xs font-medium transition-colors",title:"Call",children:[e.jsx(Un,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Me(Je.contact.phone,(Mr=Je.script)==null?void 0:Mr.script_body,Je.contact),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded text-xs font-medium transition-colors",title:"Text",children:[e.jsx(so,{className:"h-3 w-3"}),"Text"]})]}),Cs&&(ge?e.jsxs("button",{onClick:()=>{X({id:Je.contact.id,first_name:Je.contact.first_name,last_name:Je.contact.last_name,email:Je.contact.email}),Q(!0)},className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 rounded text-xs font-medium transition-colors",title:"Compose Email",children:[e.jsx(cr,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:rt(Je.contact.email,(Lr=Je.script)==null?void 0:Lr.script_body,(fn=Je.script)==null?void 0:fn.email_subject,(ki=Je.actionType)==null?void 0:ki.name,Je.contact),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 rounded text-xs font-medium transition-colors",title:"Email",children:[e.jsx(cr,{className:"h-3 w-3"}),"Email"]}))]}),Dt&&e.jsxs("button",{onClick:()=>{const Ea=`${Je.contact.first_name}${Je.contact.last_name?" "+Je.contact.last_name:""}`,dr=Vt==="birthday"?"birthday":"home_anniversary",Jr=new URLSearchParams({cardType:dr,contactId:Je.contact.id,name:Ea,...Je.contact.address?{address:Je.contact.address}:{},...Vt==="anniversary"&&Je.contact.home_anniversary?{date:Je.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${Jr.toString()}`)},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 rounded text-xs font-semibold bg-gradient-to-r from-pink-500/15 to-violet-500/15 hover:from-pink-500/25 hover:to-violet-500/25 text-pink-600 dark:text-pink-400 transition-colors",children:[e.jsx(cr,{className:"h-3 w-3"}),"Send ",Vt==="birthday"?"Birthday":"Anniversary"," Card"]}),!Ts&&!Cs&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[Je.relationshipTypeName&&e.jsx(st,{variant:"secondary",className:"text-xs",children:Je.relationshipTypeName}),Je.monthNumber>0&&e.jsxs(st,{variant:"outline",className:"text-xs",children:["Month ",Je.monthNumber]})]}),Je.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>pt(Je),children:"View Script"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{re(Je.contact.id),ce(`${Je.contact.first_name} ${Je.contact.last_name||""}`.trim())},children:[e.jsx(Rm,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var Ea;return Te(Je.contact.id,Je.actionType.id,(Ea=Je.script)==null?void 0:Ea.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},Je.contact.id+it)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"h-full w-full",children:[e.jsx(fx,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(Bd,{children:e.jsx(Ma,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rt,{className:"text-lg",children:"Momentum"}),e.jsxs(fs,{open:M,onOpenChange:L,children:[e.jsx(qi,{asChild:!0,children:e.jsx("button",{onClick:pe,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Xo,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(ps,{className:"sm:max-w-[360px]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Set Weekly Goal"}),e.jsx(Gr,{children:"How many touches do you want to complete each week?"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(ze,{id:"weekly-goal-ic",type:"number",min:"1",value:I,onChange:Je=>O(Je.target.value),placeholder:"20",onKeyDown:Je=>{Je.key==="Enter"&&ue()}})]}),e.jsx(K,{onClick:ue,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Bi,{value:Math.min(c.actionsThisWeek/q*100,100),className:"h-3 w-full max-w-full"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(eh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("span",{className:"font-medium",children:[c.actionsThisWeek," / ",q]}),e.jsx("span",{className:"text-muted-foreground",children:"Actions Completed This Week"})]}),c.streak>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-lg",children:"🔥"}),e.jsx("span",{className:"font-medium",children:"Great Job!"}),e.jsxs("span",{className:"text-muted-foreground",children:["Keep Your Streak Going! (",c.streak," days)"]})]}),u.count>0&&e.jsxs("button",{onClick:()=>t("/mission-control/contacts?filter=not-touched-90"),className:"flex items-start gap-2 text-sm pt-2 border-t w-full text-left hover:bg-accent/50 -mx-4 px-4 py-2 rounded-md transition-colors",children:[e.jsx(un,{className:"h-4 w-4 text-orange-500 mt-0.5"}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:[u.count," Contact",u.count!==1?"s":""]}),e.jsx("span",{className:"text-muted-foreground",children:" Not Reached in 90+ Days"})]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground ml-auto mt-0.5"})]})]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsx(mXe,{}),e.jsx(obs,{})]})]}),e.jsx(fs,{open:j,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{className:"flex items-center gap-2",children:b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:b.actionType.color||"#3B82F6"}}),b.actionType.name," Script"]})})}),b&&b.script&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["For: ",e.jsxs("span",{className:"font-medium text-foreground",children:[b.contact.first_name," ",b.contact.last_name]})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg",children:e.jsx("p",{className:"whitespace-pre-wrap",children:at(b.script.script_body,b.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>w(!1),children:"Close"}),e.jsx(K,{className:"flex-1",onClick:()=>{var Je;return Te(b.contact.id,b.actionType.id,(Je=b.script)==null?void 0:Je.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(Z1s,{})]}),ge&&ee&&e.jsx(Uw,{open:Y,onOpenChange:Q,contact:ee,gmailEmail:ye}),e.jsx(Uhe,{open:!!ie,onOpenChange:Je=>!Je&&re(null),contactId:ie||"",contactName:oe})]})}var kat="Toggle",aSe=k.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=ah({prop:r,onChange:a,defaultProp:n??!1,caller:kat});return e.jsx(nn.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Ir(t.onClick,()=>{t.disabled||i(!l)})})});aSe.displayName=kat;var Sat=aSe,Vw="ToggleGroup",[Cat]=ad(Vw,[Aw]),Mat=Aw(),iSe=ht.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(pbs,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(fbs,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Vw}\``)});iSe.displayName=Vw;var[Tat,Aat]=Cat(Vw),pbs=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=ah({prop:r,defaultProp:n??"",onChange:a,caller:Vw});return e.jsx(Tat,{scope:t.__scopeToggleGroup,type:"single",value:ht.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ht.useCallback(()=>i(""),[i]),children:e.jsx(Eat,{...o,ref:s})})}),fbs=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=ah({prop:r,defaultProp:n??[],onChange:a,caller:Vw}),c=ht.useCallback(p=>i((f=[])=>[...f,p]),[i]),u=ht.useCallback(p=>i((f=[])=>f.filter(g=>g!==p)),[i]);return e.jsx(Tat,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:c,onItemDeactivate:u,children:e.jsx(Eat,{...o,ref:s})})});iSe.displayName=Vw;var[xbs,gbs]=Cat(Vw),Eat=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...c}=t,u=Mat(r),p=Tw(l),f={role:"group",dir:p,...c};return e.jsx(xbs,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(Dde,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(nn.div,{...f,ref:s})}):e.jsx(nn.div,{...f,ref:s})})}),Gce="ToggleGroupItem",Pat=ht.forwardRef((t,s)=>{const r=Aat(Gce,t.__scopeToggleGroup),n=gbs(Gce,t.__scopeToggleGroup),a=Mat(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},c=ht.useRef(null);return n.rovingFocus?e.jsx(Ode,{asChild:!0,...a,focusable:!l,active:o,ref:c,children:e.jsx(GFe,{...i,ref:s})}):e.jsx(GFe,{...i,ref:s})});Pat.displayName=Gce;var GFe=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=Aat(Gce,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(aSe,{...i,...a,ref:s,onPressedChange:c=>{c?o.onItemActivate(n):o.onItemDeactivate(n)}})}),Iat=iSe,Lat=Pat;const Dat=pC("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),ybs=k.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(Sat,{ref:a,className:It(Dat({variant:s,size:r,className:t})),...n}));ybs.displayName=Sat.displayName;const Oat=k.createContext({size:"default",variant:"default"}),Rat=k.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(Iat,{ref:o,className:It("flex items-center justify-center gap-1",t),...a,children:e.jsx(Oat.Provider,{value:{variant:s,size:r},children:n})}));Rat.displayName=Iat.displayName;const Fat=k.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=k.useContext(Oat);return e.jsx(Lat,{ref:o,className:It(Dat({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});Fat.displayName=Lat.displayName;const vbs=[{value:"bidirectional",label:"Two-Way",icon:bd,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:ku,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Wh,tooltip:"Only pull BoldTrail → Agent OS"}];function B_e({value:t,onChange:s,size:r="default"}){const n=r==="sm"?"text-xs":"text-sm";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:`font-medium ${n} text-muted-foreground`,children:"Sync Direction"}),e.jsx(Rat,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:vbs.map(a=>e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(Fat,{value:a.value,"aria-label":a.tooltip,className:`gap-1.5 ${n} border border-transparent data-[state=on]:!bg-primary data-[state=on]:!text-primary-foreground data-[state=on]:!border-primary data-[state=on]:shadow-sm`,children:[e.jsx(a.icon,{className:r==="sm"?"h-3 w-3":"h-4 w-4"}),a.label]})}),e.jsx(Xl,{children:a.tooltip})]},a.value))})]})}function bbs(){const t=Qt(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(0),j=k.useRef(!1),{data:w}=mt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(V)throw V;return B}}),N=(w==null?void 0:w.sync_direction)||"bidirectional",S=u??N,M=Lt({mutationFn:async()=>{const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(V)throw V;if(B!=null&&B.error)throw new Error(B.error);return B},onSuccess:B=>{p(null),a(B),r(!0)},onError:B=>{me.error(B.message||"Failed to generate sync preview")}}),L=Lt({mutationFn:async()=>{j.current=!1,g("Initializing sync..."),_(5);const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:S}});if(V)throw V;if(B!=null&&B.error)throw new Error(B.error);const Y=B;let Q=Y.sync_log_id,ee=Y.next_phase,X=Y.next_offset;const ie=Y.push_total||0,re=Y.pull_total||0,oe=Y.update_total||0,ce=ie+re+oe;let ge=0,ye=0,ue=0;for(;ee!=="finalize"&&!j.current;){ee==="push"?(g(`Pushing contacts to BoldTrail... (${ge}/${ie})`),_(ce>0?ge/ce*90:0)):ee==="pull"?(g(`Pulling contacts from BoldTrail... (${ye}/${re})`),_(ce>0?(ie+ye)/ce*90:0)):ee==="update"&&(g(`Updating existing contacts... (${ue}/${oe})`),_(ce>0?(ie+re+ue)/ce*90:0));const{data:$e,error:Ae}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:ee,offset:X,sync_log_id:Q,sync_direction:S}});if(Ae)throw Ae;if($e!=null&&$e.error)throw new Error($e.error);const Ie=$e;ge+=Ie.chunk_pushed||0,ye+=Ie.chunk_pulled||0,ue+=Ie.chunk_updated||0,Ie.progress&&g(Ie.progress),ee=Ie.next_phase,X=Ie.next_offset}g("Finalizing sync..."),_(95);const{data:pe,error:_e}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:Q,sync_direction:S}});if(_e)throw _e;return _(100),pe},onSuccess:B=>{g(null),_(0),r(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]});const V=[`Pushed ${B.contacts_pushed||0}`,`pulled ${B.contacts_pulled||0}`,`updated ${B.contacts_updated||0}`,`skipped ${B.contacts_skipped||0} duplicates`];me.success(`Sync complete! ${V.join(", ")}.`)},onError:B=>{g(null),_(0),me.error(B.message||"Sync failed")}});if(!(w!=null&&w.connected))return null;const I=S==="pull_only"?0:(n==null?void 0:n.to_push)??0,O=S==="push_only"?0:(n==null?void 0:n.to_pull)??0,q=(n==null?void 0:n.to_update)??0,U=I>0||O>0||q>0;return e.jsxs(e.Fragment,{children:[e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",onClick:()=>M.mutate(),disabled:M.isPending,className:"shrink-0",children:M.isPending?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx(bd,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(Xl,{children:"Sync with BoldTrail"})]}),e.jsx(fs,{open:s,onOpenChange:B=>{L.isPending||r(B)},children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(bd,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Gr,{children:"Review what will happen when you sync your contacts."})]}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(B_e,{value:S,onChange:p,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:I}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(ku,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:O}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Wh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-amber-600",children:q}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(BM,{className:"h-3 w-3"})," To update"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:n.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(pr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",n.agent_os_total," contacts · BoldTrail: ",n.boldtrail_total," contacts"]}),q>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center bg-amber-50 dark:bg-amber-950/30 rounded-md p-2",children:[e.jsx(BM,{className:"h-3 w-3 inline mr-1"}),q," contacts have missing fields that will be filled from the other system"]}),I>0&&e.jsxs(yf,{open:o,onOpenChange:l,children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ku,{className:"h-3 w-3 text-emerald-600"}),I," contacts to push to BoldTrail"]}),e.jsx(Eo,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(bf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map((B,V)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:B.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:B.email})]},V)),n.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_push-20," more"]})]})})]}),O>0&&e.jsxs(yf,{open:i,onOpenChange:c,children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wh,{className:"h-3 w-3 text-blue-600"}),O," contacts to pull from BoldTrail"]}),e.jsx(Eo,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(bf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map((B,V)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:B.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:B.email})]},V)),n.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_pull-20," more"]})]})})]}),!U&&!L.isPending&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer or update."}),L.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Bi,{value:b||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:f||"Sync in progress..."})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),disabled:L.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>L.mutate(),disabled:L.isPending||!U,className:"gap-2",children:[L.isPending?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx(bd,{className:"h-4 w-4"}),L.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const _bs=()=>{const{user:t}=Ds();return mt({queryKey:["popby-items",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("popby_items").select("*").or(`owner_user_id.is.null,owner_user_id.eq.${t==null?void 0:t.id}`).eq("is_active",!0).order("name");if(r)throw r;return s},enabled:!!t})},Vhe=t=>{const{user:s}=Ds();return mt({queryKey:["popby-logs",s==null?void 0:s.id,t],queryFn:async()=>{let r=H.from("popby_logs").select("*").order("completed_at",{ascending:!1});if(t){const o=new Date;o.setDate(o.getDate()-t),r=r.gte("completed_at",o.toISOString())}const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})},oSe=()=>{const{user:t}=Ds();return mt({queryKey:["relationship-type-popby-defaults",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("relationship_type_popby_defaults").select("*");if(r)throw r;return s},enabled:!!t})},zat=()=>{const{user:t}=Ds();return mt({queryKey:["contact-popby-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_popby_settings").select("*");if(r)throw r;return s},enabled:!!t})},wbs=()=>{const{data:t}=Gm(),{data:s}=Vx(),{data:r}=Vhe(),{data:n}=zat(),{data:a}=oSe(),o=new Map;r==null||r.forEach(p=>{const f=o.get(p.contact_id);(!f||new Date(p.completed_at)>new Date(f))&&o.set(p.contact_id,p.completed_at)});const l=new Map;a==null||a.forEach(p=>l.set(p.relationship_type_id,p.frequency_days));const i=new Map;n==null||n.filter(p=>p.is_active).forEach(p=>{i.set(p.contact_id,p.frequency_days)});const c=$m(new Date);return(t||[]).map(p=>{let f=90;if(i.has(p.id))f=i.get(p.id);else if(p.tags&&p.tags.length>0){const w=p.tags.map(N=>l.get(N.relationship_type_id)).filter(N=>N!==void 0);w.length>0&&(f=Math.min(...w))}const g=o.get(p.id)||null,b=g?ly(c,$m(new Date(g))):null,_=b===null||b>=f,j=_&&b!==null?b-f:0;return{...p,lastPopby:g,daysSinceLastPopby:b,frequencyDays:f,isDue:_,daysOverdue:j}}).sort((p,f)=>f.daysOverdue-p.daysOverdue)},Bat=()=>wbs().filter(s=>s.isDue),jbs=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{const{error:n}=await H.from("popby_items").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-items"]}),wn({title:"Popby item created!"})},onError:r=>{wn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},Nbs=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{const{error:n}=await H.from("popby_logs").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-logs"]}),wn({title:"Popby logged!"})},onError:r=>{wn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},kbs=()=>{const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async r=>{const{error:n}=await H.from("relationship_type_popby_defaults").upsert({...r,owner_user_id:s==null?void 0:s.id},{onConflict:"relationship_type_id,owner_user_id"});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["relationship-type-popby-defaults"]}),wn({title:"Frequency updated!"})},onError:r=>{wn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},Sbs=()=>{const{data:t}=Vhe(30),s=Bat(),r=new Date;r.setDate(r.getDate()-7);const n=(t==null?void 0:t.filter(o=>new Date(o.completed_at)>=r).length)||0,a=(t==null?void 0:t.length)||0;return{thisWeekCount:n,thisMonthCount:a,dueCount:s.length}};function Cbs(){const{user:t}=Ds();return mt({queryKey:["contact-touch-logs",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function $at(t){const{data:s}=Cbs(),{data:r}=zat(),{data:n}=oSe(),{data:a}=Y1s();return k.useMemo(()=>{const o=a==null?void 0:a.find(w=>w.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=$m(new Date);if(l&&!VS(l,i))return{nextTouchDate:l,daysUntil:ly(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(w=>w.contact_id===t.id))||[]).sort((w,N)=>new Date(N.completed_at).getTime()-new Date(w.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let f=90;const g=r==null?void 0:r.find(w=>w.contact_id===t.id&&w.is_active);if(g)f=g.frequency_days;else if(t.tags&&t.tags.length>0){const w=t.tags.map(N=>{const S=n==null?void 0:n.find(M=>M.relationship_type_id===N.relationship_type_id);return S==null?void 0:S.frequency_days}).filter(N=>N!==void 0);w.length>0&&(f=Math.min(...w))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const b=Pl($m(p),f),_=ly(b,i);let j;return _<0?j="overdue":_<=7?j="due-soon":j="on-track",{nextTouchDate:b,daysUntil:_,status:j,frequencyDays:f,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function $_e({contact:t}){const s=$at(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:kl,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:un,text:s.daysUntil===0?"Due today":`Due in ${s.daysUntil} days`,className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400"};case"on-track":return{variant:"secondary",icon:sa,text:`Next touch in ${s.daysUntil} days`,className:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-400"};case"snoozed":return{variant:"secondary",icon:Rm,text:`Snoozed until ${ms(s.snoozedUntil,"MMM d")}`,className:"bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"};case"never-touched":return{variant:"outline",icon:hn,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(st,{variant:n.variant,className:It("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function Mbs({contact:t,onLogTouch:s,onSnooze:r}){const n=$at(t),a=Q1s(),[o,l]=k.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"}},c=()=>{switch(n.status){case"overdue":return e.jsx(kl,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(un,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(sa,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(Rm,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(hn,{className:"h-5 w-5 text-muted-foreground"})}},u=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c(),e.jsx("span",{className:It("font-medium",i()),children:u()})]}),n.status==="snoozed"&&n.snoozedUntil&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Snoozed until:"})," ",ms(n.snoozedUntil,"MMMM d, yyyy")]}),n.status!=="snoozed"&&n.nextTouchDate&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Scheduled:"})," ",ms(n.nextTouchDate,"MMMM d, yyyy")]}),n.lastTouchDate&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Last touch:"})," ",ms(n.lastTouchDate,"MMM d, yyyy")]}),n.status!=="snoozed"&&e.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-2",children:["Touch frequency: Every ",n.frequencyDays," days"]}),n.status==="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:p,disabled:a.isPending,children:[e.jsx(Rr,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(K,{size:"sm",className:"flex-1",onClick:s,children:"Log Touch"})]}),n.status!=="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(Rm,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(K,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(Uhe,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const xye=768;function SE(){const[t,s]=k.useState(void 0);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${xye-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function Tbs(){const{user:t}=Ds(),{hasLeadSite:s,leadSite:r}=rE(),{data:n,isLoading:a}=mt({queryKey:["website-active-contacts",t==null?void 0:t.id,r==null?void 0:r.id],queryFn:async()=>{if(!r)return new Set;const{data:o}=await H.from("lead_site_visitors").select("contact_id").eq("lead_site_id",r.id).not("contact_id","is",null),{data:l}=await H.from("lead_site_consumer_profiles").select("contact_id").eq("lead_site_id",r.id).not("contact_id","is",null),i=new Set;return(o||[]).forEach(c=>{c.contact_id&&i.add(c.contact_id)}),(l||[]).forEach(c=>{c.contact_id&&i.add(c.contact_id)}),i},enabled:!!t&&s,staleTime:5*60*1e3});return{activeContactIds:n??new Set,hasLeadSite:s,isLoading:a}}const Abs={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"}},Ebs={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 _8({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=Abs[t.status],l=Ebs[n],i=e.jsxs("div",{className:It("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:It("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(B1,{children:e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:i}),e.jsx(Xl,{side:"top",className:"w-64 p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-semibold",children:"Relationship Score"}),e.jsxs("span",{className:It("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(Bi,{value:t.score,className:"h-2"}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Recency"}),e.jsxs("span",{children:[t.breakdown.recency,"/40"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Touchpoints (12mo)"}),e.jsxs("span",{children:[t.breakdown.touchpoints,"/30"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transactions"}),e.jsxs("span",{children:[t.breakdown.transactions,"/20"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referrals"}),e.jsxs("span",{children:[t.breakdown.referrals,"/10"]})]})]}),t.daysSinceTouch!==null&&e.jsxs("p",{className:"text-xs text-muted-foreground pt-1 border-t",children:["Last contact: ",t.daysSinceTouch===0?"Today":`${t.daysSinceTouch} days ago`]}),t.daysSinceTouch===null&&e.jsx("p",{className:"text-xs text-muted-foreground pt-1 border-t italic",children:"Never contacted"})]})})]})}):i}const Pbs=[{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}],Wz=t=>{if(!t||!t.trim())return null;const s=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s;const r=s.match(/^(\d{1,2})[\/\-](\d{1,2})(?:[\/\-](\d{2,4}))?$/);if(r){const a=r[1].padStart(2,"0"),o=r[2].padStart(2,"0");let l="2000";r[3]&&(l=r[3].length===2?(parseInt(r[3])>50?"19":"20")+r[3]:r[3]);const i=parseInt(a),c=parseInt(o);if(i>=1&&i<=12&&c>=1&&c<=31)return`${l}-${a}-${o}`}const n=new Date(s);return isNaN(n.getTime())?null:n.toISOString().split("T")[0]},Ibs=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Ds(),{toast:o}=Ua(),l=k.useRef(null),[i,c]=k.useState("upload"),[u,p]=k.useState([]),[f,g]=k.useState([]),[b,_]=k.useState({}),[j,w]=k.useState([]),[N,S]=k.useState([]),[M,L]=k.useState(!1),[I,O]=k.useState(null),q=()=>{c("upload"),p([]),g([]),_({}),w([]),S([]),O(null),l.current&&(l.current.value="")},U=()=>{q(),s(!1)},B=ye=>{const ue=ye.split(` `).map(Ae=>Ae.trim()).filter(Ae=>Ae);if(ue.length===0)return{headers:[],data:[]};const pe=Ae=>{const Ie=[];let Ce="",xe=!1;for(let we=0;we{var _e;const ue=(_e=ye.target.files)==null?void 0:_e[0];if(!ue)return;const pe=new FileReader;pe.onload=$e=>{var we;const Ae=(we=$e.target)==null?void 0:we.result,{headers:Ie,data:Ce}=B(Ae);if(Ie.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Ie),g(Ce);const xe={};Ie.forEach(Le=>{const tt=Le.toLowerCase().replace(/[_\s-]/g,"");tt.includes("firstname")||tt==="first"?xe.first_name=Le:tt.includes("lastname")||tt==="last"?xe.last_name=Le:tt.includes("spouse")&&tt.includes("email")?xe.spouse_email=Le:tt.includes("spouse")||tt.includes("partner")?xe.spouse_name=Le:tt.includes("email")?xe.email=Le:tt.includes("phone")||tt.includes("mobile")||tt.includes("cell")?xe.phone=Le:tt.includes("address")||tt.includes("street")?xe.address=Le:tt==="city"?xe.city=Le:tt==="state"||tt==="province"?xe.state=Le:tt==="zip"||tt==="zipcode"||tt==="postalcode"?xe.zip=Le:tt.includes("company")||tt.includes("organization")||tt.includes("business")?xe.company_name=Le:tt.includes("jobtitle")||tt.includes("title")&&!tt.includes("spouse")?xe.job_title=Le:tt.includes("birthday")||tt.includes("dob")||tt.includes("birthdate")?xe.birthday=Le:tt.includes("anniversary")||tt.includes("homeanniversary")?xe.home_anniversary=Le:(tt.includes("notes")||tt.includes("comment"))&&(xe.notes=Le)}),_(xe),c("mapping")},pe.readAsText(ue)},Y=(ye,ue)=>{_(pe=>{if(ue==="none"){const{[ye]:_e,...$e}=pe;return $e}return{...pe,[ye]:ue}})},Q=ye=>{w(ue=>ue.includes(ye)?ue.filter(pe=>pe!==ye):[...ue,ye])},ee=async()=>{if(!(a!=null&&a.id))return;const{data:ye}=await H.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),ue=new Set((ye||[]).filter($e=>$e.email).map($e=>$e.email.toLowerCase())),pe=new Set((ye||[]).filter($e=>$e.phone).map($e=>$e.phone.replace(/[^0-9]/g,""))),_e=f.map($e=>{const Ae=tt=>{const Te=b[tt];if(!Te)return"";const pt=u.indexOf(Te);return pt>=0?($e[pt]||"").trim():""},Ie=Ae("first_name"),Ce=Ae("email"),xe=Ae("phone"),we=Ie.length>0,Le=!!(Ce&&ue.has(Ce.toLowerCase())||xe&&pe.has(xe.replace(/[^0-9]/g,"")));return{first_name:Ie,last_name:Ae("last_name"),email:Ce,phone:xe,address:Ae("address"),city:Ae("city"),state:Ae("state"),zip:Ae("zip"),spouse_name:Ae("spouse_name"),spouse_email:Ae("spouse_email"),company_name:Ae("company_name"),job_title:Ae("job_title"),birthday:Ae("birthday"),home_anniversary:Ae("home_anniversary"),notes:Ae("notes"),isValid:we,isDuplicate:Le,error:we?void 0:"First name is required"}});S(_e),c("preview")},X=ye=>{const ue=ye.trim().split(/\s+/);return{first_name:ue[0],last_name:ue.length>1?ue.slice(1).join(" "):null}},ie=async()=>{if(!(a!=null&&a.id))return;const ye=N.filter($e=>$e.isValid);if(ye.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}L(!0);let ue=0,pe=0,_e=0;try{for(const $e of ye)try{let Ae=null;if($e.email){const{data:xe}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",$e.email).maybeSingle();Ae=xe}if(!Ae&&$e.phone){const xe=$e.phone.replace(/[^0-9]/g,""),{data:we}=await H.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(we){const Le=we.find(tt=>tt.phone&&tt.phone.replace(/[^0-9]/g,"")===xe);Le&&(Ae={id:Le.id})}}const Ie={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:Wz($e.birthday),home_anniversary:Wz($e.home_anniversary),notes:$e.notes||null};let Ce=null;if(Ae){const{data:xe}=await H.from("innercircle_contacts").select("*").eq("id",Ae.id).single();if(xe){const we={},Le=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const tt of Le){const Te=xe[tt],pt=Ie[tt];(!Te||Te==="")&&pt&&(we[tt]=pt)}Object.keys(we).length>0&&await H.from("innercircle_contacts").update(we).eq("id",Ae.id)}Ce=Ae.id,pe++}else{const{data:xe,error:we}=await H.from("innercircle_contacts").insert(Ie).select("id").single();we?(console.error("Insert error for contact:",$e.first_name,we),_e++):xe?(Ce=xe.id,j.length>0&&await H.from("innercircle_contact_tags").insert(j.map(Le=>({contact_id:xe.id,relationship_type_id:Le}))),ue++):_e++}if(Ce&&$e.spouse_name){const xe=X($e.spouse_name);let we=null;if($e.spouse_email){const{data:tt}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",$e.spouse_email).maybeSingle();we=tt}if(!we){const{data:tt}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",xe.first_name).eq("last_name",xe.last_name||$e.last_name||"").maybeSingle();we=tt}let Le=null;if(we){Le=we.id;const tt=Wz($e.home_anniversary);tt&&await H.from("innercircle_contacts").update({home_anniversary:tt}).eq("id",we.id).is("home_anniversary",null)}else{const{data:tt}=await H.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:xe.first_name,last_name:xe.last_name||$e.last_name||null,email:$e.spouse_email||null,address:$e.address||null,city:$e.city||null,state:$e.state||null,zip:$e.zip||null,home_anniversary:Wz($e.home_anniversary),spouse_name:`${$e.first_name}${$e.last_name?" "+$e.last_name:""}`,spouse_email:$e.email||null,notes:`Spouse of ${$e.first_name} ${$e.last_name||""} (imported via CSV)`.trim()}).select("id").single();tt&&(Le=tt.id,ue++)}Le&&(await H.from("innercircle_contacts").update({spouse_contact_id:Le}).eq("id",Ce),await H.from("innercircle_contacts").update({spouse_contact_id:Ce}).eq("id",Le))}}catch(Ae){console.error("Error importing contact:",Ae),_e++}O({created:ue,updated:pe,failed:_e}),c("result"),(ue>0||pe>0)&&n(),o({title:"Import Complete",description:`${ue} created, ${pe} updated${_e>0?`, ${_e} failed`:""}.`})}catch($e){console.error("Import error:",$e),o({title:"Import Failed",description:$e.message||"Failed to import contacts",variant:"destructive"})}finally{L(!1)}},re=N.filter(ye=>ye.isValid).length,oe=N.filter(ye=>!ye.isValid).length,ce=N.filter(ye=>ye.isValid&&ye.isDuplicate).length,ge=re-ce;return e.jsx(fs,{open:t,onOpenChange:U,children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(a1,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(Gr,{children:"Upload a CSV file with your contacts. You can map columns and select relationship types."})]}),i==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:V,className:"hidden"}),e.jsx(li,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var ye;return(ye=l.current)==null?void 0:ye.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Supported Fields:"}),e.jsx("p",{className:"text-muted-foreground text-xs mb-3",children:"First Name, Last Name, Email, Phone, Street Address, City, State, Zip, Spouse Name, Spouse Email, Company, Job Title, Birthday, Home Anniversary, Notes"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const ye=`First Name,Last Name,Email,Phone,Street Address,City,State,Zip,Spouse Name,Spouse Email,Company,Job Title,Birthday,Home Anniversary,Notes John,Doe,john@example.com,555-123-4567,123 Main St,Austin,TX,78701,Jane Doe,jane@example.com,ABC Realty,Real Estate Agent,1985-06-15,2020-03-22,Met at open house`,ue=new Blob([ye],{type:"text/csv"}),pe=URL.createObjectURL(ue),_e=document.createElement("a");_e.href=pe,_e.download="contact_import_template.csv",_e.click(),URL.revokeObjectURL(pe)},children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download Template"]})]})]}),i==="mapping"&&e.jsxs("div",{className:"flex-1 overflow-auto space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:Pbs.map(ye=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(be,{className:"w-40 text-sm",children:[ye.label,ye.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Ks,{value:b[ye.key]||"none",onValueChange:ue=>Y(ye.key,ue),children:[e.jsx(Hs,{className:"w-48",children:e.jsx(Ys,{placeholder:"Select column..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"-- Not mapped --"}),u.map(ue=>e.jsx(Mt,{value:ue,children:ue},ue))]})]})]},ye.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(ye=>e.jsx(st,{variant:j.includes(ye.id)?"default":"outline",className:"cursor-pointer",onClick:()=>Q(ye.id),children:ye.name},ye.id))})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:e.jsxs("p",{className:"text-muted-foreground",children:["Preview: ",f.length," row(s) found in CSV"]})})]}),i==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[ge," new"]})]}),ce>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(kl,{className:"h-4 w-4"}),e.jsxs("span",{children:[ce," existing (will merge gaps)"]})]}),oe>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(kl,{className:"h-4 w-4"}),e.jsxs("span",{children:[oe," invalid"]})]})]}),ce>0&&e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-xs text-muted-foreground",children:"Duplicates matched by email or phone will only fill in missing fields — your existing data won't be overwritten."}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/30",children:[e.jsx(St,{children:"First Name"}),e.jsx(St,{children:"Last Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Phone"}),e.jsx(St,{children:"Status"})]})}),e.jsx(zn,{children:N.slice(0,100).map((ye,ue)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:ye.first_name}),e.jsx(dt,{children:ye.last_name}),e.jsx(dt,{children:ye.email}),e.jsx(dt,{children:ye.phone}),e.jsx(dt,{children:ye.isValid?ye.isDuplicate?e.jsx(st,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(st,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(st,{variant:"destructive",children:ye.error||"Invalid"})})]},ue))})]}),N.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",N.length," contacts"]})]})]}),i==="result"&&I&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(sa,{className:"h-12 w-12 mx-auto text-primary"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground",children:[I.created," created, ",I.updated," merged"]}),I.failed>0&&e.jsxs("p",{className:"text-destructive",children:[I.failed," failed to import"]})]}),e.jsxs(qn,{children:[i==="upload"&&e.jsx(K,{variant:"outline",onClick:U,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:q,children:"Back"}),e.jsx(K,{onClick:ee,disabled:!b.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>c("mapping"),children:"Back"}),e.jsx(K,{onClick:ie,disabled:M||re===0,children:M?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${re} Contact${re!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:U,children:"Done"})]})]})})};function Lbs(){return"contacts"in navigator&&"ContactsManager"in window}function Dbs(t){const s=[],r=t.split("BEGIN:VCARD").filter(n=>n.trim());for(const n of r){const a=n.split(/\r?\n/);let o="",l="",i="",c="",u="";for(const p of a){const f=p.replace(/^\s+/,"");if(f.startsWith("N:")||f.startsWith("N;")){const b=f.substring(f.indexOf(":")+1).split(";");l=(b[0]||"").trim(),o=(b[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const b=f.substring(f.indexOf(":")+1).trim().split(" ");o=b[0]||"",l=b.slice(1).join(" ")}(f.startsWith("EMAIL")||f.match(/^item\d+\.EMAIL/i))&&!i&&(i=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("TEL")||f.match(/^item\d+\.TEL/i))&&!c&&(c=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("ADR")||f.match(/^item\d+\.ADR/i))&&!u&&(u=f.substring(f.indexOf(":")+1).split(";").map(_=>_.trim()).filter(Boolean).join(", "))}(o||l)&&s.push({first_name:o,last_name:l,email:i,phone:c,address:u})}return s}function Obs({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Ds(),{data:a}=Gm(),o=wue(),l=k.useRef(null),[i,c]=k.useState("choose"),[u,p]=k.useState([]),[f,g]=k.useState(new Set),[b,_]=k.useState(0),[j,w]=k.useState(0),N=Lbs(),S=k.useCallback(Y=>{if(!a)return Y;const Q=new Set(a.filter(X=>X.email).map(X=>X.email.toLowerCase())),ee=new Set(a.filter(X=>X.phone).map(X=>X.phone.replace(/\D/g,"")));return Y.map(X=>{var oe,ce;const ie=(oe=X.email)==null?void 0:oe.toLowerCase(),re=(ce=X.phone)==null?void 0:ce.replace(/\D/g,"");return ie&&Q.has(ie)?{...X,isDuplicate:!0,duplicateField:"email"}:re&&re.length>=7&&ee.has(re)?{...X,isDuplicate:!0,duplicateField:"phone"}:X})},[a]),M=async()=>{try{const Y=["name","email","tel","address"],Q=await navigator.contacts.select(Y,{multiple:!0});if(!Q||Q.length===0)return;const ee=Q.map(re=>{var ge,ye,ue,pe;const ce=(((ge=re.name)==null?void 0:ge[0])||"").split(" ");return{first_name:ce[0]||"",last_name:ce.slice(1).join(" "),email:((ye=re.email)==null?void 0:ye[0])||"",phone:((ue=re.tel)==null?void 0:ue[0])||"",address:(pe=re.address)!=null&&pe[0]?[re.address[0].streetAddress,re.address[0].city,re.address[0].region,re.address[0].postalCode].filter(Boolean).join(", "):""}}),X=S(ee);p(X);const ie=new Set;X.forEach((re,oe)=>{re.isDuplicate||ie.add(oe)}),g(ie),c("preview")}catch(Y){console.error("Contact Picker error:",Y),wn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},L=Y=>{var X;const Q=(X=Y.target.files)==null?void 0:X[0];if(!Q)return;const ee=new FileReader;ee.onload=ie=>{var ye;const re=(ye=ie.target)==null?void 0:ye.result,oe=Dbs(re);if(oe.length===0){wn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const ce=S(oe);p(ce);const ge=new Set;ce.forEach((ue,pe)=>{ue.isDuplicate||ge.add(pe)}),g(ge),c("preview")},ee.readAsText(Q),l.current&&(l.current.value="")},I=async()=>{const Y=u.filter((ee,X)=>f.has(X));if(Y.length===0)return;c("importing");let Q=0;for(const ee of Y)try{await o.mutateAsync({first_name:ee.first_name,last_name:ee.last_name||void 0,email:ee.email||void 0,phone:ee.phone||void 0,address:ee.address||void 0}),Q++,w(Math.round(Q/Y.length*100))}catch(X){console.error(`Failed to import ${ee.first_name} ${ee.last_name}:`,X)}_(Q),c("done")},O=Y=>{g(Q=>{const ee=new Set(Q);return ee.has(Y)?ee.delete(Y):ee.add(Y),ee})},q=()=>{f.size===u.length?g(new Set):g(new Set(u.map((Y,Q)=>Q)))},U=Y=>{Y||(c("choose"),p([]),g(new Set),_(0),w(0),i==="done"&&r()),s(Y)},B=u.filter(Y=>Y.isDuplicate).length,V=f.size;return e.jsx(fs,{open:t,onOpenChange:U,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(v0,{className:"h-5 w-5 text-primary"}),i==="choose"&&"Import Phone Contacts",i==="preview"&&"Select Contacts to Import",i==="importing"&&"Importing Contacts...",i==="done"&&"Import Complete"]}),i==="choose"&&e.jsx(Gr,{children:"Add contacts from your phone directly into Agent OS."})]}),i==="choose"&&e.jsxs("div",{className:"space-y-4 pt-2",children:[N&&e.jsxs(K,{onClick:M,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(v0,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Select from Phone"}),e.jsx("div",{className:"text-xs opacity-80",children:"Pick contacts directly from your device"})]})]}),e.jsxs("div",{className:"relative",children:[N&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),N&&e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),e.jsxs(K,{variant:N?"outline":"default",onClick:()=>{var Y;return(Y=l.current)==null?void 0:Y.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(li,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Upload Contact File"}),e.jsx("div",{className:"text-xs opacity-80",children:N?"Import a .vcf file exported from your Contacts app":"Export contacts from your phone as a .vcf file, then upload here"})]})]}),e.jsx("input",{ref:l,type:"file",accept:".vcf,.vcard",onChange:L,className:"hidden"}),!N&&e.jsxs("div",{className:"rounded-lg bg-muted p-3 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"How to export contacts:"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"iPhone:"}),e.jsx("p",{className:"text-xs",children:'Open Contacts → select contacts → Share → choose "Export vCard"'})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"Android:"}),e.jsx("p",{className:"text-xs",children:"Open Contacts → Menu → Export → save as .vcf file"})]})]})]}),i==="preview"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{children:[u.length," contact",u.length!==1?"s":""," found",B>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",B," already exist)"]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:q,children:f.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Gi,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((Y,Q)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${Y.isDuplicate?"opacity-60":""}`,onClick:()=>O(Q),children:[e.jsx(Oo,{checked:f.has(Q),onCheckedChange:()=>O(Q),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[Y.first_name," ",Y.last_name]}),Y.isDuplicate&&e.jsxs(st,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",Y.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[Y.phone&&e.jsx("div",{children:Y.phone}),Y.email&&e.jsx("div",{className:"truncate",children:Y.email})]})]})]},Q))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c("choose"),children:"Back"}),e.jsxs(K,{onClick:I,disabled:V===0,children:["Import ",V," Contact",V!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(ws,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[j,"% complete"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${j}%`}})})]}),i==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(va,{className:"h-6 w-6 text-emerald-600"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[b," contact",b!==1?"s":""," imported!"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Your contacts are now in Agent OS and ready for touchpoint plans."})]}),e.jsx(K,{onClick:()=>U(!1),className:"mt-2",children:"Done"})]})]})})}function Hhe(){const t=ci();return mt({queryKey:["custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_custom_tags").select("*").eq("owner_user_id",t).order("name");if(r)throw r;return s},enabled:!!t})}function Rbs(t){return mt({queryKey:["contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_custom_tag_assignments").select("*, tag:contact_custom_tags(*)").eq("contact_id",t);if(r)throw r;return s},enabled:!!t})}function lSe(){const t=Qt(),s=ci();return Lt({mutationFn:async({name:r,color:n})=>{const{data:a,error:o}=await H.from("contact_custom_tags").insert({owner_user_id:s,name:r.trim(),color:n||"#6366F1"}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]})}})}function Fbs(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("contact_custom_tags").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function zbs(){const t=Qt();return Lt({mutationFn:async({id:s,name:r,color:n})=>{const a={};r!==void 0&&(a.name=r.trim()),n!==void 0&&(a.color=n);const{error:o}=await H.from("contact_custom_tags").update(a).eq("id",s);if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function qat(){const t=Qt();return Lt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await H.from("contact_custom_tag_assignments").insert({contact_id:s,tag_id:r});if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function Bbs(){const t=Qt();return Lt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await H.from("contact_custom_tag_assignments").delete().eq("contact_id",s).eq("tag_id",r);if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function $bs(){const t=ci();return mt({queryKey:["all-contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_custom_tag_assignments").select("contact_id, tag_id, tag:contact_custom_tags(id, name, color)");if(r)throw r;return s},enabled:!!t})}function qbs({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=fr(),{data:c}=Vx(),u=jNe(),p=Qt(),{isGmailConnected:f}=Gx(),{isReady:g}=nSe(),{data:b}=Hhe(),_=lSe(),j=qat(),[w,N]=k.useState(!1),[S,M]=k.useState(!1),[L,I]=k.useState(!1),[O,q]=k.useState(""),U=t.size;if(U===0)return null;const B=async re=>{N(!0);try{const ce=Array.from(t).map(ye=>({contact_id:ye,relationship_type_id:re})),{error:ge}=await H.from("innercircle_contact_tags").upsert(ce,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(ge)throw ge;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),wn({title:`Assigned type to ${U} contacts`}),r()}catch(oe){wn({title:"Error assigning type",description:oe.message,variant:"destructive"})}finally{N(!1)}},V=async re=>{N(!0);try{const oe=Array.from(t);for(const ce of oe)try{await j.mutateAsync({contactId:ce,tagId:re})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),wn({title:`Tagged ${U} contacts`}),I(!1),q("")}catch(oe){wn({title:"Error adding tags",description:oe.message,variant:"destructive"})}finally{N(!1)}},Y=async()=>{if(O.trim()){N(!0);try{const re=await _.mutateAsync({name:O.trim()});await V(re.id)}catch(re){wn({title:"Error creating tag",description:re.message,variant:"destructive"}),N(!1)}}},Q=(b==null?void 0:b.filter(re=>re.name.toLowerCase().includes(O.toLowerCase())))||[],ee=b==null?void 0:b.find(re=>re.name.toLowerCase()===O.trim().toLowerCase()),X=()=>{const re=s.filter(_e=>t.has(_e.id)),oe=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],ce=re.map(_e=>{var $e;return[_e.first_name,_e.last_name||"",_e.email||"",_e.phone||"",_e.address||"",_e.birthday||"",_e.home_anniversary||"",_e.notes||"",(($e=_e.tags)==null?void 0:$e.map(Ae=>{var Ie;return(Ie=Ae.relationship_type)==null?void 0:Ie.name}).join("; "))||""]}),ge=[oe.join(","),...ce.map(_e=>_e.map($e=>`"${($e||"").replace(/"/g,'""')}"`).join(","))].join(` `),ye=new Blob([ge],{type:"text/csv"}),ue=URL.createObjectURL(ye),pe=document.createElement("a");pe.href=ue,pe.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,pe.click(),URL.revokeObjectURL(ue),wn({title:`Exported ${U} contacts`})},ie=async()=>{if(confirm(`Are you sure you want to delete ${U} contacts? This cannot be undone.`)){N(!0);try{const re=Array.from(t);for(const oe of re)await u.mutateAsync(oe);r()}catch(re){wn({title:"Error deleting contacts",description:re.message,variant:"destructive"})}finally{N(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 border border-primary/20 rounded-lg",children:[e.jsxs(st,{variant:"secondary",className:"font-semibold",children:[U," selected"]}),e.jsxs(Ks,{onValueChange:B,disabled:w,children:[e.jsx(Hs,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fm,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(Ws,{children:c==null?void 0:c.filter(re=>re.active).map(re=>e.jsx(Mt,{value:re.id,children:re.name},re.id))})]}),e.jsxs($o,{open:L,onOpenChange:I,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:w,children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(Ro,{className:"w-56 p-2",align:"start",children:[e.jsx(ze,{placeholder:"Search or create tag...",value:O,onChange:re=>q(re.target.value),onKeyDown:re=>{re.key==="Enter"&&O.trim()&&!ee?(re.preventDefault(),Y()):re.key==="Enter"&&ee&&(re.preventDefault(),V(ee.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[Q.map(re=>e.jsxs("button",{onClick:()=>V(re.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:re.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:re.name})]},re.id)),O.trim()&&!ee&&e.jsxs("button",{onClick:Y,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx($s,{className:"h-3.5 w-3.5"}),'Create "',O.trim(),'"']}),Q.length===0&&!O.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),f&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>M(!0),disabled:w,children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),g&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const re=Array.from(t).join(",");i(`/admin/email-campaigns/new?contactIds=${re}`)},disabled:w,children:[e.jsx(Ah,{className:"h-3.5 w-3.5 mr-1"}),"Mass Email"]}),a&&n&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:w,children:[e.jsx(Xg,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:w,children:[e.jsx(s1,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:X,disabled:w,children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,disabled:w,className:"text-destructive hover:text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(Rr,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(Uw,{open:S,onOpenChange:M,bulkContacts:Array.from(t).map(re=>{const oe=s.find(ce=>ce.id===re);return oe?{id:oe.id,first_name:oe.first_name,last_name:oe.last_name,email:oe.email||""}:null}).filter(re=>re!==null&&re.email!==""),onSendComplete:()=>{M(!1),r()}})]})}function KFe({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const c=fr(),{isReady:u}=nSe(),p=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(fx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(Ma,{onClick:()=>c(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Un,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Ma,{onClick:()=>c(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Ma,{onClick:()=>c(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(ma,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(Ma,{onClick:()=>c(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(Ma,{onClick:()=>n(t.id,p),children:[e.jsx(Rm,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Ma,{onClick:()=>a(t.id),children:[e.jsx(Xg,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Ma,{onClick:()=>l(t.id),children:[e.jsx(s1,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Ma,{onClick:()=>s(t),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ma,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function Ubs(){const{user:t}=Ds();return mt({queryKey:["contact-smart-lists",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Vbs(){const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async({name:r,filters:n,sort_by:a})=>{const{data:o,error:l}=await H.from("contact_smart_lists").insert({owner_user_id:s.id,name:r,filters:n,sort_by:a}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),wn({title:"Smart filter saved"})},onError:r=>{wn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function Hbs(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("contact_smart_lists").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),wn({title:"Smart filter deleted"})}})}function Wbs({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=Ubs(),a=Vbs(),o=Hbs(),[l,i]=k.useState(!1),[c,u]=k.useState(""),p=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",f=async()=>{c.trim()&&(await a.mutateAsync({name:c.trim(),filters:t,sort_by:s}),u(""),i(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Qg,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(st,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Eo,{className:"h-3.5 w-3.5"})]})}),e.jsxs(Bd,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(g=>e.jsxs(Ma,{className:"flex items-center justify-between group",children:[e.jsx("span",{className:"flex-1 cursor-pointer",onClick:()=>r(g.filters,g.sort_by),children:g.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",onClick:b=>{b.stopPropagation(),o.mutate(g.id)},children:e.jsx(Nr,{className:"h-3 w-3 text-destructive"})})]},g.id)),e.jsx(uw,{})]}):e.jsx(Ma,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(Ma,{onClick:()=>i(!0),children:[e.jsx(YI,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ze,{placeholder:"e.g. Buyers in 40205",value:c,onChange:g=>u(g.target.value),onKeyDown:g=>g.key==="Enter"&&f(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:f,disabled:!c.trim()||a.isPending,children:"Save"})]})]})]})})]})}function AI(t){if(!t)return null;try{const s=t.split(/[-/T]/);if(s.length<3)return null;const r=parseInt(s[1],10)-1,n=parseInt(s[2],10);if(isNaN(r)||isNaN(n))return null;const a=new Date;a.setHours(0,0,0,0);let o=new Date(a.getFullYear(),r,n);return o.setHours(0,0,0,0),or)return null;const a=s==="birthday"?"🎂":"🏡",o=n===0?s==="birthday"?"Birthday today!":"Anniversary today!":n===1?s==="birthday"?"Birthday tomorrow":"Anniversary tomorrow":`${a} in ${n}d`;return{emoji:a,label:o,daysUntil:n}}function YFe({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=fr(),i=ZFe(t,"birthday",7),c=ZFe(s,"anniversary",7);if(!i&&!c)return null;const u=(p,f)=>{f.stopPropagation();const g=new URLSearchParams;n&&g.set("contactId",n),a&&g.set("name",a),o&&g.set("address",o),p==="home_anniversary"&&s&&g.set("date",s),g.set("cardType",p),l(`/mission-control/card-studio?${g.toString()}`)};return e.jsxs("div",{className:It("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(st,{variant:"secondary",className:It("text-[10px] gap-0.5 font-medium",i.daysUntil===0?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400 animate-pulse":"bg-pink-50 text-pink-600 dark:bg-pink-900/20 dark:text-pink-400"),children:i.label}),n&&e.jsxs("button",{onClick:p=>u("birthday",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-pink-500/15 text-pink-600 dark:text-pink-400 hover:bg-pink-500/25 transition-colors",title:"Send a birthday card",children:[e.jsx(cr,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),c&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(st,{variant:"secondary",className:It("text-[10px] gap-0.5 font-medium",c.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:c.label}),n&&e.jsxs("button",{onClick:p=>u("home_anniversary",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors",title:"Send an anniversary card",children:[e.jsx(cr,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function XFe({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1 font-medium whitespace-nowrap",style:{borderColor:s.color,color:s.color,backgroundColor:`${s.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:s.color}}),s.name]})}function Gbs(){const t=ci();return mt({queryKey:["contact-deals-map",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_pipeline").select(` id, deal_name, contact_id, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).not("contact_id","is",null);if(r)throw r;const n={};return(s||[]).forEach(a=>{a.contact_id&&!n[a.contact_id]&&(n[a.contact_id]=a)}),n},enabled:!!t})}function Kbs({contactId:t,compact:s=!1}){const{data:r}=Hhe(),{data:n}=Rbs(t),a=lSe(),o=qat(),l=Bbs(),[i,c]=k.useState(!1),[u,p]=k.useState(""),f=k.useRef(null),g=new Set((n==null?void 0:n.map(N=>N.tag_id))||[]),b=(r==null?void 0:r.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())))||[],_=r==null?void 0:r.find(N=>N.name.toLowerCase()===u.trim().toLowerCase()),j=async N=>{g.has(N.id)?await l.mutateAsync({contactId:t,tagId:N.id}):await o.mutateAsync({contactId:t,tagId:N.id})},w=async()=>{if(!(!u.trim()||_))try{const N=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:N.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(N=>{var S,M,L;return e.jsxs(st,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((S=N.tag)==null?void 0:S.color)||"#6366F1",color:((M=N.tag)==null?void 0:M.color)||"#6366F1"},children:[e.jsx(Fm,{className:"h-2.5 w-2.5"}),(L=N.tag)==null?void 0:L.name,e.jsx("button",{onClick:I=>{I.stopPropagation(),l.mutate({contactId:t,tagId:N.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Rr,{className:"h-2.5 w-2.5"})})]},N.id)}),e.jsxs($o,{open:i,onOpenChange:c,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:N=>N.stopPropagation(),children:[e.jsx($s,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(Ro,{className:"w-56 p-2",align:"start",onClick:N=>N.stopPropagation(),children:[e.jsx(ze,{ref:f,placeholder:"Search or create tag...",value:u,onChange:N=>p(N.target.value),onKeyDown:N=>{N.key==="Enter"&&u.trim()&&!_?(N.preventDefault(),w()):N.key==="Enter"&&_&&!g.has(_.id)&&(N.preventDefault(),j(_))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[b.map(N=>e.jsxs("button",{onClick:()=>j(N),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:N.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:N.name}),g.has(N.id)&&e.jsx(va,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},N.id)),u.trim()&&!_&&e.jsxs("button",{onClick:w,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx($s,{className:"h-3.5 w-3.5"}),'Create "',u.trim(),'"']}),b.length===0&&!u.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create your first tag"})]})]})]})]})}function QFe({contactId:t,tags:s}){return!s||s.length===0?null:e.jsx(e.Fragment,{children:s.map(r=>{var n,a,o;return e.jsx(st,{variant:"outline",className:"text-[10px] gap-0.5",style:{borderColor:((n=r.tag)==null?void 0:n.color)||"#6366F1",color:((a=r.tag)==null?void 0:a.color)||"#6366F1"},children:(o=r.tag)==null?void 0:o.name},r.tag_id)})})}const Gz=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function Zbs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Hhe(),a=lSe(),o=zbs(),l=Fbs(),[i,c]=k.useState(""),[u,p]=k.useState(Gz[0]),[f,g]=k.useState(null),[b,_]=k.useState(""),[j,w]=k.useState(""),N=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),c(""),p(Gz[0]),wn({title:"Tag created"})}catch(I){wn({title:"Error",description:I.message,variant:"destructive"})}},S=async I=>{if(b.trim())try{await o.mutateAsync({id:I,name:b.trim(),color:j}),g(null),wn({title:"Tag updated"})}catch(O){wn({title:"Error",description:O.message,variant:"destructive"})}},M=async(I,O)=>{if(confirm(`Delete tag "${O}"? It will be removed from all contacts.`))try{await l.mutateAsync(I),wn({title:"Tag deleted"})}catch(q){wn({title:"Error",description:q.message,variant:"destructive"})}},L=I=>{g(I.id),_(I.name),w(I.color)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Manage Tags"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New tag name...",value:i,onChange:I=>c(I.target.value),onKeyDown:I=>I.key==="Enter"&&N(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:N,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Gz.map(I=>e.jsx("button",{onClick:()=>p(I),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===I?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:I}},I))})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[320px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tags yet. Create one above!"}),r==null?void 0:r.map(I=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:f===I.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:Gz.map(O=>e.jsx("button",{onClick:()=>w(O),className:`h-5 w-5 rounded-full border-2 ${j===O?"border-foreground":"border-transparent"}`,style:{backgroundColor:O}},O))}),e.jsx(ze,{value:b,onChange:O=>_(O.target.value),onKeyDown:O=>O.key==="Enter"&&S(I.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(I.id),children:e.jsx(va,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>g(null),children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3.5 w-3.5 rounded-full shrink-0",style:{backgroundColor:I.color}}),e.jsx("span",{className:"flex-1 text-sm",children:I.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>L(I),children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>M(I.id,I.name),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})},I.id))]})]})})}function Ybs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=nE(),a=SNe(),o=XLt(),l=QLt(),[i,c]=k.useState(""),[u,p]=k.useState(null),[f,g]=k.useState(""),b=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),c("")}catch(N){me.error(N.message||"Failed to add lead source")}},_=async N=>{if(f.trim())try{await o.mutateAsync({id:N,name:f.trim()}),p(null)}catch(S){me.error(S.message||"Failed to update")}},j=async(N,S)=>{if(confirm(`Remove lead source "${S}"? Contacts using it will keep the label but it won't appear in new dropdowns.`))try{await l.mutateAsync(N)}catch(M){me.error(M.message||"Failed to remove")}},w=N=>{p(N.id),g(N.name)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New lead source name...",value:i,onChange:N=>c(N.target.value),onKeyDown:N=>N.key==="Enter"&&b(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:b,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[360px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No lead sources yet. Create one above!"}),r==null?void 0:r.map(N=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===N.id?e.jsxs(e.Fragment,{children:[e.jsx(ze,{value:f,onChange:S=>g(S.target.value),onKeyDown:S=>S.key==="Enter"&&_(N.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>_(N.id),children:e.jsx(va,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>p(null),children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:N.name}),N.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>w(N),children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>j(N.id,N.name),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),!N.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},N.id))]})]})})}function Uat({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=nE(),a=SNe(),[o,l]=k.useState(!1),[i,c]=k.useState(""),u=async()=>{if(i.trim())try{const p=await a.mutateAsync(i.trim());p&&(s(p.id),c(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(Hs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select lead source"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"_none",children:"No source"}),n==null?void 0:n.map(p=>e.jsx(Mt,{value:p.id,children:p.name},p.id))]})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(Rr,{className:"h-4 w-4"}):e.jsx($s,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New lead source name...",value:i,onChange:p=>c(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u())},className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function q_e({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=fr(),[c,u]=k.useState(!1),[p,f]=k.useState(""),{data:g}=mt({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:_,error:j}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(j)throw j;return _},enabled:!!s}),{data:b}=mt({queryKey:["spouse-search",p],queryFn:async()=>{let _=H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").neq("id",t).order("first_name").limit(20);p.trim()&&(_=_.or(`first_name.ilike.%${p}%,last_name.ilike.%${p}%,email.ilike.%${p}%,phone.ilike.%${p}%`));const{data:j,error:w}=await _;if(w)throw w;return j},enabled:c});if(s&&g){const _=`${g.first_name} ${g.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{onClick:()=>i(`/mission-control/contacts/${g.id}`),className:"text-sm font-medium text-primary hover:underline truncate block",children:_}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[g.phone,g.email].filter(Boolean).join(" · ")||"No contact info"})]}),l&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:o,className:"shrink-0 h-7 px-2",children:[e.jsx(gS,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${g.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(Qa,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm",children:r}),n&&e.jsx("span",{className:"text-xs text-muted-foreground block truncate",children:n})]}),l&&e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(dl,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(Ro,{className:"w-72 p-2",align:"end",children:e.jsx(JFe,{search:p,setSearch:f,results:b,onSelect:_=>{a(_),u(!1),f("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(dl,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(Ro,{className:"w-72 p-2",align:"start",children:e.jsx(JFe,{search:p,setSearch:f,results:b,onSelect:_=>{a(_),u(!1),f("")}})})]})]}):null}function JFe({search:t,setSearch:s,results:r,onSelect:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Gi,{className:"max-h-48",children:r&&r.length>0?e.jsx("div",{className:"space-y-0.5",children:r.map(a=>e.jsxs("button",{onClick:()=>n(a.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[a.first_name," ",a.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[a.phone,a.email].filter(Boolean).join(" · ")||"No contact info"})]},a.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:t?"No contacts found":"Type to search contacts"})})]})}function Xbs(){var vi;const t=fr(),[s]=Cc(),{user:r}=Ds(),n=SE(),a=Qt(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:c,isLoading:u}=kue(),{activeContactIds:p,hasLeadSite:f}=Tbs(),{data:g}=Vx(),{data:b}=Gbs(),{data:_}=Hhe(),{data:j}=$bs(),[w,N]=k.useState(new Set),[S,M]=k.useState("any"),L=wue(),I=wNe(),O=jNe(),q=KYe(),[U,B]=k.useState(""),[V,Y]=k.useState(o||"all"),[Q,ee]=k.useState(l||"all"),[X,ie]=k.useState("date-added"),[re,oe]=k.useState(i),[ce,ge]=k.useState(null),[ye,ue]=k.useState(!1),[pe,_e]=k.useState(!1),[$e,Ae]=k.useState(null),[Ie,Ce]=k.useState(""),[xe,we]=k.useState(new Set),[Le,tt]=k.useState(!1),[Te,pt]=k.useState(1),[fe,qe]=k.useState(50),[at,et]=k.useState("my"),[Me,rt]=k.useState(!1),[He,ct]=k.useState(!1),{data:Ue}=$x(),{addToLeadPond:Ze}=att(Ue==null?void 0:Ue.teamId),Qe=!!((vi=Ue==null?void 0:Ue.team)!=null&&vi.lead_pond_enabled&&(Ue!=null&&Ue.teamId)),We=!!(Ue!=null&&Ue.teamId),[Je,it]=k.useState([]),[Dt,Vt]=k.useState(!1),hs=ft=>{it([ft]),Vt(!0)},Ts=ft=>{it(ft),Vt(!0)},Cs=ft=>{Ue!=null&&Ue.teamId&&Ze.mutate({contact_id:ft,team_id:Ue.teamId})},cs=ft=>{Ue!=null&&Ue.teamId&&ft.forEach(ir=>{Ze.mutate({contact_id:ir,team_id:Ue.teamId})})},er=k.useCallback(ft=>{tt(!1),we(ir=>{const Vn=new Set(ir);return Vn.has(ft)?Vn.delete(ft):Vn.add(ft),Vn})},[]);k.useEffect(()=>{if(!(r!=null&&r.id))return;const ft=H.channel(`innercircle_contacts_inserts_${r.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"innercircle_contacts",filter:`owner_user_id=eq.${r.id}`},()=>{a.invalidateQueries({queryKey:["innercircle-contacts"]}),a.invalidateQueries({queryKey:["innercircle-contact-counts"]})}).subscribe();return()=>{H.removeChannel(ft)}},[a,r==null?void 0:r.id]),k.useEffect(()=>{l&&ee(l)},[l]);const[xt,Es]=k.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});k.useEffect(()=>{i&&oe(!0)},[i]),k.useEffect(()=>{var ft;ce&&Es({first_name:ce.first_name||"",last_name:ce.last_name||"",email:ce.email||"",phone:ce.phone||"",address:ce.address||"",city:ce.city||"",state:ce.state||"",zip_code:ce.zip_code||"",birthday:ce.birthday||"",home_anniversary:ce.home_anniversary||"",spouse_name:ce.spouse_name||"",spouse_email:ce.spouse_email||"",lead_source_id:ce.lead_source_id||"",notes:ce.notes||"",tagIds:((ft=ce.tags)==null?void 0:ft.map(ir=>ir.relationship_type_id))||[]})},[ce]);const ur=k.useMemo(()=>{if(!c)return[];let ft=c.filter(ir=>{var ea,Pa,Ii;const Vn=U===""||`${ir.first_name} ${ir.last_name}`.toLowerCase().includes(U.toLowerCase())||((ea=ir.email)==null?void 0:ea.toLowerCase().includes(U.toLowerCase()))||((Pa=ir.phone)==null?void 0:Pa.includes(U)),Sr=V==="all"||((Ii=ir.tags)==null?void 0:Ii.some(Fo=>Fo.relationship_type_id===V)),jr=w.size===0||(()=>{const Fo=(j==null?void 0:j.filter($t=>$t.contact_id===ir.id).map($t=>$t.tag_id))||[];return S==="any"?Fo.some($t=>w.has($t)):Array.from(w).every($t=>Fo.includes($t))})();return Vn&&Sr&&jr});return Q==="not-touched-90"?ft=ft.filter(ir=>{const Vn=ir.relationshipScore.daysSinceTouch;return Vn===null||Vn>90}):Q==="at-risk"?ft=ft.filter(ir=>ir.relationshipScore.status==="at-risk"):Q==="cooling"?ft=ft.filter(ir=>ir.relationshipScore.status==="cooling"):Q==="warm"?ft=ft.filter(ir=>ir.relationshipScore.status==="warm"):Q==="has-deal"?ft=ft.filter(ir=>b&&b[ir.id]):Q==="no-deal"?ft=ft.filter(ir=>!b||!b[ir.id]):Q==="open-house"?ft=ft.filter(ir=>{var Sr;return(((Sr=ir.lead_source_ref)==null?void 0:Sr.name)||ir.lead_source)==="Open House"}):Q==="website-active"&&(ft=ft.filter(ir=>p.has(ir.id))),ft=[...ft].sort((ir,Vn)=>{switch(X){case"important-dates":{const Sr=AI(ir.birthday),jr=AI(Vn.birthday),ea=AI(ir.home_anniversary),Pa=AI(Vn.home_anniversary),Ii=[Sr,ea].filter($t=>$t!==null).sort(($t,ke)=>($t??1/0)-(ke??1/0))[0]??1/0,Fo=[jr,Pa].filter($t=>$t!==null).sort(($t,ke)=>($t??1/0)-(ke??1/0))[0]??1/0;return Ii-Fo}case"last-touched":{const Sr=ir.relationshipScore.lastTouchDate,jr=Vn.relationshipScore.lastTouchDate;return!Sr&&!jr?0:Sr?jr?new Date(Sr).getTime()-new Date(jr).getTime():1:-1}case"next-touch":{const Sr=ir.relationshipScore.daysSinceTouch,jr=Vn.relationshipScore.daysSinceTouch;return Sr===null&&jr===null?0:Sr===null?-1:jr===null?1:jr-Sr}case"score":return ir.relationshipScore.score-Vn.relationshipScore.score;case"date-added":{const Sr=ir.created_at,jr=Vn.created_at;return!Sr&&!jr?0:Sr?jr?new Date(jr).getTime()-new Date(Sr).getTime():-1:1}case"name":default:{const Sr=`${ir.first_name||""} ${ir.last_name||""}`.toLowerCase(),jr=`${Vn.first_name||""} ${Vn.last_name||""}`.toLowerCase();return Sr.localeCompare(jr)}}}),ft},[c,U,V,w,S,Q,X,b,j,p]),Mr=ur.length,Lr=Math.max(1,Math.ceil(Mr/fe)),fn=Math.min(Te,Lr),ki=k.useMemo(()=>{const ft=(fn-1)*fe;return ur.slice(ft,ft+fe)},[ur,fn,fe]);k.useEffect(()=>{pt(1)},[U,V,w,S,Q,X]);const Ea=k.useCallback(()=>{tt(!1),we(ft=>ft.size>0?new Set:new Set(ki.map(ir=>ir.id)))},[ki]),dr=k.useCallback(()=>{tt(!0),we(new Set(ur.map(ft=>ft.id)))},[ur]),Jr=k.useCallback((ft,ir)=>{B(ft.search||""),Y(ft.type||"all"),ee(ft.status||"all"),ie(ir||"name")},[]),Wr=()=>{Es({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},dn=async ft=>{ft.preventDefault();const ir={...xt,lead_source_id:xt.lead_source_id||null};ce?(await I.mutateAsync({id:ce.id,...ir}),ge(null)):(await L.mutateAsync(ir),oe(!1)),Wr()},Yr=async ft=>{confirm("Are you sure you want to delete this contact?")&&await O.mutateAsync(ft)};return e.jsx(Ms,{title:"Contacts",description:"Manage your InnerCircle contacts",children:e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Contacts"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),Ue&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>et("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${at==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(Ue.team.contact_visibility==="full_team"||Ue.team.contact_visibility==="leader_only"&&Ue.role==="team_leader")&&e.jsxs("button",{onClick:()=>et("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${at==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(pr,{className:"h-3.5 w-3.5"}),"Team"]}),Ue.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>et("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${at==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Xg,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(cl,{className:"h-4 w-4 mr-1"}),"Back"]})}),at==="team"?e.jsx(Oke,{}):at==="lead-pond"&&Ue?e.jsx(Rke,{teamId:Ue.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or phone...",value:U,onChange:ft=>B(ft.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:[e.jsxs(K,{onClick:()=>oe(!0),className:"shrink-0",children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(K,{variant:"outline",onClick:()=>ue(!0),className:"shrink-0",children:[e.jsx(li,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>_e(!0),className:"shrink-0",children:[e.jsx(v0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(bbs,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Ks,{value:V,onValueChange:Y,children:[e.jsx(Hs,{className:"w-[145px] h-9 text-sm",children:e.jsx(Ys,{placeholder:"Filter by type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),g==null?void 0:g.filter(ft=>ft.active).map(ft=>e.jsx(Mt,{value:ft.id,children:ft.name},ft.id))]})]}),_&&_.length>0&&e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(Fm,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),w.size===0?"Filter by Tags":`${w.size} tag${w.size>1?"s":""}`]})}),e.jsx(Ro,{className:"w-60 p-3",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Tags"}),e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-0.5",children:[e.jsx("button",{onClick:()=>M("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${S==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>M("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${S==="all"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"All"})]})]}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:_.map(ft=>{const ir=w.has(ft.id);return e.jsxs("button",{onClick:()=>{N(Vn=>{const Sr=new Set(Vn);return Sr.has(ft.id)?Sr.delete(ft.id):Sr.add(ft.id),Sr})},className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx(Oo,{checked:ir,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:ft.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:ft.name})]},ft.id)})}),w.size>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>N(new Set),children:"Clear tags"})]})})]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx(Xo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Ma,{onClick:()=>rt(!0),children:[e.jsx(Fm,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(Ma,{onClick:()=>ct(!0),children:[e.jsx(Xg,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(Ks,{value:Q,onValueChange:ee,children:[e.jsx(Hs,{className:"w-[145px] h-9 text-sm",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"warm",children:"🟢 Warm"}),e.jsx(Mt,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(Mt,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(Mt,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(Mt,{value:"no-deal",children:"📭 No Deal"}),e.jsx(Mt,{value:"open-house",children:"🏠 Open House"}),f&&e.jsx(Mt,{value:"website-active",children:"🌐 Website Active"})]})]}),e.jsxs(Ks,{value:X,onValueChange:ie,children:[e.jsx(Hs,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bd,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Ys,{placeholder:"Sort by"})]})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"name",children:"Name (A-Z)"}),e.jsx(Mt,{value:"important-dates",children:"Important Dates"}),e.jsx(Mt,{value:"last-touched",children:"Last Touched"}),e.jsx(Mt,{value:"next-touch",children:"Next Touch Due"}),e.jsx(Mt,{value:"score",children:"Relationship Score"}),e.jsx(Mt,{value:"date-added",children:"Date Added"})]})]}),e.jsx(Wbs,{currentFilters:{search:U,type:V,status:Q},currentSortBy:X,onApplySmartList:Jr})]})]})})}),e.jsx(qbs,{selectedIds:xe,contacts:ur,onClearSelection:()=>{we(new Set),tt(!1)},showLeadPondAction:Qe,onSendToLeadPond:cs,showTransferAction:We,onTransfer:Ts}),xe.size>0&&xe.size===ki.length&&!Le&&Mr>fe&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-2 bg-primary/5 border border-primary/20 rounded-lg text-sm",children:[e.jsxs("span",{children:["All ",ki.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:dr,children:["Select all ",Mr.toLocaleString()," matching contacts"]})]}),Le&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-2 bg-primary/10 border border-primary/30 rounded-lg text-sm font-medium",children:["All ",Mr.toLocaleString()," matching contacts are selected.",e.jsx(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{we(new Set),tt(!1)},children:"Clear selection"})]}),n?e.jsx("div",{className:"space-y-3",children:u?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):ur.length===0?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:U||V!=="all"||Q!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):ki.map(ft=>{var Vn,Sr,jr;const{relationshipScore:ir}=ft;return e.jsx(Ee,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const ea=new URLSearchParams;U&&ea.set("search",U),V!=="all"&&ea.set("type",V),Q!=="all"&&ea.set("filter",Q);const Pa=ea.toString();t(`/mission-control/contacts/${ft.id}${Pa?`?${Pa}`:""}`)},children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"font-semibold text-base truncate",children:[ft.first_name," ",ft.last_name]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[ft.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(cr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:ft.email})]}),ft.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Un,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:ft.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(_8,{score:ir,size:"sm"}),e.jsx($_e,{contact:ft}),(((Vn=ft.lead_source_ref)==null?void 0:Vn.name)||ft.lead_source)&&e.jsx(st,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((Sr=ft.lead_source_ref)==null?void 0:Sr.name)||ft.lead_source}),(jr=ft.tags)==null?void 0:jr.map(ea=>{var Pa;return e.jsx(st,{variant:"secondary",className:"text-xs",children:(Pa=ea.relationship_type)==null?void 0:Pa.name},ea.id)}),e.jsx(QFe,{contactId:ft.id,tags:j==null?void 0:j.filter(ea=>ea.contact_id===ft.id)}),e.jsx(XFe,{deal:b==null?void 0:b[ft.id]})]}),e.jsx(YFe,{birthday:ft.birthday,homeAnniversary:ft.home_anniversary,className:"mb-2",contactId:ft.id,contactName:`${ft.first_name}${ft.last_name?" "+ft.last_name:""}`,contactAddress:[ft.address,ft.city,ft.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[ir.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(ir.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),ft.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(Ol(ft.birthday),"MMM d")]}),ft.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(bn,{className:"h-3 w-3"}),ms(Ol(ft.home_anniversary),"MMM d")]}),ft.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx($s,{className:"h-3 w-3"}),"Added ",ms(new Date(ft.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:ea=>ea.stopPropagation(),children:e.jsx(KFe,{contact:ft,onEdit:ge,onDelete:Yr,onSnooze:(ea,Pa)=>{Ae(ea),Ce(Pa)},showLeadPondAction:Qe,onSendToLeadPond:Cs,showTransferAction:We,onTransfer:hs})})]})})},ft.id)})}):e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(Rn,{className:"min-w-[800px]",children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:ki.length>0&&ki.every(ft=>xe.has(ft.id)),onCheckedChange:()=>Ea()})}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Score"}),e.jsx(St,{children:"Contact Info"}),e.jsx(St,{children:"Types / Pipeline"}),e.jsx(St,{children:"Last Contact"}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>ie(X==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",X==="date-added"&&e.jsx(bd,{className:"h-3 w-3"})]})}),e.jsx(St,{children:"Important Dates"}),e.jsx(St,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(zn,{children:u?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):ur.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:U||V!=="all"||Q!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):ki.map(ft=>{var Sr,jr,ea;const{relationshipScore:ir}=ft,Vn=b==null?void 0:b[ft.id];return e.jsxs(Ss,{className:`cursor-pointer hover:bg-accent/50 ${xe.has(ft.id)?"bg-accent/30":""}`,onClick:()=>{const Pa=new URLSearchParams;U&&Pa.set("search",U),V!=="all"&&Pa.set("type",V),Q!=="all"&&Pa.set("status",Q);const Ii=Pa.toString();t(`/mission-control/contacts/${ft.id}${Ii?`?${Ii}`:""}`)},children:[e.jsx(dt,{onClick:Pa=>Pa.stopPropagation(),children:e.jsx(Oo,{checked:xe.has(ft.id),onCheckedChange:()=>er(ft.id)})}),e.jsxs(dt,{className:"font-medium",children:[ft.first_name," ",ft.last_name]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(_8,{score:ir,size:"sm"}),e.jsx($_e,{contact:ft})]})}),e.jsx(dt,{children:e.jsx(_8,{score:ir,size:"sm",showScore:!0})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[ft.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(cr,{className:"h-3 w-3"}),ft.email]}),ft.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Un,{className:"h-3 w-3"}),ft.phone]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((Sr=ft.lead_source_ref)==null?void 0:Sr.name)||ft.lead_source)&&e.jsx(st,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((jr=ft.lead_source_ref)==null?void 0:jr.name)||ft.lead_source}),(ea=ft.tags)==null?void 0:ea.map(Pa=>{var Ii;return e.jsx(st,{variant:"secondary",className:"text-xs",children:(Ii=Pa.relationship_type)==null?void 0:Ii.name},Pa.id)}),e.jsx(QFe,{contactId:ft.id,tags:j==null?void 0:j.filter(Pa=>Pa.contact_id===ft.id)}),e.jsx(XFe,{deal:Vn})]})}),e.jsx(dt,{children:e.jsx("div",{className:"text-sm",children:ir.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(ir.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ft.created_at?ms(new Date(ft.created_at),"MMM d, yyyy"):"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(YFe,{birthday:ft.birthday,homeAnniversary:ft.home_anniversary,contactId:ft.id,contactName:`${ft.first_name}${ft.last_name?" "+ft.last_name:""}`,contactAddress:[ft.address,ft.city,ft.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[ft.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(Ol(ft.birthday),"MMM d")]}),ft.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(bn,{className:"h-3 w-3"}),ms(Ol(ft.home_anniversary),"MMM d")]})]})]})}),e.jsx(dt,{children:e.jsx(KFe,{contact:ft,onEdit:ge,onDelete:Yr,onSnooze:(Pa,Ii)=>{Ae(Pa),Ce(Ii)},showLeadPondAction:Qe,onSendToLeadPond:Cs,showTransferAction:We,onTransfer:hs})})]},ft.id)})})]})})}),Mr>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("span",{children:["Showing ",(fn-1)*fe+1,"–",Math.min(fn*fe,Mr)," of ",Mr.toLocaleString()," contacts"]}),e.jsxs(Ks,{value:String(fe),onValueChange:ft=>{qe(Number(ft)),pt(1)},children:[e.jsx(Hs,{className:"w-[80px] h-8",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"50",children:"50"}),e.jsx(Mt,{value:"100",children:"100"}),e.jsx(Mt,{value:"250",children:"250"})]})]}),e.jsx("span",{className:"text-xs",children:"per page"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",disabled:fn<=1,onClick:()=>pt(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:fn<=1,onClick:()=>pt(ft=>ft-1),children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",fn," of ",Lr]}),e.jsx(K,{variant:"outline",size:"sm",disabled:fn>=Lr,onClick:()=>pt(ft=>ft+1),children:e.jsx(da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:fn>=Lr,onClick:()=>pt(Lr),children:"Last"})]})]}),e.jsx(fs,{open:re||!!ce,onOpenChange:ft=>{ft||(oe(!1),ge(null),Wr())},children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:ce?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:dn,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"first_name",children:"First Name *"}),e.jsx(ze,{id:"first_name",value:xt.first_name,onChange:ft=>Es({...xt,first_name:ft.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"last_name",children:"Last Name"}),e.jsx(ze,{id:"last_name",value:xt.last_name,onChange:ft=>Es({...xt,last_name:ft.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:xt.email,onChange:ft=>Es({...xt,email:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",value:xt.phone,onChange:ft=>Es({...xt,phone:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"address",children:"Address"}),e.jsx(ze,{id:"address",value:xt.address,onChange:ft=>Es({...xt,address:ft.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:xt.city,onChange:ft=>Es({...xt,city:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:xt.state,onChange:ft=>Es({...xt,state:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"zip_code",children:"Zip"}),e.jsx(ze,{id:"zip_code",value:xt.zip_code,onChange:ft=>Es({...xt,zip_code:ft.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"birthday",children:"Birthday"}),e.jsx(ze,{id:"birthday",type:"date",value:xt.birthday,onChange:ft=>Es({...xt,birthday:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(ze,{id:"home_anniversary",type:"date",value:xt.home_anniversary,onChange:ft=>Es({...xt,home_anniversary:ft.target.value})})]})]}),ce&&e.jsx(q_e,{contactId:ce.id,currentSpouseContactId:(ce==null?void 0:ce.spouse_contact_id)||null,currentSpouseName:(ce==null?void 0:ce.spouse_name)||null,currentSpouseEmail:(ce==null?void 0:ce.spouse_email)||null,onLink:ft=>q.mutate({contactId:ce.id,spouseContactId:ft}),onUnlink:()=>q.mutate({contactId:ce.id,spouseContactId:null}),isEditing:!0}),e.jsx(Uat,{value:xt.lead_source_id,onChange:ft=>Es({...xt,lead_source_id:ft})}),e.jsxs("div",{children:[e.jsx(be,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:g==null?void 0:g.filter(ft=>ft.active).map(ft=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Oo,{checked:xt.tagIds.includes(ft.id),onCheckedChange:ir=>{Es(ir?{...xt,tagIds:[...xt.tagIds,ft.id]}:{...xt,tagIds:xt.tagIds.filter(Vn=>Vn!==ft.id)})}}),e.jsx("span",{className:"text-sm",children:ft.name})]},ft.id))})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:xt.notes,onChange:ft=>Es({...xt,notes:ft.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{oe(!1),ge(null),Wr()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:L.isPending||I.isPending,children:[ce?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(Ibs,{open:ye,onOpenChange:ue,relationshipTypes:(g==null?void 0:g.filter(ft=>ft.active))||[],onSuccess:()=>{ue(!1)}}),e.jsx(Obs,{open:pe,onOpenChange:_e,onComplete:()=>_e(!1)}),e.jsx(Uhe,{open:!!$e,onOpenChange:ft=>{ft||Ae(null)},contactId:$e||"",contactName:Ie}),e.jsx(Zbs,{open:Me,onOpenChange:rt}),e.jsx(Ybs,{open:He,onOpenChange:ct}),e.jsx(itt,{open:Dt,onOpenChange:Vt,contactIds:Je,contactNames:Je.map(ft=>{const ir=ur.find(Vn=>Vn.id===ft);return ir?`${ir.first_name} ${ir.last_name||""}`.trim():""}),onComplete:()=>{it([]),we(new Set),tt(!1)}})]})]})})}function Qbs(){return mt({queryKey:["video-script-categories"],queryFn:async()=>{const{data:t,error:s}=await H.from("video_script_categories").select("*").order("sort_order");if(s)throw s;return t}})}function Jbs(t){return mt({queryKey:["video-scripts",t],queryFn:async()=>{let s=H.from("video_scripts").select("*, category:video_script_categories(*)").eq("is_active",!0).order("title");const{data:r,error:n}=await s;if(n)throw n;return r}})}function e_s(){const{user:t}=Ds();return mt({queryKey:["user-video-scripts",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await H.from("user_video_scripts").select("*, category:video_script_categories(*)").eq("owner_user_id",t.id).order("title");if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function t_s(){const{user:t}=Ds(),s=Qt();return Lt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await H.from("user_video_scripts").insert([{owner_user_id:t.id,source_script_id:r.id,category_id:r.category_id,title:r.title,script_text:r.script_text,tags:r.tags,is_custom:!1}]).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["user-video-scripts"]})}})}function s_s(t){const{user:s}=Ds();return mt({queryKey:["agent-videos",s==null?void 0:s.id,t],queryFn:async()=>{if(!(s!=null&&s.id))return[];let r=H.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("owner_user_id",s.id).order("created_at",{ascending:!1});r=r.eq("is_deleted",!1);const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!(s!=null&&s.id)})}function r_s(t){return mt({queryKey:["agent-video",t],queryFn:async()=>{const{data:s,error:r}=await H.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function CC(){const{user:t}=Ds(),s=Qt();return Lt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await H.from("agent_videos").insert([{owner_user_id:t.id,contact_id:r.contact_id,bunny_video_id:r.bunny_video_id,playback_url:r.playback_url,thumbnail_url:r.thumbnail_url,preview_url:r.preview_url,duration_seconds:r.duration_seconds,file_size_mb:r.file_size_mb||0,title:r.title,notes:r.notes,task_id:r.task_id,status:r.status||"processing",touch_type:r.touch_type||"video",page_template:"default"}]).select("*, share_token").single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["agent-videos"]}),s.invalidateQueries({queryKey:["storage-usage"]})}})}function n_s(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("agent_videos").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["agent-video",s.id]})}})}function a_s(){const t=Qt();return Lt({mutationFn:async({id:s,bunnyVideoId:r,hardDelete:n=!1})=>{if(console.log("Deleting video:",{id:s,bunnyVideoId:r,hardDelete:n}),r){console.log("Calling bunny-upload delete for videoId:",r);const{data:a,error:o}=await H.functions.invoke("bunny-upload",{body:{action:"delete",videoId:r,isAgentVideo:!0}});o?console.error("Failed to delete from Bunny:",o):console.log("Bunny delete response:",a)}else console.warn("No bunnyVideoId provided, skipping Bunny.net deletion");if(n){console.log("Hard deleting from database:",s);const{error:a}=await H.from("agent_videos").delete().eq("id",s);if(a)throw a}else{console.log("Soft deleting from database:",s);const{error:a}=await H.from("agent_videos").update({is_deleted:!0}).eq("id",s);if(a)throw a}console.log("Video deletion complete")},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["storage-usage"]})}})}function Whe(){const{user:t}=Ds();return mt({queryKey:["storage-usage",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await H.from("agent_storage_usage").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s||{user_id:t.id,total_storage_mb:0,storage_tier:"basic",max_storage_mb:1024}},enabled:!!(t!=null&&t.id)})}function Vat(){const{data:t,isLoading:s}=Whe(),r=t?t.total_storage_mb0?t.total_storage_mb/t.max_storage_mb*100:0,o=a>=80;return{canRecord:r,remainingMb:n,usagePercent:a,isNearLimit:o,storage:t,isLoading:s}}async function xR(t){const{data:s,error:r}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:t,isAgentVideo:!0}});if(r)throw r;return s}async function gR(t){const{data:s,error:r}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}async function wA(t){const{data:s,error:r}=await H.functions.invoke("bunny-upload",{body:{action:"status",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}function i_s(){const{user:t}=Ds(),s=Qt();return Lt({mutationFn:async({contactId:r,videoId:n,notes:a})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:o}=await H.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 H.from("contact_touch_logs").insert([{owner_user_id:t.id,contact_id:r,action_type_id:o.id,notes:a||`Quick Video Touch - Video ID: ${n}`}]).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-touch-logs"]}),s.invalidateQueries({queryKey:["contacts"]})}})}function o_s(t){return mt({queryKey:["contact-video-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("video_replies").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url) `).eq("contact_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function l_s(t){return mt({queryKey:["client-portal",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("client_portals").select("*").eq("deal_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function cSe(){const t=ci(),s=Qt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("client_portals").insert({deal_id:r.deal_id,owner_user_id:t,slug:"",is_enabled:r.is_enabled??!0,visibility:r.visibility||"private",require_onboarding:r.require_onboarding??!0,allow_spouse:r.allow_spouse??!1,client_name:r.client_name||null,client_email:r.client_email||null,client_phone:r.client_phone||null,invite_method:r.invite_method||"email"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["client-portal",n.deal_id]})}})}function yR(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("client_portals").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function c_s(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("client_portals").update({archived_at:new Date().toISOString(),is_enabled:!1}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function d_s(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("client_portals").update({archived_at:null}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function u_s(){const t=Qt();return Lt({mutationFn:async({id:s,dealId:r})=>{await H.from("portal_updates").delete().eq("portal_id",s);const{error:n}=await H.from("client_portals").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function Hat(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("portal_updates").insert({portal_id:s.portal_id,title:s.title,content:s.content||null,video_url:s.video_url||null,is_stage_change:s.is_stage_change||!1}).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["portal-updates",r.portal_id]})}})}function h_s(){const t=ci();return mt({queryKey:["portal-custom-questions",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("portal_custom_questions").select("*").eq("owner_user_id",t).eq("is_active",!0).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function m_s(){const t=ci(),s=Qt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("portal_custom_questions").insert({owner_user_id:t,question_text:r.question_text,field_type:r.field_type,options:r.options||[],is_required:r.is_required||!1,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function p_s(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("portal_custom_questions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function f_s(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("portal_custom_questions").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function _1(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function x_s({contactId:t}){const s=fr(),r=Qt(),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(null),j=yR(),w=Hat(),{data:N,isLoading:S}=mt({queryKey:["contact-portals",t],queryFn:async()=>{const{data:U,error:B}=await H.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if(B)throw B;if(!U||U.length===0)return[];const V=U.map(ee=>ee.id),{data:Y,error:Q}=await H.from("client_portals").select("*").in("deal_id",V).is("archived_at",null);if(Q)throw Q;return(Y||[]).map(ee=>({...ee,deal:U.find(X=>X.id===ee.deal_id)}))},enabled:!!t}),M=(N==null?void 0:N.map(U=>U.id))||[],{data:L}=mt({queryKey:["contact-portal-updates",M],queryFn:async()=>{if(M.length===0)return{};const{data:U,error:B}=await H.from("portal_updates").select("*").in("portal_id",M).order("created_at",{ascending:!1});if(B)throw B;const V={};return(U||[]).forEach(Y=>{V[Y.portal_id]||(V[Y.portal_id]=Y)}),V},enabled:M.length>0}),I=U=>{navigator.clipboard.writeText(_1(U)),a(U),me.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},O=async U=>{u.trim()&&(await w.mutateAsync({portal_id:U,title:u,content:f||void 0}),c(!1),p(""),g(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),me.success("Portal update posted!"))},q=async()=>{b&&(await j.mutateAsync({id:b.id,welcome_message:b.welcome_message,next_step_text:b.next_step_text,is_enabled:b.is_enabled,show_post_close_tips:b.show_post_close_tips,review_url:b.review_url}),l(!1),_(null),r.invalidateQueries({queryKey:["contact-portals",t]}),me.success("Portal settings updated!"))};return S||!N||N.length===0?null:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(su,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Oe,{className:"space-y-3",children:N.map(U=>{var Q,ee,X;const B=((Q=U.stage_mapping)==null?void 0:Q.length)>0?U.stage_mapping:sNe(((ee=U.deal)==null?void 0:ee.deal_type)||"buyer"),V=B==null?void 0:B[U.current_stage_index??0],Y=L==null?void 0:L[U.id];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((X=U.deal)==null?void 0:X.deal_name)||"Portal"}),V&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",V.label||V.name]})]}),e.jsx(st,{variant:U.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:U.is_enabled?"Active":"Disabled"})]}),Y&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:Y.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ms(new Date(Y.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>I(U.slug),children:[n===U.slug?e.jsx(va,{className:"h-3 w-3 mr-1"}):e.jsx(gi,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(_1(U.slug),"_blank"),children:[e.jsx(tn,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(fs,{open:i,onOpenChange:c,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>c(!0),children:[e.jsx(so,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:u,onChange:ie=>p(ie.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Details (optional)"}),e.jsx(Er,{value:f,onChange:ie=>g(ie.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>O(U.id),disabled:!u.trim()||w.isPending,className:"w-full",children:[e.jsx(Bn,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{_({...U}),l(!0)},children:[e.jsx(Xo,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Portal Settings"})}),b&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Portal Enabled"}),e.jsx(qr,{checked:b.is_enabled,onCheckedChange:ie=>_({...b,is_enabled:ie})})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Welcome Message"}),e.jsx(Er,{value:b.welcome_message||"",onChange:ie=>_({...b,welcome_message:ie.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Next Step"}),e.jsx(ze,{value:b.next_step_text||"",onChange:ie=>_({...b,next_step_text:ie.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Review URL"}),e.jsx(ze,{value:b.review_url||"",onChange:ie=>_({...b,review_url:ie.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Show Post-Close Tips"}),e.jsx(qr,{checked:b.show_post_close_tips,onCheckedChange:ie=>_({...b,show_post_close_tips:ie})})]}),e.jsx(rl,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:q,disabled:j.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${U.deal_id}`),children:[e.jsx(Qa,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),N.length>1&&e.jsx(rl,{})]},U.id)})})]})}function g_s({contactId:t}){const{data:s}=mt({queryKey:["agent-lead-sites-slugs"],queryFn:async()=>{const{data:l,error:i}=await H.from("lead_sites").select("id, subdomain_slug").eq("is_active",!0);if(i)throw i;return new Map((l||[]).map(c=>[c.id,c.subdomain_slug]))},staleTime:6e5}),r=s&&s.size>0,{data:n,isLoading:a}=mt({queryKey:["contact-property-views",t],queryFn:async()=>{const{data:l,error:i}=await H.rpc("get_contact_property_views",{p_contact_id:t});if(i)throw i;return l||[]},enabled:!!t&&!!r});if(!r||a||!n||n.length===0)return null;const o=l=>{const i=s==null?void 0:s.get(l.lead_site_id);return i?`https://${i}.thelocalmove.com/listing/${l.mls_number}`:null};return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Ln,{className:"h-4 w-4 text-primary"})}),"Property Activity",e.jsxs(st,{variant:"secondary",className:"text-xs ml-auto",children:[n.length," ",n.length===1?"property":"properties"]})]})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"space-y-1",children:n.map(l=>{const i=o(l),c=l.property_address||`MLS# ${l.mls_number}`;return e.jsxs("a",{href:i||"#",target:"_blank",rel:"noopener noreferrer",onClick:u=>{i||u.preventDefault()},className:"group flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[l.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden flex-shrink-0 bg-muted",children:e.jsx("img",{src:l.photo_url,alt:c,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-primary/15 to-primary/5 flex items-center justify-center flex-shrink-0",children:e.jsx(bn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:"font-medium text-sm truncate",children:c})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),e.jsx("span",{title:ms(new Date(l.viewed_at),"PPp"),children:Uc(new Date(l.viewed_at),{addSuffix:!0})})]})]}),i&&e.jsx(tn,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},l.mls_number)})})})]})}const y_s=["Single Family","Condo","Townhouse","Multi-Family","Land","Commercial"];function e7e({value:t,onChange:s,onAdd:r,suggestions:n,placeholder:a,icon:o}){const[l,i]=k.useState(!1),c=k.useRef(null),u=k.useRef(null);k.useEffect(()=>{const f=g=>{u.current&&!u.current.contains(g.target)&&c.current&&!c.current.contains(g.target)&&i(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const p=n.filter(f=>f.toLowerCase().includes(t.toLowerCase()));return e.jsxs("div",{className:"relative flex-1",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ze,{ref:c,value:t,onChange:f=>{s(f.target.value),i(!0)},onFocus:()=>i(!0),placeholder:a,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),p.length>0?r(p[0]):r(t))}}),n.length>0&&e.jsx(Eo,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>r(t),children:e.jsx($s,{className:"h-4 w-4"})})]}),l&&p.length>0&&e.jsx("div",{ref:u,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:p.map(f=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>{r(f),i(!1)},children:[o||e.jsx(ma,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),f]},f))})]})}function v_s({contactId:t,contactName:s}){var U,B,V;const{user:r}=Ds(),{hasLeadSite:n}=rE(),a=Qt(),[o,l]=k.useState(!1),[i,c]=k.useState(""),[u,p]=k.useState(""),{data:f}=mt({queryKey:["agent-lead-site-config",r==null?void 0:r.id],queryFn:async()=>{const{data:Y,error:Q}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",r==null?void 0:r.id).eq("is_active",!0).maybeSingle();if(Q||!Y)return{cities:[],zipCodes:[]};const ee=Y.theme_config||{},X=Array.isArray(ee.searchCities)?ee.searchCities:[];Y.mls_market_area&&!X.includes(Y.mls_market_area)&&X.unshift(Y.mls_market_area);const ie=Array.isArray(ee.searchZipCodes)?ee.searchZipCodes:[];return{cities:X,zipCodes:ie}},enabled:!!r}),{data:g,isLoading:b}=mt({queryKey:["contact-property-alert",t],queryFn:async()=>{const{data:Y,error:Q}=await H.from("contact_property_alerts").select("*").eq("contact_id",t).maybeSingle();if(Q)throw Q;return Y},enabled:!!t&&!!r}),[_,j]=k.useState({}),w=()=>{j({is_active:(g==null?void 0:g.is_active)??!0,min_price:(g==null?void 0:g.min_price)??null,max_price:(g==null?void 0:g.max_price)??null,min_beds:(g==null?void 0:g.min_beds)??null,min_baths:(g==null?void 0:g.min_baths)??null,min_sqft:(g==null?void 0:g.min_sqft)??null,max_sqft:(g==null?void 0:g.max_sqft)??null,cities:(g==null?void 0:g.cities)??[],zip_codes:(g==null?void 0:g.zip_codes)??[],property_types:(g==null?void 0:g.property_types)??[],frequency:(g==null?void 0:g.frequency)??"daily"}),l(!0)},N=Lt({mutationFn:async()=>{const Y={contact_id:t,owner_user_id:r.id,is_active:_.is_active??!0,min_price:_.min_price||null,max_price:_.max_price||null,min_beds:_.min_beds||null,min_baths:_.min_baths||null,min_sqft:_.min_sqft||null,max_sqft:_.max_sqft||null,cities:_.cities||[],zip_codes:_.zip_codes||[],property_types:_.property_types||[],frequency:_.frequency||"daily"};if(g!=null&&g.id){const{error:Q}=await H.from("contact_property_alerts").update(Y).eq("id",g.id);if(Q)throw Q}else{const{error:Q}=await H.from("contact_property_alerts").insert(Y);if(Q)throw Q}},onSuccess:()=>{a.invalidateQueries({queryKey:["contact-property-alert",t]}),l(!1),me.success("Property alert saved!")},onError:Y=>{me.error(Y.message||"Failed to save alert")}}),S=Lt({mutationFn:async()=>{if(!(g!=null&&g.id))return;const{error:Y}=await H.from("contact_property_alerts").delete().eq("id",g.id);if(Y)throw Y},onSuccess:()=>{a.invalidateQueries({queryKey:["contact-property-alert",t]}),l(!1),me.success("Property alert removed")}}),M=Y=>{var ee;const Q=Y.trim();Q&&!((ee=_.cities)!=null&&ee.includes(Q))&&j(X=>({...X,cities:[...X.cities||[],Q]})),c("")},L=Y=>{var ee;const Q=Y.trim();Q&&!((ee=_.zip_codes)!=null&&ee.includes(Q))&&j(X=>({...X,zip_codes:[...X.zip_codes||[],Q]})),p("")},I=Y=>{j(Q=>{const ee=Q.property_types||[];return{...Q,property_types:ee.includes(Y)?ee.filter(X=>X!==Y):[...ee,Y]}})};if(!n||b)return null;if(g&&!o)return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:`h-7 w-7 rounded-lg flex items-center justify-center ${g.is_active?"bg-green-500/10":"bg-muted"}`,children:g.is_active?e.jsx(Lm,{className:"h-4 w-4 text-green-600"}):e.jsx(r1,{className:"h-4 w-4 text-muted-foreground"})}),"Property Alerts",e.jsxs(st,{variant:g.is_active?"default":"secondary",className:"text-xs ml-auto",children:[g.is_active?"Active":"Paused"," · ",g.frequency]})]})}),e.jsxs(Oe,{className:"pt-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-xs",children:[g.min_price||g.max_price?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(ac,{className:"h-3 w-3"}),g.min_price?`$${(g.min_price/1e3).toFixed(0)}k`:"$0"," - ",g.max_price?`$${(g.max_price/1e3).toFixed(0)}k`:"Any"]}):null,g.min_beds?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(Z4,{className:"h-3 w-3"}),g.min_beds,"+ beds"]}):null,g.min_baths?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(Ju,{className:"h-3 w-3"}),g.min_baths,"+ baths"]}):null,(U=g.cities)==null?void 0:U.map(Y=>e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),Y]},Y)),(B=g.zip_codes)==null?void 0:B.map(Y=>e.jsx(st,{variant:"outline",children:Y},Y)),(V=g.property_types)==null?void 0:V.map(Y=>e.jsx(st,{variant:"outline",children:Y},Y))]}),g.last_sent_at&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sent: ",new Date(g.last_sent_at).toLocaleDateString()]}),e.jsx(K,{variant:"outline",size:"sm",onClick:w,className:"w-full",children:"Edit Alert"})]})]});const O=((f==null?void 0:f.cities)||[]).filter(Y=>{var Q;return!((Q=_.cities)!=null&&Q.includes(Y))}),q=((f==null?void 0:f.zipCodes)||[]).filter(Y=>{var Q;return!((Q=_.zip_codes)!=null&&Q.includes(Y))});return o?e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Lm,{className:"h-4 w-4 text-primary"}),g?"Edit":"Setup"," Property Alert for ",s]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Alert Active"}),e.jsx(qr,{checked:_.is_active??!0,onCheckedChange:Y=>j(Q=>({...Q,is_active:Y}))})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(ac,{className:"h-3.5 w-3.5"})," Price Range"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{type:"number",placeholder:"Min price",value:_.min_price??"",onChange:Y=>j(Q=>({...Q,min_price:Y.target.value?Number(Y.target.value):null}))}),e.jsx(ze,{type:"number",placeholder:"Max price",value:_.max_price??"",onChange:Y=>j(Q=>({...Q,max_price:Y.target.value?Number(Y.target.value):null}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Z4,{className:"h-3.5 w-3.5"})," Min Beds"]}),e.jsxs(Ks,{value:_.min_beds?String(_.min_beds):"any",onValueChange:Y=>j(Q=>({...Q,min_beds:Y==="any"?null:Number(Y)})),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Any"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"any",children:"Any"}),[1,2,3,4,5].map(Y=>e.jsxs(Mt,{value:String(Y),children:[Y,"+"]},Y))]})]})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"})," Min Baths"]}),e.jsxs(Ks,{value:_.min_baths?String(_.min_baths):"any",onValueChange:Y=>j(Q=>({...Q,min_baths:Y==="any"?null:Number(Y)})),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Any"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"any",children:"Any"}),[1,1.5,2,2.5,3,4].map(Y=>e.jsxs(Mt,{value:String(Y),children:[Y,"+"]},Y))]})]})]})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(g0,{className:"h-3.5 w-3.5"})," Square Feet"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{type:"number",placeholder:"Min sqft",value:_.min_sqft??"",onChange:Y=>j(Q=>({...Q,min_sqft:Y.target.value?Number(Y.target.value):null}))}),e.jsx(ze,{type:"number",placeholder:"Max sqft",value:_.max_sqft??"",onChange:Y=>j(Q=>({...Q,max_sqft:Y.target.value?Number(Y.target.value):null}))})]})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(ma,{className:"h-3.5 w-3.5"})," Cities"]}),e.jsx(e7e,{value:i,onChange:c,onAdd:M,suggestions:O,placeholder:"Type to search cities..."}),_.cities&&_.cities.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:_.cities.map(Y=>e.jsxs(st,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>j(Q=>{var ee;return{...Q,cities:(ee=Q.cities)==null?void 0:ee.filter(X=>X!==Y)}}),children:e.jsx(Rr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsx(be,{className:"mb-1.5",children:"Zip Codes"}),e.jsx(e7e,{value:u,onChange:p,onAdd:L,suggestions:q,placeholder:"Type to search zip codes...",icon:e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:"#"})}),_.zip_codes&&_.zip_codes.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:_.zip_codes.map(Y=>e.jsxs(st,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>j(Q=>{var ee;return{...Q,zip_codes:(ee=Q.zip_codes)==null?void 0:ee.filter(X=>X!==Y)}}),children:e.jsx(Rr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(bn,{className:"h-3.5 w-3.5"})," Property Types"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:y_s.map(Y=>{var Q;return e.jsx(st,{variant:(Q=_.property_types)!=null&&Q.includes(Y)?"default":"outline",className:"cursor-pointer",onClick:()=>I(Y),children:Y},Y)})})]}),e.jsxs("div",{children:[e.jsx(be,{className:"mb-1.5",children:"Frequency"}),e.jsxs(Ks,{value:_.frequency||"daily",onValueChange:Y=>j(Q=>({...Q,frequency:Y})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"daily",children:"Daily"}),e.jsx(Mt,{value:"weekly",children:"Weekly"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>N.mutate(),disabled:N.isPending,className:"flex-1",children:[N.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(qc,{className:"h-4 w-4 mr-1"}),"Save Alert"]}),e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),g&&e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>S.mutate(),disabled:S.isPending,children:e.jsx(Rr,{className:"h-4 w-4"})})]})]})]}):e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed border-primary/30 hover:bg-primary/5 transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Lm,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Set Up Property Alerts"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Automatically email ",s," new listings matching their criteria"]})]})]})})})}function b_s({contactId:t,contactName:s}){var X;const{user:r}=Ds(),{hasLeadSite:n}=rE(),a=Qt(),[o,l]=k.useState(!1),[i,c]=k.useState(""),[u,p]=k.useState([]),[f,g]=k.useState(!1),[b,_]=k.useState(!1),[j,w]=k.useState(!1),[N,S]=k.useState(""),M=k.useRef(null),L=k.useRef(null),{data:I}=mt({queryKey:["agent-lead-site-cities",r==null?void 0:r.id],queryFn:async()=>{const{data:ie,error:re}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",r==null?void 0:r.id).eq("is_active",!0).maybeSingle();if(re||!ie)return[];const oe=ie.theme_config||{},ce=Array.isArray(oe.searchCities)?oe.searchCities:[];return ie.mls_market_area&&!ce.includes(ie.mls_market_area)&&ce.unshift(ie.mls_market_area),ce},enabled:!!r}),{data:O,isLoading:q}=mt({queryKey:["contact-market-report",t],queryFn:async()=>{const{data:ie,error:re}=await H.from("innercircle_contacts").select("market_report_enabled, market_report_cities").eq("id",t).single();if(re)throw re;return ie},enabled:!!t&&!!r});k.useEffect(()=>{const ie=re=>{L.current&&!L.current.contains(re.target)&&M.current&&!M.current.contains(re.target)&&_(!1)};return document.addEventListener("mousedown",ie),()=>document.removeEventListener("mousedown",ie)},[]);const U=()=>{g((O==null?void 0:O.market_report_enabled)??!1),p((O==null?void 0:O.market_report_cities)??[]),l(!0)},B=ie=>{const re=(ie||i).trim();re&&!u.includes(re)&&p([...u,re]),c(""),_(!1)},V=(I||[]).filter(ie=>!u.includes(ie)&&ie.toLowerCase().includes(i.toLowerCase())),Y=Lt({mutationFn:async()=>{const{data:ie,error:re}=await H.functions.invoke("send-market-report",{body:{action:"preview",agentId:r==null?void 0:r.id,cities:(O==null?void 0:O.market_report_cities)??[]}});if(re)throw new Error(re.message||"Failed to generate preview");if(ie&&!ie.ok&&ie.error)throw new Error(ie.error);return ie},onSuccess:ie=>{S(ie.html),w(!0)},onError:ie=>{me.error(ie.message||"Failed to generate preview")}}),Q=Lt({mutationFn:async()=>{const{data:ie,error:re}=await H.functions.invoke("send-market-report",{body:{action:"send",agentId:r==null?void 0:r.id,cities:(O==null?void 0:O.market_report_cities)??[],contactIds:[t]}});if(re)throw new Error(re.message||"Failed to send report");if(ie&&!ie.ok&&ie.error)throw new Error(ie.error);return ie},onSuccess:()=>{me.success(`Market report sent to ${s}!`)},onError:ie=>{me.error(ie.message||"Failed to send report")}}),ee=Lt({mutationFn:async()=>{const{error:ie}=await H.from("innercircle_contacts").update({market_report_enabled:f,market_report_cities:u}).eq("id",t);if(ie)throw ie},onSuccess:()=>{a.invalidateQueries({queryKey:["contact-market-report",t]}),l(!1),me.success(f?"Monthly market report enabled!":"Market report disabled")},onError:ie=>{me.error(ie.message||"Failed to save")}});return!n||q?null:O!=null&&O.market_report_enabled&&!o?e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg flex items-center justify-center bg-primary/10",children:e.jsx(No,{className:"h-4 w-4 text-primary"})}),"Monthly Market Report",e.jsx(st,{variant:"default",className:"text-xs ml-auto",children:"Active"})]})}),e.jsxs(Oe,{className:"pt-0 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 text-xs",children:((X=O.market_report_cities)==null?void 0:X.length)>0?O.market_report_cities.map(ie=>e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),ie]},ie)):e.jsx("span",{className:"text-muted-foreground",children:"Using default market area"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s," receives a branded market report on the 1st of each month."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Y.mutate(),disabled:Y.isPending,className:"flex-1",children:[Y.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Ln,{className:"h-4 w-4 mr-1"}),"Preview"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>Q.mutate(),disabled:Q.isPending,className:"flex-1",children:[Q.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4 mr-1"}),"Send Now"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:U,children:"Edit"})]}),e.jsx(fs,{open:j,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(No,{className:"h-5 w-5 text-primary"}),"Market Report Preview"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto -mx-6 px-6",children:e.jsx("div",{className:"border rounded-lg overflow-hidden",dangerouslySetInnerHTML:{__html:N}})}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsxs(K,{onClick:()=>{w(!1),Q.mutate()},disabled:Q.isPending,className:"flex-1",children:[Q.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4 mr-1"}),"Send to ",s]}),e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Close"})]})]})})]})]}):o?e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(No,{className:"h-4 w-4 text-primary"}),"Market Report for ",s]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Send Monthly Report"}),e.jsx(qr,{checked:f,onCheckedChange:g})]}),f&&e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(ma,{className:"h-3.5 w-3.5"})," Report Cities"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select cities from your website's configured areas."}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ze,{ref:M,value:i,onChange:ie=>{c(ie.target.value),_(!0)},onFocus:()=>_(!0),placeholder:"Type to search cities...",onKeyDown:ie=>{ie.key==="Enter"&&(ie.preventDefault(),V.length>0?B(V[0]):B())}}),e.jsx(Eo,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>B(),children:e.jsx($s,{className:"h-4 w-4"})})]}),b&&V.length>0&&e.jsx("div",{ref:L,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:V.map(ie=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>B(ie),children:[e.jsx(ma,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ie]},ie))})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:u.map(ie=>e.jsxs(st,{variant:"secondary",className:"gap-1",children:[ie,e.jsx("button",{onClick:()=>p(u.filter(re=>re!==ie)),children:e.jsx(Rr,{className:"h-3 w-3"})})]},ie))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>ee.mutate(),disabled:ee.isPending,className:"flex-1",children:[ee.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(qc,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})]}):e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("button",{onClick:U,className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed border-primary/30 hover:bg-primary/5 transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(No,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable Monthly Market Report"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Auto-send ",s," a branded market report with real MLS data every month"]})]})]})})})}function __s({videoId:t}){var l;const{data:s,isLoading:r,error:n}=r_s(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"w-full aspect-video rounded-lg"}),e.jsx(ys,{className:"h-4 w-1/3"})]});if(n||!s||s.is_deleted)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Ku,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-medium",children:"Video Unavailable"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video has been deleted or is no longer available."})]});const a=i=>{let c=i;return c.includes("iframe.mediadelivery.net/play/")&&(c=c.replace("/play/","/embed/"),c+=(c.includes("?")?"&":"?")+"autoplay=true&responsive=true"),c},o=(l=s.playback_url)==null?void 0:l.includes("iframe.mediadelivery.net");return e.jsxs("div",{className:"space-y-4",children:[s.playback_url?e.jsx("div",{className:"relative w-full aspect-video bg-black rounded-lg overflow-hidden",children:o?e.jsx("iframe",{src:a(s.playback_url),title:s.title||"Video preview",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:s.playback_url,controls:!0,autoPlay:!0,className:"absolute top-0 left-0 w-full h-full object-contain"})}):e.jsx("div",{className:"w-full aspect-video bg-muted rounded-lg flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Video is still processing..."})}),s.title&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:s.title}),s.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.notes})]})]})}function w_s({contactId:t}){const s=fr(),[r,n]=k.useState(!1),{data:a,isLoading:o}=mt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:g}=await H.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(g)throw g;return f},enabled:!!t}),l=async(f,g)=>{const b=g==="done"?"todo":"done";await H.from("deal_tasks").update({status:b,completed_at:b==="done"?new Date().toISOString():null}).eq("id",f),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=mt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:g}=await H.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(g)throw g;return f},enabled:!!t}),c={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(f=>f.status!=="done"))||[],p=(a==null?void 0:a.filter(f=>f.status==="done"))||[];return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(va,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(st,{variant:"secondary",className:"text-xs",children:u.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx($s,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Oe,{className:"space-y-1",children:o?e.jsx(ys,{className:"h-8 w-full"}):u.length===0&&p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tasks yet"}):e.jsxs(e.Fragment,{children:[u.map(f=>e.jsxs("button",{onClick:async()=>{await l(f.id,f.status),i()},className:"w-full text-left flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors group",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border-2 border-muted-foreground/30 shrink-0 group-hover:border-primary"}),e.jsxs("span",{className:"text-sm flex-1 truncate",children:[c[f.priority]," ",f.title]}),f.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ms(new Date(f.due_date),"MMM d")})]},f.id)),p.length>0&&e.jsx("div",{className:"pt-1 border-t mt-1",children:e.jsxs("p",{className:"text-[10px] text-muted-foreground px-2 py-1",children:[p.length," completed"]})})]})}),r&&e.jsx(j_s,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function j_s({contactId:t,open:s,onOpenChange:r}){const[n,a]=k.useState(""),[o,l]=k.useState("medium"),[i,c]=k.useState(),{data:u}=mt({queryKey:["session"],queryFn:async()=>{const{data:f}=await H.auth.getSession();return f.session}}),p=async()=>{var g;if(!n.trim()||!((g=u==null?void 0:u.user)!=null&&g.id))return;const{error:f}=await H.from("deal_tasks").insert([{owner_user_id:u.user.id,contact_id:t,title:n.trim(),priority:o,status:"todo",due_date:i?ms(i,"yyyy-MM-dd"):null}]);if(f){console.error("Task create error:",f);return}r(!1)};return e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ps,{className:"sm:max-w-[400px]",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:n,onChange:f=>a(f.target.value),placeholder:"Task title...",onKeyDown:f=>f.key==="Enter"&&p()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Priority"}),e.jsxs("select",{value:o,onChange:f=>l(f.target.value),className:"w-full h-10 rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"low",children:"🟢 Low"}),e.jsx("option",{value:"medium",children:"🟡 Medium"}),e.jsx("option",{value:"high",children:"🟠 High"}),e.jsx("option",{value:"urgent",children:"🔴 Urgent"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Due Date"}),e.jsx(ze,{type:"date",value:i?ms(i,"yyyy-MM-dd"):"",onChange:f=>c(f.target.value?new Date(f.target.value+"T00:00:00"):void 0)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{onClick:p,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function N_s({contactId:t}){const s=fr(),{data:r,isLoading:n}=mt({queryKey:["contact-linked-deals",t],queryFn:async()=>{const{data:a,error:o}=await H.from("deal_pipeline").select(` id, deal_name, deal_type, expected_price, property_address, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).eq("contact_id",t).order("updated_at",{ascending:!1});if(o)throw o;return a},enabled:!!t});return n||!r||r.length===0?null:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Gh,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Oe,{className:"space-y-2",children:r.map(a=>{const o=a.stage;return e.jsx("button",{onClick:()=>s(`/mission-control/pipeline?deal=${a.id}`),className:"w-full text-left p-3 rounded-lg border hover:bg-accent transition-colors group",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.deal_name}),a.property_address&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.property_address}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1",style:{borderColor:o.color,color:o.color,backgroundColor:`${o.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:o.color}}),o.name]})]})]}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function k_s(){var He,ct,Ue,Ze,Qe;const{contactId:t}=yo(),s=fr(),[r]=Cc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=sLt(t||""),{data:c}=Vx(),{data:u}=qO(),{data:p}=UO(3650),{data:f}=Vhe(365),{data:g}=o_s(t),{contactsWithScores:b}=kue(),_=wNe(),j=jNe(),w=NNe(),N=KYe(),[S,M]=k.useState(!1),[L,I]=k.useState({}),[O,q]=k.useState(!1),[U,B]=k.useState(null),[V,Y]=k.useState(""),[Q,ee]=k.useState(void 0),[X,ie]=k.useState(""),[re,oe]=k.useState(null),[ce,ge]=k.useState(!1),[ye,ue]=k.useState(null),{isGmailConnected:pe,gmailEmail:_e}=Gx(),{data:$e}=mt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:We,error:Je}=await H.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(Je)throw Je;return We},enabled:!!t}),Ae=We=>{if(!We)return null;const Je=We.match(/Video ID:\s*([a-f0-9-]+)/i);return Je?Je[1]:null},Ie=k.useMemo(()=>{if(!b)return[];let We=b.filter(Je=>{var Vt,hs,Ts;const it=n===""||`${Je.first_name} ${Je.last_name}`.toLowerCase().includes(n.toLowerCase())||((Vt=Je.email)==null?void 0:Vt.toLowerCase().includes(n.toLowerCase()))||((hs=Je.phone)==null?void 0:hs.includes(n)),Dt=a==="all"||((Ts=Je.tags)==null?void 0:Ts.some(Cs=>Cs.relationship_type_id===a));return it&&Dt});return o==="not-touched-90"?We=We.filter(Je=>{const it=Je.relationshipScore.daysSinceTouch;return it===null||it>90}):o==="at-risk"?We=We.filter(Je=>Je.relationshipScore.status==="at-risk"):o==="cooling"?We=We.filter(Je=>Je.relationshipScore.status==="cooling"):o==="warm"&&(We=We.filter(Je=>Je.relationshipScore.status==="warm")),We.map(Je=>Je.id)},[b,n,a,o]),Ce=Ie.indexOf(t||""),xe=Ce>0?Ie[Ce-1]:null,we=Ce1&&Ce!==-1,tt=We=>{const Je=new URLSearchParams;n&&Je.set("search",n),a!=="all"&&Je.set("type",a),o!=="all"&&Je.set("status",o);const it=Je.toString();return`/mission-control/contacts/${We}${it?`?${it}`:""}`},Te=k.useMemo(()=>{const We=((p==null?void 0:p.filter(it=>it.contact_id===t))||[]).map(it=>{var Ts,Cs,cs;const Dt=Ae(it.notes);let Vt=((Ts=it.action_type)==null?void 0:Ts.name)||"Touch",hs=it.notes;if(Vt==="Other"&&((Cs=it.notes)!=null&&Cs.startsWith("["))){const er=it.notes.indexOf("]");er>0&&(Vt=it.notes.substring(1,er),hs=it.notes.substring(er+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:it.id,type:"touch",completed_at:it.completed_at,name:Vt,color:((cs=it.action_type)==null?void 0:cs.color)||"#3B82F6",notes:hs,videoId:Dt}}),Je=((f==null?void 0:f.filter(it=>it.contact_id===t))||[]).map(it=>({id:it.id,type:"popby",completed_at:it.completed_at,name:"Pop-by",color:"#F97316",notes:it.notes,videoId:null}));return[...We,...Je].sort((it,Dt)=>new Date(Dt.completed_at).getTime()-new Date(it.completed_at).getTime())},[p,f,t]),pt=()=>{var We;l&&(I({first_name:l.first_name||"",last_name:l.last_name||"",email:l.email||"",phone:l.phone||"",address:l.address||"",city:l.city||"",state:l.state||"",zip_code:l.zip_code||"",birthday:l.birthday||"",home_anniversary:l.home_anniversary||"",spouse_name:l.spouse_name||"",spouse_email:l.spouse_email||"",company_name:l.company_name||"",job_title:l.job_title||"",lead_source_id:l.lead_source_id||"",notes:l.notes||"",tagIds:((We=l.tags)==null?void 0:We.map(Je=>Je.relationship_type_id))||[]}),M(!0))},fe=async()=>{await _.mutateAsync({id:t,...L,lead_source_id:L.lead_source_id||null}),M(!1)},qe=async()=>{confirm("Are you sure you want to delete this contact?")&&(await j.mutateAsync(t),s("/mission-control/contacts"))},et=((He=u==null?void 0:u.find(We=>We.id===U))==null?void 0:He.name)==="Other",Me=async()=>{if(!U||et&&!X.trim())return;const We=Q?new Date(Q.getFullYear(),Q.getMonth(),Q.getDate(),12,0,0).toISOString():void 0,Je=et?`[${X.trim()}]${V?" — "+V:""}`:V;await w.mutateAsync({contactId:t,actionTypeId:U,notes:Je,completedAt:We}),q(!1),B(null),Y(""),ee(void 0),ie("")},rt=(We,Je)=>{pe&&l?(ue({email:We,name:Je||`${l.first_name} ${l.last_name||""}`.trim()}),ge(!0)):window.location.href=`mailto:${We}`};return i?e.jsx(Ms,{title:"Contact Details",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):l?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{title:`${l.first_name} ${l.last_name||""}`,description:"Contact details and activity",children:e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/contacts"),children:[e.jsx(cl,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),Le&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>xe&&s(tt(xe)),disabled:!xe,className:"px-2",children:[e.jsx(cl,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only sm:not-sr-only sm:ml-1",children:"Prev"})]}),e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Ce+1," of ",Ie.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>we&&s(tt(we)),disabled:!we,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(da,{className:"h-4 w-4"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end flex-wrap",children:[l.email&&e.jsxs(K,{variant:"outline",onClick:()=>rt(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(cr,{className:"h-4 w-4 mr-1"}),"Email"]}),e.jsxs(K,{variant:"default",onClick:()=>s(`/mission-control/video/record?contact_id=${t}`),className:"bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(An,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(fs,{open:O,onOpenChange:q,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(ps,{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(We=>We.active).map(We=>e.jsxs("button",{onClick:()=>B(We.id),className:` p-3 rounded-lg border text-left transition-all ${U===We.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:We.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:We.description})]},We.id))}),et&&e.jsxs("div",{className:"mt-3",children:[e.jsx(be,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(ze,{id:"custom-action-name",value:X,onChange:We=>ie(We.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Date (optional — backdate if needed)"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal mt-2",!Q&&"text-muted-foreground"),children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),Q?ms(Q,"PPP"):"Today (default)"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:Q,onSelect:ee,disabled:We=>We>new Date,initialFocus:!0,className:It("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Er,{id:"action-notes",value:V,onChange:We=>Y(We.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:Me,disabled:!U||et&&!X.trim()||w.isPending,className:"w-full",children:[e.jsx(va,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:pt,children:[e.jsx(hd,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:qe,children:e.jsx(Nr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"bg-card border rounded-lg p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold",children:[l.first_name," ",l.last_name||""]}),(((ct=l.lead_source_ref)==null?void 0:ct.name)||l.lead_source)&&e.jsx(st,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((Ue=l.lead_source_ref)==null?void 0:Ue.name)||l.lead_source})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-2 text-muted-foreground",children:[l.email&&e.jsxs("button",{onClick:()=>rt(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(cr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:l.email})]}),l.phone&&e.jsxs("a",{href:`tel:${l.phone}`,className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:l.phone})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx($_e,{contact:l}),(Ze=l.tags)==null?void 0:Ze.map(We=>{const Je=c==null?void 0:c.find(it=>it.id===We.relationship_type_id);return Je?e.jsx(st,{variant:"secondary",className:"text-xs",children:Je.name},We.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Kbs,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"md:col-span-2",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Contact Information"})}),e.jsx(Oe,{children:S?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"first_name",children:"First Name"}),e.jsx(ze,{id:"first_name",value:L.first_name,onChange:We=>I({...L,first_name:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"last_name",children:"Last Name"}),e.jsx(ze,{id:"last_name",value:L.last_name,onChange:We=>I({...L,last_name:We.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:L.email,onChange:We=>I({...L,email:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",value:L.phone,onChange:We=>I({...L,phone:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"address",children:"Street Address"}),e.jsx(ze,{id:"address",value:L.address,onChange:We=>I({...L,address:We.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(be,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:L.city,onChange:We=>I({...L,city:We.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:L.state,onChange:We=>I({...L,state:We.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(ze,{id:"zip_code",value:L.zip_code,onChange:We=>I({...L,zip_code:We.target.value}),placeholder:"12345"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"birthday",children:"Birthday"}),e.jsx(ze,{id:"birthday",type:"date",value:L.birthday,onChange:We=>I({...L,birthday:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(ze,{id:"home_anniversary",type:"date",value:L.home_anniversary,onChange:We=>I({...L,home_anniversary:We.target.value})})]})]}),e.jsx(rl,{}),e.jsx(q_e,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:(l==null?void 0:l.spouse_name)||null,currentSpouseEmail:(l==null?void 0:l.spouse_email)||null,onLink:We=>N.mutate({contactId:t,spouseContactId:We}),onUnlink:()=>N.mutate({contactId:t,spouseContactId:null}),isEditing:!0}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"company_name",children:"Company"}),e.jsx(ze,{id:"company_name",value:L.company_name,onChange:We=>I({...L,company_name:We.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"job_title",children:"Job Title"}),e.jsx(ze,{id:"job_title",value:L.job_title,onChange:We=>I({...L,job_title:We.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(Uat,{value:L.lead_source_id||"",onChange:We=>I({...L,lead_source_id:We})}),e.jsxs("div",{children:[e.jsx(be,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:c==null?void 0:c.filter(We=>We.active).map(We=>{var Je;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Oo,{checked:(Je=L.tagIds)==null?void 0:Je.includes(We.id),onCheckedChange:it=>{var Dt;I(it?{...L,tagIds:[...L.tagIds||[],We.id]}:{...L,tagIds:(Dt=L.tagIds)==null?void 0:Dt.filter(Vt=>Vt!==We.id)})}}),e.jsx("span",{className:"text-sm",children:We.name})]},We.id)})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:L.notes,onChange:We=>I({...L,notes:We.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:fe,disabled:_.isPending,children:"Save Changes"}),e.jsx(K,{variant:"outline",onClick:()=>M(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[Te.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",ms(new Date(Te[0].completed_at),"MMM d, yyyy")," ","(",Te[0].name,")"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:gap-6 gap-2",children:[l.email&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(cr,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>rt(l.email),className:"text-primary hover:underline truncate text-left",children:l.email})]}),l.phone&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Un,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("a",{href:`tel:${l.phone}`,className:"text-primary hover:underline",children:l.phone})]})]}),(l.address||l.city||l.state||l.zip_code)&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ma,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"flex flex-col",children:[l.address&&e.jsx("span",{children:l.address}),(l.city||l.state||l.zip_code)&&e.jsxs("span",{className:"text-muted-foreground",children:[[l.city,l.state].filter(Boolean).join(", "),l.zip_code&&` ${l.zip_code}`]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[l.birthday&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",ms(Ol(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",ms(Ol(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($s,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",ms(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(rl,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(q_e,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:We=>N.mutate({contactId:t,spouseContactId:We}),onUnlink:()=>N.mutate({contactId:t,spouseContactId:null}),isEditing:!1}),(l.company_name||l.job_title)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:l.job_title&&l.company_name?`${l.job_title} at ${l.company_name}`:l.job_title||l.company_name})]})]}),e.jsx(rl,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(Qe=l.tags)!=null&&Qe.length?l.tags.map(We=>{var Je;return e.jsx(st,{variant:"secondary",children:(Je=We.relationship_type)==null?void 0:Je.name},We.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(rl,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Notes"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:l.notes})]})]})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Mbs,{contact:l,onLogTouch:()=>q(!0)}),e.jsx(N_s,{contactId:t}),e.jsx(x_s,{contactId:t}),e.jsx(g_s,{contactId:t}),e.jsx(v_s,{contactId:t,contactName:l.first_name}),e.jsx(b_s,{contactId:t,contactName:l.first_name}),e.jsx(w_s,{contactId:t}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Activity Log"})}),e.jsx(Oe,{children:Te.length>0?e.jsx("div",{className:"space-y-4",children:Te.map(We=>{var Je;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[e.jsx("div",{className:"h-8 w-8 rounded-full flex items-center justify-center text-white text-xs",style:{backgroundColor:We.color},children:We.type==="popby"?e.jsx(ko,{className:"h-4 w-4"}):(Je=We.name)==null?void 0:Je.charAt(0)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:We.name}),We.videoId&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>oe(We.videoId),children:[e.jsx(nl,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ms(new Date(We.completed_at),"MMM d, yyyy h:mm a")}),We.notes&&!We.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:We.notes})]})]},We.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"})})]}),g&&g.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:g.map(We=>{var Je,it;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(Je=We.video)!=null&&Je.thumbnail_url?e.jsx("img",{src:We.video.thumbnail_url,alt:We.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>oe(We.video_id)}):e.jsx("div",{className:"h-12 w-16 bg-muted rounded flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>oe(We.video_id),children:e.jsx(An,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:["Replied to: ",((it=We.video)==null?void 0:it.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>oe(We.video_id),children:[e.jsx(nl,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ms(new Date(We.created_at),"MMM d, yyyy h:mm a")}),We.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',We.message,'"']})]})]},We.id)})})})]}),$e&&$e.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Bn,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:$e.map(We=>e.jsxs(fs,{children:[e.jsx(qi,{asChild:!0,children:e.jsxs("button",{className:"w-full text-left flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors cursor-pointer",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-sky-500/10 flex items-center justify-center text-sky-600 flex-shrink-0",children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:We.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",We.to_email," · ",ms(new Date(We.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5 text-sky-500"}),We.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",We.to_email," · ",ms(new Date(We.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden rounded-lg border bg-white",children:e.jsx("iframe",{srcDoc:We.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${We.subject}`})})]})]},We.id))})})]})]}),e.jsx(fs,{open:!!re,onOpenChange:We=>!We&&oe(null),children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Video Preview"})}),re&&e.jsx(__s,{videoId:re})]})})]})]})}),pe&&l&&ye&&e.jsx(Uw,{open:ce,onOpenChange:ge,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:ye.email},gmailEmail:_e})]}):e.jsx(Ms,{title:"Contact Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This contact was not found."}),e.jsx(K,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const t7e={Crown:Dm,FileText:Sn,Users:pr,Globe:su,Star:Jn,Phone:Un,MessageSquare:so,PenTool:U_,Video:An,Gift:ko},gye=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function S_s(){var Qe,We;const t=fr(),{user:s}=Ds(),{data:r}=Vx(),{data:n}=nLt(),{data:a}=uLt(),{data:o}=GYe(),{data:l}=qO(),{data:i}=rLt(),c=hLt(),u=aLt(),p=oLt(),f=lLt(),g=cLt(),b=dLt(),_=iLt(),[j,w]=k.useState(null),[N,S]=k.useState(!1),[M,L]=k.useState(null),[I,O]=k.useState(""),[q,U]=k.useState(""),[B,V]=k.useState([]),[Y,Q]=k.useState(null),[ee,X]=k.useState(null),[ie,re]=k.useState(!1),[oe,ce]=k.useState(""),[ge,ye]=k.useState(""),[ue,pe]=k.useState(""),[_e,$e]=k.useState(""),Ae=(Je,it)=>a==null?void 0:a.some(Dt=>Dt.plan_id===Je&&Dt.relationship_type_id===it&&Dt.active),Ie=Je=>a==null?void 0:a.find(it=>it.relationship_type_id===Je&&it.active),Ce=async(Je,it)=>{const Dt=Ae(Je,it);await c.mutateAsync({planId:Je,relationshipTypeId:it,active:!Dt})},xe=(n==null?void 0:n.filter(Je=>Je.active&&!Je.owner_user_id))||[],we=(n==null?void 0:n.filter(Je=>Je.owner_user_id===(s==null?void 0:s.id)))||[],Le=r==null?void 0:r.find(Je=>Je.id===j),tt=j?Ie(j):null,Te=n==null?void 0:n.find(Je=>Je.id===(tt==null?void 0:tt.plan_id)),pt=async()=>{if(!I.trim())return;const Je=await u.mutateAsync({name:I,description:q});Je&&B.length>0&&await g.mutateAsync({planId:Je.id,items:B}),at()},fe=async()=>{!I.trim()||!M||(await p.mutateAsync({id:M,name:I,description:q}),await g.mutateAsync({planId:M,items:B}),at())},qe=Je=>{var it;L(Je.id),O(Je.name),U(Je.description||""),V(((it=Je.items)==null?void 0:it.map(Dt=>({month_number:Dt.month_number,action_type_id:Dt.action_type_id,default_script_id:Dt.default_script_id||void 0,notes:Dt.notes||void 0})))||[]),S(!0)},at=()=>{S(!1),L(null),O(""),U(""),V([])},et=(Je,it)=>{X(it)},Me=(Je,it,Dt)=>{V(Vt=>[...Vt.filter(Ts=>Ts.month_number!==Je),{month_number:Je,action_type_id:it,default_script_id:Dt}]),Q(null),X(null)},rt=Je=>{V(it=>it.filter(Dt=>Dt.month_number!==Je))},He=async()=>{if(!oe.trim()||!ge.trim()||!ee)return;const Je=await b.mutateAsync({actionTypeId:ee,title:oe,scriptBody:ge,emailSubject:ue||void 0,tone:_e||void 0});Je&&Y!==null&&Me(Y,ee,Je.id),re(!1),ce(""),ye(""),pe(""),$e("")},ct=ee?i==null?void 0:i.filter(Je=>Je.action_type_id===ee&&Je.active):[],Ue=Je=>t7e[Je||"Phone"]||Un,Ze=Je=>t7e[Je||"Users"]||pr;return e.jsxs(Ms,{title:"Touchpoint Plans",description:"Assign plans to your contact groups",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Touchpoint Plans"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(cl,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>S(!0),className:"w-full sm:w-auto",children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create Custom Plan"]})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Your Contact Groups"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a group to assign a touchpoint plan"}),r==null?void 0:r.filter(Je=>Je.active).map(Je=>{const it=Ze(Je.icon),Dt=(o==null?void 0:o[Je.id])||0,Vt=Ie(Je.id),hs=n==null?void 0:n.find(Cs=>Cs.id===(Vt==null?void 0:Vt.plan_id)),Ts=j===Je.id;return e.jsxs("button",{onClick:()=>w(Je.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Ts?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(it,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:Je.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Dt," contacts"]})]}),hs?e.jsxs(st,{variant:"secondary",className:"text-xs",children:[e.jsx(xi,{className:"h-3 w-3 mr-1"}),hs.name.split(" ")[0]]}):e.jsx(st,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},Je.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:j&&Le?e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[(()=>{const Je=Ze(Le.icon);return e.jsx(Je,{className:"h-5 w-5"})})(),Le.name," Touchpoint Plan"]}),e.jsxs(gr,{children:["Choose a plan for your ",Le.name," contacts"]})]}),e.jsxs(Oe,{className:"space-y-6",children:[Te&&e.jsxs("div",{className:"p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(xi,{className:"h-4 w-4 text-green-500"}),"Currently using: ",Te.name]}),Te.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Te.description})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Ce(Te.id,j),children:"Disable"})]}),Te.items&&Te.items.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:gye.map((Je,it)=>{var Ts,Cs;const Dt=((Ts=Te.items)==null?void 0:Ts.filter(cs=>cs.month_number===it+1))||[],Vt=(Cs=Dt[0])==null?void 0:Cs.action_type,hs=Vt?Ue(Vt.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Dt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:Je}),hs&&e.jsx(hs,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Vt==null?void 0:Vt.color)||"#3B82F6"}})]},it)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:Te?"Switch to a Different Plan":"Choose a Plan"}),xe.length>0&&e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Pre-built Templates"}),xe.map(Je=>{var Dt;const it=(Te==null?void 0:Te.id)===Je.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${it?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Je.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Dt=Je.items)==null?void 0:Dt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:_.isPending,onClick:()=>{const Vt=`${Je.name} (Copy)`;_.mutate({sourcePlanId:Je.id,newName:Vt})},children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:it?"outline":"default",disabled:it||c.isPending,onClick:()=>Ce(Je.id,j),children:it?"Active":"Use This"})]})]},Je.id)})]}),we.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),we.map(Je=>{var Dt;const it=(Te==null?void 0:Te.id)===Je.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${it?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Je.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Dt=Je.items)==null?void 0:Dt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>qe(Je),children:e.jsx(e0,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(Je.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:it?"outline":"default",disabled:it||c.isPending,onClick:()=>Ce(Je.id,j),children:it?"Active":"Use This"})]})]},Je.id)})]}),xe.length===0&&we.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No plans available. Create a custom plan to get started."})]})]})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(hn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Select a contact group to view and assign plans"})]})})})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsx(Oe,{className:"py-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"How it works:"})," When you assign a plan to a contact group, those contacts will appear in your daily suggested actions based on the plan's schedule."]})})})]}),e.jsx(fs,{open:N,onOpenChange:Je=>{Je?S(!0):at()},children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:M?"Edit Touchpoint Plan":"Create Custom Touchpoint Plan"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(ze,{id:"plan-name",value:I,onChange:Je=>O(Je.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Er,{id:"plan-description",value:q,onChange:Je=>U(Je.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"12-Month Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Click on a month to add a touchpoint"}),e.jsx("div",{className:"grid grid-cols-6 gap-2",children:gye.map((Je,it)=>{const Dt=it+1,Vt=B.find(Cs=>Cs.month_number===Dt),hs=Vt?l==null?void 0:l.find(Cs=>Cs.id===Vt.action_type_id):null,Ts=hs?Ue(hs.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>Q(Y===Dt?null:Dt),className:` w-full p-3 rounded-lg border text-center transition-all ${Vt?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${Y===Dt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:Je}),Ts?e.jsx(Ts,{className:"h-5 w-5 mx-auto mt-1",style:{color:(hs==null?void 0:hs.color)||"#3B82F6"}}):e.jsx($s,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Vt&&e.jsx("button",{type:"button",onClick:Cs=>{Cs.stopPropagation(),rt(Dt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Rr,{className:"h-3 w-3"})})]},it)})}),Y!==null&&!ee&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"text-sm font-medium mb-2",children:["Step 1: Select action for ",gye[Y-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(Je=>Je.active).map(Je=>{const it=Ue(Je.icon);return e.jsxs("button",{type:"button",onClick:()=>et(Y,Je.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(it,{className:"h-4 w-4",style:{color:Je.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:Je.name})]},Je.id)})})]}),Y!==null&&ee&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-medium",children:"Step 2: Select a script (optional)"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>X(null),children:[e.jsx(cl,{className:"h-4 w-4 mr-1"})," Back"]})]}),e.jsxs("div",{className:"space-y-2 max-h-[300px] overflow-y-auto pr-1",children:[e.jsx("button",{type:"button",onClick:()=>Me(Y,ee),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"No Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Use without a predefined script"})]})}),ct==null?void 0:ct.map(Je=>e.jsx("button",{type:"button",onClick:()=>Me(Y,ee,Je.id),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm",children:Je.title}),Je.tone&&e.jsx(st,{variant:"secondary",className:"text-xs mt-1",children:Je.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[Je.script_body.substring(0,100),"..."]})]})},Je.id)),e.jsxs("button",{type:"button",onClick:()=>re(!0),className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed bg-background hover:bg-accent transition-colors text-left",children:[e.jsx($s,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"Create Custom Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Write your own script for this action"})]})]})]})]})]}),B.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[B.length," touchpoint",B.length!==1?"s":""," per year"]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:at,children:"Cancel"}),e.jsxs(K,{onClick:M?fe:pt,disabled:!I.trim()||u.isPending||p.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),M?"Save Changes":"Create Plan"]})]})]})}),e.jsx(fs,{open:ie,onOpenChange:re,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script-title",children:"Script Title"}),e.jsx(ze,{id:"script-title",value:oe,onChange:Je=>ce(Je.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(Ks,{value:_e,onValueChange:$e,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select tone..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"friendly",children:"Friendly"}),e.jsx(Mt,{value:"professional",children:"Professional"}),e.jsx(Mt,{value:"casual",children:"Casual"}),e.jsx(Mt,{value:"formal",children:"Formal"})]})]})]}),((We=(Qe=l==null?void 0:l.find(Je=>Je.id===ee))==null?void 0:Qe.name)==null?void 0:We.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(ze,{id:"script-email-subject",value:ue,onChange:Je=>pe(Je.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Er,{id:"script-body",value:ge,onChange:Je=>ye(Je.target.value),placeholder:"Write your script here... You can use {{FirstName}} and {{LastName}} as placeholders.",rows:6}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Tip: Use ","{{FirstName}}"," and ","{{LastName}}"," as placeholders"]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsxs(K,{onClick:He,disabled:!oe.trim()||!ge.trim()||b.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const C_s="0dde5abb-0005-4c8c-a471-30d0cbc9e280",M_s=[{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 T_s(){const t=fr(),s=Bat(),{data:r}=_bs(),{data:n}=Vx(),{data:a}=oSe(),{data:o}=Vhe(90),{data:l}=Gm(),i=Sbs(),c=Nbs(),u=jbs(),p=kbs(),{data:f=[],isLoading:g}=mt({queryKey:["popby-templates"],queryFn:async()=>{const{data:ie,error:re}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",C_s).order("publish_date",{ascending:!1});if(re)throw re;const{data:oe}=await H.from("template_likes").select("template_id"),{data:ce}=await H.from("template_comments").select("template_id"),ge=new Map;oe==null||oe.forEach(ue=>{ge.set(ue.template_id,(ge.get(ue.template_id)||0)+1)});const ye=new Map;return ce==null||ce.forEach(ue=>{ye.set(ue.template_id,(ye.get(ue.template_id)||0)+1)}),(ie||[]).map(ue=>({...ue,likesCount:ge.get(ue.id)||0,commentsCount:ye.get(ue.id)||0}))}}),b=ie=>{const re=l==null?void 0:l.find(oe=>oe.id===ie);return re?`${re.first_name} ${re.last_name||""}`.trim():"Unknown"},_=ie=>{if(!ie)return null;const re=r==null?void 0:r.find(oe=>oe.id===ie);return(re==null?void 0:re.name)||null},[j,w]=k.useState(null),[N,S]=k.useState(!1),[M,L]=k.useState(!1),[I,O]=k.useState(!1),[q,U]=k.useState({popby_item_id:"",notes:""}),[B,V]=k.useState({name:"",description:""}),Y=async()=>{j&&(await c.mutateAsync({contact_id:j.id,popby_item_id:q.popby_item_id||void 0,notes:q.notes||void 0}),S(!1),w(null),U({popby_item_id:"",notes:""}))},Q=async()=>{B.name.trim()&&(await u.mutateAsync({name:B.name.trim(),description:B.description.trim()||void 0}),O(!1),V({name:"",description:""}))},ee=async(ie,re)=>{await p.mutateAsync({relationship_type_id:ie,frequency_days:parseInt(re)})},X=ie=>{var oe;const re=a==null?void 0:a.find(ce=>ce.relationship_type_id===ie);return((oe=re==null?void 0:re.frequency_days)==null?void 0:oe.toString())||"90"};return e.jsx(Ms,{title:"Popbys",description:"Drop off gifts to stay top of mind",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Popbys"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-primary",children:i.thisWeekCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Week"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-emerald-500",children:i.thisMonthCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Month"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-amber-500",children:i.dueCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Due Now"})]})})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(ma,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>L(!0),children:[e.jsx(Xo,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>O(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(ba,{defaultValue:"due",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"due",children:"Due for Popby"}),e.jsx(ns,{value:"activity",children:"Recent Activity"}),e.jsx(ns,{value:"library",children:"Popby Library"}),e.jsx(ns,{value:"templates",children:"Popby Templates"})]}),e.jsx(bs,{value:"due",className:"space-y-4 mt-4",children:!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(ko,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No contacts due for a popby right now!"}),e.jsx("p",{className:"text-sm mt-1",children:"Great job staying connected."})]})}):e.jsx("div",{className:"space-y-3",children:s.map(ie=>e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium",children:[ie.first_name," ",ie.last_name]}),ie.daysOverdue>0&&e.jsxs(st,{variant:"destructive",className:"text-xs",children:[ie.daysOverdue,"+ days overdue"]}),ie.daysSinceLastPopby===null&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Never visited"})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[ie.address&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),ie.city||ie.address]}),ie.tags&&ie.tags.length>0&&e.jsx("span",{children:ie.tags.map(re=>{var oe;return(oe=re.relationship_type)==null?void 0:oe.name}).join(", ")})]}),ie.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",ms(new Date(ie.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ie.phone&&e.jsx(K,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${ie.phone}`,children:e.jsx(Un,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{w(ie),S(!0)},children:[e.jsx(xi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},ie.id))})}),e.jsx(bs,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(un,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby activity yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Start logging popbys to see your history here."})]})}):e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Oe,{className:"space-y-3",children:o.map(ie=>e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0 last:pb-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(ko,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:b(ie.contact_id)}),_(ie.popby_item_id)&&e.jsx(st,{variant:"secondary",className:"text-xs",children:_(ie.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ms(new Date(ie.completed_at),"MMM d, yyyy h:mm a")}),ie.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ie.notes})]})]},ie.id))})]})}),e.jsx(bs,{value:"library",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[r==null?void 0:r.map(ie=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(ko,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium",children:ie.name}),ie.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ie.description}),!ie.owner_user_id&&e.jsx(st,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},ie.id)),e.jsx(Ee,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>O(!0),children:e.jsx(Oe,{className:"p-4 flex items-center justify-center h-full min-h-[100px]",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx($s,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs(bs,{value:"templates",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[f.length," template",f.length!==1?"s":""," found"]}),g&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(4)].map((ie,re)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ys,{className:"h-5 w-16"}),e.jsx(ys,{className:"h-5 w-20"})]})]})},re))}),!g&&f.length===0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Ml,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby templates available yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Check back soon for new templates."})]})}),!g&&f.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:f.map(ie=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>t(`/templates/${ie.id}`),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:ie.preview_image_url?e.jsx("img",{src:ie.preview_image_url,alt:ie.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"})}),e.jsxs(Oe,{className:"p-4 flex flex-col",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:ie.name}),ie.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:jde(ie.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(st,{variant:"secondary",className:"text-xs",children:"PopBys"})}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-3.5 w-3.5"}),ie.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($c,{className:"h-3.5 w-3.5"}),ie.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:re=>{re.stopPropagation(),t(`/templates/${ie.id}`)},children:[e.jsx(tn,{className:"h-4 w-4"}),"View Template"]})]})]},ie.id))})]})]}),e.jsx(fs,{open:N,onOpenChange:S,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Log Popby for ",j==null?void 0:j.first_name," ",j==null?void 0:j.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Popby Item (optional)"}),e.jsxs(Ks,{value:q.popby_item_id,onValueChange:ie=>U(re=>({...re,popby_item_id:ie})),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select a popby item..."})}),e.jsx(Ws,{children:r==null?void 0:r.map(ie=>e.jsx(Mt,{value:ie.id,children:ie.name},ie.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Notes (optional)"}),e.jsx(Er,{placeholder:"Any notes about this popby...",value:q.notes,onChange:ie=>U(re=>({...re,notes:ie.target.value}))})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:c.isPending,children:"Log Popby"})]})]})}),e.jsx(fs,{open:M,onOpenChange:L,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Popby Frequency Settings"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set default popby frequency for each relationship type. You can override these per-contact."}),n==null?void 0:n.map(ie=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx(be,{className:"font-medium",children:ie.name}),e.jsxs(Ks,{value:X(ie.id),onValueChange:re=>ee(ie.id,re),children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:M_s.map(re=>e.jsx(Mt,{value:re.value,children:re.label},re.value))})]})]},ie.id))]}),e.jsx(qn,{children:e.jsx(K,{onClick:()=>L(!1),children:"Done"})})]})}),e.jsx(fs,{open:I,onOpenChange:O,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Name *"}),e.jsx(ze,{placeholder:"e.g., Homemade cookies",value:B.name,onChange:ie=>V(re=>({...re,name:ie.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{placeholder:"Optional description...",value:B.description,onChange:ie=>V(re=>({...re,description:ie.target.value}))})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{onClick:Q,disabled:!B.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const A_s=yC({property_address:gc().min(1,"Property address is required"),city:gc().optional(),state:gc().optional(),zip:gc().optional(),transaction_type:DGe(["buyer","seller"]),close_date:gc().min(1,"Close date is required"),sale_price:GL().min(0,"Sale price must be positive"),commission_amount:GL().optional(),lead_source_id:gc().optional(),client_type_id:gc().optional(),contact_id:gc().optional(),notes:gc().optional(),is_win:r3t()});function Wat({open:t,onOpenChange:s,transaction:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,c]=k.useState(!1),[u,p]=k.useState(""),f=jue(),g=JLt(),{data:b}=nE(),{data:_}=Vx(),{data:j}=Gm(),w=wue(),N=SNe(),{data:S}=Nue(),M=(S==null?void 0:S.show_commission)??!0,L=pue({resolver:fue(A_s),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}});k.useEffect(()=>{r?L.reset({property_address:r.property_address,city:r.city||"",state:r.state||"",zip:r.zip||"",transaction_type:r.transaction_type,close_date:r.close_date,sale_price:Number(r.sale_price),commission_amount:r.commission_amount?Number(r.commission_amount):void 0,lead_source_id:r.lead_source_id||void 0,client_type_id:r.client_type_id||void 0,contact_id:r.contact_id||void 0,notes:r.notes||"",is_win:r.is_win}):L.reset({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1})},[r,L]);const I=async B=>{const V={property_address:B.property_address,transaction_type:B.transaction_type,close_date:B.close_date,sale_price:B.sale_price,is_win:B.is_win,commission_amount:B.commission_amount||null,lead_source_id:B.lead_source_id||null,client_type_id:B.client_type_id||null,contact_id:B.contact_id||null,city:B.city||null,state:B.state||null,zip:B.zip||null,notes:B.notes||null};r?await g.mutateAsync({id:r.id,...V}):await f.mutateAsync(V),s(!1)},O=async()=>{if(!o.trim())return;const[B,...V]=o.trim().split(" "),Y=V.join(" ")||null,Q=await w.mutateAsync({first_name:B,last_name:Y,tagIds:[]});Q&&(L.setValue("contact_id",Q.id),l(""),c(!1),a(!1))},q=async()=>{if(!u.trim())return;const B=await N.mutateAsync(u.trim());B&&(L.setValue("lead_source_id",B.id),p(""))},U=j==null?void 0:j.find(B=>B.id===L.watch("contact_id"));return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(_s,{children:e.jsx(vs,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Gi,{className:"max-h-[70vh] pr-4",children:e.jsx(xue,{...L,children:e.jsxs("form",{onSubmit:L.handleSubmit(I),className:"space-y-4",children:[e.jsx(Zc,{control:L.control,name:"property_address",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Property Address *"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"123 Main St",...B})}),e.jsx(Sm,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Zc,{control:L.control,name:"city",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"City"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"City",...B})})]})}),e.jsx(Zc,{control:L.control,name:"state",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"State"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"TX",...B})})]})}),e.jsx(Zc,{control:L.control,name:"zip",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Zip"}),e.jsx(Oc,{children:e.jsx(ze,{placeholder:"75001",...B})})]})})]}),e.jsx(Zc,{control:L.control,name:"transaction_type",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Transaction Type *"}),e.jsxs(Ks,{onValueChange:B.onChange,value:B.value,children:[e.jsx(Oc,{children:e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select type"})})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]}),e.jsx(Sm,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Zc,{control:L.control,name:"close_date",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Close Date *"}),e.jsx(Oc,{children:e.jsx(ze,{type:"date",...B})}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:L.control,name:"sale_price",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Sale Price *"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"0",...B,onChange:V=>B.onChange(Number(V.target.value))})}),e.jsx(Sm,{})]})})]}),M&&e.jsx(Zc,{control:L.control,name:"commission_amount",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Commission"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"0",...B,value:B.value??"",onChange:V=>B.onChange(V.target.value?Number(V.target.value):void 0)})})]})}),e.jsx(Zc,{control:L.control,name:"lead_source_id",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Lead Source"}),e.jsxs(Ks,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(Oc,{children:e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select source"})})}),e.jsx(Ws,{children:b==null?void 0:b.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Add custom source...",value:u,onChange:B=>p(B.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:q,disabled:!u.trim(),children:e.jsx($s,{className:"h-4 w-4"})})]}),e.jsx(Zc,{control:L.control,name:"client_type_id",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Client Type"}),e.jsxs(Ks,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(Oc,{children:e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select client type"})})}),e.jsx(Ws,{children:_==null?void 0:_.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsx(Zc,{control:L.control,name:"contact_id",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Client Contact"}),e.jsxs($o,{open:n,onOpenChange:a,children:[e.jsx(qo,{asChild:!0,children:e.jsx(Oc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:It("w-full justify-between",!B.value&&"text-muted-foreground"),children:[U?`${U.first_name} ${U.last_name||""}`.trim():"Select contact",e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(Ro,{className:"w-full p-0",align:"start",children:[e.jsxs(Dx,{children:[e.jsx(Ox,{placeholder:"Search contacts..."}),e.jsxs(Rx,{children:[e.jsx(Fx,{children:e.jsxs("div",{className:"p-2 space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No contact found."}),!i&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>c(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(zx,{children:j==null?void 0:j.map(V=>e.jsxs(bp,{value:`${V.first_name} ${V.last_name||""}`,onSelect:()=>{B.onChange(V.id),a(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",V.id===B.value?"opacity-100":"opacity-0")}),V.first_name," ",V.last_name||""]},V.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(ze,{placeholder:"Enter contact name...",value:o,onChange:V=>l(V.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:O,disabled:!o.trim()||w.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{c(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(Zc,{control:L.control,name:"notes",render:({field:B})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Notes"}),e.jsx(Oc,{children:e.jsx(Er,{placeholder:"Any notes about this transaction...",...B})})]})}),e.jsx(Zc,{control:L.control,name:"is_win",render:({field:B})=>e.jsxs(Lc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Dc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(Oc,{children:e.jsx(qr,{checked:B.value,onCheckedChange:B.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:f.isPending||g.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function dSe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=k.useState(null),[i,c]=k.useState(null),[u,p]=k.useState(""),[f,g]=k.useState("all"),[b,_]=k.useState("all"),[j,w]=k.useState("all"),[N,S]=k.useState(!1),M=e8t(),L=jue(),{data:I}=nE(),{data:O}=Vx(),q=SE(),U=Y=>{const{id:Q,created_at:ee,updated_at:X,lead_source:ie,client_type:re,contact:oe,...ce}=Y;L.mutate(ce)},B=()=>{i&&(M.mutate(i),c(null))},V=t.filter(Y=>{var oe,ce,ge,ye;const Q=u===""||Y.property_address.toLowerCase().includes(u.toLowerCase())||((ce=(oe=Y.contact)==null?void 0:oe.first_name)==null?void 0:ce.toLowerCase().includes(u.toLowerCase()))||((ye=(ge=Y.contact)==null?void 0:ge.last_name)==null?void 0:ye.toLowerCase().includes(u.toLowerCase())),ee=f==="all"||Y.transaction_type===f,X=b==="all"||Y.lead_source_id===b,ie=j==="all"||Y.client_type_id===j,re=!N||Y.is_win;return Q&&ee&&X&&ie&&re});return r?e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 space-y-4",children:[1,2,3].map(Y=>e.jsx(ys,{className:"h-16 w-full"},Y))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs(Rt,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search...",value:u,onChange:Y=>p(Y.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Hs,{className:"w-[100px]",children:e.jsx(Ys,{placeholder:"Type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]}),e.jsxs(Ks,{value:b,onValueChange:_,children:[e.jsx(Hs,{className:"w-[130px]",children:e.jsx(Ys,{placeholder:"Lead Source"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Sources"}),I==null?void 0:I.map(Y=>e.jsx(Mt,{value:Y.id,children:Y.name},Y.id))]})]}),e.jsxs(K,{variant:N?"default":"outline",size:"sm",onClick:()=>S(!N),children:[e.jsx(Nc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Oe,{children:V.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):q?e.jsx("div",{className:"space-y-3",children:V.map(Y=>e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium truncate",children:Y.property_address}),Y.is_win&&e.jsx(Nc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Y.city,Y.state?`, ${Y.state}`:""]})]}),e.jsx(st,{variant:Y.transaction_type==="buyer"?"default":"secondary",children:Y.transaction_type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Close Date: "}),LAe(Y.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Zl(Y.sale_price)]}),s&&Y.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Zl(Y.commission_amount)]}),Y.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),Y.lead_source.name]}),Y.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),Y.contact.first_name," ",Y.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[Y.owner_user_id]||"Unknown"]})]}),!a&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l(Y),children:e.jsx(hd,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>U(Y),children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(Y.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]},Y.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[n&&e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Property"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Close Date"}),e.jsx(St,{children:"Sale Price"}),s&&e.jsx(St,{children:"Commission"}),e.jsx(St,{children:"Lead Source"}),e.jsx(St,{children:"Client"}),!a&&e.jsx(St,{className:"w-[50px]"})]})}),e.jsx(zn,{children:V.map(Y=>{var Q;return e.jsxs(Ss,{children:[n&&e.jsx(dt,{className:"font-medium text-sm",children:n[Y.owner_user_id]||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[Y.is_win&&e.jsx(Nc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Y.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Y.city,Y.state?`, ${Y.state}`:""]})]})]})}),e.jsx(dt,{children:e.jsx(st,{variant:Y.transaction_type==="buyer"?"default":"secondary",children:Y.transaction_type})}),e.jsx(dt,{children:LAe(Y.close_date)}),e.jsx(dt,{children:Zl(Y.sale_price)}),s&&e.jsx(dt,{children:Y.commission_amount?Zl(Y.commission_amount):"-"}),e.jsx(dt,{children:((Q=Y.lead_source)==null?void 0:Q.name)||"-"}),e.jsx(dt,{children:Y.contact?`${Y.contact.first_name} ${Y.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(dt,{children:e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Ma,{onClick:()=>l(Y),children:[e.jsx(hd,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ma,{onClick:()=>U(Y),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Ma,{onClick:()=>c(Y.id),className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},Y.id)})})]})})})]}),e.jsx(Wat,{open:!!o,onOpenChange:Y=>!Y&&l(null),transaction:o||void 0}),e.jsx(kc,{open:!!i,onOpenChange:Y=>!Y&&c(null),children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete Transaction?"}),e.jsx(sc,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:B,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function Gat({goals:t,stats:s,year:r,showCommission:n}){const a=new Date().getMonth()+1,o=new Date().getFullYear()===r?a:12,l=12-o,i=(g,b)=>{if(!b||b===0)return null;const _=Math.min(g/b*100,100),j=Math.max(b-g,0),w=l>0?j/l:0,N=o/12*100,S=_>=N?"ahead":_>=N*.8?"on-track":"behind";return{percent:_,remaining:j,pace:w,status:S}},c=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),p=n?i(s.totalCommission,t.gci_goal):null,f=g=>{switch(g){case"ahead":return e.jsxs(st,{className:"bg-green-500 text-white",children:[e.jsx(ul,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(st,{variant:"secondary",children:[e.jsx(f0,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(st,{variant:"destructive",children:[e.jsx(fS,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"h-5 w-5 text-primary"}),e.jsxs(Rt,{children:[r," Goals Progress"]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[t.transactions_goal&&c&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Transactions"}),f(c.status)]}),e.jsx(Bi,{value:c.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[s.totalTransactions," of ",t.transactions_goal]}),e.jsxs("span",{children:[Math.round(c.percent),"%"]})]}),c.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Math.ceil(c.pace),"/month to hit goal"]})]}),t.volume_goal&&u&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Volume"}),f(u.status)]}),e.jsx(Bi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Zl(s.totalVolume,!0)," of ",Zl(t.volume_goal,!0)]}),e.jsxs("span",{children:[Math.round(u.percent),"%"]})]}),u.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Zl(u.pace,!0),"/month"]})]}),n&&t.gci_goal&&p&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"GCI"}),f(p.status)]}),e.jsx(Bi,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Zl(s.totalCommission,!0)," of ",Zl(t.gci_goal,!0)]}),e.jsxs("span",{children:[Math.round(p.percent),"%"]})]}),p.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Zl(p.pace,!0),"/month"]})]})]})})]})}const E_s={light:"",dark:".dark"},Kat=k.createContext(null);function Zat(){const t=k.useContext(Kat);if(!t)throw new Error("useChart must be used within a ");return t}const Yat=k.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=k.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(Kat.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:It("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...a,children:[e.jsx(P_s,{id:i,config:n}),e.jsx(iT,{children:r})]})})});Yat.displayName="Chart";const P_s=({id:t,config:s})=>{const r=Object.entries(s).filter(([n,a])=>a.theme||a.color);return r.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(E_s).map(([n,a])=>` ${a} [data-chart=${t}] { ${r.map(([o,l])=>{var c;const i=((c=l.theme)==null?void 0:c[n])||l.color;return i?` --color-${o}: ${i};`:null}).join(` `)} } `).join(` `)}}):null},Xat=k.forwardRef(({active:t,payload:s,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:c,formatter:u,color:p,nameKey:f,labelKey:g},b)=>{const{config:_}=Zat(),j=k.useMemo(()=>{var I;if(a||!(s!=null&&s.length))return null;const[N]=s,S=`${g||N.dataKey||N.name||"value"}`,M=U_e(_,N,S),L=!g&&typeof l=="string"?((I=_[l])==null?void 0:I.label)||l:M==null?void 0:M.label;return i?e.jsx("div",{className:It("font-medium",c),children:i(L,s)}):L?e.jsx("div",{className:It("font-medium",c),children:L}):null},[l,i,s,a,c,_,g]);if(!t||!(s!=null&&s.length))return null;const w=s.length===1&&n!=="dot";return e.jsxs("div",{ref:b,className:It("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[w?null:j,e.jsx("div",{className:"grid gap-1.5",children:s.map((N,S)=>{const M=`${f||N.name||N.dataKey||"value"}`,L=U_e(_,N,M),I=p||N.payload.fill||N.color;return e.jsx("div",{className:It("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",n==="dot"&&"items-center"),children:u&&(N==null?void 0:N.value)!==void 0&&N.name?u(N.value,N.name,N,S,N.payload):e.jsxs(e.Fragment,{children:[L!=null&&L.icon?e.jsx(L.icon,{}):!o&&e.jsx("div",{className:It("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":w&&n==="dashed"}),style:{"--color-bg":I,"--color-border":I}}),e.jsxs("div",{className:It("flex flex-1 justify-between leading-none",w?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[w?j:null,e.jsx("span",{className:"text-muted-foreground",children:(L==null?void 0:L.label)||N.name})]}),N.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:N.value.toLocaleString()})]})]})},N.dataKey)})})]})});Xat.displayName="ChartTooltip";const I_s=k.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=Zat();return r!=null&&r.length?e.jsx("div",{ref:o,className:It("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const c=`${a||i.dataKey||"value"}`,u=U_e(l,i,c);return e.jsxs("div",{className:It("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[u!=null&&u.icon&&!s?e.jsx(u.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),u==null?void 0:u.label]},i.value)})}):null});I_s.displayName="ChartLegend";function U_e(t,s,r){if(typeof s!="object"||s===null)return;const n="payload"in s&&typeof s.payload=="object"&&s.payload!==null?s.payload:void 0;let a=r;return r in s&&typeof s[r]=="string"?a=s[r]:n&&r in n&&typeof n[r]=="string"&&(a=n[r]),a in t?t[a]:t[r]}const Kz=["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 uSe({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"Add transactions to see your performance charts"})}):e.jsxs("div",{className:"grid gap-6",children:[r&&e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Oe,{className:"overflow-hidden",children:e.jsx(Yat,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(iT,{width:"100%",height:"100%",children:e.jsxs(_at,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(nat,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(iC,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(oC,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(hp,{content:e.jsx(Xat,{})}),e.jsx(L1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(iT,{width:"100%",height:"100%",children:e.jsxs(wat,{children:[e.jsx(V0,{data:t.leadSourceBreakdown,dataKey:"count",nameKey:"name",cx:"50%",cy:"50%",outerRadius:80,label:({name:a,percent:o})=>o>.05?`${a} (${(o*100).toFixed(0)}%)`:"",labelLine:!1,children:t.leadSourceBreakdown.map((a,o)=>e.jsx(lR,{fill:Kz[o%Kz.length]},`cell-${o}`))}),e.jsx(hp,{formatter:(a,o)=>[`${a} deals`,o]})]})})}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2 justify-center",children:t.leadSourceBreakdown.slice(0,6).map((a,o)=>e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:Kz[o%Kz.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function L_s(t){if(!t||!t.trim())return null;const s=t.trim(),r=["yyyy-MM-dd","M/d/yyyy","MM/dd/yyyy","M-d-yyyy","MM-dd-yyyy","MM/dd/yy","M/d/yy"];for(const n of r)try{const a=bje(s,n,new Date);if(Ive(a))return ms(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(Ive(n))return ms(n,"yyyy-MM-dd")}catch{}return null}const D_s=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function O_s({open:t,onOpenChange:s}){const[r,n]=k.useState([]),[a,o]=k.useState(!1),[l,i]=k.useState(0),{data:c}=nE(),{data:u}=Vx(),p=jue(),f=()=>{const N=D_s.join(","),S=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),M=`${N} ${S}`,L=new Blob([M],{type:"text/csv"}),I=URL.createObjectURL(L),O=document.createElement("a");O.href=I,O.download="transaction-import-template.csv",O.click(),URL.revokeObjectURL(I)},g=N=>{const S=N.split(` `).filter(L=>L.trim());if(S.length<2)return[];const M=S[0].split(",").map(L=>L.trim().toLowerCase().replace(/['"]/g,""));return S.slice(1).map((L,I)=>{var oe,ce,ge,ye;const O=[];let q="",U=!1;for(const ue of L)ue==='"'?U=!U:ue===","&&!U?(O.push(q.trim()),q=""):q+=ue;O.push(q.trim());const B=ue=>{var _e;const pe=M.indexOf(ue);return pe>=0?(_e=O[pe])==null?void 0:_e.replace(/^["']|["']$/g,"").trim():""},V=(oe=B("transaction_type"))==null?void 0:oe.toLowerCase(),Y=(ce=B("sale_price"))==null?void 0:ce.replace(/[$,]/g,""),Q=(ge=B("commission_amount"))==null?void 0:ge.replace(/[$,]/g,""),ee=(ye=B("is_win"))==null?void 0:ye.toLowerCase(),X=B("close_date"),ie=L_s(X);let re;return B("property_address")?["buyer","seller"].includes(V)?ie?(!Y||isNaN(Number(Y)))&&(re="Invalid sale price"):re=`Invalid date format: "${X}" - use MM/DD/YYYY or YYYY-MM-DD`:re='Transaction type must be "buyer" or "seller"':re="Missing property address",{property_address:B("property_address"),city:B("city"),state:B("state"),zip:B("zip"),transaction_type:V==="seller"?"seller":"buyer",close_date:ie||"",sale_price:Number(Y)||0,commission_amount:Q?Number(Q):null,lead_source_name:B("lead_source"),client_type_name:B("client_type"),is_win:["yes","true","1"].includes(ee),notes:B("notes"),error:re}})},b=N=>{var L;const S=(L=N.target.files)==null?void 0:L[0];if(!S)return;const M=new FileReader;M.onload=I=>{var U;const O=(U=I.target)==null?void 0:U.result,q=g(O);n(q)},M.readAsText(S)},_=async()=>{const N=r.filter(L=>!L.error);if(N.length===0){me.error("No valid transactions to import");return}o(!0),i(0);let S=0,M=0;for(let L=0;LU.name.toLowerCase()===I.lead_source_name.toLowerCase()),q=u==null?void 0:u.find(U=>U.name.toLowerCase()===I.client_type_name.toLowerCase());await p.mutateAsync({property_address:I.property_address,city:I.city||null,state:I.state||null,zip:I.zip||null,transaction_type:I.transaction_type,close_date:I.close_date,sale_price:I.sale_price,commission_amount:I.commission_amount,lead_source_id:(O==null?void 0:O.id)||null,client_type_id:(q==null?void 0:q.id)||null,contact_id:null,notes:I.notes||null,is_win:I.is_win}),S++}catch(O){M++,console.error("Failed to import transaction:",O)}i(Math.round((L+1)/N.length*100))}o(!1),S>0&&me.success(`Imported ${S} transaction${S>1?"s":""}`),M>0&&me.error(`Failed to import ${M} transaction${M>1?"s":""}`),n([]),s(!1)},j=r.filter(N=>!N.error).length,w=r.filter(N=>N.error).length;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Import Transactions"}),e.jsx(Gr,{children:"Upload a CSV file with your past transactions"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Download Template"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Get a CSV template with the correct format"})]}),e.jsxs(K,{variant:"outline",onClick:f,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(ze,{id:"csv-file",type:"file",accept:".csv",onChange:b})]}),r.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(st,{variant:"outline",children:[r.length," rows found"]}),j>0&&e.jsxs(st,{className:"bg-green-500 text-white",children:[e.jsx(va,{className:"h-3 w-3 mr-1"}),j," valid"]}),w>0&&e.jsxs(st,{variant:"destructive",children:[e.jsx(kl,{className:"h-3 w-3 mr-1"}),w," errors"]})]}),e.jsx(Gi,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((N,S)=>e.jsxs("div",{className:`p-2 rounded text-sm ${N.error?"bg-destructive/10":"bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:N.property_address||"(no address)"}),e.jsx(st,{variant:N.transaction_type==="buyer"?"default":"secondary",children:N.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[N.close_date," • $",N.sale_price.toLocaleString()]}),N.error&&e.jsx(Pke,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(Ike,{className:"text-xs",children:N.error})})]},S)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:_,disabled:j===0||a,children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Import ",j," Transaction",j!==1?"s":""]})]})]})]})})}const R_s=yC({transactions_goal:GL().min(0).optional(),volume_goal:GL().min(0).optional(),gci_goal:GL().min(0).optional()});function F_s({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=t8t(),{data:o}=Nue(),l=(o==null?void 0:o.show_commission)??!0,i=pue({resolver:fue(R_s),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});k.useEffect(()=>{n?i.reset({transactions_goal:n.transactions_goal??void 0,volume_goal:n.volume_goal?Number(n.volume_goal):void 0,gci_goal:n.gci_goal?Number(n.gci_goal):void 0}):i.reset({transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0})},[n,i,t]);const c=async u=>{await a.mutateAsync({year:r,transactions_goal:u.transactions_goal??null,volume_goal:u.volume_goal??null,gci_goal:l?u.gci_goal??null:null}),s(!1)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:[r," Goals"]}),e.jsx(Gr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(xue,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(Zc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Transactions Goal"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"e.g., 24",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(jie,{children:"Total number of deals you want to close"}),e.jsx(Sm,{})]})}),e.jsx(Zc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"Volume Goal ($)"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"e.g., 5000000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(jie,{children:"Total sales volume you want to achieve"}),e.jsx(Sm,{})]})}),l&&e.jsx(Zc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(Lc,{children:[e.jsx(Dc,{children:"GCI Goal ($)"}),e.jsx(Oc,{children:e.jsx(ze,{type:"number",placeholder:"e.g., 150000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(jie,{children:"Gross commission income target"}),e.jsx(Sm,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function hSe({transactions:t,isLoading:s}){const r=k.useRef(null),n=k.useRef(null),a=k.useRef([]),o=k.useRef(null),{isAdmin:l}=Ds(),[i,c]=k.useState(""),[u,p]=k.useState(!0),[f,g]=k.useState(0),[b,_]=k.useState(!1),j=t.filter(N=>N.latitude!=null&&N.longitude!=null),w=t.filter(N=>N.latitude==null||N.longitude==null);return k.useEffect(()=>{(async()=>{p(!0);try{const{data:S}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();S!=null&&S.value&&c(S.value)}catch(S){console.error("Error fetching mapbox token:",S)}p(!1)})()},[]),k.useEffect(()=>{if(!i||w.length===0||b)return;(async()=>{var M;_(!0);let S=0;for(const L of w){const I=[L.property_address,L.city,L.state,L.zip].filter(Boolean).join(", ");if(I)try{const q=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(I)}.json?access_token=${i}&limit=1`)).json();if((M=q.features)!=null&&M[0]){const[U,B]=q.features[0].center;await H.from("scorecard_transactions").update({latitude:B,longitude:U}).eq("id",L.id),L.latitude=B,L.longitude=U,S++}}catch(O){console.error("Geocode error:",O)}}g(S),_(!1)})()},[i,t]),k.useEffect(()=>{if(!r.current||!i||n.current)return;Ao.accessToken=i;const N=t.filter(L=>L.latitude!=null&&L.longitude!=null);let S=[-98.5795,39.8283],M=4;if(N.length>0){const L=N.reduce((O,q)=>O+q.longitude,0)/N.length,I=N.reduce((O,q)=>O+q.latitude,0)/N.length;S=[L,I],M=N.length===1?12:10}return n.current=new Ao.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:M,center:S}),n.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var L;(L=n.current)==null||L.remove(),n.current=null}},[i]),k.useEffect(()=>{var S;if(!n.current||!i)return;a.current.forEach(M=>M.remove()),a.current=[],(S=o.current)==null||S.remove();const N=t.filter(M=>M.latitude!=null&&M.longitude!=null);if(N.forEach(M=>{var B;const L=M.transaction_type==="buyer",I=L?"#3B82F6":"#10B981",O=document.createElement("div");O.className="cursor-pointer",O.innerHTML=`
${L?'':''}
`;const q=new Ao.Popup({offset:25,closeButton:!0}).setHTML(`
${M.property_address}
${M.city?`
${M.city}${M.state?", "+M.state:""} ${M.zip||""}
`:""}
${L?"Buyer":"Seller"} $${Number(M.sale_price).toLocaleString()}
Closed: ${Ol(M.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(B=M.lead_source)!=null&&B.name?" · "+M.lead_source.name:""}
${M.contact?`
Client: ${M.contact.first_name} ${M.contact.last_name||""}
`:""}
`),U=new Ao.Marker(O).setLngLat([M.longitude,M.latitude]).setPopup(q).addTo(n.current);a.current.push(U)}),N.length>1){const M=new Ao.LngLatBounds;N.forEach(L=>M.extend([L.longitude,L.latitude])),n.current.fitBounds(M,{padding:60,maxZoom:13})}else N.length===1&&n.current.flyTo({center:[N[0].longitude,N[0].latitude],zoom:12})},[t,i,b]),u||s?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[50vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(ma,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),e.jsx("span",{children:"Buyer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),e.jsx("span",{children:"Seller"})]}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[j.length," of ",t.length," mapped",b&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(kl,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Map Not Configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"Set up your Mapbox token in the Popby Map to enable maps across the platform.":"The map feature has not been configured yet. Please contact your administrator."})]})]})})}const Qat=()=>{const{data:t}=$x();return mt({queryKey:["team-scorecard-members",t==null?void 0:t.teamId],queryFn:async()=>{const{data:s,error:r}=await H.from("team_members").select("user_id").eq("team_id",t.teamId);if(r)throw r;const n=s.map(l=>l.user_id),{data:a,error:o}=await H.from("profiles").select("id, name, email, avatar_url").in("id",n);if(o)throw o;return a||[]},enabled:!!(t!=null&&t.teamId)&&(t==null?void 0:t.role)==="team_leader"})},z_s=t=>{const{data:s}=$x(),{data:r}=Qat();return mt({queryKey:["team-scorecard-transactions",s==null?void 0:s.teamId,t],queryFn:async()=>{const n=r.map(l=>l.id),{data:a,error:o}=await H.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).in("owner_user_id",n).gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!r&&r.length>0})};function B_s(t,s){const r=s.filter(o=>o.owner_user_id===t.id),n=r.reduce((o,l)=>o+Number(l.sale_price),0),a=r.reduce((o,l)=>o+(Number(l.commission_amount)||0),0);return{member:t,totalTransactions:r.length,buyerCount:r.filter(o=>o.transaction_type==="buyer").length,sellerCount:r.filter(o=>o.transaction_type==="seller").length,totalVolume:n,averagePrice:r.length>0?n/r.length:0,totalGCI:a}}function $_s(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function q_s({year:t}){var g;const{data:s,isLoading:r}=Qat(),{data:n,isLoading:a}=z_s(t),o=fr(),l=r||a,{aggregate:i,memberStats:c,topPerformer:u,agentNameMap:p,teamChartStats:f}=k.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const b=s.map(V=>B_s(V,n));b.sort((V,Y)=>Y.totalVolume-V.totalVolume);const _={};s.forEach(V=>{_[V.id]=V.name||V.email});const j=n.length,w=n.reduce((V,Y)=>V+Number(Y.sale_price),0),N=n.reduce((V,Y)=>V+(Number(Y.commission_amount)||0),0),S=n.filter(V=>V.transaction_type==="buyer").length,M=n.filter(V=>V.transaction_type==="seller").length,L={};n.forEach(V=>{var Q;const Y=((Q=V.lead_source)==null?void 0:Q.name)||"Unknown";L[Y]=(L[Y]||0)+1});const I=Object.entries(L).sort((V,Y)=>Y[1]-V[1])[0],O={};n.forEach(V=>{const Y=Ol(V.close_date).toLocaleString("default",{month:"short"});O[Y]=(O[Y]||0)+1});const U=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(V=>({month:V,count:O[V]||0})),B=Object.entries(L).map(([V,Y])=>({name:V,count:Y})).sort((V,Y)=>Y.count-V.count);return{aggregate:{totalTxns:j,buyerCount:S,sellerCount:M,totalVolume:w,avgPrice:j>0?w/j:0,totalGCI:N,topSource:I?{name:I[0],count:I[1]}:null,memberCount:s.length},memberStats:b,topPerformer:b[0]||null,agentNameMap:_,teamChartStats:{transactionsByMonth:U,leadSourceBreakdown:B}}},[s,n]);return l?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[1,2,3,4].map(b=>e.jsx(ys,{className:"h-24"},b))}),e.jsx(ys,{className:"h-64"})]}):!i||c.length===0?e.jsx(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-2",children:[e.jsx(pr,{className:"h-10 w-10 mx-auto text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No Team Data"}),e.jsxs("p",{className:"text-muted-foreground",children:["No scorecard transactions found for your team members in ",t,"."]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Members"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.memberCount})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.totalTxns}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.buyerCount,"B / ",i.sellerCount,"S"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Zl(i.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ul,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Zl(i.avgPrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Zl(i.totalGCI,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((g=i.topSource)==null?void 0:g.name)||"-"}),i.topSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.topSource.count," deals"]})]})})]}),u&&u.totalTransactions>0&&e.jsx(Ee,{className:"border-primary/30 bg-primary/5",children:e.jsxs(Oe,{className:"pt-4 flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-primary/10",children:e.jsx(xo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground",children:["Top Performer — ",t]}),e.jsx("p",{className:"text-lg font-bold",children:u.member.name||u.member.email})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.totalTransactions," deals"]}),e.jsx("p",{className:"font-semibold",children:Zl(u.totalVolume,!0)})]})]})}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Member Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Transactions"}),e.jsx(St,{className:"text-center",children:"B / S"}),e.jsx(St,{className:"text-right",children:"Volume"}),e.jsx(St,{className:"text-right",children:"Avg Price"}),e.jsx(St,{className:"text-right",children:"GCI"}),e.jsx(St,{className:"text-right"})]})}),e.jsx(zn,{children:c.map((b,_)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[_===0&&b.totalTransactions>0&&e.jsx(xo,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:b.member.avatar_url||void 0}),e.jsx(kn,{className:"text-xs",children:$_s(b.member.name,b.member.email)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:b.member.name||b.member.email}),b.member.name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:b.member.email})]})]})}),e.jsx(dt,{className:"text-center font-semibold",children:b.totalTransactions}),e.jsxs(dt,{className:"text-center text-sm",children:[b.buyerCount," / ",b.sellerCount]}),e.jsx(dt,{className:"text-right font-medium",children:Zl(b.totalVolume,!0)}),e.jsx(dt,{className:"text-right text-sm",children:Zl(b.averagePrice,!0)}),e.jsx(dt,{className:"text-right font-medium",children:Zl(b.totalGCI,!0)}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${b.member.id}`),children:e.jsx(Ln,{className:"h-4 w-4"})})})]},b.member.id))})]})})})]}),e.jsxs(ba,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"transactions",children:[e.jsx(Mh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(ns,{value:"charts",children:[e.jsx(No,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(ns,{value:"map",children:[e.jsx(ma,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(bs,{value:"transactions",children:e.jsx(dSe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(bs,{value:"charts",children:f&&e.jsx(uSe,{stats:f,year:t})}),e.jsx(bs,{value:"map",children:e.jsx(hSe,{transactions:n||[],isLoading:a})})]})]})}const Jat=new Date().getFullYear(),s7e=Array.from({length:10},(t,s)=>Jat-s);function U_s(){var B;const[t,s]=k.useState(Jat),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(!1),[p,f]=k.useState("my"),{data:g}=$x(),b=(g==null?void 0:g.role)==="team_leader",{data:_,isLoading:j}=CNe(t),{yearStats:w,lifetimeStats:N,showCommission:S}=hXe(t),{data:M,isLoading:L}=uXe(t),{data:I}=Nue(),O=s8t(),q=()=>{if(!_||_.length===0)return;const V=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...S?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],Y=_.map(re=>{var oe,ce;return[re.property_address,re.city||"",re.state||"",re.zip||"",re.transaction_type,re.close_date,re.sale_price,...S?[re.commission_amount||""]:[],((oe=re.lead_source)==null?void 0:oe.name)||"",((ce=re.client_type)==null?void 0:ce.name)||"",re.contact?`${re.contact.first_name} ${re.contact.last_name||""}`.trim():"",re.is_win?"Yes":"No",re.notes||""]}),Q=[V,...Y].map(re=>re.map(oe=>`"${String(oe).replace(/"/g,'""')}"`).join(",")).join(` `),ee=new Blob([Q],{type:"text/csv"}),X=URL.createObjectURL(ee),ie=document.createElement("a");ie.href=X,ie.download=`transactions-${t}.csv`,ie.click(),URL.revokeObjectURL(X)},U=!_||_.length===0;return e.jsxs(Ms,{title:"Scorecard",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Scorecard"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500/50 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),b&&e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 w-fit",children:[e.jsx(K,{variant:p==="my"?"default":"ghost",size:"sm",onClick:()=>f("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(K,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>f("team"),className:"h-8",children:[e.jsx(pr,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),p==="team"&&b?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Team Performance"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Aggregate stats and member comparison"})]}),e.jsxs(Ks,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Hs,{className:"w-[120px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:s7e.map(V=>e.jsx(Mt,{value:String(V),children:V},V))})]})]}),e.jsx(q_s,{year:t})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Business Scorecard"}),e.jsx("p",{className:"text-muted-foreground",children:"Track your transactions, goals, and performance"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Ks,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Hs,{className:"w-[120px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:s7e.map(V=>e.jsx(Mt,{value:String(V),children:V},V))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!c),children:e.jsx(Xo,{className:"h-4 w-4"})})]})]}),c&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-lg",children:"Settings"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(be,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(qr,{checked:(I==null?void 0:I.show_commission)??!0,onCheckedChange:V=>O.mutate({show_commission:V})})]})})]}),U&&!j?e.jsx(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(No,{className:"h-8 w-8 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Start Tracking Your Success"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto mt-1",children:"Add your past transactions to see your performance metrics, track your goals, and celebrate your wins."})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Import CSV"]})]}),e.jsxs("div",{className:"pt-4 border-t mt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Need help formatting your data?"}),e.jsx(K,{variant:"link",className:"h-auto p-0",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download CSV Template"]})})]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(zm,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:q,disabled:U,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Export"]}),e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"CSV Template"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:w.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[w.buyerCount,"/",w.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Zl(w.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Zl(N.totalVolume,!0)," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ul,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Zl(w.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((B=w.topLeadSource)==null?void 0:B.name)||"-"}),w.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.topLeadSource.count," deals"]})]})}),S&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Zl(w.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Zl(N.totalCommission,!0)," lifetime"]})]})}),S&&w.totalNetToAgent>0&&w.totalNetToAgent!==w.totalCommission&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-teal-600 dark:text-teal-400 mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Net to Agent"})]}),e.jsx("p",{className:"text-2xl font-bold text-teal-600 dark:text-teal-400",children:Zl(w.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Zl(N.totalNetToAgent,!0)," lifetime"]})]})})]}),M&&e.jsx(Gat,{goals:M,stats:w,year:t,showCommission:S}),e.jsxs(ba,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"transactions",children:"Transactions"}),e.jsx(ns,{value:"charts",children:"Charts"}),e.jsxs(ns,{value:"map",children:[e.jsx(ma,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(bs,{value:"transactions",children:e.jsx(dSe,{transactions:_||[],showCommission:S,isLoading:j})}),e.jsx(bs,{value:"charts",children:e.jsx(uSe,{stats:w,year:t})}),e.jsx(bs,{value:"map",children:e.jsx(hSe,{transactions:_||[],isLoading:j})})]})]})]})]}),e.jsx(Wat,{open:r,onOpenChange:n}),e.jsx(O_s,{open:a,onOpenChange:o}),e.jsx(F_s,{open:l,onOpenChange:i,year:t,existingGoals:M})]})}function eit({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Ds(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(!1);k.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:w,error:N}=await H.from("listing_shares").select("id, share_token, click_count, lead_count").eq("listing_id",r).eq("sharing_agent_id",o.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(N)throw N;if(w&&w.share_token)i(w);else if(w&&!w.share_token){const{data:S,error:M}=await H.from("listing_shares").update({share_type:"referral_link"}).eq("id",w.id).select("id, share_token, click_count, lead_count").single();if(M)throw M;i(S)}else{const{data:S,error:M}=await H.from("listing_shares").insert({listing_id:r,sharing_agent_id:o.id,share_type:"referral_link"}).select("id, share_token, click_count, lead_count").single();if(M)throw M;i(S)}}catch(w){console.error("Error creating share link:",w),me.error("Failed to generate share link")}finally{u(!1)}}})()},[t,o,r]);const g=l!=null&&l.share_token?`https://listings.relevelup.com/${n||r}?ref=${l.share_token}`:"",b=async()=>{try{await navigator.clipboard.writeText(g),f(!0),me.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)}catch{me.error("Failed to copy link")}},_=j=>{const w=encodeURIComponent(g),N=encodeURIComponent(`Check out this listing: ${a}`);switch(j){case"email":window.open(`mailto:?subject=${N}&body=${w}`);break;case"text":window.open(`sms:?body=${N}%20${w}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${w}`,"_blank");break}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(Gr,{children:"Share this listing with your network. When someone submits a lead through your link, they'll become your contact!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-3",children:e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("strong",{children:"How it works:"})," The listing still shows the original agent's info, but any leads from your unique link go directly to you!"]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:c?"Generating...":g,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:b,disabled:c||!g,variant:p?"default":"outline",children:p?e.jsx(va,{className:"h-4 w-4"}):e.jsx(gi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("email"),disabled:c,children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("text"),disabled:c,children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("facebook"),disabled:c,children:[e.jsx(Su,{className:"h-4 w-4 mr-2"}),"Facebook"]})]})]}),l&&(l.click_count>0||l.lead_count>0)&&e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx(be,{className:"mb-2 block",children:"Your Share Performance"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-muted rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-muted-foreground mb-1",children:[e.jsx(Ln,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Clicks"})]}),e.jsx("p",{className:"text-2xl font-bold",children:l.click_count})]}),e.jsxs("div",{className:"bg-primary/10 rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-primary mb-1",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Leads"})]}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:l.lead_count})]})]})]})]})]})})}const V_s={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},H_s={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},W_s={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Zz({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var j,w;const{user:o}=Ds(),{data:l}=aXe(t.id),i=nXe(),[c,u]=k.useState(!1),p=N=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(N),f=((j=t.photos)==null?void 0:j.find(N=>N.is_primary))||((w=t.photos)==null?void 0:w[0]),g=(o==null?void 0:o.id)===t.agent_id,b=async N=>{N.stopPropagation();try{const S=await i.mutateAsync(t.id);me.success(S.saved?"Listing saved!":"Listing removed from saved")}catch{me.error("Failed to save listing")}},_=N=>{if(N.stopPropagation(),o)u(!0);else{const S=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(S),me.success("Link copied to clipboard!")}};return e.jsxs(Ee,{className:"overflow-hidden hover:shadow-lg transition-shadow cursor-pointer group",onClick:s,children:[e.jsxs("div",{className:"relative aspect-[4/3] bg-muted",children:[f?e.jsx("img",{src:f.photo_url,alt:t.property_address||t.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(b0,{className:"h-12 w-12"})}),e.jsx(st,{className:`absolute top-2 left-2 ${V_s[t.status]} text-white border-0`,children:H_s[t.status]}),t.is_featured&&e.jsx("div",{className:"absolute top-2 right-2 p-1.5 bg-amber-500 rounded-full",children:e.jsx(Jn,{className:"h-4 w-4 text-white fill-white"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:b,children:e.jsx(ni,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,title:g?"Copy link":"Share & earn leads",children:g?e.jsx(wd,{className:"h-4 w-4"}):e.jsx(pn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(eit,{open:c,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xl font-bold text-primary",children:p(t.price)}),t.open_to_referrals&&e.jsxs(st,{variant:"outline",className:"text-xs",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),"Referrals"]})]}),e.jsxs("div",{children:[t.property_address&&e.jsx("p",{className:"font-medium truncate",children:t.property_address}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),t.city,", ",t.state,t.neighborhood&&` • ${t.neighborhood}`]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[t.bedrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Im,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ju,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(b0,{className:"h-4 w-4"}),t.square_footage.toLocaleString()," sqft"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx(st,{variant:"secondary",className:"text-xs",children:W_s[t.property_type]}),t.agent&&e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[120px]",children:t.agent.name})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ln,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wd,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ni,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:N=>{N.stopPropagation(),r()},children:[e.jsx(hd,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:N=>{N.stopPropagation(),n()},children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})]})}const G_s=[{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"}],K_s=[{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 Z_s({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Rt,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Rr,{className:"h-4 w-4"})})]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Status"}),e.jsxs(Ks,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"All statuses"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),G_s.map(a=>e.jsx(Mt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Property Type"}),e.jsxs(Ks,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"All types"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),K_s.map(a=>e.jsx(Mt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Min Price"}),e.jsx(ze,{type:"number",placeholder:"No minimum",value:t.minPrice||"",onChange:a=>s({...t,minPrice:a.target.value?Number(a.target.value):void 0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Max Price"}),e.jsx(ze,{type:"number",placeholder:"No maximum",value:t.maxPrice||"",onChange:a=>s({...t,maxPrice:a.target.value?Number(a.target.value):void 0})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(qr,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function Y_s({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(xo,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(c1,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(Nc,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},r=(n,a)=>!n||n.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):e.jsx("div",{className:"space-y-2",children:n.map((o,l)=>e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${l===0?"bg-gradient-to-r from-amber-500/10 to-amber-500/5 border border-amber-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"flex items-center justify-center w-8",children:s(l)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:o.name})}),e.jsxs(st,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-emerald-500/10 to-emerald-500/5 border border-emerald-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-emerald-500/20 flex items-center justify-center",children:e.jsx(wd,{className:"h-6 w-6 text-emerald-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Listing Amplifier"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Share 10+ listings"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-sky-500/10 to-sky-500/5 border border-sky-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-sky-500/20 flex items-center justify-center",children:e.jsx(bn,{className:"h-6 w-6 text-sky-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Top Contributor"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add 5+ listings"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-purple-500/10 to-purple-500/5 border border-purple-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-purple-500/20 flex items-center justify-center",children:e.jsx(c1,{className:"h-6 w-6 text-purple-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Referral Connector"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Send 3+ referrals"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-amber-500/10 to-amber-500/5 border border-amber-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-amber-500/20 flex items-center justify-center",children:e.jsx(xo,{className:"h-6 w-6 text-amber-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Community MVP"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Top performer"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Community Leaderboard"})}),e.jsx(Oe,{children:e.jsxs(ba,{defaultValue:"sharers",children:[e.jsxs(pa,{className:"w-full",children:[e.jsxs(ns,{value:"sharers",className:"flex-1",children:[e.jsx(wd,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(ns,{value:"listers",className:"flex-1",children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(bs,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(bs,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const r7e={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},n7e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function X_s(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Q_s({listings:t,isLoading:s}){const r=fr(),n=k.useRef(null),a=k.useRef(null),o=k.useRef([]),{isAdmin:l}=Ds(),[i,c]=k.useState(""),[u,p]=k.useState(!0),[f,g]=k.useState(!1),b=t.filter(j=>j.latitude!=null&&j.longitude!=null),_=t.filter(j=>(j.latitude==null||j.longitude==null)&&(j.property_address||j.city));return k.useEffect(()=>{(async()=>{p(!0);try{const{data:w}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&c(w.value)}catch(w){console.error("Error fetching mapbox token:",w)}p(!1)})()},[]),k.useEffect(()=>{if(!i||_.length===0||f)return;(async()=>{var w;g(!0);for(const N of _){const S=[N.property_address,N.city,N.state].filter(Boolean).join(", ");if(S)try{const L=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(S)}.json?access_token=${i}&limit=1`)).json();if((w=L.features)!=null&&w[0]){const[I,O]=L.features[0].center;await H.from("listings").update({latitude:O,longitude:I}).eq("id",N.id),N.latitude=O,N.longitude=I}}catch(M){console.error("Geocode error:",M)}}g(!1)})()},[i,t]),k.useEffect(()=>{if(!n.current||!i||a.current)return;Ao.accessToken=i;const j=t.filter(S=>S.latitude!=null&&S.longitude!=null);let w=[-98.5795,39.8283],N=4;if(j.length>0){const S=j.reduce((L,I)=>L+I.longitude,0)/j.length,M=j.reduce((L,I)=>L+I.latitude,0)/j.length;w=[S,M],N=j.length===1?12:10}return a.current=new Ao.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:N,center:w}),a.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var S;(S=a.current)==null||S.remove(),a.current=null}},[i]),k.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(w=>w.remove()),o.current=[];const j=t.filter(w=>w.latitude!=null&&w.longitude!=null);if(j.forEach(w=>{var O,q,U;const N=r7e[w.status]||"#10B981",S=((O=w.photos)==null?void 0:O.find(B=>B.is_primary))||((q=w.photos)==null?void 0:q[0]),M=document.createElement("div");M.className="cursor-pointer",M.innerHTML=`
`;const L=new Ao.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${S!=null&&S.photo_url?``:""}
${X_s(w.price)}
${w.property_address||""}
${w.city}, ${w.state}
${n7e[w.status]||w.status} ${w.bedrooms?`${w.bedrooms} bed`:""} ${w.bathrooms?`${w.bathrooms} bath`:""}
${(U=w.agent)!=null&&U.name?`
Listed by ${w.agent.name}
`:""}
Click to view details →
`),I=new Ao.Marker(M).setLngLat([w.longitude,w.latitude]).setPopup(L).addTo(a.current);o.current.push(I)}),j.length>1){const w=new Ao.LngLatBounds;j.forEach(N=>w.extend([N.longitude,N.latitude])),a.current.fitBounds(w,{padding:60,maxZoom:13})}else j.length===1&&a.current.flyTo({center:[j[0].longitude,j[0].latitude],zoom:12})},[t,i,f]),k.useEffect(()=>(window.__navigateToListing__=j=>{r(`/mission-control/listings/${j}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[60vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(ma,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Listings Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add listings to see them on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[Object.entries(r7e).map(([j,w])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:w}}),e.jsx("span",{className:"text-xs",children:n7e[j]})]},j)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[b.length," of ",t.length," mapped",f&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(kl,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Map Not Configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"Set up your Mapbox token in Settings to enable maps.":"The map feature has not been configured yet. Please contact your administrator."})]})]})})}function J_s(){var B,V,Y,Q,ee,X,ie,re;const t=fr(),{brokerageId:s}=Ds(),{data:r,isLoading:n}=JYe(),[a,o]=k.useState("feed"),[l,i]=k.useState(!1),[c,u]=k.useState(""),[p,f]=k.useState({sortBy:"newest"}),{data:g,isLoading:b}=eXe({...p,city:c||p.city}),{data:_,isLoading:j}=FLt(),{data:w,isLoading:N}=tXe(),{data:S,isLoading:M}=qLt(),{data:L,isLoading:I}=HLt(),{data:O}=VLt(),q=rXe(),U=async oe=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await q.mutateAsync(oe),me.success("Listing deleted successfully")}catch{me.error("Failed to delete listing")}};return n?e.jsx(Ms,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):r?e.jsx(Ms,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(bn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(g==null?void 0:g.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(ni,{className:"h-5 w-5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(_==null?void 0:_.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(X4,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(w==null?void 0:w.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(pr,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((B=S==null?void 0:S.sent)==null?void 0:B.length)||0)+(((V=S==null?void 0:S.received)==null?void 0:V.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(ba,{value:a,onValueChange:o,children:[e.jsxs(pa,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(ns,{value:"feed",children:"Community Feed"}),s&&e.jsx(ns,{value:"brokerage",children:"Brokerage"}),e.jsx(ns,{value:"my-listings",children:"My Listings"}),e.jsx(ns,{value:"saved",children:"Saved"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"map",children:"Map"}),e.jsx(ns,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(bs,{value:"feed",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by city or neighborhood...",value:c,onChange:oe=>u(oe.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:p.sortBy,onValueChange:oe=>f({...p,sortBy:oe}),children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Sort by"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"newest",children:"Newest First"}),e.jsx(Mt,{value:"updated",children:"Recently Updated"}),e.jsx(Mt,{value:"price_asc",children:"Price: Low to High"}),e.jsx(Mt,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(Qg,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(Z_s,{filters:p,onFiltersChange:f,onClose:()=>i(!1)}),b?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((oe,ce)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"}),e.jsx(ys,{className:"h-4 w-1/4"})]})]},ce))}):(g==null?void 0:g.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(bn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to share a listing with the community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:g==null?void 0:g.map(oe=>e.jsx(Zz,{listing:oe,onClick:()=>t(`/mission-control/listings/${oe.id}`)},oe.id))})]}),e.jsx(bs,{value:"my-listings",className:"space-y-4",children:N?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((oe,ce)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"})]})]},ce))}):(w==null?void 0:w.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(X4,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Share your listings with the LevelUp community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w==null?void 0:w.map(oe=>e.jsx(Zz,{listing:oe,showActions:!0,onClick:()=>t(`/mission-control/listings/${oe.id}`),onEdit:()=>t(`/mission-control/listings/${oe.id}/edit`),onDelete:()=>U(oe.id)},oe.id))})}),e.jsx(bs,{value:"saved",className:"space-y-4",children:j?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((oe,ce)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"})]})]},ce))}):(_==null?void 0:_.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(ni,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No saved listings"}),e.jsx("p",{className:"text-muted-foreground",children:"Save listings to quickly access them later"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:_==null?void 0:_.map(oe=>e.jsx(Zz,{listing:oe.listing,onClick:()=>t(`/mission-control/listings/${oe.listing.id}`)},oe.id))})}),e.jsx(bs,{value:"referrals",className:"space-y-6",children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(wd,{className:"h-4 w-4"}),"Referrals Sent (",((Y=S==null?void 0:S.sent)==null?void 0:Y.length)||0,")"]}),((Q=S==null?void 0:S.sent)==null?void 0:Q.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(ee=S==null?void 0:S.sent)==null?void 0:ee.map(oe=>{var ce,ge;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:oe.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((ce=oe.listing)==null?void 0:ce.property_address)||((ge=oe.listing)==null?void 0:ge.city)})]}),e.jsx(st,{variant:oe.status==="closed"?"default":"secondary",children:oe.status.replace("_"," ")})]})})},oe.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Referrals Received (",((X=S==null?void 0:S.received)==null?void 0:X.length)||0,")"]}),((ie=S==null?void 0:S.received)==null?void 0:ie.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(re=S==null?void 0:S.received)==null?void 0:re.map(oe=>{var ce;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:oe.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(ce=oe.sender)==null?void 0:ce.name]})]}),e.jsx(st,{variant:oe.status==="closed"?"default":"secondary",children:oe.status.replace("_"," ")})]}),e.jsx(K,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${oe.listing_id}`),children:"View Listing"})]})},oe.id)})})]})]})}),s&&e.jsx(bs,{value:"brokerage",className:"space-y-4",children:I?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((oe,ce)=>e.jsxs(Ee,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"})]})]},ce))}):(L==null?void 0:L.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(X4,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No brokerage listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No agents in your brokerage have added listings yet."}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add a Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:L==null?void 0:L.map(oe=>e.jsx(Zz,{listing:oe,onClick:()=>t(`/mission-control/listings/${oe.id}`)},oe.id))})}),e.jsx(bs,{value:"map",children:e.jsx(Q_s,{listings:g||[],isLoading:b})}),e.jsx(bs,{value:"leaderboard",children:e.jsx(Y_s,{leaderboard:O})})]})]})}):e.jsx(Ms,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(bn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Coming Soon"}),e.jsx("p",{className:"text-muted-foreground",children:"Listing Exchange is currently in development. Check back soon!"})]})})})}function vx(t){const s=t.expected_commission;if(!s)return null;if((t.commission_calc_method||"standard")==="referral_first"){let a=s;t.referral_fee_pct&&(a-=s*(t.referral_fee_pct/100));let o=a;return t.brokerage_split_pct&&(o-=a*(t.brokerage_split_pct/100)),t.team_split_pct&&(o-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(o-=s*(t.franchise_fee_pct/100)),t.transaction_fee&&(o-=t.transaction_fee),Math.max(0,o)}let n=s;return t.brokerage_split_pct&&(n-=s*(t.brokerage_split_pct/100)),t.team_split_pct&&(n-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(n-=s*(t.franchise_fee_pct/100)),t.referral_fee_pct&&(n-=s*(t.referral_fee_pct/100)),t.transaction_fee&&(n-=t.transaction_fee),Math.max(0,n)}function Ghe(){const t=ci();return mt({queryKey:["deal-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function tit(){const t=ci(),s=Qt();return Lt({mutationFn:async()=>{if(!t)throw new Error("Not authenticated");const{error:r}=await H.rpc("initialize_deal_pipeline_stages",{p_user_id:t});if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function Khe(){const t=ci();return mt({queryKey:["deal-pipeline-deals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at) `).eq("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function sit(){const t=ci(),s=Qt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("deal_pipeline").insert({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||null,contact_id:r.contact_id||null,listing_id:r.listing_id||null,property_address:r.property_address||null,city:r.city||null,state:r.state||null,zip_code:r.zip_code||null,expected_price:r.expected_price||null,expected_commission:r.expected_commission||null,commission_percentage:r.commission_percentage||3,target_close_date:r.target_close_date||null,contract_date:r.contract_date||null,listing_date:r.listing_date||null,priority:r.priority||"medium",probability:r.probability||50,notes:r.notes||null,owner_user_id:t}).select().single();if(a)throw a;return await H.from("deal_activities").insert([{deal_id:n.id,activity_type:"system",title:"Deal created",description:`Deal "${r.deal_name}" was created`}]),n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-deals"]}),s.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function rit(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("deal_pipeline").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function ews(){const t=Qt();return Lt({mutationFn:async({dealId:s,stageId:r,stageName:n})=>{const{data:a,error:o}=await H.from("deal_pipeline").update({stage_id:r}).eq("id",s).select().single();if(o)throw o;return await H.from("deal_activities").insert({deal_id:s,activity_type:"stage_change",title:`Moved to ${n}`,metadata:{new_stage_id:r,new_stage_name:n}}),a},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-activities"]})}})}function tws(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("deal_pipeline").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function sws(t){return mt({queryKey:["deal-activities",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_activities").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function rws(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("deal_activities").insert([{deal_id:s.deal_id,activity_type:s.activity_type,title:s.title,description:s.description||null}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-activities",r.deal_id]})}})}function nws(t){return mt({queryKey:["deal-checklist",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_checklist_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function aws(){const t=Qt();return Lt({mutationFn:async({id:s,is_completed:r,deal_id:n})=>{const{data:a,error:o}=await H.from("deal_checklist_items").update({is_completed:r,completed_at:r?new Date().toISOString():null}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function iws(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("deal_checklist_items").insert([{deal_id:s.deal_id,title:s.title,description:s.description||null,due_date:s.due_date||null,sort_order:s.sort_order||0}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function ows(){const t=ci();return mt({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("deal_pipeline").select("*, deal_pipeline_stages(name, is_won_stage, is_lost_stage)").eq("owner_user_id",t);if(r)throw r;const n=(s==null?void 0:s.filter(i=>{var c,u,p;return!((c=i.deal_pipeline_stages)!=null&&c.is_won_stage)&&!((u=i.deal_pipeline_stages)!=null&&u.is_lost_stage)&&((p=i.deal_pipeline_stages)==null?void 0:p.name)!=="Cancelled"}))||[],a=(s==null?void 0:s.filter(i=>{var c;return(c=i.deal_pipeline_stages)==null?void 0:c.is_won_stage}))||[],o=new Date().getFullYear(),l=a.filter(i=>{const c=i.actual_close_date;return c?new Date(c).getFullYear()===o:!0});return{totalDeals:(s==null?void 0:s.length)||0,activeDeals:n.length,wonDeals:a.length,pipelineValue:n.reduce((i,c)=>i+(c.expected_price||0),0),expectedCommission:n.reduce((i,c)=>i+(c.expected_commission||0),0),expectedNetToAgent:n.reduce((i,c)=>i+(vx(c)||0),0),wonValue:a.reduce((i,c)=>i+(c.expected_price||0),0),weightedGCI:n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(c.expected_commission||0)*u},0),weightedNet:n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(vx(c)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,c)=>i+(c.expected_commission||0),0),ytdWonNet:l.reduce((i,c)=>i+(vx(c)||0),0),projectedAnnualNet:l.reduce((i,c)=>i+(vx(c)||0),0)+n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(vx(c)||0)*u},0)}},enabled:!!t})}function lws(t){const s=ci();return mt({queryKey:["deal-by-listing",t,s],queryFn:async()=>{if(!s||!t)return null;const{data:r,error:n}=await H.from("deal_pipeline").select(` *, deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("listing_id",t).maybeSingle();if(n)throw n;return r},enabled:!!s&&!!t})}function cws(){const t=Qt();return Lt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await H.from("deal_pipeline").update({listing_id:r}).eq("id",s).select().single();if(a)throw a;return await H.from("deal_activities").insert({deal_id:s,activity_type:"system",title:"Linked to Listing Exchange",description:"This deal is now synced with Listing Exchange",metadata:{listing_id:r}}),n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",r.listingId]})}})}function dws(){const t=Qt();return Lt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await H.from("deal_pipeline").update({listing_id:null}).eq("id",s).select().single();if(a)throw a;return{data:n,listingId:r}},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",s.listingId]})}})}function uws({listing:t}){const s=fr(),[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l,isLoading:i}=lws(t.id),{data:c,isLoading:u}=Ghe(),{data:p,isLoading:f}=Khe(),g=tit(),b=cws(),_=dws(),j=sit(),w=(p==null?void 0:p.filter(I=>!I.listing_id))||[],N=I=>{if(!(c!=null&&c.length))return null;switch(I){case"coming_soon":case"active":case"price_improvement":return c.find(O=>O.name==="Active");case"under_contract":return c.find(O=>O.name==="Under Contract");case"sold":return c.find(O=>O.is_won_stage);default:return c.find(O=>O.name==="Active")}},S=async()=>{o(!0);try{c!=null&&c.length||await g.mutateAsync();const I=N(t.status);await j.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(I==null?void 0:I.id)||null,listing_id:t.id,property_address:t.property_address,city:t.city,state:t.state,expected_price:t.price,expected_commission:t.price*.03,commission_percentage:3,priority:"medium",probability:50}),me.success("Deal created and linked to listing!")}catch(I){console.error("Failed to create deal:",I),me.error("Failed to create deal")}finally{o(!1)}},M=async()=>{if(!r){me.error("Please select a deal");return}try{await b.mutateAsync({dealId:r,listingId:t.id}),me.success("Listing linked to deal!"),n("")}catch{me.error("Failed to link listing")}},L=async()=>{if(l)try{await _.mutateAsync({dealId:l.id,listingId:t.id}),me.success("Listing unlinked from deal")}catch{me.error("Failed to unlink listing")}};return i||u?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2 text-base",children:[e.jsx(m0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Ee,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"flex items-center gap-2 text-base",children:[e.jsx(dl,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.deal_name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:l.deal_pipeline_stages&&e.jsx(st,{variant:"secondary",className:"text-xs",style:{backgroundColor:`${l.deal_pipeline_stages.color}20`,color:l.deal_pipeline_stages.color},children:l.deal_pipeline_stages.name})})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes sync automatically between the listing and pipeline."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(Qa,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:L,disabled:_.isPending,children:_.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(gS,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"flex items-center gap-2 text-base",children:[e.jsx(m0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(K,{onClick:S,disabled:a||j.isPending,className:"w-full",size:"sm",children:[a||j.isPending?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),w.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:r,onValueChange:n,children:[e.jsx(Hs,{className:"flex-1 text-sm",children:e.jsx(Ys,{placeholder:"Link to existing deal..."})}),e.jsx(Ws,{children:w.map(I=>e.jsx(Mt,{value:I.id,children:I.deal_name},I.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:M,disabled:!r||b.isPending,children:b.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(dl,{className:"h-4 w-4"})})]})]})]})]})}const hws={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},mws={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},a7e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function pws(){var ee,X,ie,re,oe,ce,ge,ye,ue;const{listingId:t}=yo(),s=fr(),{user:r}=Ds(),{data:n,isLoading:a}=sXe(t||""),{data:o}=aXe(t||""),{data:l}=BLt(t||""),i=nXe(),c=zLt(),u=$Lt(),p=rXe(),f=ULt(),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(!1),[S,M]=k.useState(null),[L,I]=k.useState({buyerName:"",buyerType:"",notes:""}),O=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),q=pe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(pe),U=async pe=>{const _e=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,$e=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:pe});try{switch(pe){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(_e)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(_e),me.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${$e} ${_e}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent($e)}&body=${encodeURIComponent(`Check out this listing: ${_e}`)}`);break}}catch(Ae){console.error("Share error:",Ae),me.error("Failed to share")}},B=async()=>{try{await p.mutateAsync(n.id),me.success("Listing deleted"),s("/mission-control/listings")}catch{me.error("Failed to delete listing")}},V=async()=>{if(!L.buyerName.trim()){me.error("Please enter buyer name");return}try{await f.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:L.buyerName,buyerType:L.buyerType||void 0,notes:L.notes||void 0}),me.success("Referral sent successfully!"),j(!1),I({buyerName:"",buyerType:"",notes:""})}catch{me.error("Failed to send referral")}},Y=pe=>{var we,Le;const _e=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,$e=q((n==null?void 0:n.price)||0),Ae=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Ie=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Ce=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",xe=[Ae,Ie,Ce].filter(Boolean).join(" | ");switch(pe){case"just_listed":return`🏡 JUST LISTED! ${_e} ${$e} ${xe} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(we=n==null?void 0:n.city)==null?void 0:we.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${_e} Now ${$e}! ${xe} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${a7e[(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! ${xe} DM me for details! 📩 #ComingSoon #RealEstate #${(Le=n==null?void 0:n.city)==null?void 0:Le.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Ms,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-10 w-32"}),e.jsx(ys,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(ys,{className:"h-48"}),e.jsx(ys,{className:"h-48"}),e.jsx(ys,{className:"h-48"})]})]})});if(!n)return e.jsx(Ms,{title:"Listing Not Found",description:"",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(K,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const Q=((ee=n.photos)==null?void 0:ee.find(pe=>pe.is_primary))||((X=n.photos)==null?void 0:X[0]);return e.jsxs(Ms,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>Q&&M(Q.photo_url),children:Q?e.jsx("img",{src:Q.photo_url,alt:"Primary",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No photos"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:(ie=n.photos)==null?void 0:ie.slice(1,5).map((pe,_e)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>M(pe.photo_url),children:e.jsx("img",{src:pe.photo_url,alt:`Photo ${_e+2}`,className:"w-full h-full object-cover"})},pe.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(st,{className:`${hws[n.status]} text-white border-0`,children:mws[n.status]}),n.is_featured&&e.jsxs(st,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(st,{variant:"outline",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:q(n.price)}),n.property_address&&e.jsx("p",{className:"text-xl font-medium",children:n.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ma,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:e.jsx(ni,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>c.mutate(n.id),children:l?e.jsx(r1,{className:"h-4 w-4"}):e.jsx(Lm,{className:"h-4 w-4"})}),!O&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>N(!0),children:[e.jsx(pn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(wd,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Bd,{children:[e.jsxs(Ma,{onClick:()=>U("copy"),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Ma,{onClick:()=>U("facebook"),children:[e.jsx(Su,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Ma,{onClick:()=>U("text"),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Ma,{onClick:()=>U("email"),children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),O&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(hd,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>b(!0),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[n.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Im,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.bedrooms}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Beds"})]}),n.bathrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Ju,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.bathrooms}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Baths"})]}),n.square_footage&&e.jsxs("div",{className:"text-center",children:[e.jsx(b0,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.square_footage.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sq Ft"})]}),n.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.year_built}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"pt-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(st,{variant:"secondary",children:[e.jsx(ka,{className:"h-3 w-3 mr-1"}),a7e[n.property_type]]}),n.lot_size&&e.jsxs(st,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(st,{variant:"secondary",children:"HOA"})]}),n.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Description"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.description})]}),n.agent_notes&&n.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.agent_notes})]}),n.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]}),e.jsxs("div",{className:"flex items-center gap-4 pt-4 mt-4 border-t text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ln,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wd,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ni,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Share Content"})}),e.jsx(Oe,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(pe=>e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("p",{className:"font-medium text-sm capitalize",children:[pe.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(Y(pe)),me.success("Caption copied!")},children:e.jsx(gi,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:Y(pe)})]},pe))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-semibold text-primary",children:((oe=(re=n.agent)==null?void 0:re.name)==null?void 0:oe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ce=n.agent)==null?void 0:ce.name)||"Unknown"}),((ye=(ge=n.agent)==null?void 0:ge.brokerage)==null?void 0:ye.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!O&&e.jsx("div",{className:"space-y-2",children:((ue=n.agent)==null?void 0:ue.email)&&e.jsx(K,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),O&&e.jsx(uws,{listing:n}),!O&&n.open_to_referrals&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Have a buyer interested in this property? Send a referral to the listing agent."}),e.jsx(K,{className:"w-full",onClick:()=>j(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(fs,{open:!!S,onOpenChange:()=>M(null),children:e.jsx(ps,{className:"max-w-4xl",children:e.jsx("img",{src:S||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(fs,{open:g,onOpenChange:b,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Delete Listing"}),e.jsx(Gr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:B,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(fs,{open:_,onOpenChange:j,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Send Buyer Referral"}),e.jsx(Gr,{children:"Submit buyer information to the listing agent"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Buyer Name *"}),e.jsx(ze,{value:L.buyerName,onChange:pe=>I({...L,buyerName:pe.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Buyer Type"}),e.jsxs(Ks,{value:L.buyerType,onValueChange:pe=>I({...L,buyerType:pe}),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"first_time",children:"First-Time Buyer"}),e.jsx(Mt,{value:"investor",children:"Investor"}),e.jsx(Mt,{value:"relocating",children:"Relocating"}),e.jsx(Mt,{value:"upgrade",children:"Upgrading"}),e.jsx(Mt,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Notes"}),e.jsx(Er,{value:L.notes,onChange:pe=>I({...L,notes:pe.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(K,{onClick:V,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(eit,{open:w,onOpenChange:N,listingId:(n==null?void 0:n.id)||"",listingSlug:(n==null?void 0:n.slug)||null,listingTitle:(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`})]})}function fws({onImport:t}){const[s,r]=k.useState(""),[n,a]=k.useState([]),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState(null),f=k.useRef(),g=k.useRef(null);k.useEffect(()=>{const S=M=>{g.current&&!g.current.contains(M.target)&&c(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[]);const b=async S=>{if(S.trim().length<3){a([]),c(!1);return}l(!0);try{const{data:M,error:L}=await H.functions.invoke("mls-listing-search",{body:{query:S}});if(L)throw L;a((M==null?void 0:M.listings)||[]),c(!0)}catch(M){console.error("MLS search error:",M),a([])}finally{l(!1)}},_=S=>{r(S),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>b(S),400)},j=S=>{p(S.mlsNumber),t(S),c(!1),r(`${S.address}, ${S.city}`),me.success(`Imported: ${S.address}`,{description:"Property details and photos have been auto-filled."}),p(null)},w=S=>S?`$${S.toLocaleString()}`:"",N=S=>{const M=(S||"").toLowerCase();return M.includes("single")||M.includes("detached")?"Single Family":M.includes("condo")?"Condo":M.includes("town")?"Townhouse":M.includes("land")||M.includes("lot")?"Land":M.includes("multi")?"Multi-Family":M.includes("commercial")?"Commercial":S||"Other"};return e.jsxs(Ee,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(yi,{className:"h-4 w-4 text-primary"}),"Import from MLS"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Search by address to auto-fill property details and photos from MLS"})]}),e.jsx(Oe,{children:e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:s,onChange:S=>_(S.target.value),onFocus:()=>n.length>0&&c(!0),placeholder:"Start typing a property address...",className:"pl-9 pr-9"}),o&&e.jsx(ws,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 animate-spin text-muted-foreground"}),s&&!o&&e.jsx("button",{type:"button",onClick:()=>{r(""),a([]),c(!1)},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Rr,{className:"h-4 w-4"})})]}),i&&e.jsx("div",{className:"absolute z-50 w-full mt-1 bg-popover border rounded-lg shadow-lg max-h-[400px] overflow-y-auto",children:n.length===0&&!o?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No properties found. Try a different address."}):n.map(S=>e.jsxs("button",{type:"button",onClick:()=>j(S),disabled:u===S.mlsNumber,className:"w-full text-left p-3 hover:bg-accent/50 transition-colors border-b last:border-0 flex items-start gap-3",children:[S.photos[0]?e.jsx("img",{src:S.photos[0],alt:"",className:"w-16 h-12 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-16 h-12 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(ma,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:S.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[S.city,", ",S.state," ",S.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:w(S.price)}),S.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Im,{className:"h-3 w-3"})," ",S.bedrooms]}),S.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ju,{className:"h-3 w-3"})," ",S.bathrooms]}),S.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(g0,{className:"h-3 w-3"})," ",S.sqft.toLocaleString()]})]})]}),e.jsxs("div",{className:"flex-shrink-0 flex flex-col items-end gap-1",children:[e.jsx(st,{variant:"outline",className:"text-[10px]",children:N(S.propertyType)}),S.photos.length>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[S.photos.length," photos"]})]})]},S.mlsNumber))})]})})]})}function xws({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:c}=Yke({id:t.id}),u={transform:JS.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:It("relative aspect-square rounded-lg overflow-hidden bg-muted group",c&&"opacity-50 ring-2 ring-primary z-50"),children:[e.jsx("img",{src:t.photo_url,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...n,...a,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Cu,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>s(t.id),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Rr,{className:"h-3 w-3"})}),t.is_primary?e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Jn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]}):e.jsx("button",{type:"button",onClick:()=>r(t.id),className:"absolute bottom-1 left-1 text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded opacity-0 group-hover:opacity-100 transition-opacity hover:bg-black/80",children:"Set as Primary"})]})}function gws({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=qke(Ule(rR,{activationConstraint:{distance:5}})),i=[...t].sort((u,p)=>(u.sort_order??0)-(p.sort_order??0)),c=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const g=i.findIndex(N=>N.id===p.id),b=i.findIndex(N=>N.id===f.id),_=[...i],[j]=_.splice(g,1);_.splice(b,0,j);const w=_.map((N,S)=>({...N,sort_order:S}));a(w)};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. Hover to set primary."}),e.jsx(Gke,{sensors:l,collisionDetection:Uke,onDragEnd:c,children:e.jsx(Zke,{items:i.map(u=>u.id),strategy:nR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(xws,{photo:u,onRemove:n,onSetPrimary:o},u.id)),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[s?e.jsx(ws,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-8 w-8"}),e.jsx("span",{className:"text-xs",children:"Upload"})]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:u=>r(u.target.files),disabled:s})]})]})})})]})}function yws({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=fr(),{user:a}=Ds(),[o,l]=k.useState(!1),[i,c]=k.useState([]),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState({});k.useEffect(()=>{t&&a?j():g(null)},[t,a]);const j=async()=>{if(!t)return;const{data:B,error:V}=await H.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("id",t).eq("is_deleted",!1).single();!V&&B&&(g(B),w(B))},w=async B=>{try{const{data:V,error:Y}=await H.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:B.bunny_video_id,isAgentVideo:!0}});!Y&&(V!=null&&V.thumbnailUrl)&&_(Q=>({...Q,[B.id]:{thumbnailUrl:V.thumbnailUrl}}))}catch(V){console.warn("Failed to get signed URL",V)}},N=async()=>{if(a){p(!0);try{const{data:B,error:V}=await H.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("owner_user_id",a.id).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(V)throw V;c(B||[]),B!=null&&B.length&&S(B)}catch(B){console.error("Error fetching videos:",B),me.error("Failed to load videos")}finally{p(!1)}}},S=async B=>{var V;try{const Y=B.map(re=>re.bunny_video_id),{data:Q,error:ee}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Y,isAgentVideo:!0}});if(ee)throw ee;const X=(Q==null?void 0:Q.assets)||{},ie={};for(const re of B)(V=X[re.bunny_video_id])!=null&&V.thumbnailUrl&&(ie[re.id]={thumbnailUrl:X[re.bunny_video_id].thumbnailUrl});_(re=>({...re,...ie}))}catch(Y){console.warn("Failed to bulk-fetch signed URLs",Y)}},M=()=>{l(!0),N()},L=B=>{s(B.id),g(B),l(!1),me.success("Video selected")},I=()=>{s(null),g(null)},O=()=>{const B=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(B)}`)},q=B=>{if(!B)return"0:00";const V=Math.floor(B/60),Y=B%60;return`${V}:${Y.toString().padStart(2,"0")}`},U=B=>{var V;return((V=b[B.id])==null?void 0:V.thumbnailUrl)||B.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex items-start gap-4 p-4",children:[e.jsxs("div",{className:"relative w-32 h-20 bg-muted rounded-lg overflow-hidden flex-shrink-0",children:[U(f)?e.jsx("img",{src:U(f),alt:f.title||"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(An,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-black/30 flex items-center justify-center",children:e.jsx(nl,{className:"h-6 w-6 text-white fill-white"})}),f.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:q(f.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:f.title||"Untitled Video"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Property Video Tour"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:M,children:"Change"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:I,className:"text-destructive hover:text-destructive",children:e.jsx(Rr,{className:"h-4 w-4"})})]})]})})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(An,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a video walkthrough to showcase this property"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[e.jsxs(K,{type:"button",variant:"outline",onClick:M,className:"gap-2",children:[e.jsx(DM,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:O,className:"gap-2",children:[e.jsx(Sx,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(DM,{className:"h-5 w-5"}),"Select a Video"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:u?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(An,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No videos in your library yet"}),e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx(Sx,{className:"h-4 w-4"}),"Record Your First Video"]})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 p-1",children:i.map(B=>e.jsxs("button",{type:"button",onClick:()=>L(B),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===B.id?"border-primary ring-2 ring-primary/20":"border-transparent hover:border-muted-foreground/30"}`,children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[U(B)?e.jsx("img",{src:U(B),alt:B.title||"Video",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(An,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(nl,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),B.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:q(B.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:B.title||"Untitled Video"})})]},B.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:O,className:"gap-2",children:[e.jsx(Sx,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const vws=[{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"}],bws=[{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 _ws({id:t,url:s,index:r,onRemove:n}){const{attributes:a,listeners:o,setNodeRef:l,transform:i,transition:c,isDragging:u}=Yke({id:t}),p={transform:JS.Transform.toString(i),transition:c};return e.jsxs("div",{ref:l,style:p,className:`relative aspect-square rounded-lg overflow-hidden bg-muted group ${u?"opacity-50 ring-2 ring-primary z-50":""}`,children:[e.jsx("img",{src:s,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...a,...o,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Cu,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>n(r),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Rr,{className:"h-3 w-3"})}),r===0&&e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Jn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]})]})}function wws({photoUrls:t,pendingPhotos:s,onRemove:r,onReorder:n,uploading:a,onUpload:o}){const l=qke(Ule(rR,{activationConstraint:{distance:5}})),i=t.map((u,p)=>`pending-${p}`),c=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const g=i.indexOf(p.id),b=i.indexOf(f.id),_=[...t],j=[...s],[w]=_.splice(g,1),[N]=j.splice(g,1);_.splice(b,0,w),j.splice(b,0,N),n(_,j)};return e.jsxs("div",{className:"space-y-2",children:[t.length>1&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. First photo will be primary."}),e.jsx(Gke,{sensors:l,collisionDetection:Uke,onDragEnd:c,children:e.jsx(Zke,{items:i,strategy:nR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[t.map((u,p)=>e.jsx(_ws,{id:i[p],url:u,index:p,onRemove:r},i[p])),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[a?e.jsx(ws,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-8 w-8"}),e.jsx("span",{className:"text-xs",children:"Upload"})]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:u=>o(u.target.files),disabled:a})]})]})})}),s.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:[s.length," photo",s.length!==1?"s":""," will be uploaded when you save."]})]})}function i7e(){const{listingId:t}=yo(),[s]=Cc(),r=s.get("brokerage"),n=fr(),{user:a}=Ds(),{hasLeadSite:o}=rE(),l=!!t&&t!=="new",i=!!r&&!l,[c,u]=k.useState([]),{data:p,isLoading:f}=sXe(l?t:""),g=ELt(),b=PLt(),_=ILt(),j=LLt(),w=DLt(),N=OLt(),S=RLt(),{data:M=[]}=mt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:ue,error:pe}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(pe)throw pe;return ue||[]},enabled:i}),[L,I]=k.useState(""),[O,q]=k.useState(!1),[U,B]=k.useState([]),[V,Y]=k.useState([]),[Q,ee]=k.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});k.useEffect(()=>{var ue,pe,_e,$e,Ae;p&&l&&ee({property_address:p.property_address||"",city:p.city||"",state:p.state||"",neighborhood:p.neighborhood||"",price:((ue=p.price)==null?void 0:ue.toString())||"",property_type:p.property_type,status:p.status,bedrooms:((pe=p.bedrooms)==null?void 0:pe.toString())||"",bathrooms:((_e=p.bathrooms)==null?void 0:_e.toString())||"",square_footage:(($e=p.square_footage)==null?void 0:$e.toString())||"",lot_size:p.lot_size||"",year_built:((Ae=p.year_built)==null?void 0:Ae.toString())||"",has_hoa:p.has_hoa,description:p.description||"",agent_notes:p.agent_notes||"",agent_notes_public:p.agent_notes_public,mls_link:p.mls_link||"",video_link:p.video_link||"",video_id:p.video_id||null,allow_sharing:p.allow_sharing,open_to_referrals:p.open_to_referrals,open_to_social_promotion:p.open_to_social_promotion,share_with_brokerage:p.share_with_brokerage??!1,is_public:p.is_public})},[p,l]);const X=ue=>{var Ae,Ie;const pe={"single family":"single_family",detached:"single_family",residential:"single_family",condo:"condo",condominium:"condo",apartment:"condo",townhouse:"townhouse",townhome:"townhouse",land:"land",lot:"land","lots and land":"land","multi-family":"multi_family","multi family":"multi_family",duplex:"multi_family",commercial:"commercial"},_e=(ue.propertyType||"").toLowerCase(),$e=((Ae=Object.entries(pe).find(([Ce])=>_e.includes(Ce)))==null?void 0:Ae[1])||"other";ee(Ce=>({...Ce,property_address:ue.address||Ce.property_address,city:ue.city||Ce.city,state:ue.state||Ce.state,price:ue.price?String(ue.price):Ce.price,property_type:$e,bedrooms:ue.bedrooms?String(ue.bedrooms):Ce.bedrooms,bathrooms:ue.bathrooms?String(ue.bathrooms):Ce.bathrooms,square_footage:ue.sqft?String(ue.sqft):Ce.square_footage,lot_size:ue.lotSize?String(ue.lotSize):Ce.lot_size,year_built:ue.yearBuilt?String(ue.yearBuilt):Ce.year_built,description:ue.description||Ce.description})),((Ie=ue.photos)==null?void 0:Ie.length)>0&&(u(ue.photos),V.forEach(Ce=>URL.revokeObjectURL(Ce)),B([]),Y([]))},ie=ue=>{if(!ue)return;const pe=Array.from(ue);B($e=>[...$e,...pe]);const _e=pe.map($e=>URL.createObjectURL($e));Y($e=>[...$e,..._e])},re=ue=>{URL.revokeObjectURL(V[ue]),B(pe=>pe.filter((_e,$e)=>$e!==ue)),Y(pe=>pe.filter((_e,$e)=>$e!==ue))},oe=async ue=>{var pe;if(!(!ue||!p)){q(!0);try{for(const _e of Array.from(ue)){const $e=_e.name.split(".").pop(),Ae=`${a==null?void 0:a.id}/${p.id}/${Date.now()}.${$e}`,{error:Ie}=await H.storage.from("listing-photos").upload(Ae,_e);if(Ie)throw Ie;const{data:{publicUrl:Ce}}=H.storage.from("listing-photos").getPublicUrl(Ae);await j.mutateAsync({listingId:p.id,photoUrl:Ce,isPrimary:!((pe=p.photos)!=null&&pe.length)})}me.success("Photos uploaded!")}catch(_e){console.error("Upload error:",_e),me.error("Failed to upload photos")}finally{q(!1)}}},ce=async ue=>{for(let pe=0;pe{if(p)try{await w.mutateAsync({photoId:ue,listingId:p.id}),me.success("Photo removed")}catch{me.error("Failed to remove photo")}},ye=async ue=>{if(ue.preventDefault(),!Q.city.trim()||!Q.state.trim()||!Q.price){me.error("Please fill in required fields (City, State, Price)");return}if(i&&!L){me.error("Please select an agent to assign this listing to");return}try{const pe={property_address:Q.property_address||null,city:Q.city,state:Q.state,neighborhood:Q.neighborhood||null,price:Number(Q.price),property_type:Q.property_type,status:Q.status,bedrooms:Q.bedrooms?Number(Q.bedrooms):null,bathrooms:Q.bathrooms?Number(Q.bathrooms):null,square_footage:Q.square_footage?Number(Q.square_footage):null,lot_size:Q.lot_size||null,year_built:Q.year_built?Number(Q.year_built):null,has_hoa:Q.has_hoa,description:Q.description||null,agent_notes:Q.agent_notes||null,agent_notes_public:Q.agent_notes_public,mls_link:Q.mls_link||null,video_link:Q.video_link||null,video_id:Q.video_id||null,allow_sharing:Q.allow_sharing,open_to_referrals:Q.open_to_referrals,open_to_social_promotion:Q.open_to_social_promotion,share_with_brokerage:Q.share_with_brokerage,is_public:Q.is_public};if(l)await _.mutateAsync({id:t,...pe}),me.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{q(!0);let _e;if(i&&L?_e=await b.mutateAsync({agentId:L,...pe}):_e=await g.mutateAsync(pe),U.length>0)try{await ce(_e.id),V.forEach($e=>URL.revokeObjectURL($e)),B([]),Y([])}catch($e){console.error("Photo upload error:",$e),me.error("Listing created but some photos failed to upload")}if(c.length>0)try{for(let $e=0;$en(i?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),i?"Back to Brokerage":"Back to Listings"]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[i&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Assign to Agent *"})}),e.jsxs(Oe,{children:[e.jsxs(Ks,{value:L,onValueChange:I,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select an agent..."})}),e.jsx(Ws,{children:M.map(ue=>e.jsx(Mt,{value:ue.id,children:ue.name||ue.email},ue.id))})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"This listing will appear on the selected agent's Listing Exchange."})]})]}),!l&&o&&!i&&e.jsx(fws,{onImport:X}),c.length>0&&e.jsxs(Ee,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(yi,{className:"h-4 w-4 text-primary"}),"MLS Photos (",c.length,")"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These photos will be imported when you save the listing."})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:[c.slice(0,12).map((ue,pe)=>e.jsx("div",{className:"aspect-square rounded overflow-hidden bg-muted",children:e.jsx("img",{src:ue,alt:"",className:"w-full h-full object-cover"})},pe)),c.length>12&&e.jsxs("div",{className:"aspect-square rounded bg-muted flex items-center justify-center text-sm text-muted-foreground font-medium",children:["+",c.length-12]})]}),e.jsxs(K,{type:"button",variant:"ghost",size:"sm",className:"mt-2 text-destructive",onClick:()=>u([]),children:[e.jsx(Rr,{className:"h-3 w-3 mr-1"})," Clear MLS photos"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Property Details"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:Q.property_address,onChange:ue=>ee({...Q,property_address:ue.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"City *"}),e.jsx(ze,{value:Q.city,onChange:ue=>ee({...Q,city:ue.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"State *"}),e.jsx(ze,{value:Q.state,onChange:ue=>ee({...Q,state:ue.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Neighborhood"}),e.jsx(ze,{value:Q.neighborhood,onChange:ue=>ee({...Q,neighborhood:ue.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Price *"}),e.jsx(ze,{type:"number",value:Q.price,onChange:ue=>ee({...Q,price:ue.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Property Type"}),e.jsxs(Ks,{value:Q.property_type,onValueChange:ue=>ee({...Q,property_type:ue}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:bws.map(ue=>e.jsx(Mt,{value:ue.value,children:ue.label},ue.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Status"}),e.jsxs(Ks,{value:Q.status,onValueChange:ue=>ee({...Q,status:ue}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:vws.map(ue=>e.jsx(Mt,{value:ue.value,children:ue.label},ue.value))})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Property Specs (Optional)"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Bedrooms"}),e.jsx(ze,{type:"number",value:Q.bedrooms,onChange:ue=>ee({...Q,bedrooms:ue.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Bathrooms"}),e.jsx(ze,{type:"number",step:"0.5",value:Q.bathrooms,onChange:ue=>ee({...Q,bathrooms:ue.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Sq Ft"}),e.jsx(ze,{type:"number",value:Q.square_footage,onChange:ue=>ee({...Q,square_footage:ue.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Lot Size"}),e.jsx(ze,{value:Q.lot_size,onChange:ue=>ee({...Q,lot_size:ue.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Year Built"}),e.jsx(ze,{type:"number",value:Q.year_built,onChange:ue=>ee({...Q,year_built:ue.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(qr,{checked:Q.has_hoa,onCheckedChange:ue=>ee({...Q,has_hoa:ue})}),e.jsx(be,{children:"Has HOA"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Description & Links"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{value:Q.description,onChange:ue=>ee({...Q,description:ue.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Agent Notes"}),e.jsx(Er,{value:Q.agent_notes,onChange:ue=>ee({...Q,agent_notes:ue.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:Q.agent_notes_public,onCheckedChange:ue=>ee({...Q,agent_notes_public:ue})}),e.jsx(be,{className:"text-sm text-muted-foreground",children:"Make notes visible to other agents"})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"MLS Link"}),e.jsx(ze,{value:Q.mls_link,onChange:ue=>ee({...Q,mls_link:ue.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Video Link"}),e.jsx(ze,{value:Q.video_link,onChange:ue=>ee({...Q,video_link:ue.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(An,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Oe,{children:e.jsx(yws,{selectedVideoId:Q.video_id,onVideoSelect:ue=>ee({...Q,video_id:ue}),listingId:l?t:void 0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Photos"})}),e.jsx(Oe,{children:l&&(p!=null&&p.photos)?e.jsx(gws,{photos:p.photos,uploading:O,onUpload:ue=>oe(ue),onRemove:ue=>ge(ue),onReorder:ue=>{N.mutate({photos:ue.map(pe=>({id:pe.id,sort_order:pe.sort_order,is_primary:pe.is_primary}))})},onSetPrimary:ue=>{p&&S.mutate({photoId:ue,listingId:p.id})}}):e.jsx(wws,{photoUrls:V,onRemove:re,onReorder:(ue,pe)=>{Y(ue),B(pe)},pendingPhotos:U,uploading:O,onUpload:ie})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Sharing & Collaboration"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(qr,{checked:Q.allow_sharing,onCheckedChange:ue=>ee({...Q,allow_sharing:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(qr,{checked:Q.open_to_referrals,onCheckedChange:ue=>ee({...Q,open_to_referrals:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(qr,{checked:Q.open_to_social_promotion,onCheckedChange:ue=>ee({...Q,open_to_social_promotion:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(qr,{checked:Q.share_with_brokerage,onCheckedChange:ue=>ee({...Q,share_with_brokerage:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(qr,{checked:Q.is_public,onCheckedChange:ue=>ee({...Q,is_public:ue})})]})]})]}),e.jsx(K,{type:"submit",className:"w-full",size:"lg",disabled:g.isPending||_.isPending,children:g.isPending||_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):l?"Update Listing":"Create Listing"})]})]})]})})}let op=null;function jws(){if(op)return op;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return op={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},op;const r=s.getExtension("WEBGL_debug_renderer_info"),n=r?s.getParameter(r.UNMASKED_RENDERER_WEBGL):"Unknown",a=["swiftshader","llvmpipe","software","microsoft basic render"],o=(n||"").toLowerCase();if(a.some(c=>o.includes(c)))return op={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},op;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(op={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},op):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(op={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},op):(op={canRunVirtualBg:!0,renderer:n},op)}catch{return op={canRunVirtualBg:!0},op}}const Nws=[{type:"none",label:"Off"},{type:"blur",label:"Blur"}];function kws({value:t,onChange:s,isLoading:r=!1,disabled:n=!1,className:a}){const o=k.useRef(null),[l,i]=k.useState(!1),[c]=k.useState(()=>jws()),u=!c.canRunVirtualBg,{data:p=[],refetch:f}=mt({queryKey:["video-backgrounds"],queryFn:async()=>{const{data:{user:w}}=await H.auth.getUser();if(!w)return[];const{data:N,error:S}=await H.from("video_backgrounds").select("*").eq("is_active",!0).order("sort_order",{ascending:!0});return S?(console.error("Failed to load backgrounds:",S),[]):N||[]}}),g=p.map(w=>({type:"image",label:w.name,imageUrl:w.image_url,thumbnail:w.thumbnail_url||w.image_url})),b=[...Nws,...g],_=w=>w.type!==t.type?!1:w.type==="image"?w.imageUrl===t.imageUrl:!0,j=async w=>{var S;const N=(S=w.target.files)==null?void 0:S[0];if(N){if(!N.type.startsWith("image/")){me.error("Please select an image file");return}if(N.size>5*1024*1024){me.error("Image must be under 5MB");return}i(!0);try{const{data:{user:M}}=await H.auth.getUser();if(!M)throw new Error("Not authenticated");const L=N.name.split(".").pop()||"jpg",I=`${M.id}/${crypto.randomUUID()}.${L}`,{error:O}=await H.storage.from("video-backgrounds").upload(I,N,{contentType:N.type});if(O)throw O;const{data:q}=H.storage.from("video-backgrounds").getPublicUrl(I),U=q.publicUrl,{error:B}=await H.from("video_backgrounds").insert({name:N.name.replace(/\.[^.]+$/,""),image_url:U,thumbnail_url:U,category:"custom",is_stock:!1,user_id:M.id});if(B)throw B;await f(),s({type:"image",imageUrl:U,blurRadius:15}),me.success("Background uploaded!")}catch(M){console.error("Upload error:",M),me.error("Failed to upload background")}finally{i(!1),o.current&&(o.current.value="")}}};return e.jsxs("div",{className:It("flex flex-col gap-1",a),children:[u&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-600 bg-amber-50 dark:bg-amber-950/30 dark:text-amber-400 rounded px-2 py-1",children:[e.jsx(Ku,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:c.reason||"Virtual backgrounds may cause lag on this device"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto py-2 px-1 scrollbar-none",children:[e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap mr-1 font-medium",children:"Background:"}),r&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ws,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Loading…"})]}),b.map((w,N)=>{const S=_(w);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({type:w.type,imageUrl:w.imageUrl,blurRadius:15}),className:It("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 p-1 transition-all","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30",S?"border-primary bg-primary/10":"border-transparent bg-muted/50",n&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("div",{className:"w-12 h-8 rounded flex items-center justify-center overflow-hidden bg-muted",children:[w.type==="none"&&e.jsx(ZI,{className:"h-4 w-4 text-muted-foreground"}),w.type==="blur"&&e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/20 to-primary/40 flex items-center justify-center",children:e.jsx("span",{className:"text-[10px] font-medium text-primary",children:"Blur"})}),w.type==="image"&&w.thumbnail&&e.jsx("img",{src:w.thumbnail,alt:w.label,className:"w-full h-full object-cover"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-14",children:w.label})]},`${w.type}-${w.imageUrl||N}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var w;return(w=o.current)==null?void 0:w.click()},className:It("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 border-dashed p-1 transition-all","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30","border-muted-foreground/30 bg-muted/30",(n||l)&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"w-12 h-8 rounded flex items-center justify-center",children:l?e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx($s,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l?"Uploading":"Custom"})]}),e.jsx("input",{ref:o,type:"file",accept:"image/*",className:"hidden",onChange:j}),e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({...t,mirror:!t.mirror}),className:It("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 p-1 transition-all ml-1","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30",t.mirror?"border-primary bg-primary/10":"border-transparent bg-muted/50",n&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"w-12 h-8 rounded flex items-center justify-center",children:e.jsx(oL,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Mirror"})]})]})]})}var jA=typeof self<"u"?self:{};function nit(t,s){e:{for(var r=["CLOSURE_FLAGS"],n=jA,a=0;a>6|192;else{if(s>=55296&&s<=57343){if(s<=56319&&a=56320&&o<=57343){s=1024*(s-55296)+o-56320+65536,n[r++]=s>>18|240,n[r++]=s>>12&63|128,n[r++]=s>>6&63|128,n[r++]=63&s|128;continue}a--}s=65533}n[r++]=s>>12|224,n[r++]=s>>6&63|128}n[r++]=63&s|128}}t=r===n.length?n:n.subarray(0,r)}return t}function iit(t){jA.setTimeout(()=>{throw t},0)}var V_e,Tws=nit(610401301,!1),l7e=nit(748402147,!0);function c7e(){var t=jA.navigator;return t&&(t=t.userAgent)?t:""}const d7e=jA.navigator;function Zhe(t){return Zhe[" "](t),t}V_e=d7e&&d7e.userAgentData||null,Zhe[" "]=function(){};const oit={};let EI=null;function Aws(t){const s=t.length;let r=3*s/4;r%3?r=Math.floor(r):"=.".indexOf(t[s-1])!=-1&&(r="=.".indexOf(t[s-2])!=-1?r-2:r-1);const n=new Uint8Array(r);let a=0;return function(o,l){function i(u){for(;c>4),f!=64&&(l(p<<4&240|f>>2),g!=64&&l(f<<6&192|g))}}(t,function(o){n[a++]=o}),a!==r?n.subarray(0,a):n}function lit(){if(!EI){EI={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));oit[r]=n;for(let a=0;a0)&&(c7e().indexOf("Trident")!=-1||c7e().indexOf("MSIE")!=-1))&&typeof btoa=="function";const u7e=/[-_.]/g,Pws={"-":"+",_:"/",".":"="};function Iws(t){return Pws[t]||""}function dit(t){if(!cit)return Aws(t);t=u7e.test(t)?t.replace(u7e,Iws):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,hit(t=Error(),"incident"),iit(t))}}function CE(){return typeof BigInt=="function"}var ME=typeof Symbol=="function"&&typeof Symbol()=="symbol";function H0(t,s,r=!1){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?r&&Symbol.for&&t?Symbol.for(t):t!=null?Symbol(t):Symbol():s}var Ows=H0("jas",void 0,!0),h7e=H0(void 0,"0di"),dI=H0(void 0,"1oa"),kf=H0(void 0,Symbol()),Rws=H0(void 0,"0ub"),Fws=H0(void 0,"0ubs"),W_e=H0(void 0,"0ubsb"),zws=H0(void 0,"0actk"),SA=H0("m_m","Pa",!0),m7e=H0();const mit={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},pit=Object.defineProperties,Ta=ME?Ows:"Ga";var MC;const p7e=[];function vR(t,s){ME||Ta in t||pit(t,mit),t[Ta]|=s}function Pu(t,s){ME||Ta in t||pit(t,mit),t[Ta]=s}function bR(t){return vR(t,34),t}function aO(t){return vR(t,8192),t}Pu(p7e,7),MC=Object.freeze(p7e);var CA={};function Tf(t,s){return s===void 0?t.h!==cC&&!!(2&(0|t.v[Ta])):!!(2&s)&&t.h!==cC}const cC={};function fSe(t,s){if(t!=null){if(typeof t=="string")t=t?new C0(t,NA):lC();else if(t.constructor!==C0)if(mSe(t))t=t.length?new C0(new Uint8Array(t),NA):lC();else{if(!s)throw Error();t=void 0}}return t}class f7e{constructor(s,r,n){this.g=s,this.h=r,this.l=n}next(){const s=this.g.next();return s.done||(s.value=this.h.call(this.l,s.value)),s}[Symbol.iterator](){return this}}var Bws=Object.freeze({});function fit(t,s,r){const n=128&s?0:-1,a=t.length;var o;(o=!!a)&&(o=(o=t[a-1])!=null&&typeof o=="object"&&o.constructor===Object);const l=a+(o?-1:0);for(s=128&s?1:0;stypeof t=="number"),x7e=Yhe(t=>typeof t=="string"),qws=Yhe(t=>typeof t=="boolean"),Xhe=typeof jA.BigInt=="function"&&typeof jA.BigInt(0)=="bigint";function Sf(t){var s=t;if(x7e(s)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(s))throw Error(String(s))}else if($ws(s)&&!Number.isSafeInteger(s))throw Error(String(s));return Xhe?BigInt(t):t=qws(t)?t?"1":"0":x7e(t)?t.trim()||"0":String(t)}var G_e=Yhe(t=>Xhe?t>=Vws&&t<=Wws:t[0]==="-"?g7e(t,Uws):g7e(t,Hws));const Uws=Number.MIN_SAFE_INTEGER.toString(),Vws=Xhe?BigInt(Number.MIN_SAFE_INTEGER):void 0,Hws=Number.MAX_SAFE_INTEGER.toString(),Wws=Xhe?BigInt(Number.MAX_SAFE_INTEGER):void 0;function g7e(t,s){if(t.length>s.length)return!1;if(t.lengtha)return!1;if(n>>0;Xc=s,Qd=(t-s)/4294967296>>>0}function MA(t){if(t<0){y7e(-t);const[s,r]=ySe(Xc,Qd);Xc=s>>>0,Qd=r>>>0}else y7e(t)}function xSe(t){const s=Kws||(Kws=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),Qd=0,Xc=s.getUint32(0,!0)}function git(t,s){const r=4294967296*s+(t>>>0);return Number.isSafeInteger(r)?r:iO(t,s)}function Zws(t,s){return Sf(CE()?BigInt.asUintN(64,(BigInt(s>>>0)<>>0)):iO(t,s))}function yit(t,s){return CE()?Sf(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(s))<>>=0,(s>>>=0)<=2097151)var r=""+(4294967296*s+t);else CE()?r=""+(BigInt(s)<>>24|s<<8))+6710656*(s=s>>16&65535),r+=8147497*s,s*=2,t>=1e7&&(r+=t/1e7>>>0,t%=1e7),r>=1e7&&(s+=r/1e7>>>0,r%=1e7),r=s+v7e(r)+v7e(t));return r}function v7e(t){return t=String(t),"0000000".slice(t.length)+t}function gSe(t,s){if(2147483648&s)if(CE())t=""+(BigInt(0|s)<>>0));else{const[r,n]=ySe(t,s);t="-"+iO(r,n)}else t=iO(t,s);return t}function Qhe(t){if(t.length<16)MA(Number(t));else if(CE())t=BigInt(t),Xc=Number(t&BigInt(4294967295))>>>0,Qd=Number(t>>BigInt(32)&BigInt(4294967295));else{const s=+(t[0]==="-");Qd=Xc=0;const r=t.length;for(let n=s,a=(r-s)%6+s;a<=r;n=a,a+=6){const o=Number(t.slice(n,a));Qd*=1e6,Xc=1e6*Xc+o,Xc>=4294967296&&(Qd+=Math.trunc(Xc/4294967296),Qd>>>=0,Xc>>>=0)}if(s){const[n,a]=ySe(Xc,Qd);Xc=n,Qd=a}}}function ySe(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function ny(t){return Array.prototype.slice.call(t)}const _R=typeof BigInt=="function"?BigInt.asIntN:void 0,Yws=typeof BigInt=="function"?BigInt.asUintN:void 0,dC=Number.isSafeInteger,Jhe=Number.isFinite,TA=Math.trunc,Xws=Sf(0);function PI(t){if(t!=null&&typeof t!="number")throw Error(`Value of float/double field must be a number, found ${typeof t}: ${t}`);return t}function d0(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function oO(t){if(t!=null&&typeof t!="boolean"){var s=typeof t;throw Error(`Expected boolean but got ${s!="object"?s:t?Array.isArray(t)?"array":s:"null"}: ${t}`)}return t}function vit(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const Qws=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function wR(t){switch(typeof t){case"bigint":return!0;case"number":return Jhe(t);case"string":return Qws.test(t);default:return!1}}function AE(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Jhe(t)?0|t:void 0}function bit(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Jhe(t)?t>>>0:void 0}function _it(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(Qhe(t),gSe(Xc,Qd))}function vSe(t){if(t=TA(t),!dC(t)){MA(t);var s=Xc,r=Qd;(t=2147483648&r)&&(r=~r>>>0,(s=1+~s>>>0)==0&&(r=r+1>>>0)),t=typeof(s=git(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function wit(t){var s=TA(Number(t));return dC(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),_it(t))}function jit(t){var s=TA(Number(t));return dC(s)?Sf(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),CE()?Sf(_R(64,BigInt(t))):Sf(_it(t)))}function Nit(t){return dC(t)?t=Sf(vSe(t)):(t=TA(t),dC(t)?t=String(t):(MA(t),t=gSe(Xc,Qd)),t=Sf(t)),t}function Kce(t){const s=typeof t;return t==null?t:s==="bigint"?Sf(_R(64,t)):wR(t)?s==="string"?jit(t):Nit(t):void 0}function kit(t){if(typeof t!="string")throw Error();return t}function jR(t){if(t!=null&&typeof t!="string")throw Error();return t}function Eh(t){return t==null||typeof t=="string"?t:void 0}function bSe(t,s,r,n){return t!=null&&t[SA]===CA?t:Array.isArray(t)?((n=(r=0|t[Ta])|32&n|2&n)!==r&&Pu(t,n),new s(t)):(r?2&n?((t=s[h7e])||(bR((t=new s).v),t=s[h7e]=t),s=t):s=new s:s=void 0,s)}function Jws(t,s,r){if(s)e:{if(!wR(s=t))throw H_e("int64");switch(typeof s){case"string":s=jit(s);break e;case"bigint":s=Sf(_R(64,s));break e;default:s=Nit(s)}}else s=Kce(t);return(t=s)==null?r?Xws:void 0:t}const e2s={};let t2s=function(){try{return Zhe(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class vye{constructor(){this.g=new Map}get(s){return this.g.get(s)}set(s,r){return this.g.set(s,r),this.size=this.g.size,this}delete(s){return s=this.g.delete(s),this.size=this.g.size,s}clear(){this.g.clear(),this.size=this.g.size}has(s){return this.g.has(s)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(s,r){return this.g.forEach(s,r)}[Symbol.iterator](){return this.entries()}}const s2s=t2s?(Object.setPrototypeOf(vye.prototype,Map.prototype),Object.defineProperties(vye.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),vye):class extends Map{constructor(){super()}};function b7e(t){return t}function bye(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var D1=class extends s2s{constructor(t,s,r=b7e,n=b7e){super(),this.J=0|t[Ta],this.K=s,this.S=r,this.fa=this.K?r2s:n;for(let a=0;a{t.call(s,a.get(n),n,a)}):super.forEach(t,s)}set(t,s){return bye(this),(t=this.S(t,!0,!1))==null?this:s==null?(super.delete(t),this):super.set(t,this.fa(s,!0,!0,this.K,!1,this.J))}Ma(t){const s=this.S(t[0],!1,!0);t=t[1],t=this.K?t===void 0?null:t:this.fa(t,!1,!0,void 0,!1,this.J),super.set(s,t)}has(t){return super.has(this.S(t,!1,!1))}get(t){t=this.S(t,!1,!1);const s=super.get(t);if(s!==void 0){var r=this.K;return r?((r=this.fa(s,!1,!0,r,this.ra,this.J))!==s&&super.set(t,r),r):s}}[Symbol.iterator](){return this.entries()}};function r2s(t,s,r,n,a,o){return t=bSe(t,n,r,o),a&&(t=wSe(t)),t}function n2s(t){return[t,this.get(t)]}let a2s;function _7e(){return a2s||(a2s=new D1(bR([]),void 0,void 0,void 0,e2s))}function eme(t){return kf?t[kf]:void 0}function Zce(t,s){for(const r in t)!isNaN(r)&&s(t,+r,t[r])}D1.prototype.toJSON=void 0;var K_e=class{};const i2s={Ka:!0};function o2s(t,s){s<100||kA(Fws,1)}function tme(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=kf;!a&&ME&&l&&(o=t[l])&&Zce(o,o2s),l=[];var i=t.length;let c;o=4294967295;let u=!1;const p=!!(64&s),f=p?128&s?0:-1:void 0;1&s||(c=i&&t[i-1],c!=null&&typeof c=="object"&&c.constructor===Object?o=--i:c=void 0,!p||128&s||a||(u=!0,o=o-f+f)),s=void 0;for(var g=0;g=o){const _=g-f;(s??(s={}))[_]=b}else l[g]=b}if(c)for(let b in c){if((i=c[b])==null||(i=r(i,n))==null)continue;let _;g=+b,p&&!Number.isNaN(g)&&(_=g+f){_[w]=ny(N)}),_.da=b.da,_}(t)),l}function l2s(t){return t[0]=lO(t[0]),t[1]=lO(t[1]),t}function lO(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return G_e(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var s=0|t[Ta];return t.length===0&&1&s?void 0:tme(t,s,lO)}if(t!=null&&t[SA]===CA)return Sit(t);if(t instanceof C0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(cit){for(var r="",n=0,a=s.length-10240;n>2];o=r[(3&o)<<4|l>>4],l=r[(15&l)<<2|i>>6],i=r[63&i],n[p++]=c+o+l+i}switch(c=0,i=a,s.length-u){case 2:i=r[(15&(c=s[u+1]))<<2]||a;case 1:s=s[u],n[p]=r[s>>2]+r[(3&s)<<4|c>>4]+i+a}s=n.join("")}t=t.g=s}return t}return t instanceof D1?t=t.size!==0?t.V(l2s):void 0:void 0}return t}let c2s,d2s;function Sit(t){return tme(t=t.v,0|t[Ta],lO)}function CS(t,s){return Cit(t,s[0],s[1])}function Cit(t,s,r,n=0){if(t==null){var a=32;r?(t=[r],a|=128):t=[],s&&(a=-16760833&a|(1023&s)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(a=0|t[Ta],l7e&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(l7e)throw Error("carr");kA(zws,5)}(),256&a)throw Error("farr");if(64&a)return(a|n)!==a&&Pu(t,a|n),t;if(r&&(a|=128,r!==t[0]))throw Error("mid");e:{a|=64;var o=(r=t).length;if(o){var l=o-1;const c=r[l];if(c!=null&&typeof c=="object"&&c.constructor===Object){if((l-=s=128&a?0:-1)>=1024)throw Error("pvtlmt");for(var i in c)(o=+i)1024)throw Error("spvt");a=-16760833&a|(1023&i)<<14}}}return Pu(t,64|a|n),t}function u2s(t,s){if(typeof t!="object")return t;if(Array.isArray(t)){var r=0|t[Ta];return t.length===0&&1&r?void 0:w7e(t,r,s)}if(t!=null&&t[SA]===CA)return j7e(t);if(t instanceof D1){if(2&(s=t.J))return t;if(!t.size)return;if(r=bR(t.V()),t.K)for(t=0;t=o)if(l=t[o],l!=null&&typeof l=="object"&&l.constructor===Object)r=l[s],i=!0;else{if(a!==o)return;r=l}else r=t[a];if(n&&r!=null){if((n=n(r))==null)return n;if(!Object.is(n,r))return i?l[s]=n:t[a]=n,n}return r}}function Sl(t,s,r,n){IE(t),Au(t=t.v,0|t[Ta],s,r,n)}function Au(t,s,r,n,a){const o=r+(a?0:-1);var l=t.length-1;if(l>=1+(a?0:-1)&&o>=l){const i=t[l];if(i!=null&&typeof i=="object"&&i.constructor===Object)return i[r]=n,s}return o<=l?(t[o]=n,s):(n!==void 0&&(r>=(l=(s??(s=0|t[Ta]))>>14&1023||536870912)?n!=null&&(t[l+(a?0:-1)]={[r]:n}):t[o]=n),s)}function E4(){return Bws===void 0?2:4}function P4(t,s,r,n,a){let o=t.v,l=0|o[Ta];n=Tf(t,l)?1:n,a=!!a||n===3,n===2&&PE(t)&&(o=t.v,l=0|o[Ta]);let i=(t=NSe(o,s))===MC?7:0|t[Ta],c=kSe(i,l);var u=!(4&c);if(u){4&c&&(t=ny(t),i=0,c=TS(c,l),l=Au(o,l,s,t));let p=0,f=0;for(;p{const i=bSe(l,r,!1,s);return o=i!==l&&i!=null,i}))!=null)return o&&!Tf(n)&&TC(t,s),n}function Yo(t,s,r,n){let a=t.v,o=0|a[Ta];if((s=Iit(a,o,s,r,n))==null)return s;if(o=0|a[Ta],!Tf(t,o)){const l=wSe(s);l!==s&&(PE(t)&&(a=t.v,o=0|a[Ta]),o=Au(a,o,r,s=l,n),TC(a,o))}return s}function Lit(t,s,r,n,a,o,l,i){var c=Tf(t,r);o=c?1:o,l=!!l||o===3,c=i&&!c,(o===2||c)&&PE(t)&&(r=0|(s=t.v)[Ta]);var u=(t=NSe(s,a))===MC?7:0|t[Ta],p=kSe(u,r);if(i=!(4&p)){var f=t,g=r;const b=!!(2&p);b&&(g|=2);let _=!b,j=!0,w=0,N=0;for(;w32)for(a|=(127&r)>>4,o=3;o<32&&128&r;o+=7)r=l[i++],a|=(127&r)<>>0,a>>>0);throw Error()}function PSe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function Xce(t){var s=t.h;const r=t.g;var n=s[r],a=s[r+1];const o=s[r+2];return s=s[r+3],AS(t,t.g+4),t=2*((a=(n<<0|a<<8|o<<16|s<<24)>>>0)>>31)+1,n=a>>>23&255,a&=8388607,n==255?a?NaN:t*(1/0):n==0?1401298464324817e-60*t*a:t*Math.pow(2,n-150)*(a+8388608)}function h2s(t){return vw(t)}function AS(t,s){if(t.g=s,s>t.l)throw Error()}function Oit(t,s){if(s<0)throw Error();const r=t.g;if((s=r+s)>t.l)throw Error();return t.g=s,r}function Rit(t,s){if(s==0)return lC();var r=Oit(t,s);return t.Y&&t.j?r=t.h.subarray(r,r+s):(t=t.h,r=r===(s=r+s)?new Uint8Array(0):Gws?t.slice(r,s):new Uint8Array(t.subarray(r,s))),r.length==0?lC():new C0(r,NA)}var N7e=[];function Fit(t,s,r,n){if(Qce.length){const a=Qce.pop();return a.o(n),a.g.init(t,s,r,n),a}return new m2s(t,s,r,n)}function zit(t){t.g.clear(),t.l=-1,t.h=-1,Qce.length<100&&Qce.push(t)}function Bit(t){var s=t.g;if(s.g==s.l)return!1;t.m=t.g.g;var r=O0(t.g);if(s=r>>>3,!((r&=7)>=0&&r<=5)||s<1)throw Error();return t.l=s,t.h=r,!0}function Lie(t){switch(t.h){case 0:t.h!=0?Lie(t):PSe(t.g);break;case 1:AS(t=t.g,t.g+8);break;case 2:if(t.h!=2)Lie(t);else{var s=O0(t.g);AS(t=t.g,t.g+s)}break;case 5:AS(t=t.g,t.g+4);break;case 3:for(s=t.l;;){if(!Bit(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}Lie(t)}break;default:throw Error()}}function NR(t,s,r){const n=t.g.l;var a=O0(t.g);let o=(a=t.g.g+a)-n;if(o<=0&&(t.g.l=a,r(s,t,void 0,void 0,void 0),o=a-t.g.g),o)throw Error();return t.g.g=a,t.g.l=n,s}function ISe(t){var s=O0(t.g),r=Oit(t=t.g,s);if(t=t.h,Sws){var n,a=t;(n=yye)||(n=yye=new TextDecoder("utf-8",{fatal:!0})),s=r+s,a=r===0&&s===a.length?a:a.subarray(r,s);try{var o=n.decode(a)}catch(i){if(Yz===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),Yz=!0}catch{Yz=!1}}throw!Yz&&(yye=void 0),i}}else{s=(o=r)+s,r=[];let i,c=null;for(;o=s?V2():(i=t[o++],l<194||(192&i)!=128?(o--,V2()):r.push((31&l)<<6|63&i)):l<240?o>=s-1?V2():(i=t[o++],(192&i)!=128||l===224&&i<160||l===237&&i>=160||(192&(n=t[o++]))!=128?(o--,V2()):r.push((15&l)<<12|(63&i)<<6|63&n)):l<=244?o>=s-2?V2():(i=t[o++],(192&i)!=128||i-144+(l<<28)>>30||(192&(n=t[o++]))!=128||(192&(a=t[o++]))!=128?(o--,V2()):(l=(7&l)<<18|(63&i)<<12|(63&n)<<6|63&a,l-=65536,r.push(55296+(l>>10&1023),56320+(1023&l)))):V2(),r.length>=8192&&(c=o7e(c,r),r.length=0)}o=o7e(c,r)}return o}function $it(t){const s=O0(t.g);return Rit(t.g,s)}function rme(t,s,r){var n=O0(t.g);for(n=t.g.g+n;t.g.g>>0,this.g=s>>>0}};let p2s;function S7e(t){return t?/^-?\d+$/.test(t)?(Qhe(t),new Y_e(Xc,Qd)):null:f2s||(f2s=new Y_e(0,0))}var Y_e=class{constructor(t,s){this.h=t>>>0,this.g=s>>>0}};let f2s;function cT(t,s,r){for(;r>0||s>127;)t.g.push(127&s|128),s=(s>>>7|r<<25)>>>0,r>>>=7;t.g.push(s)}function DE(t,s){for(;s>127;)t.g.push(127&s|128),s>>>=7;t.g.push(s)}function nme(t,s){if(s>=0)DE(t,s);else{for(let r=0;r<9;r++)t.g.push(127&s|128),s>>=7;t.g.push(1)}}function LSe(t){var s=Xc;t.g.push(s>>>0&255),t.g.push(s>>>8&255),t.g.push(s>>>16&255),t.g.push(s>>>24&255)}function AA(t,s){s.length!==0&&(t.l.push(s),t.h+=s.length)}function Kx(t,s,r){DE(t.g,8*s+r)}function DSe(t,s){return Kx(t,s,2),s=t.g.end(),AA(t,s),s.push(t.h),s}function OSe(t,s){var r=s.pop();for(r=t.h+t.g.length()-r;r>127;)s.push(127&r|128),r>>>=7,t.h++;s.push(r),t.h++}function ame(t,s,r){Kx(t,s,2),DE(t.g,r.length),AA(t,t.g.end()),AA(t,r)}function Jce(t,s,r,n){r!=null&&(s=DSe(t,s),n(r,t),OSe(t,s))}function W0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var RSe=W0(),qit=W0(),FSe=W0(),zSe=W0(),BSe=W0(),Uit=W0(),x2s=W0(),ime=W0(),Vit=W0(),Hit=W0();function G0(t,s,r){var n=t.v;kf&&kf in n&&(n=n[kf])&&delete n[s.g],s.h?s.j(t,s.h,s.g,r,s.l):s.j(t,s.g,r,s.l)}var Aa=class{constructor(t,s){this.v=Cit(t,s,void 0,2048)}toJSON(){return Sit(this)}j(){var a;var t=X2s,s=this.v,r=t.g,n=kf;if(ME&&n&&((a=s[n])==null?void 0:a[r])!=null&&kA(Rws,3),s=t.g,m7e&&kf&&m7e===void 0&&(n=(r=this.v)[kf])&&(n=n.da))try{n(r,s,i2s)}catch(o){iit(o)}return t.h?t.m(this,t.h,t.g,t.l):t.m(this,t.g,t.defaultValue,t.l)}clone(){const t=this.v,s=0|t[Ta];return jSe(this,t,s)?_Se(this,t,!0):new this.constructor(EE(t,s,!1))}};Aa.prototype[SA]=CA,Aa.prototype.toString=function(){return this.v.toString()};var OE=class{constructor(t,s,r){this.g=t,this.h=s,t=RSe,this.l=!!t&&r===t||!1}};function ome(t,s){return new OE(t,s,RSe)}function Wit(t,s,r,n,a){Jce(t,r,Yit(s,n),a)}const g2s=ome(function(t,s,r,n,a){return t.h===2&&(NR(t,MSe(s,n,r),a),!0)},Wit),y2s=ome(function(t,s,r,n,a){return t.h===2&&(NR(t,MSe(s,n,r),a),!0)},Wit);var lme=Symbol(),cme=Symbol(),X_e=Symbol(),C7e=Symbol(),M7e=Symbol();let Git,Kit;function AC(t,s,r,n){var a=n[t];if(a)return a;(a={}).qa=n,a.T=function(f){switch(typeof f){case"boolean":return c2s||(c2s=[0,void 0,!0]);case"number":return f>0?void 0:f===0?d2s||(d2s=[0,void 0]):[-f,void 0];case"string":return[0,f];case"object":return f}}(n[0]);var o=n[1];let l=1;o&&o.constructor===Object&&(a.ba=o,typeof(o=n[++l])=="function"&&(a.ma=!0,Git??(Git=o),Kit??(Kit=n[l+1]),o=n[l+=2]));const i={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var c=0;ca(o,l,i,n):a}function qSe(t,s,r,n,a){const o=r.g;let l,i;t[s]=(c,u,p)=>o(c,u,p,i||(i=AC(cme,$Se,qSe,n).T),l||(l=USe(n)),a)}function USe(t){let s=t[X_e];if(s!=null)return s;const r=AC(cme,$Se,qSe,t);return s=r.ma?(n,a)=>Git(n,a,r):(n,a)=>{for(;Bit(a)&&a.h!=4;){var o=a.l,l=r[o];if(l==null){var i=r.ba;i&&(i=i[o])&&(i=b2s(i))!=null&&(l=r[o]=i)}if(l==null||!l(a,n,o)){if(l=(i=a).m,Lie(i),i.ha)var c=void 0;else c=i.g.g-l,i.g.g=l,c=Rit(i.g,c);l=void 0,i=n,c&&((l=i[kf]??(i[kf]=new K_e))[o]??(l[o]=[])).push(c)}}return(n=eme(n))&&(n.da=r.qa[M7e]),!0},t[X_e]=s,t[M7e]=v2s.bind(t),s}function v2s(t,s,r,n){var a=this[cme];const o=this[X_e],l=CS(void 0,a.T),i=eme(t);if(i){var c=!1,u=a.ba;if(u){if(a=(p,f,g)=>{if(g.length!==0)if(u[f])for(const b of g){p=Fit(b);try{c=!0,o(l,p)}finally{zit(p)}}else n==null||n(t,f,g)},s==null)Zce(i,a);else if(i!=null){const p=i[s];p&&a(i,s,p)}if(c){let p=0|t[Ta];if(2&p&&2048&p&&!(r!=null&&r.Ka))throw Error();const f=TE(p),g=(b,_)=>{if(O1(t,b,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}_!=null&&(p=Au(t,p,b,_,f)),delete i[b]};s==null?fit(l,0|l[Ta],(b,_)=>{g(b,_)}):g(s,O1(l,s,f))}}}}function b2s(t){const s=(t=Zit(t))[0].g;if(t=t[1]){const r=USe(t),n=AC(cme,$Se,qSe,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function dme(t,s,r){t[s]=r.h}function ume(t,s,r,n){let a,o;const l=r.h;t[s]=(i,c,u)=>l(i,c,u,o||(o=AC(lme,dme,ume,n).T),a||(a=Xit(n)))}function Xit(t){let s=t[C7e];if(!s){const r=AC(lme,dme,ume,t);s=(n,a)=>Qit(n,a,r),t[C7e]=s}return s}function Qit(t,s,r){fit(t,0|t[Ta],(n,a)=>{if(a!=null){var o=function(l,i){var c=l[i];if(c)return c;if((c=l.ba)&&(c=c[i])){var u=(c=Zit(c))[0].h;if(c=c[1]){const p=Xit(c),f=AC(lme,dme,ume,c).T;c=l.ma?Kit(f,p):(g,b,_)=>u(g,b,_,f,p)}else c=u;return l[i]=c}}(r,n);o?o(s,a,n):n<500||kA(W_e,3)}}),(t=eme(t))&&Zce(t,(n,a,o)=>{for(AA(s,s.g.end()),n=0;n{Jce(t,r,CS([l,o],n),a)});else if(Array.isArray(s)){for(let o=0;o>BigInt(32))),cT(t.g,r.h,r.g);break;default:r=S7e(s),cT(t.g,r.h,r.g)}}function tot(t,s,r){(s=AE(s))!=null&&s!=null&&(Kx(t,r,0),nme(t.g,s))}function sot(t,s,r){(s=vit(s))!=null&&(Kx(t,r,0),t.g.g.push(s?1:0))}function rot(t,s,r){(s=Eh(s))!=null&&ame(t,r,ait(s))}function not(t,s,r,n,a){Jce(t,r,Yit(s,n),a)}function aot(t,s,r){(s=s==null||typeof s=="string"||s instanceof C0?s:void 0)!=null&&ame(t,r,ASe(s,!0).buffer)}function iot(t,s,r){(s=bit(s))!=null&&s!=null&&(Kx(t,r,0),DE(t.g,s))}function oot(t,s,r){return(t.h===5||t.h===2)&&(s=LE(s,0|s[Ta],r),t.h==2?rme(t,Xce,s):s.push(Xce(t.g)),!0)}var tu=rm(function(t,s,r){return t.h===5&&(nm(s,r,Xce(t.g)),!0)},Jit,ime),j2s=FE(oot,function(t,s,r){if((s=RE(d0,s))!=null)for(let l=0;l=0?n=String(a):((a=n.indexOf("."))!==-1&&(n=n.substring(0,a)),(a=n[0]!=="-"&&((a=n.length)<20||a===20&&n<="18446744073709551615"))||(Qhe(n),n=iO(Xc,Qd))),n;if(a==="number")return(n=TA(n))>=0&&dC(n)||(MA(n),n=git(Xc,Qd)),n}}(s),s!=null&&(typeof s=="string"&&k7e(s),s!=null))switch(Kx(t,r,0),typeof s){case"number":t=t.g,MA(s),cT(t,Xc,Qd);break;case"bigint":r=BigInt.asUintN(64,s),r=new Z_e(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),cT(t.g,r.h,r.g);break;default:r=k7e(s),cT(t.g,r.h,r.g)}},x2s),Nu=rm(function(t,s,r){return t.h===0&&(nm(s,r,vw(t.g)),!0)},tot,zSe),kR=FE(function(t,s,r){return(t.h===0||t.h===2)&&(s=LE(s,0|s[Ta],r),t.h==2?rme(t,vw,s):s.push(vw(t.g)),!0)},function(t,s,r){if((s=RE(AE,s))!=null&&s.length){r=DSe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=Fit(r,void 0,void 0,o);try{const l=new t,i=l.v;USe(s)(i,r);var a=l}finally{zit(r)}}return a}}function hme(t){return function(){const s=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const l=this.g;return this.g=[],l}}}};Qit(this.v,s,AC(lme,dme,ume,t)),AA(s,s.g.end());const r=new Uint8Array(s.h),n=s.l,a=n.length;let o=0;for(let l=0;la;r=E7e.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=jye)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function Xz(t,...s){if(s.length===0)return P7e(t[0]);let r=t[0];for(let n=0;n({index:jx(n,1)??0??-1,score:Pd(n,2)??0,categoryName:Eh(ed(n,3))??""??"",displayName:Eh(ed(n,4))??""??""})),headIndex:s,headName:r}}function tjs(t){const s={classifications:R1(t,O2s,1).map(r=>{var n;return QSe(((n=Yo(r,xot,4))==null?void 0:n.g())??[],jx(r,2)??0,Eh(ed(r,3))??"")})};return function(r){return r==null?r:typeof r=="bigint"?(G_e(r)?r=Number(r):(r=_R(64,r),r=G_e(r)?Number(r):String(r)),r):wR(r)?typeof r=="number"?vSe(r):wit(r):void 0}(ed(t,2,void 0,void 0,Kce))!=null&&(s.timestampMs=Uot(ed(t,2,void 0,void 0,Kce)??Mit)),s}function Vot(t){var l,i;var s=P4(t,3,d0,E4()),r=P4(t,2,AE,E4()),n=P4(t,1,Eh,E4()),a=P4(t,9,Eh,E4());const o={categories:[],keypoints:[]};for(let c=0;cs>127?s-256:s)}function V7e(t,s){if(t.length!==s.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${s.length}).`);let r=0,n=0,a=0;for(let o=0;o=1&&Number(t[1])>=17))}async function H7e(t){if(typeof importScripts!="function"){const s=document.createElement("script");return s.src=t.toString(),s.crossOrigin="anonymous",new Promise((r,n)=>{s.addEventListener("load",()=>{r()},!1),s.addEventListener("error",a=>{n(a)},!1),document.body.appendChild(s)})}try{importScripts(t.toString())}catch(s){if(!(s instanceof TypeError))throw s;await self.import(t.toString())}}function Got(t){return t.videoWidth!==void 0?[t.videoWidth,t.videoHeight]:t.naturalWidth!==void 0?[t.naturalWidth,t.naturalHeight]:t.displayWidth!==void 0?[t.displayWidth,t.displayHeight]:[t.width,t.height]}function Oa(t,s,r){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(s=t.i.stringToNewUTF8(s)),t.i._free(s)}function W7e(t,s,r){if(!t.i.canvas)throw Error("No OpenGL canvas configured.");if(r?t.i._bindTextureToStream(r):t.i._bindTextureToCanvas(),!(r=t.i.canvas.getContext("webgl2")||t.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");t.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,s),t.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const[n,a]=Got(s);return!t.l||n===t.i.canvas.width&&a===t.i.canvas.height||(t.i.canvas.width=n,t.i.canvas.height=a),[n,a]}function G7e(t,s,r){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const n=new Uint32Array(s.length);for(let a=0;a>2),r(s);for(const a of n)t.i._free(a);t.i._free(s)}function qy(t,s,r){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=r}function Fb(t,s,r){let n=[];t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=(a,o,l)=>{o?(r(n,l),n=[]):n.push(a)}}W5.forVisionTasks=function(t,s=!1){return Jz("vision",t??Xz``,s)},W5.forTextTasks=function(t,s=!1){return Jz("text",t??Xz``,s)},W5.forGenAiTasks=function(t,s=!1){return Jz("genai",t??Xz``,s)},W5.forAudioTasks=function(t,s=!1){return Jz("audio",t??Xz``,s)},W5.isSimdSupported=function(t=!1){return Hot(t)};async function rjs(t,s,r,n){return t=await(async(a,o,l,i,c)=>{if(o&&await H7e(o),!self.ModuleFactory||l&&(await H7e(l),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&c&&((o=self.Module).locateFile=c.locateFile,c.mainScriptUrlOrBlob&&(o.mainScriptUrlOrBlob=c.mainScriptUrlOrBlob)),c=await self.ModuleFactory(self.Module||c),self.ModuleFactory=self.Module=void 0,new a(c,i)})(t,r.wasmLoaderPath,r.assetLoaderPath,s,{locateFile:a=>a.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&a.endsWith(".data")?r.assetBinaryPath.toString():a}),await t.o(n),t}function Sye(t,s){const r=Yo(t.baseOptions,ede,1)||new ede;typeof s=="string"?(Sl(r,2,jR(s)),Sl(r,1)):s instanceof Uint8Array&&(Sl(r,1,fSe(s,!1)),Sl(r,2)),oi(t.baseOptions,0,1,r)}function K7e(t){try{const s=t.H.length;if(s===1)throw Error(t.H[0].message);if(s>1)throw Error("Encountered multiple errors: "+t.H.map(r=>r.message).join(", "))}finally{t.H=[]}}function la(t,s){t.C=Math.max(t.C,s)}function xme(t,s){t.B=new Lp,Af(t.B,2,"PassThroughCalculator"),Vc(t.B,"free_memory"),Do(t.B,"free_memory_unused_out"),rd(s,"free_memory"),Zx(s,t.B)}function EA(t,s){Vc(t.B,s),Do(t.B,s+"_unused_out")}function gme(t){t.g.addBoolToStream(!0,"free_memory",t.C)}var swe=class{constructor(t){this.g=t,this.H=[],this.C=0,this.g.setAutoRenderToScreen(!1)}l(t,s=!0){var r,n,a,o,l,i;if(s){const c=t.baseOptions||{};if((r=t.baseOptions)!=null&&r.modelAssetBuffer&&((n=t.baseOptions)!=null&&n.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((a=Yo(this.baseOptions,ede,1))!=null&&a.g()||(o=Yo(this.baseOptions,ede,1))!=null&&o.l()||(l=t.baseOptions)!=null&&l.modelAssetBuffer||(i=t.baseOptions)!=null&&i.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(u,p){let f=Yo(u.baseOptions,z7e,3);if(!f){var g=f=new z7e,b=new I7e;w8(g,4,Die,b)}"delegate"in p&&(p.delegate==="GPU"?(p=f,g=new T2s,w8(p,2,Die,g)):(p=f,g=new I7e,w8(p,4,Die,g))),oi(u.baseOptions,0,3,f)}(this,c),c.modelAssetPath)return fetch(c.modelAssetPath.toString()).then(u=>{if(u.ok)return u.arrayBuffer();throw Error(`Failed to fetch model: ${c.modelAssetPath} (${u.status})`)}).then(u=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(u),!0,!1,!1),Sye(this,"/model.dat"),this.m(),this.L()});if(c.modelAssetBuffer instanceof Uint8Array)Sye(this,c.modelAssetBuffer);else if(c.modelAssetBuffer)return async function(u){const p=[];for(var f=0;;){const{done:g,value:b}=await u.read();if(g)break;p.push(b),f+=b.length}if(p.length===0)return new Uint8Array(0);if(p.length===1)return p[0];u=new Uint8Array(f),f=0;for(const g of p)u.set(g,f),f+=g.length;return u}(c.modelAssetBuffer).then(u=>{Sye(this,u),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let t;if(this.g.ca(s=>{t=A2s(s)}),!t)throw Error("Failed to retrieve CalculatorGraphConfig");return t}setGraph(t,s){this.g.attachErrorListener((r,n)=>{this.H.push(Error(n))}),this.g.Ja(),this.g.setGraph(t,s),this.B=void 0,K7e(this)}finishProcessing(){this.g.finishProcessing(),K7e(this)}close(){this.B=void 0,this.g.closeGraph()}};function nw(t,s){if(!t)throw Error(`Unable to obtain required WebGL resource: ${s}`);return t}swe.prototype.close=swe.prototype.close;class njs{constructor(s,r,n,a){this.g=s,this.h=r,this.m=n,this.l=a}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function Z7e(t,s,r){const n=t.g;if(r=nw(n.createShader(r),"Failed to create WebGL shader"),n.shaderSource(r,s),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${n.getShaderInfoLog(r)}`);return n.attachShader(t.h,r),r}function Y7e(t,s){const r=t.g,n=nw(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);const a=nw(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,a),r.enableVertexAttribArray(t.O),r.vertexAttribPointer(t.O,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);const o=nw(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,o),r.enableVertexAttribArray(t.L),r.vertexAttribPointer(t.L,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array(s?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.bindVertexArray(null),new njs(r,n,a,o)}function JSe(t,s){if(t.g){if(s!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=s}function ajs(t,s,r,n){return JSe(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=Y7e(t,!0)),r=t.u):(t.A||(t.A=Y7e(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function Kot(t,s,r){return JSe(t,s),t=nw(s.createTexture(),"Failed to create texture"),s.bindTexture(s.TEXTURE_2D,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,r??s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,r??s.LINEAR),s.bindTexture(s.TEXTURE_2D,null),t}function Zot(t,s,r){JSe(t,s),t.B||(t.B=nw(s.createFramebuffer(),"Failed to create framebuffe.")),s.bindFramebuffer(s.FRAMEBUFFER,t.B),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,r,0)}function ijs(t){var s;(s=t.g)==null||s.bindFramebuffer(t.g.FRAMEBUFFER,null)}var Yot=class{H(){return` precision mediump float; varying vec2 vTex; uniform sampler2D inputTexture; void main() { gl_FragColor = texture2D(inputTexture, vTex); } `}m(){const t=this.g;if(this.h=nw(t.createProgram(),"Failed to create WebGL program"),this.X=Z7e(this,` attribute vec2 aVertex; attribute vec2 aTex; varying vec2 vTex; void main(void) { gl_Position = vec4(aVertex, 0.0, 1.0); vTex = aTex; }`,t.VERTEX_SHADER),this.W=Z7e(this,this.H(),t.FRAGMENT_SHADER),t.linkProgram(this.h),!t.getProgramParameter(this.h,t.LINK_STATUS))throw Error(`Error during program linking: ${t.getProgramInfoLog(this.h)}`);this.O=t.getAttribLocation(this.h,"aVertex"),this.L=t.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){const t=this.g;t.deleteProgram(this.h),t.deleteShader(this.X),t.deleteShader(this.W)}this.B&&this.g.deleteFramebuffer(this.B),this.A&&this.A.close(),this.u&&this.u.close()}};function Wv(t,s){switch(s){case 0:return t.g.find(r=>r instanceof Uint8Array);case 1:return t.g.find(r=>r instanceof Float32Array);case 2:return t.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${s}`)}}function rwe(t){var s=Wv(t,1);if(!s){if(s=Wv(t,0))s=new Float32Array(s).map(n=>n/255);else{s=new Float32Array(t.width*t.height);const n=PA(t);var r=eCe(t);if(Zot(r,n,Xot(t)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(t.width*t.height*4),n.readPixels(0,0,t.width,t.height,n.RGBA,n.FLOAT,r);for(let a=0,o=0;aMath.round(255*r))),t.g.push(s)),s;var t,s}ia(){return rwe(this)}N(){return Xot(this)}clone(){const t=[];for(const s of this.g){let r;if(s instanceof Uint8Array)r=new Uint8Array(s);else if(s instanceof Float32Array)r=new Float32Array(s);else{if(!(s instanceof WebGLTexture))throw Error(`Type is not supported: ${s}`);{const n=PA(this),a=eCe(this);n.activeTexture(n.TEXTURE1),r=Kot(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=Qot(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),Zot(a,n,r),ajs(a,n,!1,()=>{Jot(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),nwe(this)}),ijs(a),nwe(this)}}t.push(r)}return new Uu(t,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&PA(this).deleteTexture(Wv(this,2)),X7e=-1}};Uu.prototype.close=Uu.prototype.close,Uu.prototype.clone=Uu.prototype.clone,Uu.prototype.getAsWebGLTexture=Uu.prototype.N,Uu.prototype.getAsFloat32Array=Uu.prototype.ia,Uu.prototype.getAsUint8Array=Uu.prototype.ja,Uu.prototype.hasWebGLTexture=Uu.prototype.R,Uu.prototype.hasFloat32Array=Uu.prototype.ka,Uu.prototype.hasUint8Array=Uu.prototype.Fa;var X7e=250;function xy(...t){return t.map(([s,r])=>({start:s,end:r}))}const ojs=function(t){return class extends t{Ja(){this.i._registerModelResourcesGraphService()}}}((Q7e=class{constructor(t,s){this.l=!0,this.i=t,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",s!==void 0?this.i.canvas=s:Wot()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(t){const s=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(s),t)}setGraphFromString(t){this.setGraph(new TextEncoder().encode(t),!1)}setGraph(t,s){const r=t.length,n=this.i._malloc(r);this.i.HEAPU8.set(t,n),s?this.i._changeBinaryGraph(r,n):this.i._changeTextGraph(r,n),this.i._free(n)}configureAudio(t,s,r,n,a){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Oa(this,n||"input_audio",o=>{Oa(this,a=a||"audio_header",l=>{this.i._configureAudio(o,l,t,s??0,r)})})}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.i._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.i.gpuOriginForWebTexturesIsBottomLeft=t}ca(t){qy(this,"__graph_config__",s=>{t(s)}),Oa(this,"__graph_config__",s=>{this.i._getGraphConfig(s,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(t){this.i.errorListener=t}attachEmptyPacketListener(t,s){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[t]=s}addAudioToStream(t,s,r){this.addAudioToStreamWithShape(t,0,0,s,r)}addAudioToStreamWithShape(t,s,r,n,a){const o=4*t.length;this.h!==o&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(o),this.h=o),this.i.HEAPF32.set(t,this.g/4),Oa(this,n,l=>{this.i._addAudioToInputStream(this.g,s,r,l,a)})}addGpuBufferToStream(t,s,r){Oa(this,s,n=>{const[a,o]=W7e(this,t,n);this.i._addBoundTextureToStream(n,a,o,r)})}addBoolToStream(t,s,r){Oa(this,s,n=>{this.i._addBoolToInputStream(t,n,r)})}addDoubleToStream(t,s,r){Oa(this,s,n=>{this.i._addDoubleToInputStream(t,n,r)})}addFloatToStream(t,s,r){Oa(this,s,n=>{this.i._addFloatToInputStream(t,n,r)})}addIntToStream(t,s,r){Oa(this,s,n=>{this.i._addIntToInputStream(t,n,r)})}addUintToStream(t,s,r){Oa(this,s,n=>{this.i._addUintToInputStream(t,n,r)})}addStringToStream(t,s,r){Oa(this,s,n=>{Oa(this,t,a=>{this.i._addStringToInputStream(a,n,r)})})}addStringRecordToStream(t,s,r){Oa(this,s,n=>{G7e(this,Object.keys(t),a=>{G7e(this,Object.values(t),o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(t).length,n,r)})})})}addProtoToStream(t,s,r,n){Oa(this,r,a=>{Oa(this,s,o=>{const l=this.i._malloc(t.length);this.i.HEAPU8.set(t,l),this.i._addProtoToInputStream(l,t.length,o,a,n),this.i._free(l)})})}addEmptyPacketToStream(t,s){Oa(this,t,r=>{this.i._addEmptyPacketToInputStream(r,s)})}addBoolVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateBoolVector(t.length);if(!a)throw Error("Unable to allocate new bool vector on heap.");for(const o of t)this.i._addBoolVectorEntry(a,o);this.i._addBoolVectorToInputStream(a,n,r)})}addDoubleVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateDoubleVector(t.length);if(!a)throw Error("Unable to allocate new double vector on heap.");for(const o of t)this.i._addDoubleVectorEntry(a,o);this.i._addDoubleVectorToInputStream(a,n,r)})}addFloatVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateFloatVector(t.length);if(!a)throw Error("Unable to allocate new float vector on heap.");for(const o of t)this.i._addFloatVectorEntry(a,o);this.i._addFloatVectorToInputStream(a,n,r)})}addIntVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateIntVector(t.length);if(!a)throw Error("Unable to allocate new int vector on heap.");for(const o of t)this.i._addIntVectorEntry(a,o);this.i._addIntVectorToInputStream(a,n,r)})}addUintVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateUintVector(t.length);if(!a)throw Error("Unable to allocate new unsigned int vector on heap.");for(const o of t)this.i._addUintVectorEntry(a,o);this.i._addUintVectorToInputStream(a,n,r)})}addStringVectorToStream(t,s,r){Oa(this,s,n=>{const a=this.i._allocateStringVector(t.length);if(!a)throw Error("Unable to allocate new string vector on heap.");for(const o of t)Oa(this,o,l=>{this.i._addStringVectorEntry(a,l)});this.i._addStringVectorToInputStream(a,n,r)})}addBoolToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addBoolToInputSidePacket(t,r)})}addDoubleToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addDoubleToInputSidePacket(t,r)})}addFloatToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addFloatToInputSidePacket(t,r)})}addIntToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addIntToInputSidePacket(t,r)})}addUintToInputSidePacket(t,s){Oa(this,s,r=>{this.i._addUintToInputSidePacket(t,r)})}addStringToInputSidePacket(t,s){Oa(this,s,r=>{Oa(this,t,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(t,s,r){Oa(this,r,n=>{Oa(this,s,a=>{const o=this.i._malloc(t.length);this.i.HEAPU8.set(t,o),this.i._addProtoToInputSidePacket(o,t.length,a,n),this.i._free(o)})})}addBoolVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateBoolVector(t.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const a of t)this.i._addBoolVectorEntry(n,a);this.i._addBoolVectorToInputSidePacket(n,r)})}addDoubleVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateDoubleVector(t.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const a of t)this.i._addDoubleVectorEntry(n,a);this.i._addDoubleVectorToInputSidePacket(n,r)})}addFloatVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateFloatVector(t.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const a of t)this.i._addFloatVectorEntry(n,a);this.i._addFloatVectorToInputSidePacket(n,r)})}addIntVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateIntVector(t.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const a of t)this.i._addIntVectorEntry(n,a);this.i._addIntVectorToInputSidePacket(n,r)})}addUintVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateUintVector(t.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const a of t)this.i._addUintVectorEntry(n,a);this.i._addUintVectorToInputSidePacket(n,r)})}addStringVectorToInputSidePacket(t,s){Oa(this,s,r=>{const n=this.i._allocateStringVector(t.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const a of t)Oa(this,a,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(t,s){qy(this,t,s),Oa(this,t,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(t,s){Fb(this,t,s),Oa(this,t,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(t,s){qy(this,t,s),Oa(this,t,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(t,s){Fb(this,t,s),Oa(this,t,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(t,s){qy(this,t,s),Oa(this,t,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(t,s){Fb(this,t,s),Oa(this,t,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(t,s){qy(this,t,s),Oa(this,t,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(t,s){Fb(this,t,s),Oa(this,t,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(t,s){qy(this,t,s),Oa(this,t,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(t,s){Fb(this,t,s),Oa(this,t,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(t,s){qy(this,t,s),Oa(this,t,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(t,s){Fb(this,t,s),Oa(this,t,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(t,s,r){qy(this,t,s),Oa(this,t,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(t,s,r){Fb(this,t,s),Oa(this,t,n=>{this.i._attachProtoVectorListener(n,r||!1)})}attachAudioListener(t,s,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),qy(this,t,(n,a)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),s(n,a)}),Oa(this,t,n=>{this.i._attachAudioListener(n,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Q7e{get ga(){return this.i}pa(t,s,r){Oa(this,s,n=>{const[a,o]=W7e(this,t,n);this.ga._addBoundTextureAsImageToStream(n,a,o,r)})}Z(t,s){qy(this,t,s),Oa(this,t,r=>{this.ga._attachImageListener(r)})}aa(t,s){Fb(this,t,s),Oa(this,t,r=>{this.ga._attachImageVectorListener(r)})}}));var Q7e,gy=class extends ojs{};async function Uo(t,s,r){return async function(n,a,o,l){return rjs(n,a,o,l)}(t,r.canvas??(Wot()?void 0:document.createElement("canvas")),s,r)}function elt(t,s,r,n){if(t.U){const o=new _ot;if(r!=null&&r.regionOfInterest){if(!t.oa)throw Error("This task doesn't support region-of-interest.");var a=r.regionOfInterest;if(a.left>=a.right||a.top>=a.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(a.left<0||a.top<0||a.right>1||a.bottom>1)throw Error("Expected RectF values to be in [0,1].");Ha(o,1,(a.left+a.right)/2),Ha(o,2,(a.top+a.bottom)/2),Ha(o,4,a.right-a.left),Ha(o,3,a.bottom-a.top)}else Ha(o,1,.5),Ha(o,2,.5),Ha(o,4,1),Ha(o,3,1);if(r!=null&&r.rotationDegrees){if((r==null?void 0:r.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90°.");if(Ha(o,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[l,i]=Got(s);r=Pd(o,3)*i/l,a=Pd(o,4)*l/i,Ha(o,4,r),Ha(o,3,a)}}t.g.addProtoToStream(o.g(),"mediapipe.NormalizedRect",t.U,n)}t.g.pa(s,t.X,n??performance.now()),t.finishProcessing()}function yy(t,s,r){var n;if((n=t.baseOptions)!=null&&n.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");elt(t,s,r,t.C+1)}function Z0(t,s,r,n){var a;if(!((a=t.baseOptions)!=null&&a.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");elt(t,s,r,n)}function IA(t,s,r,n){var a=s.data;const o=s.width,l=o*(s=s.height);if((a instanceof Uint8Array||a instanceof Float32Array)&&a.length!==l)throw Error("Unsupported channel count: "+a.length/l);return t=new Uu([a],r,!1,t.g.i.canvas,t.P,o,s),n?t.clone():t}var Ef=class extends swe{constructor(t,s,r,n){super(t),this.g=t,this.X=s,this.U=r,this.oa=n,this.P=new Yot}l(t,s=!0){if("runningMode"in t&&Sl(this.baseOptions,2,oO(!!t.runningMode&&t.runningMode!=="IMAGE")),t.canvas!==void 0&&this.g.i.canvas!==t.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(t,s)}close(){this.P.close(),super.close()}};Ef.prototype.close=Ef.prototype.close;var tx=class extends Ef{constructor(t,s){super(new gy(t,s),"image_in","norm_rect_in",!1),this.j={detections:[]},oi(t=this.h=new pme,0,1,s=new kd),Ha(this.h,2,.5),Ha(this.h,3,.3)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&Ha(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&Ha(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,s){return this.j={detections:[]},yy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},Z0(this,t,r,s),this.j}m(){var t=new Df;rd(t,"image_in"),rd(t,"norm_rect_in"),sl(t,"detections");const s=new Lf;G0(s,q2s,this.h);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect_in"),Do(r,"DETECTIONS:detections"),r.o(s),Zx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=yot(o),this.j.detections.push(Vot(n));la(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};tx.prototype.detectForVideo=tx.prototype.G,tx.prototype.detect=tx.prototype.F,tx.prototype.setOptions=tx.prototype.o,tx.createFromModelPath=async function(t,s){return Uo(tx,t,{baseOptions:{modelAssetPath:s}})},tx.createFromModelBuffer=function(t,s){return Uo(tx,t,{baseOptions:{modelAssetBuffer:s}})},tx.createFromOptions=function(t,s){return Uo(tx,t,s)};var tCe=xy([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),sCe=xy([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),rCe=xy([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),tlt=xy([474,475],[475,476],[476,477],[477,474]),nCe=xy([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),aCe=xy([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),slt=xy([469,470],[470,471],[471,472],[472,469]),iCe=xy([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),rlt=[...tCe,...sCe,...rCe,...nCe,...aCe,...iCe],nlt=xy([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function J7e(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var cd=class extends Ef{constructor(t,s){super(new gy(t,s),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,oi(t=this.h=new Sot,0,1,s=new kd),this.A=new kot,oi(this.h,0,3,this.A),this.u=new pme,oi(this.h,0,2,this.u),F1(this.u,4,1),Ha(this.u,2,.5),Ha(this.A,2,.5),Ha(this.h,4,.5)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"numFaces"in t&&F1(this.u,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&Ha(this.u,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&Ha(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&Ha(this.A,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in t&&(this.outputFacialTransformationMatrixes=!!t.outputFacialTransformationMatrixes),this.l(t)}F(t,s){return J7e(this),yy(this,t,s),this.j}G(t,s,r){return J7e(this),Z0(this,t,r,s),this.j}m(){var t=new Df;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"face_landmarks");const s=new Lf;G0(s,V2s,this.h);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),Zx(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=SR(o),this.j.faceLandmarks.push(fme(n));la(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{la(this,n)}),this.outputFaceBlendshapes&&(sl(t,"blendshapes"),Do(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=mme(o),this.j.faceBlendshapes.push(QSe(n.g()??[]));la(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{la(this,n)})),this.outputFacialTransformationMatrixes&&(sl(t,"face_geometry"),Do(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of n)(n=Yo(n=U2s(o),L2s,2))&&this.j.facialTransformationMatrixes.push({rows:jx(n,1)??0??0,columns:jx(n,2)??0??0,data:P4(n,3,d0,E4()).slice()??[]});la(this,a)}),this.g.attachEmptyPacketListener("face_geometry",n=>{la(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};cd.prototype.detectForVideo=cd.prototype.G,cd.prototype.detect=cd.prototype.F,cd.prototype.setOptions=cd.prototype.o,cd.createFromModelPath=function(t,s){return Uo(cd,t,{baseOptions:{modelAssetPath:s}})},cd.createFromModelBuffer=function(t,s){return Uo(cd,t,{baseOptions:{modelAssetBuffer:s}})},cd.createFromOptions=function(t,s){return Uo(cd,t,s)},cd.FACE_LANDMARKS_LIPS=tCe,cd.FACE_LANDMARKS_LEFT_EYE=sCe,cd.FACE_LANDMARKS_LEFT_EYEBROW=rCe,cd.FACE_LANDMARKS_LEFT_IRIS=tlt,cd.FACE_LANDMARKS_RIGHT_EYE=nCe,cd.FACE_LANDMARKS_RIGHT_EYEBROW=aCe,cd.FACE_LANDMARKS_RIGHT_IRIS=slt,cd.FACE_LANDMARKS_FACE_OVAL=iCe,cd.FACE_LANDMARKS_CONTOURS=rlt,cd.FACE_LANDMARKS_TESSELATION=nlt;var oCe=xy([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function eze(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function tze(t){return t.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:t.gestures,landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handedness:t.handedness,handednesses:t.handedness}}function sze(t,s=!0){const r=[];for(const a of t){var n=mme(a);t=[];for(const o of n.g())n=s&&jx(o,1)!=null?jx(o,1)??0:-1,t.push({score:Pd(o,2)??0,index:n,categoryName:Eh(ed(o,3))??""??"",displayName:Eh(ed(o,4))??""??""});r.push(t)}return r}var Wp=class extends Ef{constructor(t,s){super(new gy(t,s),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],oi(t=this.j=new Tot,0,1,s=new kd),this.u=new KSe,oi(this.j,0,2,this.u),this.D=new GSe,oi(this.u,0,3,this.D),this.A=new Mot,oi(this.u,0,2,this.A),this.h=new H2s,oi(this.j,0,3,this.h),Ha(this.A,2,.5),Ha(this.u,4,.5),Ha(this.D,2,.5)}get baseOptions(){return Yo(this.j,kd,1)}set baseOptions(t){oi(this.j,0,1,t)}o(t){var a,o,l,i;if(F1(this.A,3,t.numHands??1),"minHandDetectionConfidence"in t&&Ha(this.A,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Ha(this.u,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Ha(this.D,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var s=new L5,r=s,n=twe(t.cannedGesturesClassifierOptions,(a=Yo(this.h,L5,3))==null?void 0:a.l());oi(r,0,2,n),oi(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=Yo(this.h,L5,3))==null||o.g());return t.customGesturesClassifierOptions?(oi(r=s=new L5,0,2,n=twe(t.customGesturesClassifierOptions,(l=Yo(this.h,L5,4))==null?void 0:l.l())),oi(this.h,0,4,s)):t.customGesturesClassifierOptions===void 0&&((i=Yo(this.h,L5,4))==null||i.g()),this.l(t)}Ha(t,s){return eze(this),yy(this,t,s),tze(this)}Ia(t,s,r){return eze(this),Z0(this,t,r,s),tze(this)}m(){var t=new Df;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"hand_gestures"),sl(t,"hand_landmarks"),sl(t,"world_hand_landmarks"),sl(t,"handedness");const s=new Lf;G0(s,W2s,this.j);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"HAND_GESTURES:hand_gestures"),Do(r,"LANDMARKS:hand_landmarks"),Do(r,"WORLD_LANDMARKS:world_hand_landmarks"),Do(r,"HANDEDNESS:handedness"),r.o(s),Zx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=SR(o);const l=[];for(const i of R1(n,bot,1))l.push({x:Pd(i,1)??0,y:Pd(i,2)??0,z:Pd(i,3)??0,visibility:Pd(i,4)??0});this.landmarks.push(l)}la(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{la(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n){n=dT(o);const l=[];for(const i of R1(n,vot,1))l.push({x:Pd(i,1)??0,y:Pd(i,2)??0,z:Pd(i,3)??0,visibility:Pd(i,4)??0});this.worldLandmarks.push(l)}la(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{la(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,a)=>{this.gestures.push(...sze(n,!1)),la(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{la(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...sze(n)),la(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function rze(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Wp.prototype.recognizeForVideo=Wp.prototype.Ia,Wp.prototype.recognize=Wp.prototype.Ha,Wp.prototype.setOptions=Wp.prototype.o,Wp.createFromModelPath=function(t,s){return Uo(Wp,t,{baseOptions:{modelAssetPath:s}})},Wp.createFromModelBuffer=function(t,s){return Uo(Wp,t,{baseOptions:{modelAssetBuffer:s}})},Wp.createFromOptions=function(t,s){return Uo(Wp,t,s)},Wp.HAND_CONNECTIONS=oCe;var Gp=class extends Ef{constructor(t,s){super(new gy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],oi(t=this.h=new KSe,0,1,s=new kd),this.u=new GSe,oi(this.h,0,3,this.u),this.j=new Mot,oi(this.h,0,2,this.j),F1(this.j,3,1),Ha(this.j,2,.5),Ha(this.u,2,.5),Ha(this.h,4,.5)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"numHands"in t&&F1(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&Ha(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Ha(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Ha(this.u,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,s){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],yy(this,t,s),rze(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Z0(this,t,r,s),rze(this)}m(){var t=new Df;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"hand_landmarks"),sl(t,"world_hand_landmarks"),sl(t,"handedness");const s=new Lf;G0(s,G2s,this.h);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"LANDMARKS:hand_landmarks"),Do(r,"WORLD_LANDMARKS:world_hand_landmarks"),Do(r,"HANDEDNESS:handedness"),r.o(s),Zx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=SR(o),this.landmarks.push(fme(n));la(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{la(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n)n=dT(o),this.worldLandmarks.push(N8(n));la(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{la(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{var o=this.handedness,l=o.push;const i=[];for(const c of n){n=mme(c);const u=[];for(const p of n.g())u.push({score:Pd(p,2)??0,index:jx(p,1)??0??-1,categoryName:Eh(ed(p,3))??""??"",displayName:Eh(ed(p,4))??""??""});i.push(u)}l.call(o,...i),la(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Gp.prototype.detectForVideo=Gp.prototype.G,Gp.prototype.detect=Gp.prototype.F,Gp.prototype.setOptions=Gp.prototype.o,Gp.createFromModelPath=function(t,s){return Uo(Gp,t,{baseOptions:{modelAssetPath:s}})},Gp.createFromModelBuffer=function(t,s){return Uo(Gp,t,{baseOptions:{modelAssetBuffer:s}})},Gp.createFromOptions=function(t,s){return Uo(Gp,t,s)},Gp.HAND_CONNECTIONS=oCe;var alt=xy([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function nze(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function aze(t){try{if(!t.D)return t.h;t.D(t.h)}finally{gme(t)}}function t9(t,s){t=SR(t),s.push(fme(t))}var Pc=class extends Ef{constructor(t,s){super(new gy(t,s),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,oi(t=this.j=new Lot,0,1,s=new kd),this.I=new GSe,oi(this.j,0,2,this.I),this.W=new K2s,oi(this.j,0,3,this.W),this.u=new pme,oi(this.j,0,4,this.u),this.O=new kot,oi(this.j,0,5,this.O),this.A=new Pot,oi(this.j,0,6,this.A),this.M=new Iot,oi(this.j,0,7,this.M),Ha(this.u,2,.5),Ha(this.u,3,.3),Ha(this.O,2,.5),Ha(this.A,2,.5),Ha(this.A,3,.3),Ha(this.M,2,.5),Ha(this.I,2,.5)}get baseOptions(){return Yo(this.j,kd,1)}set baseOptions(t){oi(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&Ha(this.u,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&Ha(this.u,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&Ha(this.O,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&Ha(this.A,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&Ha(this.A,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&Ha(this.M,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&Ha(this.I,2,t.minHandLandmarksConfidence??.5),this.l(t)}F(t,s,r){const n=typeof s!="function"?s:{};return this.D=typeof s=="function"?s:r,nze(this),yy(this,t,n),aze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,nze(this),Z0(this,t,a,s),aze(this)}m(){var t=new Df;rd(t,"input_frames_image"),sl(t,"pose_landmarks"),sl(t,"pose_world_landmarks"),sl(t,"face_landmarks"),sl(t,"left_hand_landmarks"),sl(t,"left_hand_world_landmarks"),sl(t,"right_hand_landmarks"),sl(t,"right_hand_world_landmarks");const s=new Lf,r=new T7e;Af(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(a,o){if(o!=null)if(Array.isArray(o))Sl(a,2,tme(o,0,lO));else{if(!(typeof o=="string"||o instanceof C0||mSe(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");t_(a,2,fSe(o,!1),lC())}}(r,this.j.g());const n=new Lp;Af(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),TSe(n,8,T7e,r),Vc(n,"IMAGE:input_frames_image"),Do(n,"POSE_LANDMARKS:pose_landmarks"),Do(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),Do(n,"FACE_LANDMARKS:face_landmarks"),Do(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),Do(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),Do(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),Do(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),Zx(t,n),xme(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{t9(a,this.h.poseLandmarks),la(this,o)}),this.g.attachEmptyPacketListener("pose_landmarks",a=>{la(this,a)}),this.g.attachProtoListener("pose_world_landmarks",(a,o)=>{var l=this.h.poseWorldLandmarks;a=dT(a),l.push(N8(a)),la(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",a=>{la(this,a)}),this.outputPoseSegmentationMasks&&(Do(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),EA(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(a,o)=>{this.h.poseSegmentationMasks=[IA(this,a,!0,!this.D)],la(this,o)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",a=>{this.h.poseSegmentationMasks=[],la(this,a)})),this.g.attachProtoListener("face_landmarks",(a,o)=>{t9(a,this.h.faceLandmarks),la(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{la(this,a)}),this.outputFaceBlendshapes&&(sl(t,"extra_blendshapes"),Do(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=mme(a),l.push(QSe(a.g()??[]))),la(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{la(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{t9(a,this.h.leftHandLandmarks),la(this,o)}),this.g.attachEmptyPacketListener("left_hand_landmarks",a=>{la(this,a)}),this.g.attachProtoListener("left_hand_world_landmarks",(a,o)=>{var l=this.h.leftHandWorldLandmarks;a=dT(a),l.push(N8(a)),la(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",a=>{la(this,a)}),this.g.attachProtoListener("right_hand_landmarks",(a,o)=>{t9(a,this.h.rightHandLandmarks),la(this,o)}),this.g.attachEmptyPacketListener("right_hand_landmarks",a=>{la(this,a)}),this.g.attachProtoListener("right_hand_world_landmarks",(a,o)=>{var l=this.h.rightHandWorldLandmarks;a=dT(a),l.push(N8(a)),la(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",a=>{la(this,a)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Pc.prototype.detectForVideo=Pc.prototype.G,Pc.prototype.detect=Pc.prototype.F,Pc.prototype.setOptions=Pc.prototype.o,Pc.createFromModelPath=function(t,s){return Uo(Pc,t,{baseOptions:{modelAssetPath:s}})},Pc.createFromModelBuffer=function(t,s){return Uo(Pc,t,{baseOptions:{modelAssetBuffer:s}})},Pc.createFromOptions=function(t,s){return Uo(Pc,t,s)},Pc.HAND_CONNECTIONS=oCe,Pc.POSE_CONNECTIONS=alt,Pc.FACE_LANDMARKS_LIPS=tCe,Pc.FACE_LANDMARKS_LEFT_EYE=sCe,Pc.FACE_LANDMARKS_LEFT_EYEBROW=rCe,Pc.FACE_LANDMARKS_LEFT_IRIS=tlt,Pc.FACE_LANDMARKS_RIGHT_EYE=nCe,Pc.FACE_LANDMARKS_RIGHT_EYEBROW=aCe,Pc.FACE_LANDMARKS_RIGHT_IRIS=slt,Pc.FACE_LANDMARKS_FACE_OVAL=iCe,Pc.FACE_LANDMARKS_CONTOURS=rlt,Pc.FACE_LANDMARKS_TESSELATION=nlt;var sx=class extends Ef{constructor(t,s){super(new gy(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},oi(t=this.h=new Dot,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return oi(this.h,0,2,twe(t,Yo(this.h,HSe,2))),this.l(t)}sa(t,s){return this.j={classifications:[]},yy(this,t,s),this.j}ta(t,s,r){return this.j={classifications:[]},Z0(this,t,r,s),this.j}m(){var t=new Df;rd(t,"input_image"),rd(t,"norm_rect"),sl(t,"classifications");const s=new Lf;G0(s,Z2s,this.h);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Vc(r,"IMAGE:input_image"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"CLASSIFICATIONS:classifications"),r.o(s),Zx(t,r),this.g.attachProtoListener("classifications",(n,a)=>{this.j=tjs(R2s(n)),la(this,a)}),this.g.attachEmptyPacketListener("classifications",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};sx.prototype.classifyForVideo=sx.prototype.ta,sx.prototype.classify=sx.prototype.sa,sx.prototype.setOptions=sx.prototype.o,sx.createFromModelPath=function(t,s){return Uo(sx,t,{baseOptions:{modelAssetPath:s}})},sx.createFromModelBuffer=function(t,s){return Uo(sx,t,{baseOptions:{modelAssetBuffer:s}})},sx.createFromOptions=function(t,s){return Uo(sx,t,s)};var Kp=class extends Ef{constructor(t,s){super(new gy(t,s),"image_in","norm_rect",!0),this.h=new Oot,this.embeddings={embeddings:[]},oi(t=this.h,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){var s=this.h,r=Yo(this.h,F7e,2);return r=r?r.clone():new F7e,t.l2Normalize!==void 0?Sl(r,1,oO(t.l2Normalize)):"l2Normalize"in t&&Sl(r,1),t.quantize!==void 0?Sl(r,2,oO(t.quantize)):"quantize"in t&&Sl(r,2),oi(s,0,2,r),this.l(t)}za(t,s){return yy(this,t,s),this.embeddings}Aa(t,s,r){return Z0(this,t,r,s),this.embeddings}m(){var t=new Df;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"embeddings_out");const s=new Lf;G0(s,Y2s,this.h);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"EMBEDDINGS:embeddings_out"),r.o(s),Zx(t,r),this.g.attachProtoListener("embeddings_out",(n,a)=>{n=B2s(n),this.embeddings=function(o){return{embeddings:R1(o,z2s,1).map(l=>{var u,p;const i={headIndex:jx(l,3)??0??-1,headName:Eh(ed(l,4))??""??""};var c=l.v;return Iit(c,0|c[Ta],R7e,_ye(l,1))!==void 0?(l=P4(l=Yo(l,R7e,_ye(l,1),void 0),1,d0,E4()),i.floatEmbedding=l.slice()):(c=new Uint8Array(0),i.quantizedEmbedding=((p=(u=Yo(l,F2s,_ye(l,2),void 0))==null?void 0:u.na())==null?void 0:p.h())??c),i}),timestampMs:Uot(ed(o,2,void 0,void 0,Kce)??Mit)}}(n),la(this,a)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Kp.cosineSimilarity=function(t,s){if(t.floatEmbedding&&s.floatEmbedding)t=V7e(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=V7e(U7e(t.quantizedEmbedding),U7e(s.quantizedEmbedding))}return t},Kp.prototype.embedForVideo=Kp.prototype.Aa,Kp.prototype.embed=Kp.prototype.za,Kp.prototype.setOptions=Kp.prototype.o,Kp.createFromModelPath=function(t,s){return Uo(Kp,t,{baseOptions:{modelAssetPath:s}})},Kp.createFromModelBuffer=function(t,s){return Uo(Kp,t,{baseOptions:{modelAssetBuffer:s}})},Kp.createFromOptions=function(t,s){return Uo(Kp,t,s)};var awe=class{constructor(t,s,r){this.confidenceMasks=t,this.categoryMask=s,this.qualityScores=r}close(){var t,s;(t=this.confidenceMasks)==null||t.forEach(r=>{r.close()}),(s=this.categoryMask)==null||s.close()}};function ljs(t){var r,n;const s=function(a){return R1(a,Lp,1)}(t.ca()).filter(a=>(Eh(ed(a,1))??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(t.u=[],s.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");s.length===1&&(((n=(r=Yo(s[0],Lf,7))==null?void 0:r.j())==null?void 0:n.g())??new Map).forEach((a,o)=>{t.u[Number(o)]=Eh(ed(a,1))??""})}function ize(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function oze(t){try{const s=new awe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{gme(t)}}awe.prototype.close=awe.prototype.close;var xm=class extends Ef{constructor(t,s){super(new gy(t,s),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new XSe,this.A=new Rot,oi(this.h,0,3,this.A),oi(t=this.h,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?Sl(this.h,2,jR(t.displayNamesLocale)):"displayNamesLocale"in t&&Sl(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}L(){ljs(this)}segment(t,s,r){const n=typeof s!="function"?s:{};return this.j=typeof s=="function"?s:r,ize(this),yy(this,t,n),oze(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,ize(this),Z0(this,t,a,s),oze(this)}Da(){return this.u}m(){var t=new Df;rd(t,"image_in"),rd(t,"norm_rect");const s=new Lf;G0(s,zot,this.h);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),r.o(s),Zx(t,r),xme(this,t),this.outputConfidenceMasks&&(sl(t,"confidence_masks"),Do(r,"CONFIDENCE_MASKS:confidence_masks"),EA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>IA(this,o,!0,!this.j)),la(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],la(this,n)})),this.outputCategoryMask&&(sl(t,"category_mask"),Do(r,"CATEGORY_MASK:category_mask"),EA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=IA(this,n,!1,!this.j),la(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,la(this,n)})),sl(t,"quality_scores"),Do(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,la(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};xm.prototype.getLabels=xm.prototype.Da,xm.prototype.segmentForVideo=xm.prototype.La,xm.prototype.segment=xm.prototype.segment,xm.prototype.setOptions=xm.prototype.o,xm.createFromModelPath=function(t,s){return Uo(xm,t,{baseOptions:{modelAssetPath:s}})},xm.createFromModelBuffer=function(t,s){return Uo(xm,t,{baseOptions:{modelAssetBuffer:s}})},xm.createFromOptions=function(t,s){return Uo(xm,t,s)};var iwe=class{constructor(t,s,r){this.confidenceMasks=t,this.categoryMask=s,this.qualityScores=r}close(){var t,s;(t=this.confidenceMasks)==null||t.forEach(r=>{r.close()}),(s=this.categoryMask)==null||s.close()}};iwe.prototype.close=iwe.prototype.close;var Uy=class extends Ef{constructor(t,s){super(new gy(t,s),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new XSe,this.u=new Rot,oi(this.h,0,3,this.u),oi(t=this.h,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}segment(t,s,r,n){const a=typeof r!="function"?r:{};if(this.j=typeof r=="function"?r:n,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.C+1,n=new Bot,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new kye;t_(o,3,oO(!0),!1),t_(o,1,PI(s.keypoint.x),0),t_(o,2,PI(s.keypoint.y),0),w8(n,1,ewe,o)}else{if(!s.scribble)throw Error("Must provide either a keypoint or a scribble.");{const i=new Q2s;for(o of s.scribble)t_(s=new kye,3,oO(!0),!1),t_(s,1,PI(o.x),0),t_(s,2,PI(o.y),0),TSe(i,1,kye,s);w8(n,2,ewe,i)}}this.g.addProtoToStream(n.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),yy(this,t,a);e:{try{const i=new iwe(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=i;break e}this.j(i)}finally{gme(this)}l=void 0}return l}m(){var t=new Df;rd(t,"image_in"),rd(t,"roi_in"),rd(t,"norm_rect_in");const s=new Lf;G0(s,zot,this.h);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),Vc(r,"IMAGE:image_in"),Vc(r,"ROI:roi_in"),Vc(r,"NORM_RECT:norm_rect_in"),r.o(s),Zx(t,r),xme(this,t),this.outputConfidenceMasks&&(sl(t,"confidence_masks"),Do(r,"CONFIDENCE_MASKS:confidence_masks"),EA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>IA(this,o,!0,!this.j)),la(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],la(this,n)})),this.outputCategoryMask&&(sl(t,"category_mask"),Do(r,"CATEGORY_MASK:category_mask"),EA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=IA(this,n,!1,!this.j),la(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,la(this,n)})),sl(t,"quality_scores"),Do(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,la(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Uy.prototype.segment=Uy.prototype.segment,Uy.prototype.setOptions=Uy.prototype.o,Uy.createFromModelPath=function(t,s){return Uo(Uy,t,{baseOptions:{modelAssetPath:s}})},Uy.createFromModelBuffer=function(t,s){return Uo(Uy,t,{baseOptions:{modelAssetBuffer:s}})},Uy.createFromOptions=function(t,s){return Uo(Uy,t,s)};var rx=class extends Ef{constructor(t,s){super(new gy(t,s),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},oi(t=this.h=new $ot,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?Sl(this.h,2,jR(t.displayNamesLocale)):"displayNamesLocale"in t&&Sl(this.h,2),t.maxResults!==void 0?F1(this.h,3,t.maxResults):"maxResults"in t&&Sl(this.h,3),t.scoreThreshold!==void 0?Ha(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&Sl(this.h,4),t.categoryAllowlist!==void 0?Yce(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&Sl(this.h,5),t.categoryDenylist!==void 0?Yce(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&Sl(this.h,6),this.l(t)}F(t,s){return this.j={detections:[]},yy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},Z0(this,t,r,s),this.j}m(){var t=new Df;rd(t,"input_frame_gpu"),rd(t,"norm_rect"),sl(t,"detections");const s=new Lf;G0(s,J2s,this.h);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),Vc(r,"IMAGE:input_frame_gpu"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"DETECTIONS:detections"),r.o(s),Zx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=yot(o),this.j.detections.push(Vot(n));la(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{la(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};rx.prototype.detectForVideo=rx.prototype.G,rx.prototype.detect=rx.prototype.F,rx.prototype.setOptions=rx.prototype.o,rx.createFromModelPath=async function(t,s){return Uo(rx,t,{baseOptions:{modelAssetPath:s}})},rx.createFromModelBuffer=function(t,s){return Uo(rx,t,{baseOptions:{modelAssetBuffer:s}})},rx.createFromOptions=function(t,s){return Uo(rx,t,s)};var owe=class{constructor(t,s,r){this.landmarks=t,this.worldLandmarks=s,this.segmentationMasks=r}close(){var t;(t=this.segmentationMasks)==null||t.forEach(s=>{s.close()})}};function lze(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function cze(t){try{const s=new owe(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{gme(t)}}owe.prototype.close=owe.prototype.close;var Zp=class extends Ef{constructor(t,s){super(new gy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,oi(t=this.h=new qot,0,1,s=new kd),this.A=new Iot,oi(this.h,0,3,this.A),this.j=new Pot,oi(this.h,0,2,this.j),F1(this.j,4,1),Ha(this.j,2,.5),Ha(this.A,2,.5),Ha(this.h,4,.5)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){oi(this.h,0,1,t)}o(t){return"numPoses"in t&&F1(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&Ha(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&Ha(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&Ha(this.A,2,t.minPosePresenceConfidence??.5),"outputSegmentationMasks"in t&&(this.outputSegmentationMasks=t.outputSegmentationMasks??!1),this.l(t)}F(t,s,r){const n=typeof s!="function"?s:{};return this.u=typeof s=="function"?s:r,lze(this),yy(this,t,n),cze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,lze(this),Z0(this,t,a,s),cze(this)}m(){var t=new Df;rd(t,"image_in"),rd(t,"norm_rect"),sl(t,"normalized_landmarks"),sl(t,"world_landmarks"),sl(t,"segmentation_masks");const s=new Lf;G0(s,ejs,this.h);const r=new Lp;Af(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Vc(r,"IMAGE:image_in"),Vc(r,"NORM_RECT:norm_rect"),Do(r,"NORM_LANDMARKS:normalized_landmarks"),Do(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),Zx(t,r),xme(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=SR(o),this.landmarks.push(fme(n));la(this,a)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],la(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,a)=>{this.worldLandmarks=[];for(const o of n)n=dT(o),this.worldLandmarks.push(N8(n));la(this,a)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],la(this,n)}),this.outputSegmentationMasks&&(Do(r,"SEGMENTATION_MASK:segmentation_masks"),EA(this,"segmentation_masks"),this.g.aa("segmentation_masks",(n,a)=>{this.segmentationMasks=n.map(o=>IA(this,o,!0,!this.u)),la(this,a)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],la(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Zp.prototype.detectForVideo=Zp.prototype.G,Zp.prototype.detect=Zp.prototype.F,Zp.prototype.setOptions=Zp.prototype.o,Zp.createFromModelPath=function(t,s){return Uo(Zp,t,{baseOptions:{modelAssetPath:s}})},Zp.createFromModelBuffer=function(t,s){return Uo(Zp,t,{baseOptions:{modelAssetBuffer:s}})},Zp.createFromOptions=function(t,s){return Uo(Zp,t,s)},Zp.POSE_CONNECTIONS=alt;let I4=null,II=null;async function cjs(){return I4||II||(II=(async()=>{const t=await W5.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm");return I4=await xm.createFromOptions(t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/image_segmenter/selfie_multiclass_256x256/float32/latest/selfie_multiclass_256x256.tflite",delegate:"GPU"},runningMode:"VIDEO",outputCategoryMask:!1,outputConfidenceMasks:!0}),I4})(),II)}function djs(t,s,r,n,a){const o=new Float32Array(t.length);for(let l=0;l=0&&(i-=t[c+p]);const g=Math.min(f,r-1)-Math.max(p+1,0)+1;o[c+u]=i/g}}for(let l=0;l=0&&(i-=o[u*r+l]);const f=Math.min(p,n-1)-Math.max(u+1,0)+1;s[c*r+l]=i/f}}}function ujs(){I4&&(I4.close(),I4=null,II=null)}function hjs(t,s){const r=k.useRef(null),n=k.useRef(null),a=k.useRef(null),o=k.useRef(null),l=k.useRef(0),i=k.useRef(0),[c,u]=k.useState(null),[p,f]=k.useState(!1),[g,b]=k.useState(null),_=s.type!=="none"&&t!==null;return k.useEffect(()=>{if(s.type==="image"&&s.imageUrl){const j=new Image;j.crossOrigin="anonymous",j.src=s.imageUrl,j.onload=()=>{o.current=j}}else o.current=null},[s.type,s.imageUrl]),k.useEffect(()=>{if(!_||!t){a.current&&(a.current.srcObject=null,a.current=null);return}const j=document.createElement("video");return j.srcObject=t,j.muted=!0,j.playsInline=!0,j.autoplay=!0,j.play().catch(()=>{}),a.current=j,()=>{j.srcObject=null,a.current=null}},[_,t]),k.useEffect(()=>{if(!_){u(null),b(null);return}let j=!1;return(async()=>{f(!0),b(null);try{const N=await cjs();if(j)return;f(!1);const S=a.current;if(!S||(await new Promise(pe=>{if(S.videoWidth>0)return pe();S.onloadedmetadata=()=>pe(),setTimeout(pe,2e3)}),j))return;const M=S.videoWidth||640,L=S.videoHeight||480,I=r.current;if(!I)return;I.width=M,I.height=L;const O=I.getContext("2d",{willReadFrequently:!1});n.current||(n.current=document.createElement("canvas"));const q=n.current;q.width=M,q.height=L;const U=q.getContext("2d",{willReadFrequently:!0}),B=document.createElement("canvas");B.width=M,B.height=L;const V=B.getContext("2d"),Y=I.captureStream(30);((t==null?void 0:t.getAudioTracks())||[]).forEach(pe=>Y.addTrack(pe)),j||u(Y);const ee=s.blurRadius??15,X=s.mirror??!1,ie=new Float32Array(M*L),re=new Float32Array(M*L),oe=new Float32Array(M*L);let ce=!1;const ge=4,ye=.6,ue=()=>{if(j||!a.current)return;const pe=performance.now();if(pe-i.current<30){l.current=requestAnimationFrame(ue);return}i.current=pe;const _e=a.current;if(_e.readyState<2){l.current=requestAnimationFrame(ue);return}try{const Ae=N.segmentForVideo(_e,pe).confidenceMasks;if(Ae&&Ae.length>0){re.fill(0);for(let xe=1;xeLe?(pt=xe.height*Le,tt=(xe.width-pt)/2):(fe=xe.width/Le,Te=(xe.height-fe)/2),O.drawImage(xe,tt,Te,pt,fe,0,0,M,L)}U.clearRect(0,0,M,L),U.drawImage(_e,0,0,M,L);const Ie=U.getImageData(0,0,M,L),Ce=Ie.data;for(let xe=0;xe{j=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[_,s.type,s.blurRadius,s.imageUrl,t]),k.useEffect(()=>()=>{ujs()},[]),{canvasRef:r,compositedStream:c,isLoading:p,isActive:_,error:g}}function yme({maxDurationSeconds:t=30,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=k.useRef(null),i=k.useRef(null),c=k.useRef(null),[u,p]=k.useState(null),f=k.useRef([]),g=k.useRef(null),b=k.useRef(null),_=k.useRef(null),j=k.useRef(null),w=SE(),[N,S]=k.useState("camera"),M=k.useRef(null),L=k.useRef(null),I=k.useRef(null),O=k.useRef(null),q=k.useRef(null),[U,B]=k.useState(!0),[V,Y]=k.useState(!0),[Q,ee]=k.useState(null),[X,ie]=k.useState(!1),[re,oe]=k.useState(!1),[ce,ge]=k.useState(null),[ye,ue]=k.useState(null),[pe,_e]=k.useState(0),[$e,Ae]=k.useState("user"),[Ie,Ce]=k.useState(0),[xe,we]=k.useState(!1),[Le,tt]=k.useState(!0),[Te,pt]=k.useState(null),[fe,qe]=k.useState(!1),[at,et]=k.useState(null),Me=k.useRef(null),[rt,He]=k.useState(()=>{try{const dr=localStorage.getItem("video-bg-config");if(dr)return JSON.parse(dr)}catch{}return{type:"none"}});k.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(rt))}catch{}},[rt]);const{canvasRef:ct,compositedStream:Ue,isLoading:Ze,isActive:Qe}=hjs(u,rt),We=k.useRef(r);We.current=r;const Je=k.useCallback(dr=>{B(dr)},[]),it=k.useRef(U),Dt=k.useCallback(()=>{I.current&&(cancelAnimationFrame(I.current),I.current=null),M.current&&(M.current.getTracks().forEach(dr=>dr.stop()),M.current=null),O.current&&(O.current.getTracks().forEach(dr=>dr.stop()),O.current=null),q.current&&(q.current.srcObject=null,q.current=null)},[]),Vt=k.useCallback(async()=>{var dr;try{const Jr=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080}},audio:!0});M.current=Jr;let Wr=null;try{Wr=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:320},height:{ideal:240}},audio:{echoCancellation:!0,noiseSuppression:!0}})}catch{console.warn("[VideoRecorder] No webcam for PiP overlay")}let dn=null;if(!Wr)try{dn=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.warn("[VideoRecorder] No mic audio")}const Yr=Jr.getVideoTracks()[0],vi=Yr.getSettings(),ft=vi.width||1920,ir=vi.height||1080,Vn=document.createElement("canvas");Vn.width=ft,Vn.height=ir,L.current=Vn;const Sr=Vn.getContext("2d");let jr=null;Wr&&(jr=document.createElement("video"),jr.srcObject=Wr,jr.muted=!0,jr.playsInline=!0,jr.autoplay=!0,await jr.play(),q.current=jr);const ea=document.createElement("video");ea.srcObject=Jr,ea.muted=!0,ea.playsInline=!0,ea.autoplay=!0,await ea.play();const Pa=()=>{if(Sr.drawImage(ea,0,0,ft,ir),jr&&jr.readyState>=2){const Be=Math.round(ft*.2),Ye=Math.round(Be*(jr.videoHeight/jr.videoWidth||.75)),bt=ft-Be-20,gt=ir-Ye-20,Ft=12;Sr.save(),Sr.beginPath(),Sr.moveTo(bt+Ft,gt),Sr.lineTo(bt+Be-Ft,gt),Sr.quadraticCurveTo(bt+Be,gt,bt+Be,gt+Ft),Sr.lineTo(bt+Be,gt+Ye-Ft),Sr.quadraticCurveTo(bt+Be,gt+Ye,bt+Be-Ft,gt+Ye),Sr.lineTo(bt+Ft,gt+Ye),Sr.quadraticCurveTo(bt,gt+Ye,bt,gt+Ye-Ft),Sr.lineTo(bt,gt+Ft),Sr.quadraticCurveTo(bt,gt,bt+Ft,gt),Sr.closePath(),Sr.clip(),Sr.translate(bt+Be,gt),Sr.scale(-1,1),Sr.drawImage(jr,0,0,Be,Ye),Sr.restore(),Sr.strokeStyle="rgba(255,255,255,0.6)",Sr.lineWidth=2,Sr.beginPath(),Sr.moveTo(bt+Ft,gt),Sr.lineTo(bt+Be-Ft,gt),Sr.quadraticCurveTo(bt+Be,gt,bt+Be,gt+Ft),Sr.lineTo(bt+Be,gt+Ye-Ft),Sr.quadraticCurveTo(bt+Be,gt+Ye,bt+Be-Ft,gt+Ye),Sr.lineTo(bt+Ft,gt+Ye),Sr.quadraticCurveTo(bt,gt+Ye,bt,gt+Ye-Ft),Sr.lineTo(bt,gt+Ft),Sr.quadraticCurveTo(bt,gt,bt+Ft,gt),Sr.closePath(),Sr.stroke()}I.current=requestAnimationFrame(Pa)};Pa();const Ii=Vn.captureStream(30),Fo=[],$t=Jr.getAudioTracks();if($t.length&&Fo.push(...$t),Wr){const Be=Wr.getAudioTracks();Be.length&&Fo.push(...Be)}else dn&&Fo.push(...dn.getAudioTracks());const ke=new MediaStream([...Ii.getVideoTracks(),...Fo]);return O.current=ke,Yr.onended=()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),Dt()},ke}catch(Jr){return console.error("[VideoRecorder] Screen capture error:",Jr),Jr.name!=="NotAllowedError"&&((dr=We.current)==null||dr.call(We,"Failed to start screen capture: "+(Jr.message||"Unknown error"))),null}},[Dt]),hs=k.useCallback(async()=>{var Jr,Wr;Y(!0),pt(null);const dr=w&&U;console.log("[VideoRecorder] initCamera start",{isMobile:w,usePortraitMode:U,shouldBePortrait:dr,facingMode:$e});try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Camera not available in this browser or context. Try opening in a new tab.");c.current&&(console.log("[VideoRecorder] stopping existing stream"),c.current.getTracks().forEach(ir=>ir.stop()));const dn=w&&dr?{facingMode:{ideal:$e},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:$e},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",dn);const Yr=await navigator.mediaDevices.getUserMedia({video:dn,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),Yr.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");c.current=Yr,p(Yr),ee(!0);const ft=Yr.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",ft.width,"x",ft.height),l.current){const ir=l.current;ir.srcObject=Yr,ir.muted=!0,ir.playsInline=!0,ir.autoplay=!0,ir.setAttribute("muted",""),ir.setAttribute("playsinline",""),ir.setAttribute("autoplay","");try{(Jr=ir.load)==null||Jr.call(ir)}catch(Sr){console.warn("[VideoRecorder] videoEl.load failed",Sr)}const Vn=async()=>{try{return await ir.play(),console.log("[VideoRecorder] preview play ok"),qe(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:ir.readyState,videoWidth:ir.videoWidth,videoHeight:ir.videoHeight})},300),!0}catch(Sr){return console.warn("[VideoRecorder] preview play blocked",Sr),qe(!0),!1}};await new Promise(Sr=>{let jr=!1;const ea=()=>{jr||(jr=!0,Sr())},Pa=()=>{Vn().finally(ea)};ir.onloadedmetadata=Pa,ir.onloadeddata=Pa,setTimeout(ea,1500)})}try{b.current=new AudioContext;const ir=b.current.createMediaStreamSource(Yr);_.current=b.current.createAnalyser(),_.current.fftSize=256,ir.connect(_.current);const Vn=()=>{if(_.current){const Sr=new Uint8Array(_.current.frequencyBinCount);_.current.getByteFrequencyData(Sr);const jr=Sr.reduce((ea,Pa)=>ea+Pa)/Sr.length;Ce(Math.min(100,jr/128*100))}j.current=requestAnimationFrame(Vn)};Vn()}catch(ir){console.warn("Audio context not available:",ir)}}catch(dn){console.error("Camera initialization error:",dn),ee(!1);let Yr="Failed to access camera or microphone.";dn.name==="NotAllowedError"?Yr="Camera permission denied. Please allow camera access in your browser settings.":dn.name==="NotFoundError"?Yr="No camera found. Please connect a camera and try again.":dn.name==="NotReadableError"?Yr="Camera is in use by another application. Please close other apps using the camera.":dn.message&&(Yr=dn.message),pt(Yr),(Wr=We.current)==null||Wr.call(We,Yr)}finally{Y(!1)}},[$e,w,U]);k.useEffect(()=>{it.current!==U&&Q&&!X&&!ye&&(it.current=U,hs())},[U,Q,X,ye,hs]),k.useEffect(()=>(hs(),()=>{c.current&&c.current.getTracks().forEach(dr=>dr.stop()),g.current&&clearInterval(g.current),j.current&&cancelAnimationFrame(j.current),b.current&&b.current.close(),Me.current&&clearInterval(Me.current),ye&&URL.revokeObjectURL(ye),Dt()}),[hs,ye]),k.useEffect(()=>{if(V||Q!==!0||ye)return;const dr=c.current,Jr=l.current;!dr||!Jr||Qe||(Jr.srcObject!==dr&&(Jr.srcObject=dr,Jr.muted=!0,Jr.playsInline=!0,Jr.autoplay=!0,Jr.setAttribute("muted",""),Jr.setAttribute("playsinline",""),Jr.setAttribute("autoplay","")),Jr.play().then(()=>qe(!1)).catch(Wr=>{qe(!0),console.warn("Live preview play blocked on mount:",Wr)}))},[Q,V,ye,Qe]),k.useEffect(()=>{n==null||n(X)},[X,n]);const Ts=k.useCallback(async()=>{if(ye)return;const dr=l.current;if(dr)try{await dr.play(),qe(!1)}catch(Jr){qe(!0),console.warn("Live preview still blocked (needs user gesture):",Jr)}},[ye]),Cs=k.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),g.current&&(clearInterval(g.current),g.current=null),Dt(),ie(!1),oe(!1)},[Dt]),cs=k.useCallback(async()=>{let dr=null;if(N==="screen"){if(dr=await Vt(),!dr)return}else dr=Qe&&Ue?Ue:c.current;if(!dr)return;Ts(),f.current=[],_e(0);const Wr=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Yr=>MediaRecorder.isTypeSupported(Yr)),dn=new MediaRecorder(dr,Wr?{mimeType:Wr,videoBitsPerSecond:N==="screen"?4e6:25e5}:{videoBitsPerSecond:N==="screen"?4e6:25e5});dn.ondataavailable=Yr=>{Yr.data.size>0&&f.current.push(Yr.data)},dn.onstop=()=>{var ir;const Yr=dn.mimeType||Wr||((ir=f.current[0])==null?void 0:ir.type)||"video/webm",vi=new Blob(f.current,{type:Yr});ge(vi);const ft=URL.createObjectURL(vi);ue(ft)},i.current=dn,dn.start(100),ie(!0),g.current=setInterval(()=>{_e(Yr=>Yr>=t-1?(Cs(),t):Yr+1)},1e3)},[Ts,t,Cs,Qe,Ue,N,Vt]),er=k.useCallback(()=>{Me.current&&(clearInterval(Me.current),Me.current=null),et(3);let dr=3;Me.current=setInterval(()=>{dr-=1,dr<=0?(Me.current&&clearInterval(Me.current),Me.current=null,et(null),cs()):et(dr)},1e3)},[cs]),xt=k.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),oe(!0),g.current&&clearInterval(g.current))},[]),Es=k.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),oe(!1),g.current=setInterval(()=>{_e(dr=>dr>=t-1?(Cs(),t):dr+1)},1e3))},[t,Cs]),ur=k.useCallback(()=>{ye&&URL.revokeObjectURL(ye),ge(null),ue(null),_e(0),we(!1),tt(!0),l.current&&c.current&&!Qe&&(l.current.srcObject=c.current,l.current.muted=!0,Ts())},[Ts,ye,Qe]),Mr=k.useCallback(()=>{Ae(dr=>dr==="user"?"environment":"user")},[]),Lr=k.useCallback(()=>{ce&&s(ce,pe)},[ce,pe,s]),fn=k.useCallback(()=>{l.current&&ye&&(xe?l.current.pause():(tt(!1),l.current.muted=!1,l.current.play()),we(!xe))},[ye,xe]);k.useEffect(()=>{if(!ye)return;const dr=l.current;if(!dr)return;tt(!1),dr.pause(),dr.removeAttribute("src"),dr.srcObject=null,dr.load(),dr.src=ye,dr.currentTime=0,dr.playsInline=!0,dr.muted=!1,dr.onended=()=>we(!1);const Jr=()=>{var Yr;const Wr=dr.error,dn=Wr?`Recorded video failed to play (code ${Wr.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Wr),(Yr=We.current)==null||Yr.call(We,dn)};return dr.addEventListener("error",Jr),dr.load(),()=>{dr.removeEventListener("error",Jr)}},[ye]);const ki=dr=>{const Jr=Math.floor(dr/60),Wr=dr%60;return`${Jr}:${Wr.toString().padStart(2,"0")}`},Ea=N==="screen"?"aspect-video":w&&U?"aspect-[9/16]":"aspect-video";return V?e.jsx("div",{className:It("flex items-center justify-center bg-black rounded-lg",Ea,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):Q===!1?e.jsx("div",{className:It("flex items-center justify-center bg-black rounded-lg",Ea,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(kl,{className:"h-12 w-12 mx-auto mb-4 text-destructive"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Camera Access Required"}),e.jsx("p",{className:"text-gray-400 mb-4 text-sm",children:Te||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(K,{onClick:()=>hs(),variant:"secondary",className:"w-full",children:[e.jsx(Go,{className:"h-4 w-4 mr-2"}),"Try Again"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-3",children:"💡 Tip: If you're viewing this in an embedded preview, try opening the app in a new browser tab for full camera access."})]})]})}):e.jsxs("div",{className:It("flex flex-col gap-2",a),children:[!X&&!ye&&e.jsxs("div",{className:"flex items-center justify-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsxs(K,{variant:N==="camera"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>S("camera"),children:[e.jsx(Sx,{className:"h-4 w-4"}),"Camera"]}),e.jsxs(K,{variant:N==="screen"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>S("screen"),children:[e.jsx(cS,{className:"h-4 w-4"}),"Screen"]})]}),N==="camera"&&!X&&!ye&&e.jsx(kws,{value:rt,onChange:He,isLoading:Ze,disabled:X}),N==="camera"&&w&&!X&&!ye&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(dS,{className:It("h-4 w-4",U?"text-muted-foreground":"text-primary")}),e.jsx(be,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(qr,{id:"orientation-toggle",checked:U,onCheckedChange:Je}),e.jsx(be,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(v0,{className:It("h-4 w-4",U?"text-primary":"text-muted-foreground")})]}),N==="screen"&&!X&&!ye&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 px-4 bg-muted/50 rounded-lg text-sm text-muted-foreground",children:[e.jsx(cS,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Press record to share your screen. Your webcam will appear as a small overlay."})]}),e.jsxs("div",{className:It("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{Ts()},children:[e.jsx("video",{ref:l,src:ye??void 0,className:It("w-full bg-black",U&&!ye?"object-contain":"object-cover",Ea,!ye&&$e==="user"!==(rt.mirror??!1)&&"scale-x-[-1]",Qe&&!ye&&"hidden"),playsInline:!0,controls:!!ye,muted:ye?Le:!0,autoPlay:!ye},ye??"live"),Qe&&!ye&&e.jsx("canvas",{ref:ct,className:It("w-full bg-black",U?"object-contain":"object-cover",Ea,$e==="user"!==(rt.mirror??!1)&&"scale-x-[-1]")}),Qe&&Ze&&!ye&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/60 z-20",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(ws,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!ye&&fe&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(K,{type:"button",variant:"secondary",onClick:()=>void Ts(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!ye&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),at!==null&&!ye&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:at},at),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),X&&e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx("div",{className:It("w-3 h-3 rounded-full",re?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[ki(pe)," / ",ki(t)]})]}),X&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(Bi,{value:pe/t*100,className:"h-1 rounded-none"})}),!ye&&e.jsxs("div",{className:"absolute bottom-20 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx(yL,{className:"h-4 w-4 text-white"}),e.jsx("div",{className:"w-20 h-2 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 transition-all duration-75",style:{width:`${Ie}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:ye?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:ur,children:[e.jsx(Go,{className:"h-5 w-5 mr-2"}),"Re-record"]}),e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:fn,children:xe?e.jsx(Rm,{className:"h-5 w-5"}):e.jsx(nl,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:Lr,children:[e.jsx(va,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[N==="camera"?e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Mr,disabled:X||at!==null,children:e.jsx(m1,{className:"h-5 w-5"})}):e.jsx("div",{className:"h-12 w-12"}),!X&&at===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:N==="screen"?cs:er,children:N==="screen"?e.jsx(cS,{className:"h-6 w-6"}):e.jsx(An,{className:"h-6 w-6"})}):e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:re?Es:xt,children:re?e.jsx(nl,{className:"h-5 w-5"}):e.jsx(Rm,{className:"h-5 w-5"})}),e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Cs,children:e.jsx(b0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const ilt="teleprompter_settings",Cye={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function mjs(){try{const t=localStorage.getItem(ilt);return t?{...Cye,...JSON.parse(t)}:Cye}catch{return Cye}}function pjs(t){try{localStorage.setItem(ilt,JSON.stringify(t))}catch{}}function olt({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=k.useRef(null),c=k.useRef(null),u=k.useRef(0),p=k.useRef(0),[f,g]=k.useState(mjs),{scrollSpeed:b,fontSize:_,lineHeight:j,opacity:w,position:N,isMirrored:S}=f,M=k.useCallback((Q,ee)=>{g(X=>{const ie={...X,[Q]:ee};return pjs(ie),ie})},[]),[L,I]=k.useState(!1),[O,q]=k.useState(null),U=k.useCallback(Q=>{if(!i.current)return;u.current===0&&(u.current=Q);const ee=Q-u.current;u.current=Q,p.current+=b*ee/1e3;const X=Math.floor(p.current);X>0&&(i.current.scrollTop+=X,p.current-=X);const{scrollTop:ie,scrollHeight:re,clientHeight:oe}=i.current;if(ie+oe>=re){I(!1);return}c.current=requestAnimationFrame(U)},[b]);k.useEffect(()=>(L?(u.current=0,p.current=0,c.current=requestAnimationFrame(U)):c.current&&cancelAnimationFrame(c.current),()=>{c.current&&cancelAnimationFrame(c.current)}),[L,U]),k.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){q(3);let Q=3;const ee=setInterval(()=>{Q-=1,Q<=0?(clearInterval(ee),q(null),o==null||o(),I(!0)):q(Q)},1e3);return()=>clearInterval(ee)}else setTimeout(()=>I(!0),100);else n||(I(!1),q(null))},[n,s,a,o]);const B=k.useCallback(()=>{i.current&&(i.current.scrollTop=0),I(!1)},[]),V=k.useCallback(()=>{I(Q=>!Q)},[]);if(!s)return e.jsx("div",{className:It("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Ln,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const Y={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:It("absolute inset-0 pointer-events-none",l),children:[O!==null&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:O},O),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:It("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",Y[N],O!==null&&"opacity-30"),style:{opacity:O!==null?.3:w},children:e.jsxs("div",{ref:i,className:It("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",S&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${_}px`,lineHeight:j,textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:t}),e.jsx("div",{className:"h-full"})]})}),e.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 pointer-events-auto",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsx(K,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(Xo,{className:"h-4 w-4"})})}),e.jsx(Ro,{className:"w-72",side:"left",align:"start",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium",children:"Teleprompter Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:b})]}),e.jsx(Kg,{value:[b],onValueChange:([Q])=>M("scrollSpeed",Q),min:1,max:100,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[_,"px"]})]}),e.jsx(Kg,{value:[_],onValueChange:([Q])=>M("fontSize",Q),min:16,max:48,step:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:j.toFixed(1)})]}),e.jsx(Kg,{value:[j*10],onValueChange:([Q])=>M("lineHeight",Q/10),min:12,max:24,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(w*100),"%"]})]}),e.jsx(Kg,{value:[w*100],onValueChange:([Q])=>M("opacity",Q/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:N==="top"?"default":"outline",size:"sm",onClick:()=>M("position","top"),children:e.jsx(ff,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="center"?"default":"outline",size:"sm",onClick:()=>M("position","center"),children:e.jsx(f0,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="bottom"?"default":"outline",size:"sm",onClick:()=>M("position","bottom"),children:e.jsx(Eo,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Mirror Mode"}),e.jsx(qr,{checked:S,onCheckedChange:Q=>M("isMirrored",Q)})]})]})})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:V,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:L?e.jsx(Rm,{className:"h-4 w-4"}):e.jsx(nl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"secondary",size:"icon",onClick:B,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(m1,{className:"h-4 w-4"})}),e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(kp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function fjs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=Ua(),[o,l]=k.useState(""),[i,c]=k.useState(null),[u,p]=k.useState("levelup"),{data:f,isLoading:g}=Qbs(),{data:b,isLoading:_}=Jbs(),{data:j,isLoading:w}=e_s(),N=t_s(),S=k.useMemo(()=>b?b.filter(q=>{const U=!o||q.title.toLowerCase().includes(o.toLowerCase())||q.script_text.toLowerCase().includes(o.toLowerCase())||q.tags.some(V=>V.toLowerCase().includes(o.toLowerCase())),B=!i||q.category_id===i;return U&&B}):[],[b,o,i]),M=k.useMemo(()=>j?j.filter(q=>!o||q.title.toLowerCase().includes(o.toLowerCase())||q.script_text.toLowerCase().includes(o.toLowerCase())):[],[j,o]),L=q=>{t({title:q.title,text:q.script_text})},I=async q=>{try{await N.mutateAsync(q),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},O=g||_||w;return e.jsxs("div",{className:It("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search scripts...",value:o,onChange:q=>l(q.target.value),className:"pl-9"})]})}),e.jsxs(ba,{value:u,onValueChange:q=>p(q),className:"flex-1 flex flex-col",children:[e.jsxs(pa,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(ns,{value:"levelup",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(ns,{value:"my-scripts",children:[e.jsx(kx,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(bs,{value:"levelup",className:"flex-1 flex flex-col mt-0 p-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx(st,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>c(null),children:"All"}),f==null?void 0:f.map(q=>e.jsx(st,{variant:i===q.id?"default":"outline",className:"cursor-pointer",onClick:()=>c(q.id),children:q.name},q.id))]}),e.jsx(Gi,{className:"flex-1 max-h-[50vh]",children:O?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Sn,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:S.map(q=>e.jsxs(Ee,{className:It("cursor-pointer hover:bg-accent/50 transition-colors",r===q.id&&"ring-2 ring-primary"),onClick:()=>L(q),children:[e.jsx(Pt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-sm font-medium truncate",children:q.title}),q.category&&e.jsx(st,{variant:"secondary",className:"mt-1 text-xs",children:q.category.name})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:U=>{U.stopPropagation(),I(q)},children:e.jsx(kx,{className:"h-4 w-4"})}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:q.script_text})})]},q.id))})})]}),e.jsxs(bs,{value:"my-scripts",className:"flex-1 flex flex-col mt-0 p-4",children:[s&&e.jsxs(K,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(Gi,{className:"flex-1 max-h-[50vh]",children:w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):M.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(kx,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No saved scripts"}),e.jsx("p",{className:"text-sm mt-1",children:"Save LevelUp scripts or create your own"})]}):e.jsx("div",{className:"space-y-2",children:M.map(q=>e.jsxs(Ee,{className:It("cursor-pointer hover:bg-accent/50 transition-colors",r===q.id&&"ring-2 ring-primary"),onClick:()=>L(q),children:[e.jsx(Pt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-sm font-medium truncate",children:q.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:q.is_custom?e.jsx(st,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(st,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:q.script_text})})]},q.id))})})]})]})]})}function xjs({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=k.useState(()=>{const i=QM(t);return new Set([i.category])}),l=i=>{o(c=>{const u=new Set(c);return u.has(i)?u.delete(i):u.add(i),u})};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(ws,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:DIt.map(i=>{const c=OIt(i.id),u=a.has(i.id),p=c.some(f=>f.id===t);return e.jsxs(yf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(vf,{className:"flex items-center justify-between w-full p-2.5 rounded-lg bg-muted/50 hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:i.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",c.length,")"]}),p&&!u&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(Eo,{className:It("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(bf,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:c.map(f=>{const g=t===f.id;return e.jsxs("button",{type:"button",onClick:()=>s(f.id),disabled:n,className:It("relative rounded-lg border-2 p-2.5 text-left transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",g?"border-primary ring-1 ring-primary/20 bg-primary/5":"border-muted hover:border-muted-foreground/30"),children:[g&&e.jsx("div",{className:"absolute top-1 right-1 w-4 h-4 rounded-full bg-primary flex items-center justify-center",children:e.jsx(va,{className:"h-2.5 w-2.5 text-primary-foreground"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"opacity-70 shrink-0",children:f.icon}),e.jsx("span",{className:"text-sm font-medium truncate",children:f.name})]})]},f.id)})})})]},i.id)})}),r&&t!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Will show: "',QM(t).headerText(r),'"']})]})}function llt({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=k.useState(r.page_template||"default"),[i,c]=k.useState(!1),[u,p]=k.useState(!1),[f,g]=k.useState(r.page_template||"default"),[b,_]=k.useState([]),[j,w]=k.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[N,S]=k.useState(!1),[M,L]=k.useState(!1),I=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";k.useEffect(()=>{t&&b.length===0&&O()},[t]);const O=async()=>{L(!0);try{const{data:ie,error:re}=await H.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(re)throw re;const oe=(ie||[]).map(ce=>({id:ce.id,name:[ce.first_name,ce.last_name].filter(Boolean).join(" ")||"Unnamed",email:ce.email||null}));_(oe)}catch(ie){console.error("Failed to fetch contacts:",ie)}finally{L(!1)}},q=async ie=>{w(ie),S(!1),c(!0);try{const{error:re}=await H.from("agent_videos").update({contact_id:(ie==null?void 0:ie.id)||null,recipient_name:(ie==null?void 0:ie.name)||null}).eq("id",r.id);if(re)throw re;me.success(ie?`Assigned to ${ie.name}`:"Contact removed"),a==null||a()}catch(re){console.error("Failed to update contact:",re),me.error("Failed to update contact")}finally{c(!1)}},U=async ie=>{l(ie),c(!0);try{const{error:re}=await H.from("agent_videos").update({page_template:ie}).eq("id",r.id);if(re)throw re;g(ie),me.success("Template saved!"),a==null||a()}catch(re){console.error("Failed to save template:",re),me.error("Failed to save template"),l(f)}finally{c(!1)}},B=(j==null?void 0:j.name)||null,V=()=>{const ie=r.title||"Video Message",re=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},Y=async()=>{if(!r.thumbnail_url){me.error("Video thumbnail not available yet");return}const ie=V(),re=`Watch: ${r.title||"Video Message"} ${I}`;try{const oe=new Blob([ie],{type:"text/html"}),ce=new Blob([re],{type:"text/plain"}),ge=new ClipboardItem({"text/html":oe,"text/plain":ce});await navigator.clipboard.write([ge]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(re+` `+ie),me.success("Copied! Paste into your email.")}},Q=async()=>{await navigator.clipboard.writeText(I),p(!0),me.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},ee=()=>{const re=QM(o).headerText(B),oe=o==="default"?`Check out this video: ${I}`:`${re} Check out this special video: ${I}`;window.open(`sms:?body=${encodeURIComponent(oe)}`,"_self")},X=()=>{const ie=QM(o),re=ie.headerText(B),oe=o==="default"?r.title||"Video Message":re,ce=`${ie.subText} Watch the video: ${I}`,ge=j!=null&&j.email?encodeURIComponent(j.email):"";window.open(`mailto:${ge}?subject=${encodeURIComponent(oe)}&body=${encodeURIComponent(ce)}`,"_self")};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(Gr,{children:"Choose a themed page template and share your video"})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($o,{open:N,onOpenChange:S,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":N,className:"flex-1 justify-between",disabled:i,children:[j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),j.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Dx,{children:[e.jsx(Ox,{placeholder:"Search contacts..."}),e.jsxs(Rx,{children:[e.jsx(Fx,{children:M?"Loading...":"No contacts found."}),e.jsx(zx,{children:b.map(ie=>e.jsxs(bp,{value:ie.name,onSelect:()=>q(ie),children:[e.jsx(va,{className:It("mr-2 h-4 w-4",(j==null?void 0:j.id)===ie.id?"opacity-100":"opacity-0")}),ie.name]},ie.id))})]})]})})]}),j&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q(null),disabled:i,className:"shrink-0",children:e.jsx(Rr,{className:"h-4 w-4"})})]}),j&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',QM(o).headerText(j.name),'"']})]}),e.jsx(xjs,{selectedTemplate:o,onSelect:U,contactName:B,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:I,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:Q,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(va,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Share for Email"}),e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:Y,children:[e.jsx(gl,{className:"h-4 w-4"}),"Copy with Thumbnail (for Gmail)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste into Gmail to embed a clickable video thumbnail"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:ee,children:[e.jsx(so,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:X,children:[e.jsx(cr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(qn,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function gjs(){var et;const t=fr(),[s]=Cc(),{toast:r}=Ua(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:c}=Vat(),{data:u}=Gm(),p=CC(),f=i_s(),[g,b]=k.useState("record"),[_,j]=k.useState(""),[w,N]=k.useState(!1),[S,M]=k.useState(!1),[L,I]=k.useState(!1),[O,q]=k.useState(null),[U,B]=k.useState(0),[V,Y]=k.useState(0),[Q,ee]=k.useState(null),[X,ie]=k.useState(null),[re,oe]=k.useState(n||""),[ce,ge]=k.useState(""),[ye,ue]=k.useState(""),[pe,_e]=k.useState(null),[$e,Ae]=k.useState(null),[Ie,Ce]=k.useState(null),[xe,we]=k.useState(!1),Le=k.useCallback(async(Me,rt)=>{q(Me),b("uploading");try{const{videoId:He,uploadUrl:ct}=await xR(ce||"Quick Video Touch");ee(He);const{apiKey:Ue}=await gR(He),Ze=new XMLHttpRequest;Ze.upload.onprogress=it=>{it.lengthComputable&&B(it.loaded/it.total*100)},await new Promise((it,Dt)=>{Ze.onload=()=>{Ze.status>=200&&Ze.status<300?it():Dt(new Error(`Upload failed: ${Ze.status}`))},Ze.onerror=()=>Dt(new Error("Upload failed")),Ze.open("PUT",ct),Ze.setRequestHeader("AccessKey",Ue),Ze.send(Me)}),b("processing");let Qe=0;const We=Date.now(),Je=90*1e3;for(;Qe<4;){if(await new Promise(Dt=>setTimeout(Dt,3e3)),Date.now()-We>Je){const Dt=Me.size/1048576,Vt=`https://iframe.mediadelivery.net/play/${He}/${He}`;await p.mutateAsync({bunny_video_id:He,playback_url:Vt,file_size_mb:Dt,title:ce||"Quick Video Touch",notes:ye||void 0,contact_id:re&&re!=="none"?re:void 0,status:"processing",touch_type:"video_touch"}),r({title:"Video saved — still processing",description:'Your video has been saved and will appear in your library with a "processing" badge. It will be ready to share once encoding completes (usually within a few minutes).',duration:8e3}),t("/mission-control/video-library");return}const it=await wA(He);if(Qe=it.status,Y(it.encodeProgress||0),Qe===4)ie({playbackUrl:it.directPlayUrl,thumbnailUrl:it.thumbnailUrl,previewUrl:it.previewUrl||null,duration:it.length||rt,fileSizeMb:(it.storageSize||Me.size)/(1024*1024)});else if(Qe===5||Qe===6)throw new Error("Video processing failed")}b("details")}catch(He){console.error("Upload error:",He),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),b("record")}},[ce,r]),tt=async()=>{if(!(!Q||!X))try{const Me=re&&re!=="none"?re:null,rt=await p.mutateAsync({bunny_video_id:Q,contact_id:Me,playback_url:X.playbackUrl,thumbnail_url:X.thumbnailUrl,preview_url:X.previewUrl,duration_seconds:X.duration,file_size_mb:X.fileSizeMb,title:ce||"Quick Video Touch",notes:ye,task_id:a||null,status:"ready"});_e(rt.id),Ae(rt.share_token||null),Me&&await f.mutateAsync({contactId:Me,videoId:rt.id,notes:ye}),r({title:"Video saved successfully!"}),b("share")}catch(Me){console.error("Save video error:",Me),r({title:"Failed to save video",description:(Me==null?void 0:Me.message)||"Please try again.",variant:"destructive"})}},Te=(Me,rt)=>{navigator.clipboard.writeText(rt),Ce(Me),setTimeout(()=>Ce(null),2e3),r({title:"Copied to clipboard!"})},pt=()=>$e?`https://video.relevelup.com/${$e}`:(X==null?void 0:X.playbackUrl)||"",fe=()=>{const Me=u==null?void 0:u.find(Ze=>Ze.id===re),rt=Me?`${Me.first_name}`:"",He=(Me==null?void 0:Me.phone)||"",ct=(Me==null?void 0:Me.email)||"",Ue=pt();return{text:`Hey${rt?` ${rt}`:""}! I recorded a quick video for you: ${Ue}`,link:Ue,contactPhone:He,contactEmail:ct}},qe=()=>{const{text:Me,contactPhone:rt}=fe(),He=rt?`sms:${rt}?body=${encodeURIComponent(Me)}`:`sms:?body=${encodeURIComponent(Me)}`;window.open(He,"_self")},at=()=>{const{link:Me,contactEmail:rt}=fe(),He="Check out this video",ct=`I recorded a quick video for you: ${Me}`,Ue=rt?`mailto:${rt}?subject=${encodeURIComponent(He)}&body=${encodeURIComponent(ct)}`:`mailto:?subject=${encodeURIComponent(He)}&body=${encodeURIComponent(ct)}`;window.open(Ue,"_self")};return o?e.jsx(Ms,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"QuickVid"}),e.jsx("p",{className:"text-muted-foreground",children:"Record a personal video message"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>t("/mission-control/video-library"),className:"gap-1.5",children:[e.jsx(Sn,{className:"h-4 w-4"}),"Video Library"]}),c&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-warning",children:["Storage: ",i.toFixed(0),"% used"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.toFixed(0)," MB remaining"]})]})]})]}),g==="record"&&e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx(yme,{maxDurationSeconds:60,onRecordingComplete:Le,onRecordingStateChange:I,className:"w-full",teleprompterContent:w&&_&&e.jsx(olt,{text:_,isVisible:w,onToggleVisibility:()=>N(!1),isRecording:L,startCountdown:!0})}),!w&&_&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>N(!0),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Er,{placeholder:"Type or paste your script here...",value:_,onChange:Me=>j(Me.target.value),rows:6}),e.jsxs(eE,{open:S,onOpenChange:M,children:[e.jsx(rNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(vC,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(tE,{className:"p-4 border-b",children:e.jsx(sE,{children:"Select a Script"})}),e.jsx(fjs,{onSelectScript:Me=>{j(Me.text),M(!1),N(!0)},className:"h-[calc(100vh-80px)]"})]})]}),_&&e.jsx(K,{className:"w-full",onClick:()=>N(!0),children:"Use Script"})]})]})]}),g==="uploading"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center",children:[e.jsx(li,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-pulse"}),e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Uploading Video..."}),e.jsx(Bi,{value:U,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[U.toFixed(0),"%"]})]})}),g==="processing"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center space-y-4",children:[e.jsx(ws,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-spin"}),e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Processing Video..."}),e.jsx(Bi,{value:V,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[V.toFixed(0),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:`This usually takes 30-60 seconds. If it takes longer, we'll auto-save your video and you can find it in your Video Library — look for the "processing" badge.`})]})}),g==="details"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Video Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:ce,onChange:Me=>ge(Me.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Attach to Contact (Optional)"}),e.jsxs(Ks,{value:re,onValueChange:oe,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"No contact - use anywhere"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Bo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(Me=>e.jsx(Mt,{value:Me.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4"}),Me.first_name," ",Me.last_name]})},Me.id))]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Notes"}),e.jsx(Er,{value:ye,onChange:Me=>ue(Me.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:tt,disabled:p.isPending,children:[p.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),g==="share"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(va,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(K,{variant:"outline",className:"justify-start",onClick:qe,children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:at,children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>Te("link",fe().link),children:[e.jsx(Bo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Ie==="link"&&e.jsx(va,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>we(!0),children:[e.jsx(ic,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(K,{onClick:()=>{b("record"),q(null),ee(null),ie(null)},children:"Record Another"})]})]})]}),pe&&$e&&e.jsx(llt,{open:xe,onOpenChange:we,video:{id:pe,share_token:$e,title:ce||null,contact_id:re||null,thumbnail_url:(X==null?void 0:X.thumbnailUrl)||null},contactName:((et=u==null?void 0:u.find(Me=>Me.id===re))==null?void 0:et.first_name)||null})]})}):e.jsx(Ms,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(Ku,{className:"h-16 w-16 text-destructive mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Storage Limit Reached"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"You've reached your video storage limit. Delete videos from your library to record more."}),e.jsx(K,{onClick:()=>t("/mission-control/video-library"),children:"Open Video Library"})]})})}function yjs({open:t,onOpenChange:s}){const{data:r}=Gm(),{data:n}=Whe(),a=CC(),o=k.useRef(null),[l,i]=k.useState(null),[c,u]=k.useState(""),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(!1),[w,N]=k.useState(0),[S,M]=k.useState("idle"),L=(n==null?void 0:n.total_storage_mb)||0,O=((n==null?void 0:n.max_storage_mb)||1024)-L,q=Y=>{var X;const Q=(X=Y.target.files)==null?void 0:X[0];if(!Q)return;if(!Q.type.startsWith("video/")){me.error("Please select a video file");return}const ee=Q.size/(1024*1024);if(ee>500){me.error("Video file must be less than 500MB");return}if(ee>O){me.error(`Not enough storage. You have ${O.toFixed(1)} MB remaining.`);return}i(Q),c||u(Q.name.replace(/\.[^/.]+$/,""))},U=async()=>{if(!l){me.error("Please select a video file");return}j(!0),N(0),M("creating");try{const{data:Y,error:Q}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:c||l.name,isAgentVideo:!0}});if(Q)throw new Error(Q.message);const{videoId:ee,libraryId:X}=Y;M("uploading");const{data:ie,error:re}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ee,isAgentVideo:!0}});if(re)throw new Error(re.message);await new Promise((ge,ye)=>{const ue=new XMLHttpRequest;ue.upload.addEventListener("progress",pe=>{if(pe.lengthComputable){const _e=Math.round(pe.loaded/pe.total*100);N(_e)}}),ue.addEventListener("load",()=>{ue.status>=200&&ue.status<300?ge():ye(new Error(`Upload failed with status ${ue.status}`))}),ue.addEventListener("error",()=>ye(new Error("Upload failed"))),ue.open("PUT",ie.uploadUrl),ue.setRequestHeader("AccessKey",ie.apiKey),ue.send(l)}),M("processing");const oe=l.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${X}/${ee}`;await a.mutateAsync({bunny_video_id:ee,playback_url:ce,file_size_mb:oe,title:c||l.name,notes:p||void 0,contact_id:g||void 0,status:"processing",touch_type:"video_upload"}),me.success("Video uploaded successfully! Processing may take a few minutes."),B()}catch(Y){console.error("Upload error:",Y),me.error(Y instanceof Error?Y.message:"Failed to upload video")}finally{j(!1),M("idle")}},B=()=>{_||(i(null),u(""),f(""),b(""),N(0),M("idle"),s(!1))},V=()=>{switch(S){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${w}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(fs,{open:t,onOpenChange:B,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Upload Video"}),e.jsx(Gr,{children:"Upload a video file from your device to your video library."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Video File"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(An,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:l.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(l.size/(1024*1024)).toFixed(1)," MB"]})]}),!_&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Y=>{Y.stopPropagation(),i(null)},children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var Y;return(Y=o.current)==null?void 0:Y.click()},children:[e.jsx(li,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:o,type:"file",accept:"video/*",className:"hidden",onChange:q,disabled:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",value:c,onChange:Y=>u(Y.target.value),placeholder:"Enter video title",disabled:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Associate with Contact (optional)"}),e.jsxs(Ks,{value:g||"__none__",onValueChange:Y=>b(Y==="__none__"?"":Y),disabled:_,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select a contact"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(Y=>e.jsxs(Mt,{value:Y.id,children:[Y.first_name," ",Y.last_name||""]},Y.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Er,{id:"notes",value:p,onChange:Y=>f(Y.target.value),placeholder:"Add any notes about this video",rows:2,disabled:_})]}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:V()})]}),e.jsx(Bi,{value:S==="uploading"?w:S==="processing"?100:10})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:B,disabled:_,children:"Cancel"}),e.jsx(K,{onClick:U,disabled:!l||_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function vjs(t){return mt({queryKey:["video-share-recipients",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("video_share_recipients").select("*").eq("video_id",t).order("sent_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function bjs(){const{user:t}=Ds();return mt({queryKey:["video-share-stats",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await H.from("video_share_recipients").select("*").eq("owner_user_id",t.id);if(r)throw r;const n=s;return{totalSent:n.length,totalOpened:n.filter(a=>a.opened_at).length,totalClicked:n.filter(a=>a.clicked_at).length,totalWatched:n.filter(a=>a.watched_at).length,openRate:n.length>0?Math.round(n.filter(a=>a.opened_at).length/n.length*100):0,clickRate:n.length>0?Math.round(n.filter(a=>a.clicked_at).length/n.length*100):0,watchRate:n.length>0?Math.round(n.filter(a=>a.watched_at).length/n.length*100):0}},enabled:!!(t!=null&&t.id)})}function _js(){const{user:t}=Ds();return mt({queryKey:["video-share-history",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await H.from("video_share_recipients").select(` *, agent_videos!inner(id, title, thumbnail_url, share_token, duration_seconds) `).eq("owner_user_id",t.id).order("sent_at",{ascending:!1}).limit(200);if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function wjs(){const{user:t}=Ds(),s=Qt();return Lt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await H.from("video_share_recipients").insert([{video_id:r.video_id,owner_user_id:t.id,recipient_email:r.recipient_email,recipient_name:r.recipient_name||null,contact_id:r.contact_id||null,sent_via:r.sent_via||"gmail",share_token:"placeholder"}]).select().single();if(a)throw a;return n},onSuccess:r=>{s.invalidateQueries({queryKey:["video-share-recipients",r.video_id]}),s.invalidateQueries({queryKey:["video-share-stats"]}),s.invalidateQueries({queryKey:["video-share-history"]})}})}function jjs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function Njs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function kjs({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=k.useState([]),[c,u]=k.useState(null),[p,f]=k.useState(!1),[g,b]=k.useState(!1),[_,j]=k.useState(""),[w,N]=k.useState(""),[S,M]=k.useState(""),[L,I]=k.useState(!1),O=wjs(),q=r.share_token?`https://video.relevelup.com/share/video/${r.share_token}`:"",U=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:a||r.thumbnail_url||"",B=r.title||"Video Message";k.useEffect(()=>{t&&l.length===0&&V()},[t]),k.useEffect(()=>{if(t&&(N(`I recorded a video for you — ${B}`),M("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),j(""),r.contact_id)){const re=l.find(oe=>oe.id===r.contact_id);re&&(u(re),j(re.email||""))}},[t,r.contact_id,l]);const V=async()=>{b(!0);try{const{data:re,error:oe}=await H.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(oe)throw oe;i(re||[])}catch{console.error("Failed to fetch contacts")}finally{b(!1)}},Y=re=>{u(re),f(!1),j(re.email||""),M(`Hey ${re.first_name}! I recorded a quick video just for you. Click below to watch it:`),N(`I recorded a video for you — ${B}`)},Q=()=>{u(null),j(""),M("Hey! I recorded a quick video just for you. Click below to watch it:")},ee=re=>`${re.first_name} ${re.last_name||""}`.trim(),X=re=>{const oe=S.split(/\n\n+/).map(ye=>`

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

`).join(""),ce=re?Njs(re):q,ge=re?``:"";return`
${oe}

▶ Watch Video

${ge}
`},ie=async()=>{if(!_){me.error("Please enter a recipient email");return}if(!q){me.error("Video does not have a share link");return}I(!0);try{let re;try{const ye=c?ee(c):_.split("@")[0];re=(await O.mutateAsync({video_id:r.id,recipient_email:_,recipient_name:ye,contact_id:(c==null?void 0:c.id)||null,sent_via:"gmail"})).share_token}catch(ye){console.warn("Failed to create tracking record, sending without tracking:",ye)}const oe=X(re),{data:ce,error:ge}=await H.functions.invoke("gmail-send",{body:{to:_,subject:w,body:oe,contactId:(c==null?void 0:c.id)||null}});if(ge)throw ge;if(!(ce!=null&&ce.success))throw new Error((ce==null?void 0:ce.error)||"Failed to send");me.success("Video email sent!"),s(!1),o==null||o()}catch(re){console.error("Gmail send error:",re),me.error("Failed to send: "+(re instanceof Error?re.message:"Unknown error"))}finally{I(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5 text-red-500"}),"Send Video via Gmail"]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:n})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($o,{open:p,onOpenChange:f,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[c?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),ee(c),c.email&&e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",c.email,")"]})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Dx,{children:[e.jsx(Ox,{placeholder:"Search contacts..."}),e.jsxs(Rx,{children:[e.jsx(Fx,{children:g?"Loading...":"No contacts found."}),e.jsx(zx,{children:l.filter(re=>re.email).map(re=>e.jsxs(bp,{value:`${re.first_name} ${re.last_name||""} ${re.email||""}`,onSelect:()=>Y(re),children:[e.jsx(va,{className:It("mr-2 h-4 w-4",(c==null?void 0:c.id)===re.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ee(re)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:re.email})]})]},re.id))})]})]})})]}),c&&e.jsx(K,{variant:"ghost",size:"icon",onClick:Q,className:"shrink-0",children:e.jsx(Rr,{className:"h-4 w-4"})})]})]}),!c&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(ze,{id:"video-to",value:_,onChange:re=>j(re.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(rl,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"video-subject",children:"Subject"}),e.jsx(ze,{id:"video-subject",value:w,onChange:re=>N(re.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Er,{id:"video-message",value:S,onChange:re=>M(re.target.value),rows:4,className:"resize-y"})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Video Preview (embedded in email)"}),e.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-black",style:{maxWidth:320},children:[U?e.jsx("img",{src:U,alt:B,className:"w-full aspect-video object-cover"}):e.jsx("div",{className:"w-full aspect-video flex items-center justify-center bg-muted",children:e.jsx(nl,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 rounded-full bg-white/80 flex items-center justify-center shadow",children:e.jsx(nl,{className:"h-5 w-5 text-primary ml-0.5"})})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will see the thumbnail with a play button. Clicking opens the video page."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:L,children:"Cancel"}),e.jsxs(K,{onClick:ie,disabled:L||!_||!w,className:"gap-2",children:[L?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),L?"Sending...":"Send Video Email"]})]})]})]})})}const Sjs=()=>{const{user:t}=Ds();return mt({queryKey:["team-videos",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.rpc("get_team_videos",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function Cjs({recipient:t}){return t.watched_at?e.jsxs(st,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(nl,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(st,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(wh,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(st,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(Ln,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(st,{variant:"outline",className:"text-[10px]",children:[e.jsx(Bn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function Mjs({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=vjs(r);return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(No,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(ys,{className:"h-12 w-full"},i))}):a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No recipients tracked for this video yet."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{className:"text-center p-2 rounded-lg bg-muted/50",children:[e.jsx("div",{className:"text-lg font-bold",children:a.length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Sent"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-amber-50",children:[e.jsx("div",{className:"text-lg font-bold text-amber-700",children:a.filter(l=>l.opened_at).length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Opened"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-blue-50",children:[e.jsx("div",{className:"text-lg font-bold text-blue-700",children:a.filter(l=>l.clicked_at).length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Clicked"})]})]}),e.jsx(Gi,{className:"h-[400px]",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Recipient"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Sent"}),e.jsx(St,{children:"Last Activity"})]})}),e.jsx(zn,{children:a.map(l=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.recipient_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.recipient_email})]})}),e.jsx(dt,{children:e.jsx(Cjs,{recipient:l})}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:ms(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:l.last_activity_at?Uc(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function Tjs(){const{data:t,isLoading:s}=bjs(),{data:r=[],isLoading:n}=_js(),[a,o]=k.useState(null),l=s||n,i=r.reduce((c,u)=>{const p=u.agent_videos,f=(p==null?void 0:p.id)||u.video_id;return c[f]||(c[f]={videoId:f,title:(p==null?void 0:p.title)||"Untitled",thumbnailUrl:p==null?void 0:p.thumbnail_url,recipients:[]}),c[f].recipients.push(u),c},{});return l?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((c,u)=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(ys,{className:"h-8 w-16"})})]},u))})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(Bn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(Ln,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.openRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalOpened)||0," opened"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(wh,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.clickRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalClicked)||0," clicked"]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(gr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Oe,{children:Object.keys(i).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No tracked sends yet. Send a video via Gmail to start tracking."}):e.jsx("div",{className:"space-y-2",children:Object.values(i).map(c=>{const u=c.recipients.filter(f=>f.opened_at).length,p=c.recipients.filter(f=>f.clicked_at).length;return e.jsxs("button",{onClick:()=>o({id:c.videoId,title:c.title}),className:"w-full flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-left",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:c.thumbnailUrl?e.jsx("img",{src:c.thumbnailUrl,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer",onError:f=>{const g=f.currentTarget;g.style.display="none",g.parentElement.innerHTML='
'}}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:c.title}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Bn,{className:"h-3 w-3"})," ",c.recipients.length]}),e.jsxs("span",{className:"text-xs text-amber-600 flex items-center gap-1",children:[e.jsx(Ln,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(wh,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(ul,{className:"h-4 w-4 text-muted-foreground"})]},c.videoId)})})})]}),e.jsx(Mjs,{open:!!a,onOpenChange:c=>!c&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function Ajs({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=k.useState(!1),[l,i]=k.useState(!1),c=n&&t&&!a,u=s&&!l;return!u&&!c?e.jsx("div",{className:"w-full h-full flex items-center justify-center absolute inset-0 bg-muted",children:e.jsx(An,{className:"h-12 w-12 text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[u&&e.jsx("img",{src:s,alt:r,loading:"lazy",className:`w-full h-full object-cover absolute inset-0 transition-opacity duration-200 ${c?"opacity-0":"opacity-100"}`,onError:()=>i(!0)}),c&&e.jsx("img",{src:t,alt:r,className:"w-full h-full object-cover absolute inset-0",onError:()=>o(!0)})]})}function Ejs({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:c,onEmbedToCrm:u,onShareWithTemplate:p,onSendViaGmail:f,isGmailConnected:g,getContactName:b,getShareUrl:_,copyToClipboard:j,formatDuration:w}){const[N,S]=k.useState(!1);return e.jsxs(Ee,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(Ajs,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:N}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-white/90 flex items-center justify-center",children:e.jsx(nl,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:w(t.duration_seconds)}),t.status!=="ready"&&e.jsx(st,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(to,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:b(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),e.jsx("span",{children:ms(new Date(t.created_at),"MMM d, yyyy")})]}),(t.view_count??0)>0&&e.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[e.jsx(Ln,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),g&&t.share_token&&e.jsxs(K,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:M=>{M.stopPropagation(),f==null||f()},children:[e.jsx(cr,{className:"h-3 w-3"}),"Send via Gmail"]}),e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(to,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:b(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),e.jsx("span",{children:ms(new Date(t.created_at),"MMM d, yyyy")})]}),(t.view_count??0)>0&&e.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[e.jsx(Ln,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:M=>M.stopPropagation(),children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",className:"bg-popover",children:[e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),n()},children:[e.jsx(Ln,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(uw,{}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),p()},children:[e.jsx(ic,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),j(_(t),"Share link")},children:[e.jsx(Bo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),i()},children:[e.jsx(Q4,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),c()},children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),u()},children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),g&&t.share_token&&e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),f==null||f()},children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),o()},children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(uw,{}),t.contact_id&&e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),l()},children:[e.jsx(to,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Ma,{onClick:M=>{M.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function Pjs(){var it,Dt;const t=fr(),{data:s,isLoading:r,refetch:n}=s_s(),{data:a}=Whe(),{data:o}=Gm(),l=a_s(),i=n_s(),{isGmailConnected:c,gmailEmail:u}=Gx(),{data:p}=$x(),{data:f=[],isLoading:g}=Sjs(),[b,_]=k.useState("my"),[j,w]=k.useState(""),[N,S]=k.useState(null),[M,L]=k.useState(!1),[I,O]=k.useState(!1),[q,U]=k.useState(!1),[B,V]=k.useState(!1),[Y,Q]=k.useState(!1),[ee,X]=k.useState(""),[ie,re]=k.useState(!1),[oe,ce]=k.useState(!1),[ge,ye]=k.useState(!1),[ue,pe]=k.useState(!1),[_e,$e]=k.useState(""),[Ae,Ie]=k.useState({}),Ce=Vt=>{if(!Vt)return"Unassigned";const hs=o==null?void 0:o.find(Ts=>Ts.id===Vt);return hs?`${hs.first_name} ${hs.last_name||""}`.trim():"Unknown"},xe=Vt=>{if(!Vt)return"0:00";const hs=Math.floor(Vt/60),Ts=Vt%60;return`${hs}:${Ts.toString().padStart(2,"0")}`},we=s==null?void 0:s.filter(Vt=>{if(!j)return!0;const hs=Ce(Vt.contact_id).toLowerCase(),Ts=(Vt.title||"").toLowerCase(),Cs=(Vt.notes||"").toLowerCase();return hs.includes(j.toLowerCase())||Ts.includes(j.toLowerCase())||Cs.includes(j.toLowerCase())}),[Le,tt]=k.useState(!1);k.useEffect(()=>{if(Le)return;(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(Cs=>Cs.status==="processing"&&Cs.bunny_video_id);if(!hs.length)return;let Ts=!1;for(const Cs of hs)try{const{data:cs,error:er}=await H.functions.invoke("bunny-upload",{body:{action:"status",videoId:Cs.bunny_video_id,isAgentVideo:!0}});if(er||!cs)continue;cs.status===4&&(await H.from("agent_videos").update({status:"ready",playback_url:cs.directPlayUrl,thumbnail_url:cs.thumbnailUrl,preview_url:cs.previewUrl,duration_seconds:cs.length||Cs.duration_seconds,updated_at:new Date().toISOString()}).eq("id",Cs.id),Ts=!0)}catch(cs){console.warn("Reconcile check failed for video",Cs.id,cs)}tt(!0),Ts&&n()})()},[s,Le,n]),k.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(xt=>(xt==null?void 0:xt.bunny_video_id)&&!Ae[xt.id]);if(!hs.length)return;const Ts=hs.map(xt=>xt.bunny_video_id),{data:Cs,error:cs}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Ts,isAgentVideo:!0}});if(cs)throw cs;const er=(Cs==null?void 0:Cs.assets)||{};Ie(xt=>{const Es={...xt};for(const ur of hs)er[ur.bunny_video_id]&&(Es[ur.id]={previewUrl:er[ur.bunny_video_id].previewUrl,thumbnailUrl:er[ur.bunny_video_id].thumbnailUrl});return Es})})().catch(hs=>console.warn("Failed to load signed Bunny asset URLs",hs))},[s,Ae]);const Te=(a==null?void 0:a.total_storage_mb)||0,pt=(a==null?void 0:a.max_storage_mb)||1024,fe=Te/pt*100,qe=fe>=80,at=fe>=100,et=async(Vt,hs)=>{await navigator.clipboard.writeText(Vt),me.success(`${hs} copied to clipboard`)},Me=Vt=>Vt.share_token?`https://video.relevelup.com/${Vt.share_token}`:Vt.playback_url||"",rt=Vt=>{const hs=Me(Vt),Ts=o==null?void 0:o.find(ur=>ur.id===Vt.contact_id),Cs=Ce(Vt.contact_id),cs=Cs!=="Unassigned"?Cs.split(" ")[0]:"",er=(Ts==null?void 0:Ts.phone)||"",xt=`Hey${cs?` ${cs}`:""}! I recorded a quick video message for you. Check it out: ${hs}`,Es=er?`sms:${er}?body=${encodeURIComponent(xt)}`:`sms:?body=${encodeURIComponent(xt)}`;window.open(Es,"_self")},He=Vt=>{const hs=o==null?void 0:o.find(Es=>Es.id===Vt.contact_id),Ts=(hs==null?void 0:hs.email)||"",Cs=Me(Vt),cs="Check out this video",er=`I recorded a quick video for you: ${Cs}`,xt=Ts?`mailto:${Ts}?subject=${encodeURIComponent(cs)}&body=${encodeURIComponent(er)}`:`mailto:?subject=${encodeURIComponent(cs)}&body=${encodeURIComponent(er)}`;window.open(xt,"_self")},ct=Vt=>{var cs;const hs=Me(Vt),Ts=Vt.title||"Video Message",Cs=Vt.share_token?`https://video.relevelup.com/thumb/${Vt.share_token}`:((cs=Ae[Vt.id])==null?void 0:cs.thumbnailUrl)||Vt.thumbnail_url||"";return``},Ue=async Vt=>{if(!Vt.thumbnail_url&&!Vt.share_token){me.error("Video thumbnail not available yet");return}const hs=ct(Vt),Ts=Me(Vt),Cs=`Watch: ${Vt.title||"Video Message"} ${Ts}`;try{const cs=new Blob([hs],{type:"text/html"}),er=new Blob([Cs],{type:"text/plain"}),xt=new ClipboardItem({"text/html":cs,"text/plain":er});await navigator.clipboard.write([xt]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(Cs+` `+hs),me.success("Copied! Paste into your email.")}},Ze=async Vt=>{try{me.loading("Preparing download...",{id:"download"});const{data:hs,error:Ts}=await H.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Vt.bunny_video_id,isAgentVideo:!0}});if(Ts||!(hs!=null&&hs.downloadUrl))throw new Error((Ts==null?void 0:Ts.message)||"Failed to get download URL");const cs=`${((Vt.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,er=await fetch(hs.downloadUrl);if(!er.ok)throw new Error("Failed to fetch video file");const xt=await er.blob(),Es=URL.createObjectURL(xt),ur=document.createElement("a");ur.href=Es,ur.download=cs,ur.rel="noreferrer",document.body.appendChild(ur),ur.click(),ur.remove(),URL.revokeObjectURL(Es),me.success("Download started",{id:"download"})}catch(hs){console.error("Download error:",hs),me.error("Could not force download (your browser may block it).",{id:"download"})}},Qe=async Vt=>{S(Vt),re(!0),X(""),Q(!0);try{const{data:hs,error:Ts}=await H.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Vt.bunny_video_id,title:Vt.title,isAgentVideo:!0,shareToken:Vt.share_token}});if(Ts||!(hs!=null&&hs.html))throw new Error("Failed to generate CRM embed code");X(hs.html)}catch(hs){console.error("CRM embed error:",hs),me.error("Failed to generate CRM embed code"),Q(!1)}finally{re(!1)}},We=Vt=>{S(Vt),L(!0)},Je=async()=>{if(N)try{await l.mutateAsync({id:N.id,bunnyVideoId:N.bunny_video_id,hardDelete:!0}),O(!1),S(null),me.success("Video deleted successfully")}catch{me.error("Failed to delete video")}};return e.jsx(Ms,{title:"Video Library",description:"Manage your video touches",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Video Library"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage and share your video touches"})]}),e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>_("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${b==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),p&&((it=p.team)==null?void 0:it.shared_videos_enabled)&&e.jsxs("button",{onClick:()=>_("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${b==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(pr,{className:"h-3.5 w-3.5"}),"Team"]}),e.jsxs("button",{onClick:()=>_("analytics"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${b==="analytics"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(No,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),b==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>U(!0),children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),b==="team"?e.jsx(Ijs,{videos:f,isLoading:g,searchTerm:j,setSearchTerm:w}):b==="analytics"?e.jsx(Tjs,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:qe?"border-amber-500":at?"border-destructive":"",children:e.jsxs(Oe,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(dL,{className:`h-5 w-5 ${at?"text-destructive":qe?"text-amber-500":"text-muted-foreground"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"Storage Used"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[Te.toFixed(1)," MB / ",pt>=1024?`${(pt/1024).toFixed(0)} GB`:`${pt} MB`]})]}),e.jsx(Bi,{value:Math.min(fe,100),className:`h-2 ${at?"[&>div]:bg-destructive":qe?"[&>div]:bg-amber-500":""}`})]}),qe&&!at&&e.jsxs(st,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(kl,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),at&&e.jsxs(st,{variant:"destructive",children:[e.jsx(kl,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),at&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:"You've reached your storage limit. Delete videos to record more."})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos by contact, title, or notes...",value:j,onChange:Vt=>w(Vt.target.value),className:"pl-10"})]}),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):(we==null?void 0:we.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(An,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No videos yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Record your first video touch to get started"}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Record Video"]})]})}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:we==null?void 0:we.map(Vt=>{var hs,Ts;return e.jsx(Ejs,{video:Vt,previewSrc:(hs=Ae[Vt.id])==null?void 0:hs.previewUrl,thumbnailSrc:(Ts=Ae[Vt.id])==null?void 0:Ts.thumbnailUrl,onOpen:()=>We(Vt),onDelete:()=>{S(Vt),O(!0)},onRename:()=>{S(Vt),$e(Vt.title||""),pe(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Vt.contact_id}`),onGetEmbedCode:()=>{S(Vt),V(!0)},onCopyEmailHtml:()=>Ue(Vt),onEmbedToCrm:()=>Qe(Vt),onShareWithTemplate:()=>{S(Vt),ce(!0)},onSendViaGmail:()=>{S(Vt),ye(!0)},isGmailConnected:c,getContactName:Ce,getShareUrl:Me,copyToClipboard:et,formatDuration:xe},Vt.id)})}),e.jsx(fs,{open:M,onOpenChange:L,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:(N==null?void 0:N.title)||"Video Preview"}),e.jsx(Gr,{children:(N==null?void 0:N.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(to,{className:"h-3 w-3"}),Ce(N.contact_id)]})})]}),N&&e.jsxs("div",{className:"space-y-4",children:[N.status==="processing"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6 bg-muted/50 rounded-lg border border-dashed border-border text-center space-y-4",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(ws,{className:"h-8 w-8 text-primary animate-spin"})})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Video is still processing"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:"Your video is being encoded and will be ready shortly. This usually takes 1–3 minutes. Check back soon!"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(!1),n()},children:[e.jsx(Go,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:N.playback_url?(()=>{let Vt=N.playback_url;return Vt.includes("iframe.mediadelivery.net/play/")&&(Vt=Vt.replace("/play/","/embed/"),Vt+=(Vt.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Vt.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:Vt,title:N.title||"Video preview",className:"absolute top-0 left-0 w-full h-full rounded-lg",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:N.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:N.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>me.error("Video preview failed to load")},N.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(An,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground ml-2",children:"Video not available"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>rt(N),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!c&&e.jsxs(K,{variant:"outline",onClick:()=>He(N),children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>et(Me(N),"Share link"),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ue(N),children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ze(N),children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),Qe(N)},children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),ce(!0)},children:[e.jsx(ic,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),c&&(N==null?void 0:N.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),ye(!0)},children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(K,{variant:"destructive",onClick:()=>{L(!1),O(!0)},children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(fs,{open:I,onOpenChange:O,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Delete Video"}),e.jsx(Gr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Je,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(yjs,{open:q,onOpenChange:U}),e.jsx(fs,{open:B,onOpenChange:V,children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Embed Video"}),e.jsx(Gr,{children:"Copy this code to embed the video on your website."})]}),N&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Embed Code"}),e.jsx(Er,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{className:"flex-1",onClick:()=>{const Vt=``;et(Vt,"Embed code")},children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Embed Code"]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste this code into your website's HTML where you want the video to appear. The video will automatically resize to fit its container."})]})]})}),N&&e.jsx(llt,{open:oe,onOpenChange:ce,video:N,contactName:Ce(N.contact_id)}),N&&e.jsx(kjs,{open:ge,onOpenChange:ye,video:N,gmailEmail:u,signedThumbnailUrl:(Dt=Ae[N.id])==null?void 0:Dt.thumbnailUrl}),e.jsx(fs,{open:ue,onOpenChange:pe,children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Rename Video"}),e.jsx(Gr,{children:"Enter a new title for this video."})]}),e.jsx(ze,{value:_e,onChange:Vt=>$e(Vt.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Vt=>{Vt.key==="Enter"&&_e.trim()&&i.mutate({id:N.id,title:_e.trim()},{onSuccess:()=>{me.success("Video renamed"),pe(!1)}})}}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>pe(!1),children:"Cancel"}),e.jsx(K,{disabled:!_e.trim()||i.isPending,onClick:()=>{i.mutate({id:N.id,title:_e.trim()},{onSuccess:()=>{me.success("Video renamed"),pe(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:Y,onOpenChange:Q,children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(tn,{className:"h-5 w-5"}),"Embed to CRM"]}),e.jsx(Gr,{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."})]}),ie?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):ee?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"CRM Email HTML"}),e.jsx(Er,{readOnly:!0,rows:12,value:ee,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{et(ee,"CRM embed code")},children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy CRM Embed Code"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste this into your CRM's email HTML editor. The recipient will see the video thumbnail and can click to watch. Works with Follow Up Boss, KvCORE, BoomTown, Sierra, and more."})]}):null]})})]})]})})}function Ijs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=k.useMemo(()=>{if(!r)return t;const i=r.toLowerCase();return t.filter(c=>(c.title||"").toLowerCase().includes(i)||(c.owner_name||"").toLowerCase().includes(i)||(c.recipient_name||"").toLowerCase().includes(i))},[t,r]),o=k.useMemo(()=>{const i=new Map;return a.forEach(c=>{const u=i.get(c.owner_user_id);u?u.videos.push(c):i.set(c.owner_user_id,{name:c.owner_name,avatar:c.owner_avatar_url,videos:[c]})}),Array.from(i.entries())},[a]),l=i=>{if(!i)return"0:00";const c=Math.floor(i/60),u=i%60;return`${c}:${u.toString().padStart(2,"0")}`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search team videos by title, owner, or recipient...",value:r,onChange:i=>n(i.target.value),className:"pl-10"})]}),s?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):a.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(pr,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No team videos"}),e.jsx("p",{className:"text-muted-foreground",children:t.length===0?"Your teammates haven't recorded any videos yet.":"No videos match your search."})]})}):e.jsx("div",{className:"space-y-6",children:o.map(([i,c])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-7 w-7",children:[e.jsx($a,{src:c.avatar||""}),e.jsx(kn,{children:(c.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:c.name}),e.jsx(st,{variant:"secondary",className:"text-xs",children:c.videos.length})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.videos.map(u=>e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center",children:[u.thumbnail_url?e.jsx("img",{src:u.thumbnail_url,alt:u.title||"Video",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:p=>{p.target.style.display="none"}}):e.jsx(An,{className:"h-10 w-10 text-muted-foreground"}),u.duration_seconds&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:l(u.duration_seconds)})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:u.title||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[u.recipient_name&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(to,{className:"h-3 w-3"}),u.recipient_name]}),u.view_count!=null&&u.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ln,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const Ljs=()=>{const{user:t}=Ds();return mt({queryKey:["team-deals",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.rpc("get_team_deals",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},dze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Djs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Ljs(),[a,o]=k.useState(""),[l,i]=k.useState("all"),c=k.useMemo(()=>{if(!r)return new Map;const _=new Map;let j=0;return r.forEach(w=>{_.has(w.owner_user_id)||(_.set(w.owner_user_id,{name:w.owner_name||"Unknown",avatar:w.owner_avatar_url,color:dze[j%dze.length]}),j++)}),_},[r]),u=k.useMemo(()=>Array.from(c.entries()).map(([_,j])=>({id:_,...j})),[c]),p=k.useMemo(()=>{if(!r)return[];let _=r;if(l!=="all"&&(_=_.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();_=_.filter(w=>{var N,S,M,L;return w.deal_name.toLowerCase().includes(j)||((N=w.contact_name)==null?void 0:N.toLowerCase().includes(j))||((S=w.property_address)==null?void 0:S.toLowerCase().includes(j))||((M=w.city)==null?void 0:M.toLowerCase().includes(j))||((L=w.owner_name)==null?void 0:L.toLowerCase().includes(j))})}return _},[r,a,l]),f=k.useMemo(()=>{const _=new Map;return p.forEach(j=>{const w=j.stage_name||"Unknown";_.has(w)||_.set(w,{name:w,color:j.stage_color,icon:j.stage_icon,deals:[],totalValue:0});const N=_.get(w);N.deals.push(j),N.totalValue+=j.sale_price||0}),Array.from(_.values())},[p]),g=_=>_>=1e6?`$${(_/1e6).toFixed(1)}M`:_>=1e3?`$${(_/1e3).toFixed(0)}K`:`$${_.toFixed(0)}`,b=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):null;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Team Pipeline"]})}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search deals...",value:a,onChange:_=>o(_.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:l,onValueChange:i,children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"All Members"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Members"}),u.map(_=>e.jsx(Mt,{value:_.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full inline-block",style:{backgroundColor:_.color}}),_.name]})},_.id))]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3 ml-auto text-xs text-muted-foreground",children:[u.slice(0,6).map(_=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:_.color}}),_.name.split(" ")[0]]},_.id)),u.length>6&&e.jsxs("span",{children:["+",u.length-6," more"]})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden mt-2",children:n?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(_=>e.jsxs("div",{className:"min-w-[260px] flex-1",children:[e.jsx(ys,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(ys,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(ys,{className:"h-24 w-full rounded-lg"})]},_))}):f.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pr,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No team deals found"}),e.jsx("p",{className:"text-sm",children:"Team members' deals will appear here."})]})}):e.jsx("div",{className:"flex gap-3 h-full overflow-x-auto pb-2",children:f.map(_=>{const j=_.icon&&g2e[_.icon]||_d;return e.jsxs("div",{className:"flex flex-col h-full min-w-[260px] max-w-[300px] flex-1 bg-muted/30 rounded-xl border border-border/50",children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:_.color||"hsl(var(--border))",borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{backgroundColor:_.color?`${_.color}20`:void 0},children:e.jsx(j,{className:"h-3.5 w-3.5",style:{color:_.color||void 0}})}),e.jsx("h3",{className:"font-semibold text-sm",children:_.name})]}),e.jsx(st,{variant:"secondary",className:"text-xs px-2",children:_.deals.length})]}),_.totalValue>0&&e.jsx("p",{className:"text-xs text-muted-foreground ml-8",children:g(_.totalValue)})]}),e.jsx(Gi,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:_.deals.map(w=>{const N=c.get(w.owner_user_id);return e.jsx(Ojs,{deal:w,ownerColor:(N==null?void 0:N.color)||"#888",ownerName:(N==null?void 0:N.name)||"Unknown",ownerAvatar:(N==null?void 0:N.avatar)||null,formatPrice:b},w.id)})})})]},_.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[p.length," deal",p.length!==1?"s":""," across ",f.length," stage",f.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function Ojs({deal:t,ownerColor:s,ownerName:r,ownerAvatar:n,formatPrice:a}){const o={buyer:{label:"Buyer",className:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",className:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",className:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",className:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",className:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},l=t.deal_type?o[t.deal_type]:null;return e.jsxs("div",{className:"rounded-lg border bg-card p-3 space-y-2 transition-all hover:shadow-sm",style:{borderLeftWidth:4,borderLeftColor:s},children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(Nn,{className:"h-4 w-4",children:[e.jsx($a,{src:n||""}),e.jsx(kn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:s},children:r.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium truncate",style:{color:s},children:r})]}),e.jsxs("div",{className:"flex items-start justify-between gap-1",children:[e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2",children:t.deal_name}),l&&e.jsx(st,{variant:"outline",className:It("text-[10px] px-1.5 py-0 shrink-0",l.className),children:l.label})]}),t.contact_name&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.contact_name}),(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(bn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.property_address||`${t.city}, ${t.state}`})]}),t.sale_price&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(ac,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function Rjs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:It("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[e.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(pr,{className:"h-4 w-4 shrink-0 text-primary"}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs font-semibold flex-1 text-left",children:"Team"}),o>0&&e.jsx("span",{className:"text-[10px] bg-primary text-primary-foreground rounded-full px-1.5 py-0.5",children:o}),e.jsx(cl,{className:"h-3 w-3 text-muted-foreground"})]}),!n&&o>0&&e.jsx("span",{className:"absolute -top-1 -right-1 text-[9px] bg-primary text-primary-foreground rounded-full w-4 h-4 flex items-center justify-center",children:o})]})}),n?e.jsxs(Gi,{className:"flex-1 p-2",children:[e.jsx("div",{className:"space-y-1",children:t.map(l=>{const i=s.has(l.id);return e.jsxs("button",{onClick:()=>r(l.id),className:It("w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left transition-colors",i?"bg-primary/10 hover:bg-primary/15":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-7 w-7",children:[e.jsx($a,{src:l.avatar_url||""}),e.jsx(kn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]}),i&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-background",style:{backgroundColor:l.color}})]}),e.jsx("span",{className:It("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(qr,{checked:i,onCheckedChange:()=>r(l.id),className:"scale-75",onClick:c=>c.stopPropagation()})]},l.id)})}),t.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No team members"})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center pt-2 gap-2",children:[t.slice(0,5).map(l=>{const i=s.has(l.id);return e.jsx("button",{onClick:()=>r(l.id),className:"relative",title:l.name,children:e.jsxs(Nn,{className:It("h-7 w-7 transition-all",i?"ring-2 ring-offset-1 ring-offset-background":"opacity-50"),style:i?{"--tw-ring-color":l.color}:{},children:[e.jsx($a,{src:l.avatar_url||""}),e.jsx(kn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]})},l.id)}),t.length>5&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",t.length-5]})]})]})}const uze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Fjs(){const t=ci(),{data:s}=$x(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=mt({queryKey:["team-pipeline-members",n,t],queryFn:async()=>{const{data:o,error:l}=await H.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",t);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(p=>p.user_id),{data:c,error:u}=await H.from("profiles").select("id, name, avatar_url").in("id",i);if(u)throw u;return(c||[]).map((p,f)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:uze[f%uze.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function zjs(t){return mt({queryKey:["team-member-deals",t],queryFn:async()=>{if(t.length===0)return[];const{data:s,error:r}=await H.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at), deal_pipeline_stages(name) `).in("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return(s||[]).map(n=>{var a;return{...n,_stage_name:((a=n.deal_pipeline_stages)==null?void 0:a.name)||null}})},enabled:t.length>0})}function clt({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=k.useState(!1),l=t.find(c=>c.id===s),i=c=>{c.id!==s&&r(c.id,c.name),o(!1)};return e.jsxs(iu,{open:a,onOpenChange:o,children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",disabled:n,onClick:c=>c.stopPropagation(),children:[l&&e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l.color}}),e.jsx("span",{className:"max-w-[80px] truncate",children:(l==null?void 0:l.name)||"Move"}),e.jsx(da,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Bd,{align:"end",className:"w-48 z-50 bg-popover",onClick:c=>c.stopPropagation(),children:t.map(c=>{const u=c.icon&&g2e[c.icon]||_d,p=c.id===s;return e.jsxs(Ma,{onClick:()=>i(c),className:It("flex items-center gap-2 cursor-pointer",p&&"bg-accent"),children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0",style:{backgroundColor:`${c.color}20`},children:e.jsx(u,{className:"h-3 w-3",style:{color:c.color}})}),e.jsx("span",{className:"flex-1",children:c.name}),p&&e.jsx(va,{className:"h-4 w-4 text-primary"})]},c.id)})})]})}const Bjs={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"}},$js={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 dlt({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var S,M;const c=SE(),u=Bjs[t.deal_type],p=$js[t.priority],f=k.useMemo(()=>t.target_close_date?ly(Ol(t.target_close_date),new Date):null,[t.target_close_date]),g=f!==null&&f<0,b=f!==null&&f<=7&&f>=0,_=k.useMemo(()=>{var O;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const L=((O=t.listing)==null?void 0:O.created_at)||t.listing_date;if(!L)return null;const I=t.contract_date?Ol(t.contract_date):new Date;return ly(I,Ol(L))},[t]),j=l&&!t.scorecard_transaction_id,w=!!t.scorecard_transaction_id,N=L=>L?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(L):null;return e.jsx(Ee,{className:It("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",g&&"border-red-200 bg-red-50/30",j&&"border-amber-300 bg-amber-50/30 dark:bg-amber-950/20"),onClick:s,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:e.jsxs(Oe,{className:"p-3 space-y-2.5",children:[i&&e.jsxs("div",{className:"flex items-center gap-1.5 -mt-0.5 mb-1",children:[e.jsxs(Nn,{className:"h-4 w-4",children:[e.jsx($a,{src:i.avatar_url||""}),e.jsx(kn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:i.color},children:i.name.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium",style:{color:i.color},children:i.name})]}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2 group-hover:text-primary transition-colors",children:t.deal_name})}),e.jsx(st,{variant:"outline",className:It("text-[10px] px-1.5 py-0 shrink-0",u.color),children:u.label})]}),t.contact&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Nn,{className:"h-5 w-5",children:e.jsxs(kn,{className:"text-[10px] bg-primary/10 text-primary",children:[(S=t.contact.first_name)==null?void 0:S[0],(M=t.contact.last_name)==null?void 0:M[0]]})}),e.jsxs("span",{className:"truncate",children:[t.contact.first_name," ",t.contact.last_name]})]}),t.listing&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(dl,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),j&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[e.jsx(xo,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),w&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(sa,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:"Synced to Scorecard"})]}),_!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(eL,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:It("font-medium",_>90?"text-red-600":_>60?"text-amber-600":"text-muted-foreground"),children:[_," DOM"]}),t.contract_date&&e.jsx("span",{className:"text-muted-foreground",children:"(final)"})]}),!t.listing&&(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(bn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.property_address||`${t.city}, ${t.state}`})]}),t.expected_price&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(ac,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:N(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",N(t.expected_commission)," GCI"]}),(()=>{const L=vx(t);return L!==null&&L!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",N(L)," Net"]}):null})()]}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:It("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:It("w-1.5 h-1.5 rounded-full",p.dot)}),e.jsx("span",{className:"capitalize",children:t.priority})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.probability,"%"]})]}),o&&c&&n&&a?e.jsx(clt,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(L,I)=>a(t.id,L,I)}):t.target_close_date?e.jsxs("div",{className:It("flex items-center gap-1 text-[10px]",g&&"text-red-600",b&&!g&&"text-amber-600",!g&&!b&&"text-muted-foreground"),children:[g?e.jsx(kl,{className:"h-3 w-3"}):e.jsx(hn,{className:"h-3 w-3"}),e.jsx("span",{children:g?`${Math.abs(f)}d overdue`:b?`${f}d left`:ms(Ol(t.target_close_date),"MMM d")})]}):null]})]})})}function qjs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:c=!1,getOwnerInfo:u}){const p=k.useRef(null),f=s.reduce((w,N)=>w+(N.expected_price||0),0),g=s.reduce((w,N)=>w+(N.expected_commission||0),0),b=s.reduce((w,N)=>w+(vx(N)||0),0),_=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,j=t.icon&&g2e[t.icon]||_d;return e.jsxs("div",{ref:p,className:It("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:w=>o(w,t.id),onDrop:w=>l(w,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(j,{className:"h-4 w-4",style:{color:t.color}})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-sm",children:t.name})})]}),e.jsx(st,{variant:"secondary",className:"text-xs font-medium px-2",children:s.length})]}),f>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-wrap",children:[e.jsx("span",{className:"font-medium text-foreground",children:_(f)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[_(g)," GCI"]}),b>0&&b!==g&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:[_(b)," Net"]})]})]})]}),e.jsx(Gi,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:N=>{N.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx(dlt,{deal:w,onClick:()=>r(w),isWonStage:c,ownerInfo:(u==null?void 0:u(w))||null})},w.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function Ujs({stats:t,isLoading:s}){const r=a=>a>=1e6?`$${(a/1e6).toFixed(1)}M`:a>=1e3?`$${(a/1e3).toFixed(0)}K`:`$${a.toLocaleString()}`,n=[{label:"Active Deals",value:(t==null?void 0:t.activeDeals)||0,icon:zm,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:SL,color:"text-indigo-500",bgColor:"bg-indigo-500/10",tooltip:"GCI adjusted by each deal's win probability"},{label:"Weighted Net",value:r((t==null?void 0:t.weightedNet)||0),icon:zL,color:"text-teal-500",bgColor:"bg-teal-500/10",tooltip:"Net to Agent adjusted by each deal's win probability"},{label:"YTD Closed Net",value:r((t==null?void 0:t.ytdWonNet)||0),icon:JI,color:"text-green-500",bgColor:"bg-green-500/10",subtitle:`${(t==null?void 0:t.ytdWonDeals)||0} deals`,tooltip:"Net commission from deals closed this year"},{label:"Projected Annual",value:r((t==null?void 0:t.projectedAnnualNet)||0),icon:ul,color:"text-amber-500",bgColor:"bg-amber-500/10",tooltip:"YTD Closed Net + Weighted Active Net"}];return s?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[1,2,3,4,5].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(B1,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>{const o=e.jsx(Ee,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:It("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:It("h-5 w-5",a.color)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a.label}),e.jsx("p",{className:"text-xl font-bold",children:a.value}),"subtitle"in a&&a.subtitle&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a.subtitle})]})]})})},a.label);return"tooltip"in a&&a.tooltip?e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:o}),e.jsx(Xl,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function Vjs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Ds(),[a,o]=k.useState(t.portal_enabled);if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 opacity-60",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(st,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Give your clients a premium, real-time view of their transaction — coming soon!"})]});const l=i=>{s({...t,...i})};return e.jsx(yf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(vf,{className:"w-full p-4 flex items-center justify-between hover:bg-muted/50 transition-colors rounded-t-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(st,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Eo,{className:It("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(bf,{children:e.jsxs("div",{className:"px-4 pb-4 space-y-5 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Enable Client Portal"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Create a beautiful portal your client can track their deal from"})]}),e.jsx(qr,{checked:t.portal_enabled,onCheckedChange:i=>l({portal_enabled:i})})]}),t.portal_enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(yNe,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:It("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="private"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(Goe,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Th,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Private"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Link-only access"})]})]}),e.jsxs("label",{className:It("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="public"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(Goe,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(su,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Public"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Shareable link"})]})]})]})]}),e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/30",children:[e.jsx(Oo,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"require_onboarding",className:"text-sm font-medium cursor-pointer",children:"Require client onboarding before portal access"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Client confirms contact details + preferences before viewing portal. Info is saved to your contacts."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oo,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(be,{htmlFor:"allow_spouse",className:"text-sm cursor-pointer",children:"Allow client to add spouse/partner during onboarding"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-sm font-medium",children:"Client Invite Details"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),e.jsx(ze,{value:t.client_name,onChange:i=>l({client_name:i.target.value}),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(ze,{type:"email",value:t.client_email,onChange:i=>l({client_email:i.target.value}),placeholder:"jane@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(ze,{type:"tel",value:t.client_phone,onChange:i=>l({client_phone:i.target.value}),placeholder:"(555) 123-4567"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(Ks,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"email",children:"Email"}),e.jsxs(Mt,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const Hjs=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],Wjs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function Gjs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Ghe(),{data:o}=Gm(),{data:l}=tXe(),i=wue(),c=sit(),u=rit(),p=cSe(),[f,g]=k.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,S]=k.useState(!1),[M,L]=k.useState({first_name:"",last_name:"",email:"",phone:""}),I=(l==null?void 0:l.filter(ee=>((r==null?void 0:r.listing_id)===ee.id,!0)))||[],[O,q]=k.useState({deal_name:"",deal_type:"buyer",stage_id:"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""});k.useEffect(()=>{var ee,X,ie,re,oe,ce,ge,ye;t&&(r?(q({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||"",contact_id:r.contact_id||"",listing_id:r.listing_id||"",property_address:r.property_address||"",city:r.city||"",state:r.state||"",zip_code:r.zip_code||"",expected_price:((ee=r.expected_price)==null?void 0:ee.toString())||"",commission_percentage:((X=r.commission_percentage)==null?void 0:X.toString())||"3",brokerage_split_pct:((ie=r.brokerage_split_pct)==null?void 0:ie.toString())||"",team_split_pct:((re=r.team_split_pct)==null?void 0:re.toString())||"",referral_fee_pct:((oe=r.referral_fee_pct)==null?void 0:oe.toString())||"",franchise_fee_pct:((ce=r.franchise_fee_pct)==null?void 0:ce.toString())||"",transaction_fee:((ge=r.transaction_fee)==null?void 0:ge.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?Ol(r.target_close_date):void 0,contract_date:r.contract_date?Ol(r.contract_date):void 0,listing_date:r.listing_date?Ol(r.listing_date):void 0,priority:r.priority,probability:r.probability.toString(),notes:r.notes||""}),r.contact&&_(`${r.contact.first_name} ${r.contact.last_name}`)):(q({deal_name:"",deal_type:"buyer",stage_id:n||((ye=a==null?void 0:a[0])==null?void 0:ye.id)||"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""}),_(""),g({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"})))},[t,r,n,a]);const U=o==null?void 0:o.filter(ee=>{var ie,re,oe;const X=b.toLowerCase();return((ie=ee.first_name)==null?void 0:ie.toLowerCase().includes(X))||((re=ee.last_name)==null?void 0:re.toLowerCase().includes(X))||((oe=ee.email)==null?void 0:oe.toLowerCase().includes(X))}).slice(0,5),B=()=>{const ee=parseFloat(O.expected_price)||0,X=parseFloat(O.commission_percentage)||0;return ee*(X/100)},V=()=>{const ee=B();if(!ee)return null;const X=parseFloat(O.brokerage_split_pct)||0,ie=parseFloat(O.team_split_pct)||0,re=parseFloat(O.referral_fee_pct)||0,oe=parseFloat(O.franchise_fee_pct)||0,ce=parseFloat(O.transaction_fee)||0;if(O.commission_calc_method==="referral_first"){let ye=ee;re&&(ye-=ee*re/100);let ue=ye;return X&&(ue-=ye*X/100),ie&&(ue-=ee*ie/100),oe&&(ue-=ee*oe/100),ce&&(ue-=ce),Math.max(0,ue)}let ge=ee;return X&&(ge=ge*((100-X)/100)),ie&&(ge=ge*((100-ie)/100)),re&&(ge=ge-ee*re/100),oe&&(ge=ge-ee*oe/100),ce&&(ge=ge-ce),Math.max(0,ge)},Y=async ee=>{var X,ie,re;if(ee.preventDefault(),!O.deal_name.trim()){me.error("Please enter a deal name");return}try{const oe={deal_name:O.deal_name,deal_type:O.deal_type,stage_id:O.stage_id||null,contact_id:O.contact_id||null,listing_id:O.listing_id||null,property_address:O.property_address||null,city:O.city||null,state:O.state||null,zip_code:O.zip_code||null,expected_price:O.expected_price?parseFloat(O.expected_price):null,expected_commission:B()||null,commission_percentage:O.commission_percentage?parseFloat(O.commission_percentage):3,brokerage_split_pct:O.brokerage_split_pct?parseFloat(O.brokerage_split_pct):null,team_split_pct:O.team_split_pct?parseFloat(O.team_split_pct):null,referral_fee_pct:O.referral_fee_pct?parseFloat(O.referral_fee_pct):null,franchise_fee_pct:O.franchise_fee_pct?parseFloat(O.franchise_fee_pct):null,transaction_fee:O.transaction_fee?parseFloat(O.transaction_fee):null,commission_calc_method:O.commission_calc_method,target_close_date:((X=O.target_close_date)==null?void 0:X.toISOString().split("T")[0])||null,contract_date:((ie=O.contract_date)==null?void 0:ie.toISOString().split("T")[0])||null,listing_date:((re=O.listing_date)==null?void 0:re.toISOString().split("T")[0])||null,priority:O.priority,probability:parseInt(O.probability)||50,notes:O.notes||null};if(r)await u.mutateAsync({id:r.id,...oe}),me.success("Deal updated successfully");else{const ce=await c.mutateAsync(oe);if(me.success("Deal created successfully"),f.portal_enabled&&(ce!=null&&ce.id))try{await p.mutateAsync({deal_id:ce.id,visibility:f.visibility,require_onboarding:f.require_onboarding,allow_spouse:f.allow_spouse,client_name:f.client_name||null,client_email:f.client_email||null,client_phone:f.client_phone||null,invite_method:f.invite_method}),me.success("Client portal created!")}catch{me.error("Deal created, but portal setup failed")}}s(!1)}catch{me.error("Failed to save deal")}},Q=c.isPending||u.isPending;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:r?"Edit Deal":"Add New Deal"}),e.jsx(Gr,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:Y,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(be,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(ze,{id:"deal_name",value:O.deal_name,onChange:ee=>q(X=>({...X,deal_name:ee.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Deal Type"}),e.jsxs(Ks,{value:O.deal_type,onValueChange:ee=>q(X=>({...X,deal_type:ee})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Hjs.map(ee=>e.jsx(Mt,{value:ee.value,children:ee.label},ee.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Stage"}),e.jsxs(Ks,{value:O.stage_id||"none",onValueChange:ee=>q(X=>({...X,stage_id:ee==="none"?"":ee})),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select stage"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No Stage"}),a==null?void 0:a.map(ee=>e.jsx(Mt,{value:ee.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:ee.color}}),ee.name]})},ee.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:b,onChange:ee=>{_(ee.target.value),w(!0),S(!1),ee.target.value||q(X=>({...X,contact_id:""}))},onFocus:()=>w(!0),placeholder:"Search contacts...",className:"pl-9"}),j&&b&&e.jsxs("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[U&&U.length>0?U.map(ee=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{q(X=>({...X,contact_id:ee.id})),_(`${ee.first_name} ${ee.last_name}`),w(!1)},children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[ee.first_name," ",ee.last_name]}),ee.email&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:ee.email})]},ee.id)):e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No contacts found"}),e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2 border-t text-primary font-medium",onClick:()=>{const ee=b.trim().split(/\s+/);L({first_name:ee[0]||"",last_name:ee.slice(1).join(" ")||"",email:"",phone:""}),S(!0),w(!1)},children:[e.jsx(Tl,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',b.trim(),'"']})]})]})]}),N&&e.jsxs("div",{className:"border rounded-lg p-3 space-y-3 bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(Tl,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>S(!1),children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{placeholder:"First name *",value:M.first_name,onChange:ee=>L(X=>({...X,first_name:ee.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Last name",value:M.last_name,onChange:ee=>L(X=>({...X,last_name:ee.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Email",type:"email",value:M.email,onChange:ee=>L(X=>({...X,email:ee.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Phone",type:"tel",value:M.phone,onChange:ee=>L(X=>({...X,phone:ee.target.value})),className:"h-8 text-sm"})]}),e.jsx(K,{type:"button",size:"sm",className:"w-full h-8",disabled:!M.first_name.trim()||i.isPending,onClick:async()=>{try{const ee=await i.mutateAsync({first_name:M.first_name.trim(),last_name:M.last_name.trim()||null,email:M.email.trim()||null,phone:M.phone.trim()||null});ee&&(q(X=>({...X,contact_id:ee.id})),_(`${ee.first_name} ${ee.last_name||""}`.trim()),S(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Tl,{className:"h-3.5 w-3.5 mr-1"})," Add & Link Contact"]})})]})]}),I.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(dl,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(Ks,{value:O.listing_id||"none",onValueChange:ee=>{const X=ee==="none"?"":ee,ie=I.find(re=>re.id===X);q(ie?re=>{var oe;return{...re,listing_id:X,deal_type:"seller",property_address:ie.property_address||re.property_address,city:ie.city||re.city,state:ie.state||re.state,expected_price:((oe=ie.price)==null?void 0:oe.toString())||re.expected_price}}:re=>({...re,listing_id:X}))},children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"None"}),I.map(ee=>e.jsx(Mt,{value:ee.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:ee.property_address||`${ee.city}, ${ee.state}`}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["$",(ee.price/1e3).toFixed(0),"K"]})]})},ee.id))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes will sync automatically between the deal and listing."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Property Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(be,{htmlFor:"property_address",children:"Address"}),e.jsx(ze,{id:"property_address",value:O.property_address,onChange:ee=>q(X=>({...X,property_address:ee.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:O.city,onChange:ee=>q(X=>({...X,city:ee.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:O.state,onChange:ee=>q(X=>({...X,state:ee.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(ze,{id:"zip_code",value:O.zip_code,onChange:ee=>q(X=>({...X,zip_code:ee.target.value}))})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Financial Details"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"expected_price",children:"Expected Price"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx(ze,{id:"expected_price",type:"number",value:O.expected_price,onChange:ee=>q(X=>({...X,expected_price:ee.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{id:"commission_percentage",type:"number",step:"0.1",value:O.commission_percentage,onChange:ee=>q(X=>({...X,commission_percentage:ee.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Expected GCI"}),e.jsx(ze,{value:B()?`$${B().toLocaleString()}`:"-",disabled:!0,className:"bg-muted"})]})]}),e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"text-xs font-medium text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-1 py-1",children:[e.jsx("span",{className:"group-open:rotate-90 transition-transform text-[10px]",children:"▶"}),"Commission Splits (optional)"]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/50",children:[e.jsx(be,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs(Ks,{value:O.commission_calc_method,onValueChange:ee=>q(X=>({...X,commission_calc_method:ee})),children:[e.jsx(Hs,{className:"h-7 text-xs",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"standard",children:"Standard (all splits on GCI)"}),e.jsx(Mt,{value:"referral_first",children:"Referral First (brokerage split after referral)"})]})]})]}),O.commission_calc_method==="referral_first"&&e.jsx("p",{className:"text-[10px] text-muted-foreground bg-blue-50 dark:bg-blue-950/30 p-2 rounded",children:"💡 Referral fee is deducted from GCI first, then the brokerage split is applied to the remaining amount."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.brokerage_split_pct,onChange:ee=>q(X=>({...X,brokerage_split_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"30"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to brokerage"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.team_split_pct,onChange:ee=>q(X=>({...X,team_split_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to team lead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.referral_fee_pct,onChange:ee=>q(X=>({...X,referral_fee_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.franchise_fee_pct,onChange:ee=>q(X=>({...X,franchise_fee_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Transaction Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"$"}),e.jsx(ze,{type:"number",step:"1",min:"0",value:O.transaction_fee,onChange:ee=>q(X=>({...X,transaction_fee:ee.target.value})),className:"pl-7 h-8 text-sm",placeholder:"500"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Flat fee deducted"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Net to Agent"}),e.jsx(ze,{value:V()?`$${Math.round(V()).toLocaleString()}`:"-",disabled:!0,className:"bg-muted h-8 text-sm font-semibold"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Dates & Status"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Target Close Date"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O.target_close_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O.target_close_date?ms(O.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:O.target_close_date,onSelect:ee=>q(X=>({...X,target_close_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Contract Date"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O.contract_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O.contract_date?ms(O.contract_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:O.contract_date,onSelect:ee=>q(X=>({...X,contract_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(O.deal_type==="seller"||O.deal_type==="dual")&&!O.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(be,{children:"Listing Date (for Days on Market)"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O.listing_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O.listing_date?ms(O.listing_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:O.listing_date,onSelect:ee=>q(X=>({...X,listing_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used to calculate Days on Market. Auto-filled for linked listings."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Priority"}),e.jsxs(Ks,{value:O.priority,onValueChange:ee=>q(X=>({...X,priority:ee})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Wjs.map(ee=>e.jsx(Mt,{value:ee.value,children:ee.label},ee.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",min:"0",max:"100",value:O.probability,onChange:ee=>q(X=>({...X,probability:ee.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:O.notes,onChange:ee=>q(X=>({...X,notes:ee.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(Vjs,{formData:f,onChange:g}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:Q,children:[Q&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function Kjs({dealId:t}){const s=ci(),r=Qt(),[n,a]=k.useState(""),[o,l]=k.useState(!1),{data:i=[]}=mt({queryKey:["deal-tags",t],queryFn:async()=>{const{data:_,error:j}=await H.from("deal_tags").select("*").eq("deal_id",t).order("created_at");if(j)throw j;return _},enabled:!!t}),{data:c=[]}=mt({queryKey:["all-deal-tags",s],queryFn:async()=>{if(!s)return[];const{data:_,error:j}=await H.from("deal_tags").select("tag").eq("owner_user_id",s);if(j)throw j;return[...new Set(_.map(N=>N.tag))].sort()},enabled:!!s}),u=Lt({mutationFn:async _=>{if(!s)throw new Error("Not authenticated");const{error:j}=await H.from("deal_tags").insert({deal_id:t,owner_user_id:s,tag:_.trim()});if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]}),r.invalidateQueries({queryKey:["all-deal-tags"]}),a("")}}),p=Lt({mutationFn:async _=>{const{error:j}=await H.from("deal_tags").delete().eq("id",_);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]})}}),f=()=>{const _=n.trim();_&&(i.some(j=>j.tag.toLowerCase()===_.toLowerCase())||u.mutate(_))},g=i.map(_=>_.tag.toLowerCase()),b=c.filter(_=>_.toLowerCase().includes(n.toLowerCase())&&!g.includes(_.toLowerCase())).slice(0,5);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i.map(_=>e.jsxs(st,{variant:"secondary",className:"gap-1 text-xs",children:[_.tag,e.jsx("button",{type:"button",onClick:()=>p.mutate(_.id),className:"ml-0.5 hover:text-destructive",children:e.jsx(Rr,{className:"h-3 w-3"})})]},_.id)),!o&&e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-dashed border-border hover:border-primary transition-colors",children:[e.jsx($s,{className:"h-3 w-3"})," Add tag"]})]}),o&&e.jsxs("div",{className:"relative",children:[e.jsx(ze,{value:n,onChange:_=>a(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),f()),_.key==="Escape"&&(l(!1),a(""))},placeholder:"Type tag and press Enter...",className:"h-7 text-xs",autoFocus:!0,onBlur:()=>{n.trim()||l(!1)}}),n&&b.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded shadow-lg max-h-32 overflow-y-auto",children:b.map(_=>e.jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-left text-xs hover:bg-muted",onMouseDown:j=>{j.preventDefault(),u.mutate(_)},children:_},_))})]})]})}function Zjs(t){return mt({queryKey:["deal-files",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_files").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Yjs(){const t=ci(),s=Qt();return Lt({mutationFn:async({dealId:r,file:n})=>{if(!t)throw new Error("Not authenticated");const a=n.name.split(".").pop(),o=`${t}/${r}/${crypto.randomUUID()}.${a}`,{error:l}=await H.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:c}=await H.from("deal_files").insert({deal_id:r,owner_user_id:t,file_name:n.name,file_size:n.size,file_type:n.type||null,storage_path:o}).select().single();if(c)throw c;return i},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["deal-files",n.dealId]})}})}function Xjs(){const t=Qt();return Lt({mutationFn:async({fileId:s,storagePath:r,dealId:n})=>{await H.storage.from("deal-files").remove([r]);const{error:a}=await H.from("deal_files").delete().eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}function Qjs(){const t=Qt();return Lt({mutationFn:async({fileId:s,visible:r,dealId:n})=>{const{error:a}=await H.from("deal_files").update({visible_on_portal:r}).eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}async function Jjs(t){const{data:s,error:r}=await H.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const hze={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function eNs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=h_s(),a=m_s(),o=p_s(),l=f_s(),[i,c]=k.useState(!1),[u,p]=k.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,g]=k.useState(""),b=async()=>{if(u.question_text.trim())try{await a.mutateAsync({question_text:u.question_text.trim(),field_type:u.field_type,options:u.field_type==="dropdown"?u.options:[],is_required:u.is_required,sort_order:((r==null?void 0:r.length)||0)+1}),p({question_text:"",field_type:"text",options:[],is_required:!1}),g(""),c(!1),me.success("Question added")}catch{me.error("Failed to add question")}},_=async S=>{try{await l.mutateAsync(S),me.success("Question removed")}catch{me.error("Failed to remove question")}},j=async(S,M)=>{try{await o.mutateAsync({id:S,is_required:M})}catch{me.error("Failed to update question")}},w=()=>{f.trim()&&(p(S=>({...S,options:[...S.options,f.trim()]})),g(""))},N=S=>{p(M=>({...M,options:M.options.filter((L,I)=>I!==S)}))};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Custom Intake Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These questions appear on all your portal onboarding forms."})]}),e.jsx(Gi,{className:"flex-1",children:e.jsxs("div",{className:"space-y-3 pr-2",children:[n&&e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(S=>{var M;return e.jsx("div",{className:"border rounded-lg p-3 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:S.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"secondary",className:"text-xs",children:hze[S.field_type]||S.field_type}),S.is_required&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Required"})]}),S.field_type==="dropdown"&&((M=S.options)==null?void 0:M.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",S.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(qr,{checked:S.is_required,onCheckedChange:L=>j(S.id,L),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>_(S.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})},S.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Question"}),e.jsx(ze,{value:u.question_text,onChange:S=>p(M=>({...M,question_text:S.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(hze).map(([S,M])=>e.jsx("button",{type:"button",onClick:()=>p(L=>({...L,field_type:S,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===S?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:M},S))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((S,M)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:S}),e.jsx("button",{onClick:()=>N(M),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]},M)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:f,onChange:S=>g(S.target.value),onKeyDown:S=>S.key==="Enter"&&(S.preventDefault(),w()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(K,{variant:"outline",size:"sm",onClick:w,disabled:!f.trim(),className:"h-8",children:e.jsx($s,{className:"h-3 w-3"})})]})]})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:u.is_required,onCheckedChange:S=>p(M=>({...M,is_required:S}))}),e.jsx(be,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>c(!1),className:"flex-1",children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:b,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(ws,{className:"h-3 w-3 mr-1 animate-spin"}):null,"Add Question"]})]})]})]})}),e.jsxs("div",{className:"flex justify-between pt-4 border-t shrink-0",children:[i?e.jsx("div",{}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>c(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function tNs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=k.useState(""),[i,c]=k.useState(!1),{data:u,isLoading:p}=mt({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:_,error:j}=await H.from("client_portals").select(` id, slug, client_name, client_email, deal_id, archived_at, deal_pipeline (id, deal_name, deal_type, property_address) `).eq("owner_user_id",s).neq("id",t).is("archived_at",null).eq("is_enabled",!0);if(j)throw j;return _},enabled:i||!!n}),f=k.useMemo(()=>!n||!u?null:u.find(_=>_.id===n),[n,u]),g=k.useMemo(()=>!u||!r?[]:u.filter(_=>{var j;return((j=_.client_email)==null?void 0:j.toLowerCase())===r.toLowerCase()&&_.id!==t}),[u,r,t]),b=k.useMemo(()=>{if(!u||!o.trim())return[];const _=o.toLowerCase();return u.filter(j=>{var N,S,M,L;const w=j.deal_pipeline;return((N=j.client_name)==null?void 0:N.toLowerCase().includes(_))||((S=j.client_email)==null?void 0:S.toLowerCase().includes(_))||((M=w==null?void 0:w.deal_name)==null?void 0:M.toLowerCase().includes(_))||((L=w==null?void 0:w.property_address)==null?void 0:L.toLowerCase().includes(_))})},[u,o]);if(n){const _=f==null?void 0:f.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Linked Portal"}),e.jsxs("div",{className:"flex items-center gap-2 bg-primary/5 border border-primary/20 rounded-lg p-3",children:[e.jsx(dl,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:(f==null?void 0:f.client_name)||(_==null?void 0:_.deal_name)||"Linked Portal"}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[(_==null?void 0:_.deal_type)==="listing"?"🏠 Listing":"🔑 Purchase"," · ",(_==null?void 0:_.property_address)||"No address"]})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive shrink-0",onClick:()=>a(null),children:[e.jsx(gS,{className:"h-3 w-3 mr-1"}),"Unlink"]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Client will see both transactions in a tabbed view on one portal link."})]})}return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Link Another Transaction"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Combine buy + sell into one portal"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>c(!i),children:[e.jsx(dl,{className:"h-3 w-3 mr-1"}),i?"Cancel":"Link"]})]}),!i&&g.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground font-medium",children:"✨ Suggested match (same client email)"}),g.map(_=>{const j=_.deal_pipeline;return e.jsxs("button",{onClick:()=>a(_.id),className:"w-full flex items-center gap-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5 hover:bg-amber-100 transition-colors text-left",children:[e.jsx(st,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(j==null?void 0:j.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(j==null?void 0:j.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:j==null?void 0:j.property_address})]}),e.jsx(dl,{className:"h-3.5 w-3.5 text-amber-600 shrink-0"})]},_.id)})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{value:o,onChange:_=>l(_.target.value),placeholder:"Search by name, email, or address...",className:"pl-8 h-8 text-xs",autoFocus:!0})]}),p&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),b.length>0&&e.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:b.map(_=>{const j=_.deal_pipeline;return e.jsxs("button",{onClick:()=>{a(_.id),c(!1),l("")},className:"w-full flex items-center gap-2 border rounded-lg p-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(st,{variant:"outline",className:"text-[10px] shrink-0",children:(j==null?void 0:j.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(j==null?void 0:j.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:_.client_email})]})]},_.id)})}),o&&b.length===0&&!p&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function lCe({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=k.useState(!1),[c,u]=k.useState([]),[p,f]=k.useState(!1),[g,b]=k.useState("");k.useEffect(()=>{!l||!t||(f(!0),H.from("agent_videos").select("id, title, recipient_name, playback_url, thumbnail_url, created_at, duration_seconds").eq("owner_user_id",t).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1}).limit(50).then(({data:j})=>{u(j||[]),f(!1)}))},[l,t]);const _=c.filter(j=>!g||(j.title||j.recipient_name||"").toLowerCase().includes(g.toLowerCase()));return e.jsxs(fs,{open:l,onOpenChange:i,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(gu,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(ps,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Select from Video Library"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a video from your library"})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos...",value:g,onChange:j=>b(j.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-16 w-full"}),e.jsx(ys,{className:"h-16 w-full"})]}):_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:c.length===0?"No videos in your library yet":"No videos match your search"}):_.map(j=>e.jsxs("button",{onClick:()=>{s(j.playback_url||""),i(!1)},className:"w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/50 hover:bg-accent/50 transition-colors text-left",children:[e.jsx("div",{className:"w-16 h-10 rounded bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:w=>{const N=w.currentTarget.parentElement;if(N){w.currentTarget.remove();const S=document.createElement("span");S.innerHTML="🎬",S.className="text-lg",N.appendChild(S)}}}):e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:j.title||j.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.duration_seconds?`${Math.round(j.duration_seconds)}s`:"",j.created_at?` · ${new Date(j.created_at).toLocaleDateString()}`:""]})]})]},j.id))})]})]})}function cCe({contactId:t,onVideoReady:s}){const[r,n]=k.useState(!1),[a,o]=k.useState("record"),[l,i]=k.useState(0),[c,u]=k.useState(0),p=CC(),f=()=>{o("record"),i(0),u(0)},g=_=>{!_&&(a==="uploading"||a==="processing")||(n(_),_||f())},b=k.useCallback(async(_,j)=>{o("uploading");try{const w="Card Video",{videoId:N,libraryId:S}=await xR(w),{uploadUrl:M,apiKey:L}=await gR(N),I=new XMLHttpRequest;I.upload.onprogress=Q=>{Q.lengthComputable&&i(Q.loaded/Q.total*100)},await new Promise((Q,ee)=>{I.onload=()=>I.status>=200&&I.status<300?Q():ee(new Error("Upload failed")),I.onerror=()=>ee(new Error("Upload failed")),I.open("PUT",M),I.setRequestHeader("AccessKey",L),I.send(_)}),o("processing");let O=0;const q=Date.now(),U=9e4,B=`https://iframe.mediadelivery.net/embed/${S}/${N}`;for(;O<4;){if(await new Promise(ee=>setTimeout(ee,3e3)),Date.now()-q>U){const ee=_.size/1048576;await p.mutateAsync({bunny_video_id:N,playback_url:`https://iframe.mediadelivery.net/play/${S}/${N}`,file_size_mb:ee,title:w,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(B),me.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const Q=await wA(N);if(O=Q.status,u(Q.encodeProgress||0),O===5||O===6)throw new Error("Video processing failed")}const V=await wA(N),Y=(V.storageSize||_.size)/(1024*1024);await p.mutateAsync({bunny_video_id:N,contact_id:t||void 0,playback_url:V.directPlayUrl||B,thumbnail_url:V.thumbnailUrl,preview_url:V.previewUrl||null,duration_seconds:V.length||j,file_size_mb:Y,title:w,status:"ready",touch_type:"video"}),s(B),me.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(w){console.error("Recording upload error:",w),me.error("Failed to process video. Please try again."),o("record")}},[t,s,p]);return e.jsxs(fs,{open:r,onOpenChange:g,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(An,{className:"h-3.5 w-3.5"}),"Record Video"]})}),e.jsxs(ps,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(yme,{maxDurationSeconds:60,onRecordingComplete:b,onError:_=>me.error(_)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ws,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(Bi,{value:l,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(l),"%"]})]}),a==="processing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ws,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(Bi,{value:c,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(c),"%"]})]}),a==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(xi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}const sNs=t=>`portal-settings-draft:${t}`;function ult({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=yR(),[o,l]=k.useState(!1),i=k.useMemo(()=>sNs(r.id),[r.id]),[c,u]=k.useState(!1),[p,f]=k.useState(r.next_step_text||""),[g,b]=k.useState(r.next_step_video_url||""),[_,j]=k.useState(r.inspection_date||""),[w,N]=k.useState(r.appraisal_date||""),[S,M]=k.useState(r.welcome_message||""),[L,I]=k.useState(r.review_url||""),[O,q]=k.useState(r.show_post_close_tips),[U,B]=k.useState(r.notify_client),[V,Y]=k.useState(r.require_onboarding),[Q,ee]=k.useState(r.allow_spouse),[X,ie]=k.useState(r.visibility),[re,oe]=k.useState(r.stage_mapping||[]),[ce,ge]=k.useState(null),[ye,ue]=k.useState(r.linked_portal_id||null),pe=()=>{f(r.next_step_text||""),b(r.next_step_video_url||""),j(r.inspection_date||""),N(r.appraisal_date||""),M(r.welcome_message||""),I(r.review_url||""),q(r.show_post_close_tips),B(r.notify_client),Y(r.require_onboarding),ee(r.allow_spouse),ie(r.visibility),oe(r.stage_mapping||[]),ue(r.linked_portal_id||null)};k.useEffect(()=>{u(!1);const we=localStorage.getItem(i);if(we)try{const Le=JSON.parse(we);f(Le.nextStepText||""),b(Le.nextStepVideo||""),j(Le.inspectionDate||""),N(Le.appraisalDate||""),M(Le.welcomeMessage||""),I(Le.reviewUrl||""),q(!!Le.showPostClose),B(!!Le.notifyClient),Y(!!Le.requireOnboarding),ee(!!Le.allowSpouse),ie(Le.visibility||r.visibility),oe(Le.stageMapping||[]),ue(Le.linkedPortalId??null),u(!0);return}catch{localStorage.removeItem(i)}pe(),u(!0)},[i,r]),k.useEffect(()=>{if(!c)return;const we={nextStepText:p,nextStepVideo:g,inspectionDate:_,appraisalDate:w,welcomeMessage:S,reviewUrl:L,showPostClose:O,notifyClient:U,requireOnboarding:V,allowSpouse:Q,visibility:X,stageMapping:re,linkedPortalId:ye};p!==(r.next_step_text||"")||g!==(r.next_step_video_url||"")||_!==(r.inspection_date||"")||w!==(r.appraisal_date||"")||S!==(r.welcome_message||"")||L!==(r.review_url||"")||O!==r.show_post_close_tips||U!==r.notify_client||V!==r.require_onboarding||Q!==r.allow_spouse||X!==r.visibility||JSON.stringify(re)!==JSON.stringify(r.stage_mapping||[])||ye!==(r.linked_portal_id||null)?localStorage.setItem(i,JSON.stringify(we)):localStorage.removeItem(i)},[p,g,_,w,S,L,O,U,V,Q,X,re,ye,i,c,r]);const _e=()=>{localStorage.removeItem(i),pe()},$e=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:p||null,next_step_video_url:g||null,inspection_date:_||null,appraisal_date:w||null,welcome_message:S||null,review_url:L||null,show_post_close_tips:O,notify_client:U,require_onboarding:V,allow_spouse:Q,visibility:X,stage_mapping:re.length>0?re:null,linked_portal_id:ye});const we=r.linked_portal_id;ye&&ye!==we&&await H.from("client_portals").update({linked_portal_id:r.id}).eq("id",ye),!ye&&we&&await H.from("client_portals").update({linked_portal_id:null}).eq("id",we),localStorage.removeItem(i),me.success("Portal settings saved"),s(!1)}catch{me.error("Failed to save settings")}},Ae=()=>{oe([...re,{label:""}])},Ie=we=>{oe(re.filter((Le,tt)=>tt!==we)),ce===we&&ge(null)},Ce=(we,Le,tt)=>{const Te=[...re];Te[we]={...Te[we],[Le]:tt},oe(Te)},xe=()=>{const Le=sNe(null).map(tt=>({label:tt.label,description:tt.description,stageId:void 0}));oe(Le)};return e.jsxs(e.Fragment,{children:[e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Portal Settings"})}),e.jsxs(ba,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(pa,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(ns,{value:"general",children:"General"}),e.jsx(ns,{value:"timeline",children:"Timeline"}),e.jsx(ns,{value:"content",children:"Content"})]}),e.jsxs(Gi,{className:"flex-1 mt-4",children:[e.jsxs(bs,{value:"general",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Visibility"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Public portals appear without restrictions"})]}),e.jsx("div",{className:"flex gap-1",children:["private","public"].map(we=>e.jsx("button",{onClick:()=>ie(we),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${X===we?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:we.charAt(0).toUpperCase()+we.slice(1)},we))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Require Onboarding"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Clients must fill out intake form"})]}),e.jsx(qr,{checked:V,onCheckedChange:Y})]}),V&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Custom Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>l(!0),className:"text-xs",children:"Manage"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Allow Spouse/Partner"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show spouse fields on onboarding"})]}),e.jsx(qr,{checked:Q,onCheckedChange:ee})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Post-Close Celebration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show congrats card when deal closes"})]}),e.jsx(qr,{checked:O,onCheckedChange:q})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Notify Client on Updates"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email client when you post portal updates"})]}),e.jsx(qr,{checked:U,onCheckedChange:B})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(tNs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:ye,onLink:ue})}),e.jsx("div",{children:e.jsx(ze,{type:"date",value:_,onChange:we=>j(we.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(ze,{type:"date",value:w,onChange:we=>N(we.target.value),className:"mt-1"})]})]}),e.jsx(bs,{value:"timeline",className:"space-y-4 mt-0 px-1",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Client-Facing Stages"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Customize the client-friendly stage labels shown on the portal timeline"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:xe,className:"text-xs",children:"Auto-map"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground bg-muted/50 rounded-md p-2",children:'💡 These labels are what clients see. Click "More" on any stage to customize its description and add a video link. Internal pipeline stages are automatically translated to friendly names.'}),re.length===0&&e.jsxs("div",{className:"border border-dashed rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"No custom mapping — using default client-friendly journey stages"}),e.jsx(K,{variant:"outline",size:"sm",onClick:xe,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:re.map((we,Le)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(ze,{value:we.label,onChange:tt=>Ce(Le,"label",tt.target.value),placeholder:`Stage ${Le+1} label`,className:"flex-1 h-9 text-sm"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-primary",onClick:()=>ge(ce===Le?null:Le),children:ce===Le?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>Ie(Le),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),ce===Le&&e.jsxs("div",{className:"ml-6 space-y-2 pl-2 border-l-2 border-primary/15 pb-2",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:we.description||"",onChange:tt=>Ce(Le,"description",tt.target.value),placeholder:"e.g. Now it's time to start actively looking at homes",className:"mt-0.5 w-full rounded-md border border-input bg-background px-3 py-2 text-xs min-h-[50px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Video"}),we.video_url?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:we.video_url.length>40?we.video_url.slice(0,40)+"...":we.video_url}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>Ce(Le,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(cCe,{onVideoReady:tt=>Ce(Le,"video_url",tt)}),e.jsx(lCe,{userId:n,onSelect:tt=>Ce(Le,"video_url",tt),triggerSize:"sm",triggerClassName:"gap-1.5 shrink-0 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const tt=prompt("Paste a YouTube or Loom URL:");tt&&Ce(Le,"video_url",tt)},children:[e.jsx(Bo,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Le))}),re.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:Ae,className:"mt-2 text-xs w-full",children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(bs,{value:"content",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:S,onChange:we=>M(we.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Welcome! Here's everything you need for your transaction."})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"What's Next"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Tell your client what to expect next"}),e.jsx("textarea",{value:p,onChange:we=>f(we.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"We're waiting on the inspection report..."})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(ze,{value:g,onChange:we=>b(we.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Review URL"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Shown after deal closes"}),e.jsx(ze,{value:L,onChange:we=>I(we.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]})]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-4 border-t shrink-0",children:[e.jsx(K,{variant:"ghost",onClick:_e,children:"Reset Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:$e,disabled:a.isPending,children:[a.isPending?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qc,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})]})}),e.jsx(eNs,{open:o,onOpenChange:l})]})}const rNs=t=>`portal-update-draft:${t}`;function hlt({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const o=k.useMemo(()=>rNs(r),[r]),[l,i]=k.useState(""),[c,u]=k.useState(""),[p,f]=k.useState(""),[g,b]=k.useState(!1),[_,j]=k.useState(a??!1),[w,N]=k.useState(!1),S=Hat();k.useEffect(()=>{N(!1);const I=localStorage.getItem(o);if(I)try{const O=JSON.parse(I);i(O.title||""),u(O.content||""),f(O.videoUrl||""),b(!!O.isStageChange),j(typeof O.sendNotification=="boolean"?O.sendNotification:a??!1),N(!0);return}catch{localStorage.removeItem(o)}i(""),u(""),f(""),b(!1),j(a??!1),N(!0)},[o,a]),k.useEffect(()=>{if(!w)return;const I={title:l,content:c,videoUrl:p,isStageChange:g,sendNotification:_};l.trim()||c.trim()||p.trim()||g||_!==(a??!1)?localStorage.setItem(o,JSON.stringify(I)):localStorage.removeItem(o)},[l,c,p,g,_,w,o,a]);const M=()=>{localStorage.removeItem(o),i(""),u(""),f(""),b(!1),j(a??!1)},L=async()=>{if(l.trim())try{if(await S.mutateAsync({portal_id:r,title:l.trim(),content:c.trim()||void 0,video_url:p.trim()||void 0,is_stage_change:g}),_&&n)try{const I=_1(n);await H.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:l.trim(),update_content:c.trim()||null,portal_url:I}}),me.success("Update posted & client notified")}catch(I){console.error("Notification failed:",I),me.success("Update posted (notification failed to send)")}else me.success("Update posted to portal");M(),s(!1)}catch{me.error("Failed to post update")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Title *"}),e.jsx(ze,{value:l,onChange:I=>i(I.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:c,onChange:I=>u(I.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Everything looked great during the inspection..."})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(ze,{value:p,onChange:I=>f(I.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(An,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>b(!g),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${g?"bg-emerald-500/10 text-emerald-700 border-emerald-200":"bg-background text-muted-foreground border-input"}`,children:"📊 Stage Change"}),e.jsxs("button",{type:"button",onClick:()=>j(!_),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${_?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[_?e.jsx(Lm,{className:"h-3 w-3"}):e.jsx(r1,{className:"h-3 w-3"}),_?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",onClick:M,children:"Clear Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:L,disabled:!l.trim()||S.isPending,children:[S.isPending?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})]})})}function mlt({open:t,onOpenChange:s,portal:r,dealName:n}){const a=yR(),{isGmailConnected:o,gmailEmail:l}=Gx(),[i,c]=k.useState(r.client_name||""),[u,p]=k.useState(r.client_email||""),[f,g]=k.useState(!1),[b,_]=k.useState(!1),j=_1(r.slug),w=i.split(" ")[0]||"there",N=`Your Transaction Portal – ${n}`,S=`Hi ${w}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${j} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,M=()=>{navigator.clipboard.writeText(j),_(!0),setTimeout(()=>_(!1),2e3),me.success("Portal link copied!")},L=async()=>{if(!u.trim()){me.error("Please enter the client email");return}g(!0);try{await a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"});const{error:O}=await H.functions.invoke("gmail-send",{body:{to:u,subject:N,body:S.replace(/\n/g,"
")}});if(O)throw O;me.success(`Invite sent to ${u}`),s(!1)}catch(O){me.error(O.message||"Failed to send invite")}finally{g(!1)}},I=()=>{const O=encodeURIComponent(N),q=encodeURIComponent(S);window.open(`mailto:${u}?subject=${O}&body=${q}`,"_blank"),a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"}).catch(()=>{})};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(ze,{value:i,onChange:O=>c(O.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(ze,{type:"email",value:u,onChange:O=>p(O.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Portal Link"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-muted/50 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:j})}),e.jsx(K,{variant:"outline",size:"icon",onClick:M,className:"shrink-0",children:b?e.jsx(va,{className:"h-4 w-4 text-emerald-600"}):e.jsx(gi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(K,{onClick:L,disabled:f||!u.trim(),className:"w-full",children:[f?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(K,{onClick:I,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{variant:"ghost",onClick:M,className:"w-full text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function nNs({deal:t}){const{isAdmin:s,user:r}=Ds(),{data:n,isLoading:a}=l_s(t.id),o=cSe(),l=yR(),[i,c]=k.useState(!1),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState(!1),j=`portal-management-ui:${t.id}`;if(k.useEffect(()=>{const O=sessionStorage.getItem(j);if(O)try{const q=JSON.parse(O);p(!!q.settingsOpen),g(!!q.composerOpen),_(!!q.inviteOpen)}catch{sessionStorage.removeItem(j)}},[j]),k.useEffect(()=>{u||f||b?sessionStorage.setItem(j,JSON.stringify({settingsOpen:u,composerOpen:f,inviteOpen:b})):sessionStorage.removeItem(j)},[u,f,b,j]),a)return e.jsx("div",{className:"border rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(ws,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var O,q;c(!0);try{await o.mutateAsync({deal_id:t.id,visibility:"private",require_onboarding:!0,client_name:t.contact?`${t.contact.first_name} ${t.contact.last_name}`:void 0,client_email:((O=t.contact)==null?void 0:O.email)||void 0,client_phone:((q=t.contact)==null?void 0:q.phone)||void 0}),me.success("Client portal enabled!")}catch{me.error("Failed to create portal")}finally{c(!1)}},N=async O=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:O}),me.success(O?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},S=()=>{if(!n)return;const O=_1(n.slug);navigator.clipboard.writeText(O),me.success("Portal link copied!")},M=()=>{if(!n)return;const O=_1(n.slug);window.open(O,"_blank")};if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 border-dashed",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Create a beautiful portal so your client can track their deal progress in real-time."}),e.jsxs(K,{onClick:w,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(pn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const L=_1(n.slug),I=(r==null?void 0:r.id)||"";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(st,{variant:"outline",className:n.is_enabled?"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-xs bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx(qr,{checked:n.is_enabled,onCheckedChange:N})]}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Visibility:"}),e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:n.visibility==="private"?"Private":"Public"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Onboarding:"}),e.jsx("span",{className:"text-foreground",children:n.require_onboarding?"Required":"Disabled"})]}),n.client_name&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Client:"}),e.jsx("span",{className:"text-foreground",children:n.client_name})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-md p-2 mb-3",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:L})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:S,className:"text-xs flex-1 min-w-0",children:[e.jsx(gi,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:M,className:"text-xs flex-1 min-w-0",children:[e.jsx(tn,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>_(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(Bn,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>g(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(zM,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>p(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(Xo,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(ult,{open:u,onOpenChange:p,portal:n,dealOwnerId:I}),e.jsx(hlt,{open:f,onOpenChange:g,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(mlt,{open:b,onOpenChange:_,portal:n,dealName:t.deal_name})]})}const aNs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function iNs(t){return mt({queryKey:["deal-contacts",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_contacts").select(` id, deal_id, contact_id, role, created_at, contact:innercircle_contacts(id, first_name, last_name, email, phone) `).eq("deal_id",t).order("created_at");if(r)throw r;return s||[]},enabled:!!t})}function oNs(){const t=Qt();return Lt({mutationFn:async({dealId:s,contactId:r,role:n})=>{const{data:a,error:o}=await H.from("deal_contacts").insert({deal_id:s,contact_id:r,role:n}).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),me.success("Contact linked to deal")},onError:s=>{var r;(r=s.message)!=null&&r.includes("duplicate")?me.error("This contact is already linked to this deal"):me.error("Failed to link contact")}})}function lNs(){const t=Qt();return Lt({mutationFn:async({id:s,dealId:r})=>{const{error:n}=await H.from("deal_contacts").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),me.success("Contact removed from deal")},onError:()=>{me.error("Failed to remove contact")}})}function cNs({dealId:t,primaryContactId:s}){const r=fr(),{data:n,isLoading:a}=iNs(t),{data:o}=Gm(),l=oNs(),i=lNs(),[c,u]=k.useState(!1),[p,f]=k.useState(""),[g,b]=k.useState("Client"),_=new Set((n==null?void 0:n.map(M=>M.contact_id))||[]);s&&_.add(s);const j=o==null?void 0:o.filter(M=>{var I,O,q;if(_.has(M.id))return!1;if(!p.trim())return!0;const L=p.toLowerCase();return((I=M.first_name)==null?void 0:I.toLowerCase().includes(L))||((O=M.last_name)==null?void 0:O.toLowerCase().includes(L))||((q=M.email)==null?void 0:q.toLowerCase().includes(L))}).slice(0,8),w=M=>{l.mutate({dealId:t,contactId:M,role:g}),u(!1),f("")},N=M=>{i.mutate({id:M,dealId:t})},S={Client:"bg-primary/10 text-primary","Co-Buyer":"bg-blue-500/10 text-blue-600","Co-Seller":"bg-emerald-500/10 text-emerald-600",Spouse:"bg-pink-500/10 text-pink-600",Lender:"bg-amber-500/10 text-amber-600","Title Company":"bg-purple-500/10 text-purple-600",Inspector:"bg-orange-500/10 text-orange-600",Appraiser:"bg-cyan-500/10 text-cyan-600",Attorney:"bg-slate-500/10 text-slate-600",Contractor:"bg-lime-500/10 text-lime-600",Other:"bg-muted text-muted-foreground"};return!(n!=null&&n.length)&&!c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(Ro,{className:"w-80 p-3",align:"start",children:e.jsx(mze,{search:p,setSearch:f,selectedRole:g,setSelectedRole:b,filteredContacts:j,onAdd:w})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(st,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx($s,{className:"h-3.5 w-3.5"})})}),e.jsx(Ro,{className:"w-80 p-3",align:"end",children:e.jsx(mze,{search:p,setSearch:f,selectedRole:g,setSelectedRole:b,filteredContacts:j,onAdd:w})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(M=>{var L,I,O,q,U,B,V,Y;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(Nn,{className:"h-7 w-7",children:e.jsxs(kn,{className:"text-[10px] bg-primary/10 text-primary",children:[(I=(L=M.contact)==null?void 0:L.first_name)==null?void 0:I[0],(q=(O=M.contact)==null?void 0:O.last_name)==null?void 0:q[0]]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("button",{onClick:()=>r(`/mission-control/contacts/${M.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(U=M.contact)==null?void 0:U.first_name," ",(B=M.contact)==null?void 0:B.last_name]})}),e.jsx(st,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${S[M.role]||S.Other}`,children:M.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((V=M.contact)==null?void 0:V.phone)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${M.contact.phone}`,children:e.jsx(Un,{className:"h-3 w-3"})})}),((Y=M.contact)==null?void 0:Y.email)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${M.contact.email}`,children:e.jsx(cr,{className:"h-3 w-3"})})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>N(M.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]},M.id)})})]})}function mze({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Ks,{value:r,onValueChange:n,children:[e.jsx(Hs,{className:"h-8 text-sm",children:e.jsx(Ys,{placeholder:"Role"})}),e.jsx(Ws,{children:aNs.map(l=>e.jsx(Mt,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Gi,{className:"max-h-40",children:a&&a.length>0?e.jsx("div",{className:"space-y-0.5",children:a.map(l=>e.jsxs("button",{onClick:()=>o(l.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[l.first_name," ",l.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[l.phone,l.email].filter(Boolean).join(" · ")||"No contact info"})]},l.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:t?"No contacts found":"Type to search"})})]})}const dNs={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"}},uNs={note:so,call:Un,email:cr,meeting:hn,stage_change:tn,task_completed:sa,document:bn,system:un};function hNs({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Ce,xe;const{data:l,isLoading:i}=sws((t==null?void 0:t.id)||""),{data:c,isLoading:u}=nws((t==null?void 0:t.id)||""),p=rws(),f=iws(),g=aws(),b=tws(),{data:_,isLoading:j}=Zjs((t==null?void 0:t.id)||""),w=Yjs(),N=Xjs(),S=Qjs(),M=k.useRef(null),[L,I]=k.useState(""),[O,q]=k.useState(""),[U,B]=k.useState(!1),[V,Y]=k.useState(!1);if(!t)return null;const Q=dNs[t.deal_type],ee=(()=>{var tt;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const we=((tt=t.listing)==null?void 0:tt.created_at)||t.listing_date;if(!we)return null;const Le=t.contract_date?Ol(t.contract_date):new Date;return ly(Le,Ol(we))})(),X=we=>we?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(we):"-",ie=async()=>{if(L.trim())try{await p.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:L}),I(""),me.success("Note added")}catch{me.error("Failed to add note")}},re=async()=>{if(O.trim())try{await f.mutateAsync({deal_id:t.id,title:O,sort_order:((c==null?void 0:c.length)||0)+1}),q(""),me.success("Task added")}catch{me.error("Failed to add task")}},oe=async(we,Le)=>{try{await g.mutateAsync({id:we,is_completed:Le,deal_id:t.id})}catch{me.error("Failed to update task")}},ce=async()=>{try{await b.mutateAsync(t.id),me.success("Deal deleted"),r(!1)}catch{me.error("Failed to delete deal")}},ge=(c==null?void 0:c.filter(we=>we.is_completed).length)||0,ye=(c==null?void 0:c.length)||0,ue=(_==null?void 0:_.length)||0,pe=we=>we<1024?`${we} B`:we<1024*1024?`${(we/1024).toFixed(1)} KB`:`${(we/(1024*1024)).toFixed(1)} MB`,_e=we=>we?we.startsWith("image/")?gl:we.includes("pdf")?Sn:AM:AM,$e=async we=>{const Le=we.target.files;if(!(!Le||!t)){Y(!0);try{for(const tt of Array.from(Le)){if(tt.size>20*1024*1024){me.error(`${tt.name} exceeds 20MB limit`);continue}await w.mutateAsync({dealId:t.id,file:tt})}me.success("File(s) uploaded")}catch{me.error("Failed to upload file")}finally{Y(!1),M.current&&(M.current.value="")}}},Ae=async(we,Le)=>{if(t)try{await N.mutateAsync({fileId:we,storagePath:Le,dealId:t.id}),me.success("File deleted")}catch{me.error("Failed to delete file")}},Ie=async(we,Le)=>{try{const tt=await Jjs(we),Te=document.createElement("a");Te.href=tt,Te.download=Le,Te.target="_blank",document.body.appendChild(Te),Te.click(),document.body.removeChild(Te)}catch{me.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(eE,{open:s,onOpenChange:r,children:e.jsxs(vC,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(tE,{className:"p-6 pb-4 border-b shrink-0",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(st,{variant:"outline",className:It("text-xs",Q.color),children:Q.label}),e.jsxs(st,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(sE,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(Kjs,{dealId:t.id})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(hd,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>B(!0),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})}),e.jsx(Gi,{className:"flex-1",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.contact&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(Nn,{className:"h-10 w-10",children:e.jsxs(kn,{className:"bg-primary/10 text-primary",children:[(Ce=t.contact.first_name)==null?void 0:Ce[0],(xe=t.contact.last_name)==null?void 0:xe[0]]})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"font-medium",children:[t.contact.first_name," ",t.contact.last_name]}),t.contact.email&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t.contact.email})]}),e.jsxs("div",{className:"flex gap-2",children:[t.contact.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(Un,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(cr,{className:"h-4 w-4"})})})]})]}),e.jsx(cNs,{dealId:t.id,primaryContactId:t.contact_id}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(t.property_address||t.city)&&e.jsxs("div",{className:"col-span-2 flex items-start gap-2 text-sm",children:[e.jsx(bn,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.property_address||"Address TBD"}),e.jsx("p",{className:"text-muted-foreground",children:[t.city,t.state,t.zip_code].filter(Boolean).join(", ")})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected Price"}),e.jsx("p",{className:"text-lg font-bold",children:X(t.expected_price)})]}),e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected GCI"}),e.jsx("p",{className:"text-lg font-bold text-emerald-600",children:X(t.expected_commission)})]}),(t.brokerage_split_pct||t.team_split_pct||t.referral_fee_pct||t.franchise_fee_pct||t.transaction_fee)&&e.jsxs("div",{className:"col-span-2 bg-muted/30 rounded-lg p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Commission Splits"}),t.brokerage_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Brokerage Split"}),e.jsxs("span",{children:[t.brokerage_split_pct,"%",t.expected_commission?` (${X(t.expected_commission*t.brokerage_split_pct/100)})`:""]})]}),t.team_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Team Split"}),e.jsxs("span",{children:[t.team_split_pct,"%"]})]}),t.referral_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referral Fee"}),e.jsxs("span",{children:[t.referral_fee_pct,"%"]})]}),t.franchise_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Franchise Fee"}),e.jsxs("span",{children:[t.franchise_fee_pct,"%"]})]}),t.transaction_fee!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transaction Fee"}),e.jsx("span",{children:X(t.transaction_fee)})]}),t.net_commission!=null&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"border-t pt-1.5 mt-1.5",children:e.jsxs("div",{className:"flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:"Net to Agent"}),e.jsx("span",{className:"text-emerald-600",children:X(t.net_commission)})]})})})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(K,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(xo,{className:"h-4 w-4 mr-2"}),"Add to Scorecard"]}),t.scorecard_transaction_id&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground bg-muted/50 rounded-lg p-3",children:[e.jsx(sa,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"Synced to Scorecard"})]}),ee!==null&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 col-span-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Days on Market"}),e.jsxs("p",{className:It("text-lg font-bold",ee>90?"text-red-600":ee>60?"text-amber-600":"text-foreground"),children:[ee," ",t.contract_date?"(final)":"days"]})]}),t.target_close_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",ms(Ol(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ac,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[t.probability,"% probability"]})]})]}),t.notes&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium mb-1",children:"Notes"}),e.jsx("p",{className:"text-muted-foreground",children:t.notes})]}),e.jsx(nNs,{deal:t}),e.jsxs(ba,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(pa,{className:"w-full grid grid-cols-3",children:[e.jsxs(ns,{value:"tasks",className:"gap-1",children:[e.jsx(sa,{className:"h-4 w-4"}),"Tasks ",ye>0&&`(${ge}/${ye})`]}),e.jsxs(ns,{value:"files",className:"gap-1",children:[e.jsx(uS,{className:"h-4 w-4"}),"Files ",ue>0&&`(${ue})`]}),e.jsxs(ns,{value:"activity",className:"gap-1",children:[e.jsx(un,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(bs,{value:"tasks",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Add a new task...",value:O,onChange:we=>q(we.target.value),onKeyDown:we=>we.key==="Enter"&&re()}),e.jsx(K,{onClick:re,disabled:!O.trim(),children:e.jsx($s,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[c==null?void 0:c.map(we=>e.jsxs("div",{className:It("flex items-center gap-3 p-3 rounded-lg border transition-colors",we.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Oo,{checked:we.is_completed,onCheckedChange:Le=>oe(we.id,!!Le)}),e.jsx("span",{className:It("flex-1 text-sm",we.is_completed&&"line-through text-muted-foreground"),children:we.title}),we.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(we.due_date),"MMM d")})]},we.id)),(c==null?void 0:c.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No tasks yet. Add one above!"})]})]}),e.jsxs(bs,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:M,className:"hidden",multiple:!0,onChange:$e,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var we;return(we=M.current)==null?void 0:we.click()},disabled:V,children:[V?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(li,{className:"h-4 w-4 mr-2"}),V?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[_==null?void 0:_.map(we=>{const Le=_e(we.file_type);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-background",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center shrink-0",children:e.jsx(Le,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:we.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[pe(we.file_size)," · ",ms(new Date(we.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B1,{children:e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${we.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>S.mutate({fileId:we.id,visible:!we.visible_on_portal,dealId:t.id}),children:we.visible_on_portal?e.jsx(Ln,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})})}),e.jsx(Xl,{side:"top",children:we.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ie(we.storage_path,we.file_name),children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Ae(we.id,we.storage_path),children:e.jsx(Rr,{className:"h-4 w-4"})})]})]},we.id)}),(_==null?void 0:_.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No files yet. Upload contracts, disclosures, or other documents."})]})]}),e.jsxs(bs,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Er,{placeholder:"Add a note...",value:L,onChange:we=>I(we.target.value),rows:2}),e.jsxs(K,{onClick:ie,disabled:!L.trim(),size:"sm",className:"w-full",children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(we=>{const Le=uNs[we.activity_type]||un;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(Le,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:we.title}),we.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:we.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Uc(new Date(we.created_at),{addSuffix:!0})})]})]},we.id)}),(l==null?void 0:l.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No activity yet"})]})]})]})]})})]})}),e.jsx(kc,{open:U,onOpenChange:B,children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete Deal?"}),e.jsxs(sc,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:ce,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function mNs({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=jue(),o=rit(),{data:l}=nE(),{data:i}=Vx(),[c,u]=k.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ms(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});k.useEffect(()=>{if(r&&t){const g=r.deal_type==="seller"?"seller":"buyer",b=r.expected_price||0,_=r.commission_percentage||3,j=r.expected_commission||b*_/100;u({property_address:r.property_address||r.deal_name||"",city:r.city||"",state:r.state||"",zip:r.zip_code||"",transaction_type:g,close_date:r.actual_close_date||r.target_close_date||ms(new Date,"yyyy-MM-dd"),sale_price:b,commission_amount:j,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const p=async g=>{if(g.preventDefault(),!!r)try{const b=await a.mutateAsync({property_address:c.property_address,city:c.city||null,state:c.state||null,zip:c.zip||null,transaction_type:c.transaction_type,close_date:c.close_date,sale_price:c.sale_price,commission_amount:c.commission_amount||null,brokerage_split_pct:r.brokerage_split_pct||null,team_split_pct:r.team_split_pct||null,franchise_fee_pct:r.franchise_fee_pct||null,referral_fee_pct:r.referral_fee_pct||null,transaction_fee:r.transaction_fee||null,lead_source_id:c.lead_source_id||null,client_type_id:c.client_type_id||null,contact_id:r.contact_id||null,notes:c.notes||null,is_win:!0});await o.mutateAsync({id:r.id,scorecard_transaction_id:b.id,actual_close_date:c.close_date}),me.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(b){console.error("Error syncing to scorecard:",b),me.error("Failed to add to scorecard")}},f=g=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(g);return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{className:"space-y-3",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/20",children:e.jsx(xo,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(vs,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),e.jsx(Gr,{className:"text-center",children:"Review and confirm the details before adding this deal to your Scorecard."})]}),e.jsxs("form",{onSubmit:p,className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(ze,{id:"property_address",value:c.property_address,onChange:g=>u(b=>({...b,property_address:g.target.value})),placeholder:"123 Main St",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:c.city,onChange:g=>u(b=>({...b,city:g.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:c.state,onChange:g=>u(b=>({...b,state:g.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"zip",children:"Zip"}),e.jsx(ze,{id:"zip",value:c.zip,onChange:g=>u(b=>({...b,zip:g.target.value})),placeholder:"75001"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Transaction Type *"}),e.jsxs(Ks,{value:c.transaction_type,onValueChange:g=>u(b=>({...b,transaction_type:g})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(ze,{id:"close_date",type:"date",value:c.close_date,onChange:g=>u(b=>({...b,close_date:g.target.value})),required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(ac,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(ze,{id:"sale_price",type:"number",value:c.sale_price||"",onChange:g=>u(b=>({...b,sale_price:Number(g.target.value)})),placeholder:"450000",required:!0,min:0}),c.sale_price>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(c.sale_price)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(hS,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(ze,{id:"commission_amount",type:"number",value:c.commission_amount||"",onChange:g=>u(b=>({...b,commission_amount:Number(g.target.value)})),placeholder:"13500",min:0}),c.commission_amount>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(c.commission_amount)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Lead Source"}),e.jsxs(Ks,{value:c.lead_source_id,onValueChange:g=>u(b=>({...b,lead_source_id:g})),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select source"})}),e.jsx(Ws,{children:l==null?void 0:l.map(g=>e.jsx(Mt,{value:g.id,children:g.name},g.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Client Type"}),e.jsxs(Ks,{value:c.client_type_id,onValueChange:g=>u(b=>({...b,client_type_id:g})),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select type"})}),e.jsx(Ws,{children:i==null?void 0:i.map(g=>e.jsx(Mt,{value:g.id,children:g.name},g.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:c.notes,onChange:g=>u(b=>({...b,notes:g.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(qn,{className:"gap-2 sm:gap-0 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Skip for now"}),e.jsx(K,{type:"submit",disabled:a.isPending||o.isPending,className:"bg-green-600 hover:bg-green-700",children:a.isPending?"Adding...":e.jsxs(e.Fragment,{children:["Add to Scorecard",e.jsx(Qa,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const pNs={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"}},pze={urgent:0,high:1,medium:2,low:3};function fNs({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=k.useState("target_close_date"),[l,i]=k.useState("asc"),c=b=>{a===b?i(_=>_==="asc"?"desc":"asc"):(o(b),i("asc"))},u=k.useMemo(()=>[...t].sort((b,_)=>{var w,N;let j=0;switch(a){case"deal_name":j=b.deal_name.localeCompare(_.deal_name);break;case"stage":{const S=((w=s.find(L=>L.id===b.stage_id))==null?void 0:w.sort_order)||0,M=((N=s.find(L=>L.id===_.stage_id))==null?void 0:N.sort_order)||0;j=S-M;break}case"expected_price":j=(b.expected_price||0)-(_.expected_price||0);break;case"expected_commission":j=(b.expected_commission||0)-(_.expected_commission||0);break;case"target_close_date":{const S=b.target_close_date?Ol(b.target_close_date).getTime():1/0,M=_.target_close_date?Ol(_.target_close_date).getTime():1/0;j=S-M;break}case"priority":j=pze[b.priority]-pze[_.priority];break}return l==="asc"?j:-j}),[t,s,a,l]),p=b=>b?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(b):"—",f=b=>b?s.find(_=>_.id===b):null,g=({field:b,children:_})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>c(b),children:[_,a===b?l==="asc"?e.jsx(ku,{className:"ml-2 h-4 w-4"}):e.jsx(Wh,{className:"ml-2 h-4 w-4"}):e.jsx(bd,{className:"ml-2 h-4 w-4 opacity-50"})]});return t.length===0?e.jsx("div",{className:"text-center py-16",children:e.jsx("p",{className:"text-muted-foreground",children:"No deals to display"})}):e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{className:"bg-muted/50",children:[e.jsx(St,{className:"w-[250px]",children:e.jsx(g,{field:"deal_name",children:"Deal Name"})}),e.jsx(St,{className:"w-[150px]",children:e.jsx(g,{field:"stage",children:"Stage"})}),e.jsx(St,{className:"w-[100px]",children:"Type"}),e.jsx(St,{className:"w-[120px]",children:e.jsx(g,{field:"expected_price",children:"Price"})}),e.jsx(St,{className:"w-[120px]",children:e.jsx(g,{field:"expected_commission",children:"GCI"})}),e.jsx(St,{className:"w-[130px]",children:e.jsx(g,{field:"target_close_date",children:"Close Date"})}),e.jsx(St,{className:"w-[100px]",children:e.jsx(g,{field:"priority",children:"Priority"})})]})}),e.jsx(zn,{children:u.map(b=>{f(b.stage_id);const _=pNs[b.deal_type],j=b.target_close_date?ly(Ol(b.target_close_date),new Date):null,w=j!==null&&j<0,N=j!==null&&j<=7&&j>=0;return e.jsxs(Ss,{className:It("cursor-pointer hover:bg-muted/50 transition-colors",w&&"bg-red-50/50"),onClick:()=>r(b),children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{children:[e.jsx("p",{className:"truncate max-w-[230px]",children:b.deal_name}),b.contact&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[b.contact.first_name," ",b.contact.last_name]})]})}),e.jsx(dt,{onClick:S=>S.stopPropagation(),children:e.jsx(clt,{stages:s,currentStageId:b.stage_id||"",onStageSelect:(S,M)=>n(b.id,S,M)})}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",className:It("text-xs",_.color),children:_.label})}),e.jsx(dt,{children:e.jsx("span",{className:"font-medium",children:p(b.expected_price)})}),e.jsx(dt,{children:e.jsx("span",{className:"text-emerald-600",children:p(b.expected_commission)})}),e.jsx(dt,{children:b.target_close_date?e.jsxs("div",{className:It("flex items-center gap-1 text-sm",w&&"text-red-600",N&&!w&&"text-amber-600"),children:[w&&e.jsx(kl,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ms(Ol(b.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",className:It("text-xs capitalize",b.priority==="urgent"&&"border-red-200 bg-red-50 text-red-700",b.priority==="high"&&"border-orange-200 bg-orange-50 text-orange-700",b.priority==="medium"&&"border-amber-200 bg-amber-50 text-amber-700",b.priority==="low"&&"border-slate-200 bg-slate-50 text-slate-600"),children:b.priority})})]},b.id)})})]})})}function xNs(){const t=ci();return mt({queryKey:["deal-tasks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_tasks").select(` *, deal:deal_pipeline(id, deal_name, stage_id), contact:innercircle_contacts(id, first_name, last_name), stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function gNs(t){const s=ci();return mt({queryKey:["deal-tasks","deal",t,s],queryFn:async()=>{if(!s||!t)return[];const{data:r,error:n}=await H.from("deal_tasks").select(` *, stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("deal_id",t).order("sort_order",{ascending:!0});if(n)throw n;return r},enabled:!!s&&!!t})}function yNs(){const t=ci(),s=Qt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("deal_tasks").insert({owner_user_id:t,title:r.title,description:r.description||null,deal_id:r.deal_id||null,contact_id:r.contact_id||null,stage_id:r.stage_id||null,priority:r.priority||"medium",status:r.status||"todo",due_date:r.due_date||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}function vNs(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("deal_tasks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function bNs(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("deal_tasks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function dCe(){const t=Qt();return Lt({mutationFn:async({id:s,status:r})=>{const{data:n,error:a}=await H.from("deal_tasks").update({status:r,completed_at:r==="done"?new Date().toISOString():null}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function _Ns(){const t=Qt();return Lt({mutationFn:async s=>{if(s.length===0)return;const{error:r}=await H.from("deal_tasks").update({status:"done",completed_at:new Date().toISOString()}).in("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function wNs(t){const s=ci();return mt({queryKey:["deal-task-templates",s,t],queryFn:async()=>{if(!s)return[];let r=H.from("deal_task_templates").select("*").eq("owner_user_id",s).order("sort_order",{ascending:!0});t&&(r=r.eq("stage_id",t));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})}function jNs(){const t=ci(),s=Qt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("deal_task_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title,description:r.description||null,priority:r.priority||"medium",default_due_offset_days:r.default_due_offset_days||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-task-templates"]})}})}function NNs(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("deal_task_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-task-templates"]})}})}function kNs(){const t=ci(),s=Qt();return Lt({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("deal_task_templates").select("*").eq("owner_user_id",t).eq("stage_id",n).order("sort_order");if(o)throw o;if(!a||a.length===0)return[];const{data:l}=await H.from("deal_tasks").select("title, stage_id").eq("deal_id",r).eq("stage_id",n),i=new Set((l||[]).map(f=>f.title)),c=a.filter(f=>!i.has(f.title)).map((f,g)=>({owner_user_id:t,deal_id:r,stage_id:n,title:f.title,description:f.description,priority:f.priority,due_date:f.default_due_offset_days?new Date(Date.now()+f.default_due_offset_days*864e5).toISOString().split("T")[0]:null,sort_order:g,status:"todo"}));if(c.length===0)return[];const{data:u,error:p}=await H.from("deal_tasks").insert(c).select();if(p)throw p;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const SNs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function CNs({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:c,isLoading:u}=gNs(t?r:void 0),p=_Ns(),f=kNs(),[g,b]=k.useState(new Set),[_,j]=k.useState(!1),w=(c||[]).filter(L=>L.status!=="done");k.useEffect(()=>{w.length>0&&b(new Set(w.map(L=>L.id)))},[c]);const N=L=>{b(I=>{const O=new Set(I);return O.has(L)?O.delete(L):O.add(L),O})},S=async()=>{j(!0);try{const L=Array.from(g);L.length>0&&await p.mutateAsync(L),await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(L){console.error("Stage move failed:",L),me.error((L==null?void 0:L.message)||"Failed to move deal. Please try again.")}finally{j(!1)}},M=async()=>{j(!0);try{await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(L){console.error("Stage move (skip) failed:",L),me.error((L==null?void 0:L.message)||"Failed to move deal. Please try again.")}finally{j(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[480px]",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Move Deal"}),e.jsxs(Gr,{children:["Moving ",e.jsx("span",{className:"font-medium text-foreground",children:n})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2",children:[e.jsx(st,{variant:"outline",className:"text-sm",children:a}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(st,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:w.length})," incomplete task",w.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Gi,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:w.map(L=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(Oo,{checked:g.has(L.id),onCheckedChange:()=>N(L.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[SNs[L.priority]," ",L.title]}),L.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:L.stage.color+"20",color:L.stage.color},children:L.stage.name})]},L.id))})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>{g.size===w.length?b(new Set):b(new Set(w.map(L=>L.id)))},children:g.size===w.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:M,disabled:_,children:"Skip"}),e.jsxs(K,{size:"sm",onClick:S,disabled:_,children:[_&&e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}),g.size>0?`Complete ${g.size} & Move`:"Move Deal"]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx(sa,{className:"h-8 w-8 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All tasks completed! Ready to move."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:S,disabled:_,children:[_&&e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function MNs(){const t=ci();return mt({queryKey:["all-client-portals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("client_portals").select("*").eq("owner_user_id",t);if(r)throw r;return s||[]},enabled:!!t})}function TNs({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const c=cSe(),u=yR(),p=c_s(),f=d_s(),[g,b]=k.useState(!1),_=!!(n!=null&&n.archived_at),j=async()=>{b(!0);try{await c.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),me.success("Portal enabled!")}catch{me.error("Failed to create portal")}finally{b(!1)}},w=async I=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:I}),me.success(I?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},N=()=>{n&&(navigator.clipboard.writeText(_1(n.slug)),me.success("Link copied!"))},S=()=>{n&&window.open(_1(n.slug),"_blank")},M=async()=>{if(n)try{await p.mutateAsync(n.id),me.success("Portal archived")}catch{me.error("Failed to archive portal")}},L=async()=>{if(n)try{await f.mutateAsync(n.id),me.success("Portal restored")}catch{me.error("Failed to restore portal")}};return n?_?e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg opacity-60 bg-muted/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(st,{variant:"outline",className:"text-[10px] bg-muted text-muted-foreground",children:"Archived"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:L,className:"text-xs gap-1",children:[e.jsx(WI,{className:"h-3.5 w-3.5"}),"Restore"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5"}),"Delete"]})]})]}):e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(st,{variant:"outline",className:n.is_enabled?"text-[10px] bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-[10px] bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:N,title:"Copy link",children:e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:S,title:"Preview",children:e.jsx(tn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,s),title:"Invite client",children:e.jsx(Bn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n),title:"Post update",children:e.jsx(zM,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx(Xo,{className:"h-3.5 w-3.5"})}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(fx,{className:"h-3.5 w-3.5"})})}),e.jsx(Bd,{align:"end",children:e.jsxs(Ma,{onClick:M,children:[e.jsx(kM,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(qr,{checked:n.is_enabled,onCheckedChange:w,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(K,{size:"sm",onClick:j,disabled:g,className:"shrink-0 ml-4",children:[g?e.jsx(ws,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(pn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function ANs(){const{data:t,isLoading:s}=Khe(),{data:r,isLoading:n}=MNs(),[a,o]=k.useState(""),[l,i]=k.useState("all"),c=u_s(),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(null),N=ci(),S=s||n,M=new Map;r==null||r.forEach(V=>M.set(V.deal_id,V));const I=[...(t||[]).filter(V=>{var ie,re,oe,ce,ge;const Y=M.get(V.id),Q=a.toLowerCase(),ee=!Q||V.deal_name.toLowerCase().includes(Q)||((re=(ie=V.contact)==null?void 0:ie.first_name)==null?void 0:re.toLowerCase().includes(Q))||((ce=(oe=V.contact)==null?void 0:oe.last_name)==null?void 0:ce.toLowerCase().includes(Q))||((ge=Y==null?void 0:Y.client_name)==null?void 0:ge.toLowerCase().includes(Q));let X=!0;return l==="active"?X=!!(Y!=null&&Y.is_enabled)&&!(Y!=null&&Y.archived_at):l==="disabled"?X=!!Y&&!Y.is_enabled&&!Y.archived_at:l==="archived"?X=!!(Y!=null&&Y.archived_at):l==="none"?X=!Y:l==="all"&&(X=!(Y!=null&&Y.archived_at)||!Y),ee&&X})].sort((V,Y)=>{const Q=M.get(V.id),ee=M.get(Y.id);if(Q!=null&&Q.archived_at&&!(ee!=null&&ee.archived_at))return 1;if(!(Q!=null&&Q.archived_at)&&(ee!=null&&ee.archived_at)||Q&&!ee)return-1;if(!Q&&ee)return 1;if(Q&&ee){if(Q.is_enabled&&!ee.is_enabled)return-1;if(!Q.is_enabled&&ee.is_enabled)return 1}return 0}),O=(r==null?void 0:r.filter(V=>!V.archived_at).length)||0,q=(r==null?void 0:r.filter(V=>V.is_enabled&&!V.archived_at).length)||0,U=(r==null?void 0:r.filter(V=>V.archived_at).length)||0,B=async()=>{if(j)try{await c.mutateAsync({id:j.id,dealId:j.deal_id}),me.success("Portal permanently deleted"),w(null)}catch{me.error("Failed to delete portal")}};return S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[O," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[q," active · ",O-q," disabled",U>0&&` · ${U} archived`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search deals or clients...",value:a,onChange:V=>o(V.target.value),className:"pl-9 pr-8"}),a&&e.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:["all","active","disabled","archived","none"].map(V=>e.jsx(K,{variant:l===V?"secondary":"ghost",size:"sm",onClick:()=>i(V),className:"text-xs px-3 capitalize",children:V==="none"?"No Portal":V},V))})]}),e.jsx(Gi,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[I.map(V=>{const Y=M.get(V.id)||null,Q=V.contact?`${V.contact.first_name||""} ${V.contact.last_name||""}`.trim():"";return e.jsx(TNs,{dealId:V.id,dealName:V.deal_name,contactName:Q,portal:Y,onSettingsOpen:p,onComposerOpen:ee=>g(ee),onInviteOpen:(ee,X)=>_({portal:ee,dealName:X}),onDeleteConfirm:w},V.id)}),I.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted rounded-full flex items-center justify-center",children:e.jsx(pn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("p",{className:"text-sm font-medium",children:"No matching deals"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Try adjusting your search or filters"})]})]})})]}),u&&e.jsx(ult,{open:!!u,onOpenChange:V=>!V&&p(null),portal:u,dealOwnerId:N||""}),f&&e.jsx(hlt,{open:!!f,onOpenChange:V=>!V&&g(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),b&&e.jsx(mlt,{open:!!b,onOpenChange:V=>!V&&_(null),portal:b.portal,dealName:b.dealName}),e.jsx(kc,{open:!!j,onOpenChange:V=>!V&&w(null),children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Permanently delete this portal?"}),e.jsx(sc,{children:"This will permanently remove the portal and all its updates. The client will no longer be able to access their portal page. This action cannot be undone."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class ENs extends k.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){console.error("DealPipeline error:",s,r)}render(){return this.state.hasError?e.jsx(Ms,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] gap-4 text-center px-4",children:[e.jsx("div",{className:"w-16 h-16 bg-destructive/10 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"⚠️"})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"There was an error in the deal pipeline. Click below to try again."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>this.setState({hasError:!1,error:null}),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md text-sm font-medium hover:bg-primary/90",children:"Try Again"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 border border-border rounded-md text-sm font-medium hover:bg-muted",children:"Refresh Page"})]})]})}):this.props.children}}const uI="deal-pipeline-detail-sheet";function PNs(){var Cs;const t=SE(),{data:s,isLoading:r}=Ghe(),{data:n,isLoading:a,refetch:o}=Khe(),{data:l,isLoading:i}=ows(),c=tit(),u=ews(),[p,f]=k.useState("board"),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(null),[S,M]=k.useState(null),[L,I]=k.useState(null),[O,q]=k.useState(null),[U,B]=k.useState(!1),[V,Y]=k.useState(null),[Q,ee]=k.useState(""),[X,ie]=k.useState("all"),[re,oe]=k.useState(!1),[ce,ge]=k.useState(!1),[ye,ue]=k.useState(new Set),pe=k.useRef(!1),[_e,$e]=k.useState(null),{data:Ae}=$x(),{isTeamLeader:Ie,teamMembers:Ce}=Fjs(),xe=k.useMemo(()=>Array.from(ye),[ye]),{data:we}=zjs(xe),Le=k.useMemo(()=>{const cs=new Map;return Ce.forEach(er=>cs.set(er.id,{name:er.name,avatar_url:er.avatar_url,color:er.color})),cs},[Ce]),tt=k.useCallback(cs=>cs.owner_user_id&&Le.get(cs.owner_user_id)||null,[Le]),Te=k.useCallback(cs=>{ue(er=>{const xt=new Set(er);return xt.has(cs)?xt.delete(cs):xt.add(cs),xt})},[]);k.useEffect(()=>{!r&&s&&s.length===0&&c.mutate()},[r,s]);const[pt,fe]=Cc(),qe=k.useRef(!1);k.useEffect(()=>{const cs=pt.get("deal");if(cs&&n&&n.length>0&&!qe.current){const er=n.find(xt=>xt.id===cs);er&&(qe.current=!0,N(er),j(!0),pt.delete("deal"),fe(pt,{replace:!0}))}},[n,pt]);const at=k.useMemo(()=>{if(!we||!s)return[];const cs=new Map(s.map(er=>[er.name,er.id]));return we.map(er=>{const xt=er._stage_name&&cs.get(er._stage_name)||null;return{...er,stage_id:xt||er.stage_id}})},[we,s]),et=k.useMemo(()=>[...n||[],...at],[n,at]);k.useEffect(()=>{if(pe.current||et.length===0)return;pe.current=!0;const cs=sessionStorage.getItem(uI);if(cs)try{const er=JSON.parse(cs);if(!er.open||!er.dealId)return;const xt=et.find(Es=>Es.id===er.dealId);xt&&(N(xt),j(!0))}catch{sessionStorage.removeItem(uI)}},[et]),k.useEffect(()=>{_&&(w!=null&&w.id)?sessionStorage.setItem(uI,JSON.stringify({dealId:w.id,open:!0})):sessionStorage.removeItem(uI)},[_,w==null?void 0:w.id]);const Me=et.filter(cs=>{var ur,Mr,Lr,fn,ki,Ea;const er=Q.toLowerCase(),xt=!er||cs.deal_name.toLowerCase().includes(er)||((Mr=(ur=cs.contact)==null?void 0:ur.first_name)==null?void 0:Mr.toLowerCase().includes(er))||((fn=(Lr=cs.contact)==null?void 0:Lr.last_name)==null?void 0:fn.toLowerCase().includes(er))||((ki=cs.property_address)==null?void 0:ki.toLowerCase().includes(er))||((Ea=cs.city)==null?void 0:Ea.toLowerCase().includes(er)),Es=X==="all"||cs.deal_type===X;return xt&&Es}),rt=k.useMemo(()=>{if(!s)return l||null;const cs=new Set(s.filter(Lr=>Lr.is_won_stage).map(Lr=>Lr.id)),er=new Set(s.filter(Lr=>Lr.is_lost_stage).map(Lr=>Lr.id)),xt=et.filter(Lr=>Lr.stage_id&&!cs.has(Lr.stage_id)&&!er.has(Lr.stage_id)),Es=et.filter(Lr=>Lr.stage_id&&cs.has(Lr.stage_id)),ur=new Date().getFullYear(),Mr=Es.filter(Lr=>Lr.actual_close_date?new Date(Lr.actual_close_date).getFullYear()===ur:!0);return{totalDeals:et.length,activeDeals:xt.length,wonDeals:Es.length,pipelineValue:xt.reduce((Lr,fn)=>Lr+(fn.expected_price||0),0),expectedCommission:xt.reduce((Lr,fn)=>Lr+(fn.expected_commission||0),0),expectedNetToAgent:xt.reduce((Lr,fn)=>Lr+(vx(fn)||0),0),wonValue:Es.reduce((Lr,fn)=>Lr+(fn.expected_price||0),0),weightedGCI:xt.reduce((Lr,fn)=>Lr+(fn.expected_commission||0)*((fn.probability??50)/100),0),weightedNet:xt.reduce((Lr,fn)=>Lr+(vx(fn)||0)*((fn.probability??50)/100),0),ytdWonDeals:Mr.length,ytdWonGCI:Mr.reduce((Lr,fn)=>Lr+(fn.expected_commission||0),0),ytdWonNet:Mr.reduce((Lr,fn)=>Lr+(vx(fn)||0),0),projectedAnnualNet:Mr.reduce((Lr,fn)=>Lr+(vx(fn)||0),0)+xt.reduce((Lr,fn)=>Lr+(vx(fn)||0)*((fn.probability??50)/100),0)}},[et,s,l]),He=cs=>{N(cs),j(!0)},ct=cs=>{M(cs||null),N(null),b(!0)},Ue=cs=>{N(cs),j(!1),b(!0)},Ze=cs=>{j(cs),cs||sessionStorage.removeItem(uI)},Qe=(cs,er)=>{I(cs)},We=(cs,er)=>{cs.preventDefault(),cs.dataTransfer.dropEffect="move",q(er)},Je=async(cs,er)=>{if(cs.preventDefault(),q(null),!L)return;const xt=n==null?void 0:n.find(Mr=>Mr.id===L),Es=s==null?void 0:s.find(Mr=>Mr.id===er),ur=s==null?void 0:s.find(Mr=>Mr.id===(xt==null?void 0:xt.stage_id));if(!xt||!Es||xt.stage_id===er){I(null);return}$e({dealId:L,dealName:xt.deal_name,fromStageName:(ur==null?void 0:ur.name)||"Unknown",toStageName:Es.name,toStageId:er,isWonStage:Es.is_won_stage,deal:xt}),I(null)},it=async()=>{if(!_e)return;const{dealId:cs,toStageId:er,toStageName:xt,isWonStage:Es,deal:ur}=_e;if(await u.mutateAsync({dealId:cs,stageId:er,stageName:xt}),me.success(`Moved to ${xt}`),Es&&!ur.scorecard_transaction_id){const Mr={...ur,stage_id:er};Y(Mr),B(!0)}},Dt=k.useCallback(async(cs,er,xt)=>{const Es=n==null?void 0:n.find(Lr=>Lr.id===cs),ur=s==null?void 0:s.find(Lr=>Lr.id===er),Mr=s==null?void 0:s.find(Lr=>Lr.id===(Es==null?void 0:Es.stage_id));!Es||!ur||Es.stage_id===er||$e({dealId:cs,dealName:Es.deal_name,fromStageName:(Mr==null?void 0:Mr.name)||"Unknown",toStageName:xt,toStageId:er,isWonStage:ur.is_won_stage,deal:Es})},[n,s]),Vt=cs=>Me.filter(er=>er.stage_id===cs),hs=r||a,Ts=t?"list":p;return e.jsxs(Ms,{children:[e.jsxs("div",{className:"flex flex-col h-[calc(100vh-4rem)]",children:[e.jsxs("div",{className:"shrink-0 p-4 md:p-6 pb-0 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Deal Pipeline"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Track and manage your active deals"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(Go,{className:"h-4 w-4"})}),!t&&e.jsx(B1,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(K,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>f("board"),className:"px-3 gap-1.5",children:[e.jsx(Cp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Xl,{children:"Kanban board view"})]}),e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(K,{variant:p==="list"?"secondary":"ghost",size:"sm",onClick:()=>f("list"),className:"px-3 gap-1.5",children:[e.jsx(Mh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Xl,{children:"Grouped list view"})]}),e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(K,{variant:p==="table"?"secondary":"ghost",size:"sm",onClick:()=>f("table"),className:"px-3 gap-1.5",children:[e.jsx(qM,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Xl,{children:"Sortable table view"})]}),e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(K,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>f("portals"),className:"px-3 gap-1.5",children:[e.jsx(pn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Xl,{children:"Client portal management"})]})]})}),Ae&&!Ie&&e.jsxs(K,{variant:"outline",onClick:()=>oe(!0),children:[e.jsx(pr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>ct(),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),Ts!=="portals"&&e.jsx(Ujs,{stats:rt,isLoading:i}),Ts!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search deals, contacts, addresses...",value:Q,onChange:cs=>ee(cs.target.value),className:"pl-9 pr-8"}),Q&&e.jsx("button",{onClick:()=>ee(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Rr,{className:"h-4 w-4"})})]}),e.jsxs(Ks,{value:X,onValueChange:ie,children:[e.jsx(Hs,{className:"w-[140px]",children:e.jsx(Ys,{placeholder:"All Types"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"}),e.jsx(Mt,{value:"dual",children:"Dual"}),e.jsx(Mt,{value:"referral",children:"Referral"}),e.jsx(Mt,{value:"lease",children:"Lease"})]})]}),(Q||X!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Me.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[Ie&&!t&&Ce.length>0&&e.jsx(Rjs,{members:Ce,enabledMembers:ye,onToggleMember:Te,isOpen:ce,onToggleOpen:()=>ge(cs=>!cs)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:hs?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(cs=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(ys,{className:"h-full rounded-xl"})},cs))}):Ts==="board"?e.jsxs(Gi,{className:"h-full -mx-4 md:-mx-6 px-4 md:px-6",children:[e.jsx("div",{className:"flex gap-4 h-full pb-4",children:s==null?void 0:s.map(cs=>e.jsx(qjs,{stage:cs,deals:Vt(cs.id),onDealClick:He,onAddDeal:ct,onDragStart:Qe,onDragOver:We,onDrop:Je,isDragOver:O===cs.id,isWonStage:cs.is_won_stage,getOwnerInfo:tt},cs.id))}),e.jsx(aue,{orientation:"horizontal"})]}):Ts==="table"?e.jsx(Gi,{className:"h-full",children:e.jsx(fNs,{deals:Me,stages:s||[],onDealClick:He,onStageChange:Dt})}):Ts==="portals"?e.jsx(ANs,{}):e.jsx(Gi,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(cs=>{const er=Vt(cs.id);return er.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:cs.color}}),e.jsx("h3",{className:"font-semibold",children:cs.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",er.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:er.map(xt=>e.jsx(dlt,{deal:xt,onClick:()=>He(xt),stages:s,onStageChange:Dt,showStagePicker:!0,isWonStage:cs.is_won_stage,ownerInfo:tt(xt)},xt.id))})]},cs.id)}),(n==null?void 0:n.length)===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:e.jsx(Cp,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start tracking your opportunities by adding your first deal"}),e.jsxs(K,{onClick:()=>ct(),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&Me.length===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:e.jsx(cn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No matching deals"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Try adjusting your search or filters"}),e.jsx(K,{variant:"outline",onClick:()=>{ee(""),ie("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(Gjs,{open:g,onOpenChange:b,deal:w,defaultStageId:S}),e.jsx(hNs,{deal:w,open:_,onOpenChange:Ze,onEdit:Ue,isWonStage:w?(Cs=s==null?void 0:s.find(cs=>cs.id===w.stage_id))==null?void 0:Cs.is_won_stage:!1,onAddToScorecard:cs=>{Y(cs),B(!0),j(!1)}}),e.jsx(mNs,{open:U,onOpenChange:B,deal:V,onComplete:()=>{o(),Y(null)}}),_e&&e.jsx(CNs,{open:!!_e,onOpenChange:cs=>{cs||$e(null)},dealId:_e.dealId,dealName:_e.dealName,fromStageName:_e.fromStageName,toStageName:_e.toStageName,toStageId:_e.toStageId,onConfirm:it}),e.jsx(Djs,{open:re,onOpenChange:oe})]})}function INs(){return e.jsx(ENs,{children:e.jsx(PNs,{})})}function plt({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var ee;const o=yNs(),l=vNs(),{data:i}=Khe(),c=ci(),{data:u}=mt({queryKey:["contacts-for-tasks",c],queryFn:async()=>{if(!c)return[];const{data:X,error:ie}=await H.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",c).order("first_name").limit(500);if(ie)throw ie;return X},enabled:!!c&&t}),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState("none"),[w,N]=k.useState("none"),[S,M]=k.useState("medium"),[L,I]=k.useState("todo"),[O,q]=k.useState(),[U,B]=k.useState(!1),[V,Y]=k.useState(!1);k.useEffect(()=>{r?(f(r.title),b(r.description||""),j(r.deal_id||"none"),N(r.contact_id||"none"),M(r.priority),I(r.status),q(r.due_date?jm(r.due_date):void 0)):(f(""),b(""),j(n||"none"),N("none"),M("medium"),I("todo"),q(void 0))},[r,t,n]);const Q=async()=>{if(!p.trim()){me.error("Task title is required");return}try{const X={title:p.trim(),description:g.trim()||null,deal_id:_==="none"?null:_,contact_id:w==="none"?null:w,stage_id:a||null,priority:S,status:L,due_date:O?ms(O,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...X}),me.success("Task updated")):(await o.mutateAsync(X),me.success("Task created")),s(!1)}catch{me.error("Failed to save task")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[480px]",children:[e.jsx(_s,{children:e.jsx(vs,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title *"}),e.jsx(ze,{value:p,onChange:X=>f(X.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{value:g,onChange:X=>b(X.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Priority"}),e.jsxs(Ks,{value:S,onValueChange:X=>M(X),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"low",children:"🟢 Low"}),e.jsx(Mt,{value:"medium",children:"🟡 Medium"}),e.jsx(Mt,{value:"high",children:"🟠 High"}),e.jsx(Mt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Status"}),e.jsxs(Ks,{value:L,onValueChange:X=>I(X),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"todo",children:"To Do"}),e.jsx(Mt,{value:"in_progress",children:"In Progress"}),e.jsx(Mt,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Due Date"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O?ms(O,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(wf,{mode:"single",selected:O,onSelect:q,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Link to Deal"}),e.jsxs($o,{open:U,onOpenChange:B,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(ka,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),_!=="none"?((ee=i==null?void 0:i.find(X=>X.id===_))==null?void 0:ee.deal_name)||"Select deal":"No Deal"]}),e.jsx(Cx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Dx,{children:[e.jsx(Ox,{placeholder:"Search deals..."}),e.jsxs(Rx,{children:[e.jsx(Fx,{children:"No deals found."}),e.jsxs(zx,{children:[e.jsxs(bp,{value:"no-deal",onSelect:()=>{j("none"),B(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",_==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(X=>e.jsxs(bp,{value:X.deal_name,onSelect:()=>{j(X.id),B(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",_===X.id?"opacity-100":"opacity-0")}),X.deal_name]},X.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Link to Contact"}),e.jsxs($o,{open:V,onOpenChange:Y,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(to,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),w!=="none"?(()=>{const X=u==null?void 0:u.find(ie=>ie.id===w);return X?`${X.first_name} ${X.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(Cx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Dx,{children:[e.jsx(Ox,{placeholder:"Search contacts..."}),e.jsxs(Rx,{children:[e.jsx(Fx,{children:"No contacts found."}),e.jsxs(zx,{children:[e.jsxs(bp,{value:"no-contact",onSelect:()=>{N("none"),Y(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",w==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(X=>e.jsxs(bp,{value:`${X.first_name} ${X.last_name}`,onSelect:()=>{N(X.id),Y(!1)},children:[e.jsx(va,{className:It("mr-2 h-4 w-4",w===X.id?"opacity-100":"opacity-0")}),X.first_name," ",X.last_name]},X.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:Q,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const LNs={urgent:{label:"Urgent",color:"bg-red-500/10 text-red-600 border-red-200",dot:"🔴"},high:{label:"High",color:"bg-orange-500/10 text-orange-600 border-orange-200",dot:"🟠"},medium:{label:"Medium",color:"bg-amber-500/10 text-amber-600 border-amber-200",dot:"🟡"},low:{label:"Low",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200",dot:"🟢"}};function DNs({tasks:t}){const s=dCe(),r=bNs(),n=fr(),[a,o]=k.useState(null),l=async p=>{const f=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:f})}catch{me.error("Failed to update task")}},i=async p=>{try{await r.mutateAsync(p),me.success("Task deleted")}catch{me.error("Failed to delete task")}};if(t.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(sa,{className:"h-12 w-12 text-muted-foreground/30 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:"No tasks found"}),e.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Create a new task to get started"})]});const c=new Map,u=[];return t.forEach(p=>{if(p.deal){const f=c.get(p.deal.id)||{dealName:p.deal.deal_name,tasks:[]};f.tasks.push(p),c.set(p.deal.id,f)}else u.push(p)}),e.jsxs("div",{className:"space-y-4",children:[u.length>0&&e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 px-4 py-2 border-b",children:e.jsx("h3",{className:"font-medium text-sm text-muted-foreground",children:"General Tasks"})}),u.map(p=>e.jsx(fze,{task:p,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:f=>n(`/mission-control/pipeline?deal=${f}`)},p.id))]}),Array.from(c.entries()).map(([p,f])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${p}`),className:"w-full bg-muted/30 px-4 py-2 border-b flex items-center gap-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(ka,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(st,{variant:"secondary",className:"ml-auto text-xs",children:[f.tasks.filter(g=>g.status==="done").length,"/",f.tasks.length]}),e.jsx(da,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),f.tasks.map(g=>e.jsx(fze,{task:g,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:b=>n(`/mission-control/pipeline?deal=${b}`)},g.id))]},p)),a&&e.jsx(plt,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function fze({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&w0(jm(t.due_date))&&!bu(jm(t.due_date)),i=!o&&t.due_date&&bu(jm(t.due_date)),c=LNs[t.priority];return e.jsxs("div",{className:It("flex items-center gap-3 px-4 py-3 border-b last:border-b-0 group hover:bg-muted/30 transition-colors",o&&"opacity-60"),children:[e.jsx("button",{onClick:()=>s(t),className:"shrink-0",children:o?e.jsx(sa,{className:"h-5 w-5 text-emerald-500"}):e.jsx(_d,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:It("text-sm font-medium truncate",o&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(to,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(st,{variant:"outline",className:It("text-[10px] shrink-0",c.color),children:[c.dot," ",c.label]}),t.due_date&&e.jsxs("span",{className:It("text-xs shrink-0 flex items-center gap-1",l&&"text-destructive font-medium",i&&"text-amber-600 font-medium",!l&&!i&&"text-muted-foreground"),children:[e.jsx(un,{className:"h-3 w-3"}),ms(jm(t.due_date),"MMM d")]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>n(t),className:"p-1 hover:bg-muted rounded",children:e.jsx(hd,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("button",{onClick:()=>r(t.id),className:"p-1 hover:bg-destructive/10 rounded",children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const ONs=[{status:"todo",label:"To Do",icon:_d,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:pp,color:"border-t-blue-500"},{status:"done",label:"Done",icon:sa,color:"border-t-emerald-500"}],RNs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function FNs({tasks:t}){const s=dCe(),r=k.useMemo(()=>{const o={todo:[],in_progress:[],done:[]};return t.forEach(l=>o[l.status].push(l)),o},[t]),n=(o,l)=>{o.dataTransfer.setData("taskId",l)},a=async(o,l)=>{o.preventDefault();const i=o.dataTransfer.getData("taskId");if(!i)return;const c=t.find(u=>u.id===i);if(!(!c||c.status===l))try{await s.mutateAsync({id:i,status:l})}catch{me.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:ONs.map(o=>e.jsxs("div",{className:It("border rounded-lg border-t-4 bg-muted/20",o.color),onDragOver:l=>l.preventDefault(),onDrop:l=>a(l,o.status),children:[e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[e.jsx(o.icon,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold text-sm",children:o.label}),e.jsx(st,{variant:"secondary",className:"ml-auto text-xs",children:r[o.status].length})]}),e.jsxs("div",{className:"p-2 space-y-2 min-h-[200px]",children:[r[o.status].map(l=>e.jsx(zNs,{task:l,onDragStart:n},l.id)),r[o.status].length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"Drag tasks here"})]})]},o.status))})}function zNs({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&w0(jm(t.due_date))&&!bu(jm(t.due_date)),a=!r&&t.due_date&&bu(jm(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:It("bg-background border rounded-lg p-3 cursor-grab active:cursor-grabbing shadow-sm hover:shadow-md transition-shadow",n&&"border-destructive/50"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs mt-0.5",children:RNs[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:It("text-sm font-medium",r&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.deal&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(ka,{className:"h-2.5 w-2.5"}),t.deal.deal_name]}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(to,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:It("text-[10px] mt-1.5 flex items-center gap-1",n&&"text-destructive font-medium",a&&"text-amber-600 font-medium",!n&&!a&&"text-muted-foreground"),children:[e.jsx(un,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ms(jm(t.due_date),"MMM d")]}),t.stage&&e.jsx("span",{className:"inline-block text-[10px] px-1.5 py-0.5 rounded-full font-medium mt-1.5",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name})]})]})})}const xze={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function BNs({tasks:t}){const[s,r]=k.useState(new Date),n=dCe(),a=Fc(s),o=cx(s),l=Xh(a),i=eue(o),c=v4t({start:l,end:i}),u=k.useMemo(()=>{const g=new Map;return t.forEach(b=>{if(!b.due_date)return;const _=b.due_date,j=g.get(_)||[];j.push(b),g.set(_,j)}),g},[t]),p=k.useMemo(()=>t.filter(g=>!g.due_date),[t]),f=async g=>{const b=g.status==="done"?"todo":"done";try{await n.mutateAsync({id:g.id,status:b})}catch{me.error("Failed to update task")}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(v4(s,1)),children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ms(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Bm(s,1)),children:e.jsx(da,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-7 text-center",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(g=>e.jsx("div",{className:"text-xs font-medium text-muted-foreground py-2",children:g},g))}),e.jsx("div",{className:"grid grid-cols-7 border-l border-t",children:c.map(g=>{const b=ms(g,"yyyy-MM-dd"),_=u.get(b)||[],j=sue(g,s),w=bu(g);return e.jsxs("div",{className:It("border-r border-b min-h-[100px] p-1",!j&&"bg-muted/30",w&&"bg-primary/5"),children:[e.jsx("div",{className:It("text-xs font-medium mb-1 text-right px-1",!j&&"text-muted-foreground/40",w&&"text-primary font-bold"),children:ms(g,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[_.slice(0,3).map(N=>e.jsxs("button",{onClick:()=>f(N),className:It("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",N.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[N.status==="done"?e.jsx(sa,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(_d,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[xze[N.priority]," ",N.title]})]},N.id)),_.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",_.length-3," more"]})]})]},b)})}),p.length>0&&e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:["No Due Date (",p.length,")"]}),e.jsx("div",{className:"space-y-1",children:p.map(g=>e.jsxs("button",{onClick:()=>f(g),className:It("w-full text-left text-xs px-2 py-1.5 rounded flex items-center gap-2 hover:bg-muted transition-colors",g.status==="done"&&"opacity-50 line-through"),children:[g.status==="done"?e.jsx(sa,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(_d,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[xze[g.priority]," ",g.title]}),g.deal&&e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0",children:["• ",g.deal.deal_name]})]},g.id))})]})]})}const $Ns={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function qNs({open:t,onOpenChange:s,stages:r}){var N;const[n,a]=k.useState(((N=r[0])==null?void 0:N.id)||""),{data:o,isLoading:l}=wNs(n||void 0),i=jNs(),c=NNs(),[u,p]=k.useState(""),[f,g]=k.useState("medium"),[b,_]=k.useState(""),j=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:f,default_due_offset_days:b?parseInt(b):null,sort_order:((o==null?void 0:o.length)||0)+1}),p(""),_(""),me.success("Template added")}catch{me.error("Failed to add template")}},w=async S=>{try{await c.mutateAsync(S),me.success("Template deleted")}catch{me.error("Failed to delete template")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[560px]",children:[e.jsx(_s,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(iL,{className:"h-5 w-5"}),"Task Templates by Stage"]})}),e.jsx("p",{className:"text-sm text-muted-foreground -mt-2",children:"Create default tasks that auto-populate when a deal enters a stage."}),e.jsxs("div",{children:[e.jsx(be,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(S=>!S.is_won_stage&&!S.is_lost_stage).map(S=>e.jsx("button",{onClick:()=>a(S.id),className:It("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===S.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:S.name},S.id))})]}),e.jsx(Gi,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((S,M)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border rounded-lg group",children:[e.jsx("span",{className:"text-xs",children:$Ns[S.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:S.title}),S.default_due_offset_days&&e.jsxs(st,{variant:"outline",className:"text-[10px]",children:["+",S.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>w(S.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},S.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Task title...",value:u,onChange:S=>p(S.target.value),className:"flex-1",onKeyDown:S=>S.key==="Enter"&&j()}),e.jsxs(Ks,{value:f,onValueChange:S=>g(S),children:[e.jsx(Hs,{className:"w-[100px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"low",children:"🟢 Low"}),e.jsx(Mt,{value:"medium",children:"🟡 Med"}),e.jsx(Mt,{value:"high",children:"🟠 High"}),e.jsx(Mt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(ze,{type:"number",placeholder:"e.g., 7",value:b,onChange:S=>_(S.target.value)})]}),e.jsxs(K,{onClick:j,disabled:!u.trim()||i.isPending,children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function UNs(){const{data:t,isLoading:s}=xNs(),{data:r}=Ghe(),[n,a]=k.useState("list"),[o,l]=k.useState(""),[i,c]=k.useState("active"),[u,p]=k.useState("all"),[f,g]=k.useState("all"),[b,_]=k.useState(!1),[j,w]=k.useState(!1),N=k.useMemo(()=>{if(!t)return[];const L=new Map;return t.forEach(I=>{I.deal&&L.set(I.deal.id,I.deal.deal_name)}),Array.from(L,([I,O])=>({id:I,name:O}))},[t]),S=k.useMemo(()=>t?t.filter(L=>{var V,Y,Q,ee;const I=o.toLowerCase(),O=!I||L.title.toLowerCase().includes(I)||((Y=(V=L.deal)==null?void 0:V.deal_name)==null?void 0:Y.toLowerCase().includes(I))||`${((Q=L.contact)==null?void 0:Q.first_name)||""} ${((ee=L.contact)==null?void 0:ee.last_name)||""}`.toLowerCase().includes(I),q=i==="all"||i==="active"&&L.status!=="done"||i==="todo"&&L.status==="todo"||i==="in_progress"&&L.status==="in_progress"||i==="done"&&L.status==="done"||i==="overdue"&&L.status!=="done"&&L.due_date&&w0(jm(L.due_date))&&!bu(jm(L.due_date)),U=u==="all"||L.priority===u,B=f==="all"||f==="no_deal"&&!L.deal_id||L.deal_id===f;return O&&q&&U&&B}):[],[t,o,i,u,f]),M=k.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const L=t.filter(I=>I.status!=="done");return{total:L.length,overdue:L.filter(I=>I.due_date&&w0(jm(I.due_date))&&!bu(jm(I.due_date))).length,dueToday:L.filter(I=>I.due_date&&bu(jm(I.due_date))).length,dueThisWeek:L.filter(I=>I.due_date&&fCt(jm(I.due_date))).length,completed:t.filter(I=>I.status==="done").length}},[t]);return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage tasks across deals and contacts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>w(!0),children:[e.jsx(Qg,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(K,{size:"sm",onClick:()=>_(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"}),"New Task"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("button",{onClick:()=>c("active"),className:`p-3 rounded-lg border text-left transition-colors ${i==="active"?"border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs font-medium",children:[e.jsx(Mh,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.total})]}),e.jsxs("button",{onClick:()=>c("overdue"),className:`p-3 rounded-lg border text-left transition-colors ${i==="overdue"?"border-destructive bg-destructive/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive text-xs font-medium",children:[e.jsx(Ku,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:M.overdue})]}),e.jsxs("button",{onClick:()=>{c("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-xs font-medium",children:[e.jsx(un,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.dueToday})]}),e.jsxs("button",{onClick:()=>{c("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-600 text-xs font-medium",children:[e.jsx(Od,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.dueThisWeek})]}),e.jsxs("button",{onClick:()=>c("done"),className:`p-3 rounded-lg border text-left transition-colors ${i==="done"?"border-emerald-500 bg-emerald-500/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 text-xs font-medium",children:[e.jsx(sa,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.completed})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 items-start md:items-center",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search tasks...",value:o,onChange:L=>l(L.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:u,onValueChange:p,children:[e.jsx(Hs,{className:"w-[130px]",children:e.jsx(Ys,{placeholder:"Priority"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Priorities"}),e.jsx(Mt,{value:"urgent",children:"🔴 Urgent"}),e.jsx(Mt,{value:"high",children:"🟠 High"}),e.jsx(Mt,{value:"medium",children:"🟡 Medium"}),e.jsx(Mt,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Hs,{className:"w-[160px]",children:e.jsx(Ys,{placeholder:"Deal"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Deals"}),e.jsx(Mt,{value:"no_deal",children:"No Deal"}),N.map(L=>e.jsx(Mt,{value:L.id,children:L.name},L.id))]})]}),e.jsxs("div",{className:"flex items-center border rounded-lg p-0.5 ml-auto",children:[e.jsx("button",{onClick:()=>a("list"),className:`p-1.5 rounded-md transition-colors ${n==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(Mh,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>a("kanban"),className:`p-1.5 rounded-md transition-colors ${n==="kanban"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(m0,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>a("calendar"),className:`p-1.5 rounded-md transition-colors ${n==="calendar"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(Od,{className:"h-4 w-4"})})]})]}),s?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-primary border-t-transparent rounded-full"})}):e.jsxs(e.Fragment,{children:[n==="list"&&e.jsx(DNs,{tasks:S}),n==="kanban"&&e.jsx(FNs,{tasks:S}),n==="calendar"&&e.jsx(BNs,{tasks:S})]}),e.jsx(plt,{open:b,onOpenChange:_}),e.jsx(qNs,{open:j,onOpenChange:w,stages:r||[]})]})})}const lwe=[{value:"video_intro",label:"Video Intro",icon:An,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:gL,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:Fm,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:dl,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:wd,description:"Links to your social profiles"}],VNs=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],HNs={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function flt({cardId:t}){const{data:s,isLoading:r}=pkt(t),n=fkt(),a=xkt(),o=gkt(),[l,i]=k.useState(!1),[c,u]=k.useState(""),[p,f]=k.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ys,{className:"h-16 w-full"}),e.jsx(ys,{className:"h-16 w-full"})]});const g=()=>{c&&n.mutate({card_id:t,block_type:c,sort_order:(s==null?void 0:s.length)||0,config:HNs[c]||{}},{onSuccess:()=>{i(!1),u("")}})},b=S=>{a.mutate({id:S.id,is_visible:!S.is_visible})},_=(S,M)=>{if(!s)return;const L=s.findIndex(q=>q.id===S.id),I=M==="up"?L-1:L+1;if(I<0||I>=s.length)return;const O=s[I];a.mutate({id:S.id,sort_order:O.sort_order}),a.mutate({id:O.id,sort_order:S.sort_order})},j=S=>{confirm("Remove this block from this card?")&&o.mutate(S.id)},w=(S,M)=>{a.mutate({id:S.id,config:M},{onSuccess:()=>f(null)})},N=S=>lwe.find(M=>M.value===S);return e.jsxs("div",{className:"space-y-3",children:[!s||s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),e.jsxs(K,{size:"sm",onClick:()=>i(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((S,M)=>{const L=N(S.block_type),I=(L==null?void 0:L.icon)||Fm;return e.jsx(Ee,{className:S.is_visible?"":"opacity-50",children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(I,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(L==null?void 0:L.label)||S.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:WNs(S)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S,"up"),disabled:M===0,children:e.jsx(ku,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S,"down"),disabled:M===s.length-1,children:e.jsx(Wh,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(S),children:S.is_visible?e.jsx(Ln,{className:"h-3 w-3"}):e.jsx(kp,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(S),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>j(S),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]})})},S.id)}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:lwe.map(S=>{const M=S.icon;return e.jsxs("button",{onClick:()=>u(S.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${c===S.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[e.jsx(M,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:S.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.description})]})]},S.value)})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:g,disabled:!c||n.isPending,children:"Add Block"})]})]})}),p&&e.jsx(GNs,{block:p,onSave:S=>w(p,S),onClose:()=>f(null)})]})}function WNs(t){var r;const s=t.config;switch(t.block_type){case"video_intro":return s.video_url?"Video configured":"No video set";case"testimonials":{const n=((r=s.testimonials)==null?void 0:r.length)||0;return`${n} testimonial${n!==1?"s":""}`}case"specialties":{const n=s.tags||[];return n.length?n.slice(0,3).join(", ")+(n.length>3?"...":""):"No tags"}case"custom_links":{const n=s.links||[];return`${n.length} link${n.length!==1?"s":""}`}case"social_media":{const n=s.platforms||[];return n.length?n.map(a=>a.platform).join(", "):"No platforms"}default:return""}}function GNs({block:t,onSave:s,onClose:r}){const[n,a]=k.useState(t.config),o=lwe.find(l=>l.value===t.block_type);return e.jsx(fs,{open:!0,onOpenChange:r,children:e.jsxs(ps,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(KNs,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(ZNs,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(YNs,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(XNs,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(QNs,{config:n,onChange:a}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function KNs({config:t,onChange:s,cardId:r}){var b,_;const[n,a]=k.useState(""),[o,l]=k.useState((b=t.video_url)!=null&&b.includes("youtube")||(_=t.video_url)!=null&&_.includes("youtu.be")?"youtube":"library"),{data:i}=mt({queryKey:["card-owner",r],queryFn:async()=>{const{data:j}=await H.from("agent_cards").select("user_id").eq("id",r).single();return j==null?void 0:j.user_id},enabled:!!r}),{data:c,isLoading:u}=mt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:j,error:w}=await H.from("agent_videos").select("id, title, bunny_video_id, thumbnail_url, playback_url, created_at").eq("owner_user_id",i).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(w)throw w;return j||[]},enabled:!!i}),p=(c==null?void 0:c.filter(j=>!n||(j.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,g=j=>{var M;const w=(M=j.playback_url)==null?void 0:M.match(/\/(?:play|embed)\/(\d+)\//),S=`https://iframe.mediadelivery.net/embed/${w?w[1]:"570924"}/${j.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:S,bunny_video_id:j.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(ba,{value:o,onValueChange:l,children:[e.jsxs(pa,{className:"w-full",children:[e.jsx(ns,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(ns,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(bs,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos...",value:n,onChange:j=>a(j.target.value),className:"pl-9"})]}),e.jsx(Gi,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ys,{className:"h-14 w-full"}),e.jsx(ys,{className:"h-14 w-full"})]}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:(c==null?void 0:c.length)===0?"No videos in library yet":"No matching videos"}):e.jsx("div",{className:"space-y-1.5 pr-3",children:p.map(j=>e.jsxs("button",{onClick:()=>g(j),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===j.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:w=>{var N;w.currentTarget.style.display="none",(N=w.currentTarget.nextElementSibling)==null||N.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${j.thumbnail_url?"hidden":""}`,children:e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:j.title||"Untitled Video"}),f===j.bunny_video_id&&e.jsx(va,{className:"h-4 w-4 text-primary flex-shrink-0"})]},j.id))})})]}),e.jsx(bs,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(be,{children:"YouTube URL"}),e.jsx(ze,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:j=>s({...t,video_url:j.target.value,bunny_video_id:null,video_source:"youtube"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function ZNs({config:t,onChange:s}){const r=t.testimonials||[],n=(l,i,c)=>{const u=[...r];u[l]={...u[l],[i]:c},s({...t,testimonials:u})},a=()=>s({...t,testimonials:[...r,{name:"",quote:"",role:""}]}),o=l=>s({...t,testimonials:r.filter((i,c)=>c!==l)});return e.jsxs("div",{className:"space-y-4",children:[r.map((l,i)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"text-xs font-medium",children:["Testimonial ",i+1]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:e.jsx(Nr,{className:"h-3 w-3"})})]}),e.jsx(ze,{placeholder:"Client name",value:l.name,onChange:c=>n(i,"name",c.target.value)}),e.jsx(ze,{placeholder:"Role/title (optional)",value:l.role||"",onChange:c=>n(i,"role",c.target.value)}),e.jsx("textarea",{className:"w-full min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Their testimonial quote...",value:l.quote,onChange:c=>n(i,"quote",c.target.value)})]})},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function YNs({config:t,onChange:s}){const r=t.tags||[],[n,a]=k.useState(""),o=i=>{s({...t,tags:r.includes(i)?r.filter(c=>c!==i):[...r,i]})},l=()=>{n.trim()&&!r.includes(n.trim())&&(s({...t,tags:[...r,n.trim()]}),a(""))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:VNs.map(i=>e.jsx("button",{onClick:()=>o(i),className:`px-3 py-1.5 text-xs rounded-full border transition-colors ${r.includes(i)?"bg-primary text-primary-foreground border-primary":"bg-muted border-border hover:bg-muted/80"}`,children:i},i))})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm mb-2 block",children:"Custom Tag"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(be,{className:"text-xs text-muted-foreground mb-1 block",children:["Selected (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs bg-primary/10 text-primary rounded-full",children:[i,e.jsx("button",{onClick:()=>o(i),className:"hover:text-destructive",children:"×"})]},i))})]})]})}function XNs({config:t,onChange:s}){const r=t.links||[],n=(l,i,c)=>{const u=[...r];u[l]={...u[l],[i]:c},s({...t,links:u})},a=()=>s({...t,links:[...r,{label:"",url:""}]}),o=l=>s({...t,links:r.filter((i,c)=>c!==l)});return e.jsxs("div",{className:"space-y-3",children:[r.map((l,i)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{placeholder:"Button label",value:l.label,onChange:c=>n(i,"label",c.target.value)}),e.jsx(ze,{placeholder:"https://...",value:l.url,onChange:c=>n(i,"url",c.target.value)})]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(Nr,{className:"h-3 w-3"})})]},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const gze=[{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 QNs({config:t,onChange:s}){const r=t.platforms||[],n=c=>{r.find(u=>u.platform===c)||s({...t,platforms:[...r,{platform:c,url:""}]})},a=(c,u)=>{const p=[...r];p[c]={...p[c],url:u},s({...t,platforms:p})},o=c=>{s({...t,platforms:r.filter((u,p)=>p!==c)})},l=gze.filter(c=>!r.find(u=>u.platform===c.value)),i=c=>{const u=Pve[c],p=gze.find(f=>f.value===c);return{label:(p==null?void 0:p.label)||c,color:(u==null?void 0:u.color)||"#666",iconPath:u==null?void 0:u.icon}};return e.jsxs("div",{className:"space-y-4",children:[r.length>0&&e.jsx("div",{className:"space-y-3",children:r.map((c,u)=>{const p=i(c.platform);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0 border",style:{borderColor:p.color+"30",backgroundColor:p.color+"10"},children:p.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:p.color,children:e.jsx("path",{d:p.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(ze,{placeholder:`Your ${p.label} profile URL`,value:c.url,onChange:f=>a(u,f.target.value)})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-muted-foreground mb-2 block",children:"Add a platform"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(c=>{const u=Pve[c.value];return e.jsxs("button",{onClick:()=>n(c.value),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-full border border-border bg-muted hover:bg-muted/80 transition-colors",children:[(u==null?void 0:u.icon)&&e.jsx("svg",{viewBox:"0 0 24 24",width:12,height:12,fill:u.color,children:e.jsx("path",{d:u.icon})}),c.label]},c.value)})})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Tap a platform above to add your social media profile."})]})}var JNs=Object.defineProperty,tde=Object.getOwnPropertySymbols,xlt=Object.prototype.hasOwnProperty,glt=Object.prototype.propertyIsEnumerable,yze=(t,s,r)=>s in t?JNs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,cwe=(t,s)=>{for(var r in s||(s={}))xlt.call(s,r)&&yze(t,r,s[r]);if(tde)for(var r of tde(s))glt.call(s,r)&&yze(t,r,s[r]);return t},dwe=(t,s)=>{var r={};for(var n in t)xlt.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&tde)for(var n of tde(t))s.indexOf(n)<0&&glt.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var uC;(t=>{const s=class po{constructor(c,u,p,f){if(this.version=c,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],cpo.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let g=[];for(let _=0;_7)throw new RangeError("Invalid value");let _,j;for(_=p;;_++){const M=po.getNumDataCodewords(_,u)*8,L=l.getTotalBits(c,_);if(L<=M){j=L;break}if(_>=f)throw new RangeError("Data too long")}for(const M of[po.Ecc.MEDIUM,po.Ecc.QUARTILE,po.Ecc.HIGH])b&&j<=po.getNumDataCodewords(_,M)*8&&(u=M);let w=[];for(const M of c){r(M.mode.modeBits,4,w),r(M.numChars,M.mode.numCharCountBits(_),w);for(const L of M.getData())w.push(L)}a(w.length==j);const N=po.getNumDataCodewords(_,u)*8;a(w.length<=N),r(0,Math.min(4,N-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let M=236;w.lengthS[L>>>3]|=M<<7-(L&7)),new po(_,u,S,g)}getModule(c,u){return 0<=c&&c>>9)*1335;const f=(u<<10|p)^21522;a(f>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(f,g));this.setFunctionModule(8,7,n(f,6)),this.setFunctionModule(8,8,n(f,7)),this.setFunctionModule(7,8,n(f,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(f,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(f,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(f,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let p=0;p<12;p++)c=c<<1^(c>>>11)*7973;const u=this.version<<12|c;a(u>>>18==0);for(let p=0;p<18;p++){const f=n(u,p),g=this.size-11+p%3,b=Math.floor(p/3);this.setFunctionModule(g,b,f),this.setFunctionModule(b,g,f)}}drawFinderPattern(c,u){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const g=Math.max(Math.abs(f),Math.abs(p)),b=c+f,_=u+p;0<=b&&b{(M!=j-g||I>=_)&&S.push(L[M])});return a(S.length==b),S}drawCodewords(c){if(c.length!=Math.floor(po.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f>>3],7-(u&7)),u++)}}a(u==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let u=0;u5&&c++):(this.finderPenaltyAddHistory(_,j),b||(c+=this.finderPenaltyCountPatterns(j)*po.PENALTY_N3),b=this.modules[g][w],_=1);c+=this.finderPenaltyTerminateAndCount(b,_,j)*po.PENALTY_N3}for(let g=0;g5&&c++):(this.finderPenaltyAddHistory(_,j),b||(c+=this.finderPenaltyCountPatterns(j)*po.PENALTY_N3),b=this.modules[w][g],_=1);c+=this.finderPenaltyTerminateAndCount(b,_,j)*po.PENALTY_N3}for(let g=0;gb+(_?1:0),u);const p=this.size*this.size,f=Math.ceil(Math.abs(u*20-p*10)/p)-1;return a(0<=f&&f<=9),c+=f*po.PENALTY_N4,a(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let p=[6];for(let f=this.size-7;p.lengthpo.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*c+128)*c+64;if(c>=2){const p=Math.floor(c/7)+2;u-=(25*p-10)*p-55,c>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(c,u){return Math.floor(po.getNumRawDataModules(c)/8)-po.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c]*po.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let u=[];for(let f=0;f0);for(const f of c){const g=f^p.shift();p.push(0),u.forEach((b,_)=>p[_]^=po.reedSolomonMultiply(b,g))}return p}static reedSolomonMultiply(c,u){if(c>>>8||u>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(u>>>f&1)*c;return a(p>>>8==0),p}finderPenaltyCountPatterns(c){const u=c[1];a(u<=this.size*3);const p=u>0&&c[2]==u&&c[3]==u*3&&c[4]==u&&c[5]==u;return(p&&c[0]>=u*4&&c[6]>=u?1:0)+(p&&c[6]>=u*4&&c[0]>=u?1:0)}finderPenaltyTerminateAndCount(c,u,p){return c&&(this.finderPenaltyAddHistory(u,p),u=0),u+=this.size,this.finderPenaltyAddHistory(u,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(c,u){u[0]==0&&(c+=this.size),u.pop(),u.unshift(c)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=s;function r(i,c,u){if(c<0||c>31||i>>>c)throw new RangeError("Value out of range");for(let p=c-1;p>=0;p--)u.push(i>>>p&1)}function n(i,c){return(i>>>c&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class dd{constructor(c,u,p){if(this.mode=c,this.numChars=u,this.bitData=p,u<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(c){let u=[];for(const p of c)r(p,8,u);return new dd(dd.Mode.BYTE,c.length,u)}static makeNumeric(c){if(!dd.isNumeric(c))throw new RangeError("String contains non-numeric characters");let u=[];for(let p=0;p=1<{(s=>{const r=class{constructor(a,o){this.ordinal=a,this.formatBits=o}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(t.QrCode||(t.QrCode={}))})(uC||(uC={}));(t=>{(s=>{const r=class{constructor(a,o){this.modeBits=a,this.numBitsCharCount=o}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(t.QrSegment||(t.QrSegment={}))})(uC||(uC={}));var yM=uC;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var eks={L:yM.QrCode.Ecc.LOW,M:yM.QrCode.Ecc.MEDIUM,Q:yM.QrCode.Ecc.QUARTILE,H:yM.QrCode.Ecc.HIGH},ylt=128,vlt="L",blt="#FFFFFF",_lt="#000000",wlt=!1,jlt=1,tks=4,sks=0,rks=.1;function Nlt(t,s=0){const r=[];return t.forEach(function(n,a){let o=null;n.forEach(function(l,i){if(!l&&o!==null){r.push(`M${o+s} ${a+s}h${i-o}v1H${o+s}z`),o=null;return}if(i===n.length-1){if(!l)return;o===null?r.push(`M${i+s},${a+s} h1v1H${i+s}z`):r.push(`M${o+s},${a+s} h${i+1-o}v1H${o+s}z`);return}l&&o===null&&(o=i)})}),r.join("")}function klt(t,s){return t.slice().map((r,n)=>n=s.y+s.h?r:r.map((a,o)=>o=s.x+s.w?a:!1))}function nks(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*rks),l=a/s,i=(n.width||o)*l,c=(n.height||o)*l,u=n.x==null?t.length/2-i/2:n.x*l,p=n.y==null?t.length/2-c/2:n.y*l,f=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let _=Math.floor(u),j=Math.floor(p),w=Math.ceil(i+u-_),N=Math.ceil(c+p-j);g={x:_,y:j,w,h:N}}const b=n.crossOrigin;return{x:u,y:p,h:c,w:i,excavation:g,opacity:f,crossOrigin:b}}function aks(t,s){return s!=null?Math.max(Math.floor(s),0):t?tks:sks}function Slt({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let c=ht.useMemo(()=>{const _=(Array.isArray(t)?t:[t]).reduce((j,w)=>(j.push(...yM.QrSegment.makeSegments(w)),j),[]);return yM.QrCode.encodeSegments(_,eks[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:f,calculatedImageSettings:g}=ht.useMemo(()=>{let b=c.getModules();const _=aks(n,a),j=b.length+_*2,w=nks(b,l,_,o);return{cells:b,margin:_,numCells:j,calculatedImageSettings:w}},[c,l,o,n,a]);return{qrcode:c,margin:p,cells:u,numCells:f,calculatedImageSettings:g}}var iks=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),oks=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=ylt,level:l=vlt,bgColor:i=blt,fgColor:c=_lt,includeMargin:u=wlt,minVersion:p=jlt,boostLevel:f,marginSize:g,imageSettings:b}=n,j=dwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=j,N=dwe(j,["style"]),S=b==null?void 0:b.src,M=ht.useRef(null),L=ht.useRef(null),I=ht.useCallback(X=>{M.current=X,typeof r=="function"?r(X):r&&(r.current=X)},[r]),[O,q]=ht.useState(!1),{margin:U,cells:B,numCells:V,calculatedImageSettings:Y}=Slt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:g,imageSettings:b,size:o});ht.useEffect(()=>{if(M.current!=null){const X=M.current,ie=X.getContext("2d");if(!ie)return;let re=B;const oe=L.current,ce=Y!=null&&oe!==null&&oe.complete&&oe.naturalHeight!==0&&oe.naturalWidth!==0;ce&&Y.excavation!=null&&(re=klt(B,Y.excavation));const ge=window.devicePixelRatio||1;X.height=X.width=o*ge;const ye=o/V*ge;ie.scale(ye,ye),ie.fillStyle=i,ie.fillRect(0,0,V,V),ie.fillStyle=c,iks?ie.fill(new Path2D(Nlt(re,U))):B.forEach(function(ue,pe){ue.forEach(function(_e,$e){_e&&ie.fillRect($e+U,pe+U,1,1)})}),Y&&(ie.globalAlpha=Y.opacity),ce&&ie.drawImage(oe,Y.x+U,Y.y+U,Y.w,Y.h)}}),ht.useEffect(()=>{q(!1)},[S]);const Q=cwe({height:o,width:o},w);let ee=null;return S!=null&&(ee=ht.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{q(!0)},ref:L,crossOrigin:Y==null?void 0:Y.crossOrigin})),ht.createElement(ht.Fragment,null,ht.createElement("canvas",cwe({style:Q,height:o,width:o,ref:I,role:"img"},N)),ee)});oks.displayName="QRCodeCanvas";var CR=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=ylt,level:l=vlt,bgColor:i=blt,fgColor:c=_lt,includeMargin:u=wlt,minVersion:p=jlt,boostLevel:f,title:g,marginSize:b,imageSettings:_}=n,j=dwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:N,numCells:S,calculatedImageSettings:M}=Slt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:b,imageSettings:_,size:o});let L=N,I=null;_!=null&&M!=null&&(M.excavation!=null&&(L=klt(N,M.excavation)),I=ht.createElement("image",{href:_.src,height:M.h,width:M.w,x:M.x+w,y:M.y+w,preserveAspectRatio:"none",opacity:M.opacity,crossOrigin:M.crossOrigin}));const O=Nlt(L,w);return ht.createElement("svg",cwe({height:o,width:o,viewBox:`0 0 ${S} ${S}`,ref:r,role:"img"},j),!!g&&ht.createElement("title",null,g),ht.createElement("path",{fill:i,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),ht.createElement("path",{fill:c,d:O,shapeRendering:"crispEdges"}),I)});CR.displayName="QRCodeSVG";function lks({slug:t,agentName:s}){const r=k.useRef(null),n=`https://cards.relevelup.com/${t}`,a=k.useCallback(()=>{var f;const o=(f=r.current)==null?void 0:f.querySelector("svg");if(!o)return;const l=document.createElement("canvas"),i=1024;l.width=i,l.height=i;const c=l.getContext("2d");if(!c)return;const u=new XMLSerializer().serializeToString(o),p=new Image;p.onload=()=>{c.fillStyle="#ffffff",c.fillRect(0,0,i,i),c.drawImage(p,0,0,i,i);const g=document.createElement("a");g.download=`${t}-qr-code.png`,g.href=l.toDataURL("image/png"),g.click(),me.success("QR code downloaded!")},p.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(u)))},[t]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-sm font-medium",children:"QR Code"}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{ref:r,className:"bg-white p-3 rounded-lg border shadow-sm shrink-0",children:e.jsx(CR,{value:n,size:120,level:"H",bgColor:"#ffffff",fgColor:"#000000"})}),e.jsxs("div",{className:"space-y-2 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Download this QR code to use on business cards, flyers, signs, or any print materials. Scanning it opens your digital card instantly."}),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[e.jsx(yi,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function Mye(t){return{is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56,bold_theme_colors:t.bold_theme_colors||null,display_email:t.display_email||""}}function cks(){const{user:t}=Ds(),{data:s,isLoading:r}=ukt(t==null?void 0:t.id),n=SE(),[a,o]=k.useState(null),l=k.useMemo(()=>a||(s?Mye(s):null),[a,s]);if(r)return e.jsx(Ms,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(ys,{className:"h-8 w-48"}),e.jsx(ys,{className:"h-32 w-full"}),e.jsx(ys,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Ms,{children:e.jsx(uks,{userId:t==null?void 0:t.id})});const i=l||Mye(s),c=u=>{o(p=>{const f=p||Mye(s);return typeof u=="function"?u(f):u})};return e.jsx(Ms,{children:e.jsxs("div",{className:"flex gap-6 items-start",children:[e.jsxs("div",{className:`${n?"w-full":"flex-1 min-w-0"} max-w-2xl p-4 space-y-6 animate-fade-in`,children:[e.jsx(hks,{card:s}),e.jsx(xks,{card:s,form:i,setForm:c})]}),!n&&e.jsx("div",{className:"w-[400px] shrink-0","aria-hidden":"true"}),!n&&e.jsx("div",{className:"fixed right-8 top-[5.5rem] w-[400px] z-30",style:{height:"calc(100vh - 6.5rem)"},children:e.jsxs("div",{className:"rounded-xl border bg-muted/30 overflow-hidden h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b bg-card shrink-0",children:[e.jsx(dS,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Live Preview"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(dks,{card:s,form:i})})]})})]})})}function dks({card:t,form:s}){const{data:r}=mt({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await H.from("profiles").select("name, email, phone, avatar_url, brokerage_id").eq("id",t.user_id).single();let o=(a==null?void 0:a.avatar_url)||null;if(!o){const{data:l}=await H.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=k.useMemo(()=>({...t,is_published:s.is_published,theme:s.theme,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,custom_cta_url:t.custom_cta_url,show_photo:s.show_photo,show_bio:s.show_bio,show_video:t.show_video,show_credentials:s.show_credentials,show_social_links:s.show_social_links,show_save_contact:s.show_save_contact,show_leave_review:s.show_leave_review,show_refer_friend:s.show_refer_friend,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,display_email:s.display_email||null,social_links:t.social_links||[],profile:{name:(r==null?void 0:r.name)||null,email:s.display_email||(r==null?void 0:r.email)||null,phone:(r==null?void 0:r.phone)||null,brokerage_id:(r==null?void 0:r.brokerage_id)||null},brokerage_name:s.brokerage_display_name||null,avatar_url:(r==null?void 0:r.avatar_url)||null}),[t,s,r]);return e.jsx("div",{className:"transform scale-[0.85] origin-top",children:e.jsx(uje,{card:n})})}function uks({userId:t}){var c;const[s,r]=k.useState(""),n=iGe(),{data:a}=mt({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:u}=await H.from("profiles").select("name").eq("id",t).single();return u},enabled:!!t}),o=((c=a==null?void 0:a.name)==null?void 0:c.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||"",l=()=>{if(!t)return;const u=(s.trim()||o).toLowerCase().replace(/[^a-z0-9-]/g,"-");if(!u){me.error("Please enter a URL slug for your card");return}n.mutate({user_id:t,slug:u,is_published:!0},{onSuccess:()=>me.success("Your digital card has been created!")})},i=[{icon:su,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Zh,title:"Lead Capture",desc:"Collect leads automatically"},{icon:th,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:ic,title:"Fully Customizable",desc:"Themes, colors, and content blocks"}];return e.jsxs("div",{className:"max-w-2xl mx-auto p-4 animate-fade-in",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/90 via-primary to-primary/80 p-8 md:p-12 mb-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_30%_20%,rgba(255,255,255,0.15),transparent_50%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_80%_80%,rgba(0,0,0,0.1),transparent_50%)]"}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm text-sm font-medium mb-4",children:[e.jsx(pn,{className:"h-3.5 w-3.5"}),"New Feature"]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3 tracking-tight",children:"Your Digital Business Card"}),e.jsx("p",{className:"text-primary-foreground/80 text-lg max-w-md leading-relaxed",children:"Ditch the paper. Share a beautiful, interactive card that captures leads and makes a lasting impression."})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-8",children:i.map(u=>e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl border bg-card hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"mt-0.5 p-2 rounded-lg bg-primary/10 shrink-0",children:e.jsx(u.icon,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:u.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.desc})]})]},u.title))}),e.jsxs(Ee,{className:"shadow-lg border-2",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx(Rt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(gr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Oe,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Your Card URL"}),e.jsxs("div",{className:"flex items-center gap-0 mt-1.5",children:[e.jsx("span",{className:"inline-flex items-center px-3 h-10 rounded-l-md border border-r-0 bg-muted text-sm text-muted-foreground whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(ze,{value:s||o,onChange:u=>r(u.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(K,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(pn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function hks({card:t}){const r=`https://cards.relevelup.com/${t.slug}`,n=()=>{navigator.clipboard.writeText(r),me.success("Card link copied!")};return e.jsx("div",{className:"rounded-xl border bg-card p-5",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:"My Digital Card"}),e.jsx(st,{variant:t.is_published?"default":"secondary",className:"text-[10px] uppercase tracking-wider",children:t.is_published?"Live":"Draft"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(su,{className:"h-3.5 w-3.5"}),"cards.relevelup.com/",t.slug]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(gi,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(K,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function mks({userId:t}){const s=Qt(),r=k.useRef(null),[n,a]=k.useState(!1),[o,l]=k.useState(""),{data:i,isLoading:c}=mt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:Y}=await H.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let Q=(Y==null?void 0:Y.avatar_url)||null;if(!Q){const{data:ee}=await H.storage.from("avatars").list(`${t}`);if(ee&&ee.length>0){const{data:X}=H.storage.from("avatars").getPublicUrl(`${t}/${ee[0].name}`);Q=`${X.publicUrl}?t=${Date.now()}`,await H.from("profiles").update({avatar_url:Q}).eq("id",t)}}return{...Y,avatar_url:Q}}}),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(!1),N=u??(i==null?void 0:i.name)??"",S=f??(i==null?void 0:i.phone)??"",M=b??(i==null?void 0:i.email)??"",L=i==null?void 0:i.avatar_url,I=((i==null?void 0:i.name)||"A").split(" ").map(Y=>Y[0]).join("").toUpperCase().slice(0,2),O=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),q=Lt({mutationFn:async Y=>{const{error:Q}=await H.from("profiles").update(Y).eq("id",t);if(Q)throw Q},onSuccess:()=>{s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),me.success("Profile updated!")},onError:()=>me.error("Failed to update profile")}),U=()=>{const Y={};if(u!==null&&u!==(i==null?void 0:i.name)&&(Y.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(Y.phone=f||null),b!==null&&b!==(i==null?void 0:i.email)&&(Y.email=b),Object.keys(Y).length===0){me.info("No changes to save");return}q.mutate(Y)},B=Y=>{var X;const Q=(X=Y.target.files)==null?void 0:X[0];if(!Q)return;if(!Q.type.startsWith("image/")){me.error("Please select an image file");return}const ee=new FileReader;ee.onloadend=()=>{l(ee.result),a(!0)},ee.readAsDataURL(Q),Y.target.value=""},V=async Y=>{w(!0);try{const{data:Q}=await H.storage.from("avatars").list(`${t}`);Q&&Q.length>0&&await H.storage.from("avatars").remove(Q.map(oe=>`${t}/${oe.name}`));const ee=`${t}/avatar.jpg`,{error:X}=await H.storage.from("avatars").upload(ee,Y,{upsert:!0,contentType:"image/jpeg"});if(X)throw X;const{data:ie}=H.storage.from("avatars").getPublicUrl(ee),re=ie.publicUrl+"?t="+Date.now();await H.from("profiles").update({avatar_url:re}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),me.success("Photo updated!")}catch{me.error("Failed to upload photo")}finally{w(!1)}};return c?e.jsx(ys,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:O?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(Oe,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(be,{className:"text-sm font-semibold",children:"Profile Info"}),O&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[e.jsx(kl,{className:"h-3 w-3"}),"Missing info — complete below so your card looks great"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-3",children:"This info shows on your digital card and updates your profile everywhere."}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{var Y;return(Y=r.current)==null?void 0:Y.click()},children:[e.jsxs(Nn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx($a,{src:L||void 0,alt:N}),e.jsx(kn,{className:"text-lg font-semibold bg-primary/10 text-primary",children:I})]}),e.jsx("div",{className:"absolute inset-0 bg-black/40 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Sx,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:B})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:j?"Uploading...":L?"Tap to change photo":"Add a profile photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This photo appears on your card, profile, and community posts"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(ze,{value:N,onChange:Y=>p(Y.target.value),placeholder:"Your full name",className:"h-10"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(ze,{value:S,onChange:Y=>g(Y.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(ze,{value:M,onChange:Y=>_(Y.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:U,disabled:q.isPending,className:"w-full",children:q.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(wke,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:V,aspectRatio:1})]})}function pks({form:t,setForm:s,userId:r}){const[n,a]=k.useState(null),[o,l]=k.useState(t.brokerage_logo_url?"logo":"name"),[i,c]=k.useState(t.team_logo_url?"logo":"name"),u=b=>{l(b),s(b==="name"?_=>({..._,brokerage_logo_url:""}):_=>({..._,brokerage_display_name:""}))},p=b=>{c(b),s(b==="name"?_=>({..._,team_logo_url:""}):_=>({..._,team_name:""}))},f=async(b,_)=>{var w;const j=(w=b.target.files)==null?void 0:w[0];if(j){if(!j.type.startsWith("image/")){me.error("Please select an image file");return}a(_);try{const N=j.name.split(".").pop()||"png",M=`${r}/${_==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${N}`,{error:L}=await H.storage.from("card-logos").upload(M,j,{upsert:!0});if(L)throw L;const{data:I}=H.storage.from("card-logos").getPublicUrl(M),O=I.publicUrl+"?t="+Date.now();s(_==="brokerage_logo_url"?q=>({...q,[_]:O,brokerage_display_name:""}):q=>({...q,[_]:O,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{a(null),b.target.value=""}}},g=b=>{s(_=>({..._,[b]:""}))};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-semibold",children:"Brokerage & Team Branding"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Choose either a name or a logo for each — not both."})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(be,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:o==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("logo"),children:"Use Logo"})]}),o==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(ze,{value:t.brokerage_display_name,onChange:b=>s(_=>({..._,brokerage_display_name:b.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Logo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.brokerage_logo_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${t.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>g("brokerage_logo_url"),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}):null,e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(Sx,{className:"h-3.5 w-3.5"}),n==="brokerage_logo_url"?"Uploading...":t.brokerage_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:b=>f(b,"brokerage_logo_url"),disabled:n!==null})]})]}),t.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.brokerage_logo_size||56,"px"]})]}),e.jsx(Kg,{value:[t.brokerage_logo_size||56],onValueChange:([b])=>s(_=>({..._,brokerage_logo_size:b})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(be,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("logo"),children:"Use Logo"})]}),i==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(ze,{value:t.team_name,onChange:b=>s(_=>({..._,team_name:b.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Team Logo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.team_logo_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.team_logo_url,alt:"Team logo",style:{height:`${t.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>g("team_logo_url"),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}):null,e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(Sx,{className:"h-3.5 w-3.5"}),n==="team_logo_url"?"Uploading...":t.team_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:b=>f(b,"team_logo_url"),disabled:n!==null})]})]}),t.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.team_logo_size||56,"px"]})]}),e.jsx(Kg,{value:[t.team_logo_size||56],onValueChange:([b])=>s(_=>({..._,team_logo_size:b})),min:24,max:120,step:4})]})]})]})]})})}function fks({form:t,setForm:s}){const r={accent:"#ff5722",dark:"#1a1a2e",button:"#ff5722"},n=t.bold_theme_colors||r,a=(i,c)=>{s(u=>({...u,bold_theme_colors:{...r,...u.bold_theme_colors,[i]:c}}))},o=()=>{s(i=>({...i,bold_theme_colors:null}))},l=[{key:"accent",label:"Accent Color",desc:"Page background, icons, highlights"},{key:"dark",label:"Dark Color",desc:"Header background, action buttons, social icons"},{key:"button",label:"CTA Button Color",desc:"Main call-to-action button"}];return e.jsxs("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(ic,{className:"h-4 w-4"})," Brand Colors"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Customize colors to match your brand"})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:o,children:"Reset to Default"})]}),e.jsx("div",{className:"grid gap-3",children:l.map(({key:i,label:c,desc:u})=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"relative shrink-0",children:[e.jsx("input",{type:"color",value:n[i],onChange:p=>a(i,p.target.value),className:"sr-only"}),e.jsx("div",{className:"h-10 w-10 rounded-lg border-2 border-border cursor-pointer shadow-sm hover:scale-105 transition-transform",style:{backgroundColor:n[i]}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:c}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]}),e.jsx(ze,{value:n[i],onChange:p=>{const f=p.target.value;/^#[0-9a-fA-F]{0,6}$/.test(f)&&a(i,f)},className:"w-24 h-8 text-xs font-mono",placeholder:"#ff5722"})]},i))}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Preview:"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.accent}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.dark}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.button}})]})]})]})}function xks({card:t,form:s,setForm:r}){var j;const n=oGe(),a=Qt(),{data:o}=lGe(t.id),[l,i]=k.useState(t.slug),[c,u]=k.useState(!1),[p,f]=k.useState("idle"),g=k.useRef(JSON.stringify(s)),b=k.useRef(null);k.useEffect(()=>{const w=JSON.stringify(s);if(w!==g.current)return b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{f("saving"),n.mutate({id:t.id,...s,is_published:!0,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,bold_theme_colors:s.bold_theme_colors||null,display_email:s.display_email||null},{onSuccess:()=>{g.current=w,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{b.current&&clearTimeout(b.current)}},[s]);const _=async()=>{const w=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!w){me.error("Please enter a valid URL");return}if(w===t.slug){me.info("No changes to save");return}u(!0);try{const{data:N}=await H.from("agent_cards").select("id").eq("slug",w).neq("id",t.id).maybeSingle();if(N){me.error("This URL is already taken. Try another one.");return}const{error:S}=await H.from("agent_cards").update({slug:w}).eq("id",t.id);if(S)throw S;i(w),a.invalidateQueries({queryKey:["agent-card"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{u(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ba,{defaultValue:"content",children:[e.jsxs(pa,{className:"w-full h-11 p-1",children:[e.jsxs(ns,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Mx,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(ns,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Ln,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(ns,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Zh,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(ns,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(u1,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(ns,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Jg,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs(bs,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(mks,{userId:t.user_id}),e.jsx(pks,{form:s,setForm:r,userId:t.user_id}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-semibold",children:"Card Status"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Toggle your card on or off"})]}),e.jsx(qr,{checked:s.is_published,onCheckedChange:w=>r(N=>({...N,is_published:w}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Card Address"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-1",children:[e.jsx("span",{className:"inline-flex items-center px-3 rounded-l-md border border-r-0 bg-muted text-muted-foreground text-xs whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(ze,{value:l,onChange:w=>i(w.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:_,disabled:c||l===t.slug,className:"shrink-0",children:c?"Saving...":"Update"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is your unique card URL. Only letters, numbers, and dashes allowed."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(ze,{value:s.display_email,onChange:w=>r(N=>({...N,display_email:w.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(Ks,{value:s.theme,onValueChange:w=>r(N=>({...N,theme:w})),children:[e.jsx(Hs,{className:"h-11",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(Mt,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(Mt,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(Mt,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(fks,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(ze,{value:s.title,onChange:w=>r(N=>({...N,title:w.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(ze,{value:s.positioning_statement,onChange:w=>r(N=>({...N,positioning_statement:w.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Bio"}),e.jsx(Er,{value:s.bio,onChange:w=>r(N=>({...N,bio:w.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(ze,{value:s.review_snippet,onChange:w=>r(N=>({...N,review_snippet:w.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(ze,{value:s.review_source_url,onChange:w=>r(N=>({...N,review_source_url:w.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(ze,{value:s.booking_url,onChange:w=>r(N=>({...N,booking_url:w.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(ze,{value:s.custom_cta_label,onChange:w=>r(N=>({...N,custom_cta_label:w.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(bs,{value:"sections",className:"mt-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:w,label:N,desc:S})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(be,{className:"text-sm font-medium",children:N}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),e.jsx(qr,{checked:s[w],onCheckedChange:M=>r(L=>({...L,[w]:M}))})]},w))})})}),e.jsx(bs,{value:"blocks",className:"mt-4",children:e.jsx(flt,{cardId:t.id})}),e.jsx(bs,{value:"analytics",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{label:"Views",value:(o==null?void 0:o.views)??0,icon:Ln,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:Jg,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((j=o==null?void 0:o.leads)==null?void 0:j.length)??0,icon:Tl,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(w=>e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded-md ${w.color}`,children:e.jsx(w.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:w.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:w.value})]})},w.label))}),o&&o.leads.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-base",children:"Recent Leads"})}),e.jsx(Oe,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(w=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:w.name}),w.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:w.phone})]}),w.intent&&e.jsx(st,{variant:"secondary",className:"text-xs",children:w.intent})]},w.id))})]}),(!o||o.leads.length===0)&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(Jg,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"font-medium text-muted-foreground",children:"No analytics data yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Share your card link to start tracking"})]})})]})}),e.jsx(bs,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(lks,{slug:t.slug})})})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[p==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),p==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),p==="idle"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function gks(){const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState(null),[j,w]=k.useState(null),[N,S]=k.useState(0),{data:M,isLoading:L}=mt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:ee,error:X}=await H.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(X)throw X;return ee}}),I=Lt({mutationFn:async ee=>{const{data:X,error:ie}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:ee}});if(ie)throw ie;if(X!=null&&X.error)throw new Error(X.error);return X},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),me.success("BoldTrail connected successfully!")},onError:ee=>{me.error(ee.message||"Failed to connect BoldTrail")}}),O=Lt({mutationFn:async()=>{const{data:ee,error:X}=await H.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(X)throw X;return ee},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("BoldTrail disconnected")},onError:()=>me.error("Failed to disconnect")}),q=Lt({mutationFn:async ee=>{const{data:X,error:ie}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:ee}});if(ie)throw ie;if(X!=null&&X.error)throw new Error(X.error);return X},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("Sync direction saved")},onError:ee=>{me.error(ee.message||"Failed to save sync direction")}}),U=Lt({mutationFn:async()=>{const{data:ee,error:X}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(X)throw X;if(ee!=null&&ee.error)throw new Error(ee.error);return ee},onSuccess:ee=>{_(null),c(ee),a(!0)},onError:ee=>{me.error(ee.message||"Failed to generate sync preview")}}),B=Lt({mutationFn:async()=>{w("Initializing sync..."),S(5);const{data:ee,error:X}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:Q}});if(X)throw X;if(ee!=null&&ee.error)throw new Error(ee.error);const ie=ee;let re=ie.sync_log_id,oe=ie.next_phase,ce=ie.next_offset;const ge=ie.push_total||0,ye=ie.pull_total||0,ue=ge+ye;let pe=0,_e=0;for(;oe!=="finalize";){oe==="push"?(w(`Pushing contacts to BoldTrail... (${pe}/${ge})`),S(ue>0?pe/ue*100:0)):oe==="pull"&&(w(`Pulling contacts from BoldTrail... (${_e}/${ye})`),S(ue>0?(ge+_e)/ue*100:0));const{data:Ie,error:Ce}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:oe,offset:ce,sync_log_id:re,sync_direction:Q}});if(Ce)throw Ce;if(Ie!=null&&Ie.error)throw new Error(Ie.error);const xe=Ie;pe+=xe.chunk_pushed||0,_e+=xe.chunk_pulled||0,xe.progress&&w(xe.progress),oe==="pull"&&ye>0?S(Math.min(95,_e/ye*100)):oe==="push"&&ge>0&&S(Math.min(95,pe/ge*100)),oe=xe.next_phase,ce=xe.next_offset}w("Finalizing sync..."),S(95);const{data:$e,error:Ae}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:re,sync_direction:Q}});if(Ae)throw Ae;return S(100),$e},onSuccess:ee=>{w(null),S(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),me.success(`Sync complete! Pushed ${ee.contacts_pushed||0}, pulled ${ee.contacts_pulled||0}, skipped ${ee.contacts_skipped||0} duplicates.`)},onError:ee=>{w(null),S(0),me.error(ee.message||"Sync failed")}}),V=M==null?void 0:M.connected,Y=(M==null?void 0:M.sync_direction)||"bidirectional",Q=b??Y;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:e.jsx(bd,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["BoldTrail",V&&e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}),e.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(pp,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(gr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Two-way contact sync with duplicate prevention"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Preview what will sync before executing"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Syncs name, email, phone, address, notes, and lead source"})]}),V?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx("div",{className:"rounded-lg border p-3 space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"BoldTrail Connected"}),(M==null?void 0:M.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(M.last_sync_at).toLocaleString(),M.last_sync_status&&e.jsx(st,{variant:M.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:M.last_sync_status})]}),(M==null?void 0:M.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[M.boldtrail_contact_count," contacts in BoldTrail"]}),(M==null?void 0:M.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:M.last_sync_message})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect BoldTrail?"}),e.jsx(sc,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>O.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsx(B_e,{value:Y,onChange:ee=>q.mutate(ee)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{onClick:()=>U.mutate(),disabled:U.isPending||B.isPending,variant:"outline",className:"gap-2",children:[U.isPending?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx(Ln,{className:"h-4 w-4"}),"Preview Sync"]})})]}):e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:ee=>r(ee.target.value),className:"flex-1"}),e.jsxs(K,{onClick:()=>I.mutate(s),disabled:!s||s.length<10||I.isPending,children:[I.isPending?e.jsx(Go,{className:"h-4 w-4 animate-spin mr-2"}):null,"Connect"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find your API token in BoldTrail → Lead Engine → Lead Dropbox → My API Tokens. Generate a ",e.jsx("strong",{children:"Contacts"})," scope token."]})]})]})})]}),e.jsx(fs,{open:n,onOpenChange:ee=>{B.isPending||a(ee)},children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(bd,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Gr,{children:"Review what will happen when you sync your contacts."})]}),i&&(()=>{const ee=Q==="pull_only"?0:i.to_push,X=Q==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(B_e,{value:Q,onChange:_,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${Q==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:ee}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(ku,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${Q==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:X}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Wh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:i.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(pr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",i.agent_os_total," contacts · BoldTrail: ",i.boldtrail_total," contacts"]}),B.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Bi,{value:N||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:j||"Sync in progress..."})]}),ee>0&&e.jsxs(yf,{open:u,onOpenChange:p,children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ku,{className:"h-3 w-3 text-emerald-600"}),ee," contacts to push to BoldTrail"]}),e.jsx(Eo,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(bf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((ie,re)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ie.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ie.email})]},re)),i.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_push-20," more"]})]})})]}),X>0&&e.jsxs(yf,{open:f,onOpenChange:g,children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wh,{className:"h-3 w-3 text-blue-600"}),X," contacts to pull from BoldTrail"]}),e.jsx(Eo,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(bf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((ie,re)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ie.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ie.email})]},re)),i.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_pull-20," more"]})]})})]}),ee===0&&X===0&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer."}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),disabled:B.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>B.mutate(),disabled:B.isPending||ee===0&&X===0,className:"gap-2",children:[B.isPending?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx(bd,{className:"h-4 w-4"}),B.isPending?"Syncing...":"Sync Now"]})]})]})})()]})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(_s,{className:"p-6 pb-0",children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(bd,{className:"h-5 w-5 text-emerald-600"}),"How BoldTrail Sync Works"]})}),e.jsx("div",{className:"px-6 pb-6",children:e.jsx("video",{src:"/videos/BoldTrailIntegration.mp4",controls:!0,autoPlay:!0,className:"w-full rounded-lg",controlsList:"nodownload"})})]})})]})}function Clt(){const t=fr(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState("Test from ReLevelUp"),[i,c]=k.useState(!1),{data:u,isLoading:p}=mt({queryKey:["ses-config"],queryFn:async()=>{const{data:{session:b}}=await H.auth.getSession();if(!b)throw new Error("Not authenticated");return(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.access_token}`},body:JSON.stringify({action:"check_config"})})).json()}}),f=async()=>{if(!s||!n){me.error("Please fill in From and To email addresses");return}c(!0);try{const{data:{session:b}}=await H.auth.getSession();if(!b)throw new Error("Not authenticated");const j=await(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.access_token}`},body:JSON.stringify({action:"test_send",to:s,from_email:n,subject:o,body_html:"

Test Email

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

If you received this, SES is configured correctly! 🎉

"})})).json();j.success?me.success(`Test email sent! Message ID: ${j.messageId}`):me.error(j.error||"Failed to send test email")}catch(b){me.error(b.message||"Failed to send test email")}finally{c(!1)}},g=(u==null?void 0:u.configured)===!0;return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx(cr,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(gr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(st,{variant:g?"default":"secondary",children:p?"Checking...":g?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xi,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(kl,{className:"h-3 w-3"})," Not Configured"]})})]})}),g&&e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Send Test Email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Verify your SES setup by sending a test email. The "From" address must be verified in SES or belong to a verified domain.'}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"From Email"}),e.jsx(ze,{placeholder:"notifications@mail.relevelup.com",value:n,onChange:b=>a(b.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"To Email"}),e.jsx(ze,{placeholder:"your@email.com",value:s,onChange:b=>r(b.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Subject"}),e.jsx(ze,{value:o,onChange:b=>l(b.target.value),className:"text-sm"})]})]}),e.jsxs(K,{onClick:f,disabled:i,size:"sm",children:[i?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(K,{onClick:()=>t("/admin/email-campaigns"),className:"w-full",children:[e.jsx(Ah,{className:"h-4 w-4 mr-2"})," Launch Campaign Composer"]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Region:"})," ",u==null?void 0:u.region]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Domain:"})," send.relevelup.com (verified)"]})]})]}),!g&&!p&&e.jsx(Oe,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["AWS SES credentials are not configured. Add ",e.jsx("code",{children:"AWS_SES_ACCESS_KEY_ID"}),", ",e.jsx("code",{children:"AWS_SES_SECRET_ACCESS_KEY"}),", and ",e.jsx("code",{children:"AWS_SES_REGION"})," as secrets to enable."]})})]})}function yks(){var _,j,w,N;const{user:t}=Ds(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(""),[l,i]=k.useState(""),{data:c}=mt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:M}=await H.from("mass_email_settings").select("*").eq("user_id",t.id).maybeSingle();if(M)throw M;return S}}),{data:u}=mt({queryKey:["agent-profile-email",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:M}=await H.from("profiles").select("email, name").eq("id",t.id).single();if(M)throw M;return S}}),p=((_=c==null?void 0:c.reply_to_email)==null?void 0:_.trim())||((j=u==null?void 0:u.email)==null?void 0:j.trim())||"",f=((w=c==null?void 0:c.display_name)==null?void 0:w.trim())||((N=u==null?void 0:u.name)==null?void 0:N.trim())||"";k.useEffect(()=>{r||(o(p),i(f))},[r,p,f]);const g=Lt({mutationFn:async()=>{if(!t||!a.trim())throw new Error("Please enter a reply-to email");const S={reply_to_email:a.trim(),display_name:l.trim()||null,updated_at:new Date().toISOString()};if(c){const{error:M}=await H.from("mass_email_settings").update(S).eq("user_id",t.id);if(M)throw M}else{const{error:M}=await H.from("mass_email_settings").insert({user_id:t.id,...S});if(M)throw M}},onSuccess:()=>{s.invalidateQueries({queryKey:["mass-email-settings",t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["mass-email-ready",t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["mass-email-settings-check",t==null?void 0:t.id]}),me.success("Reply-to email saved!"),n(!1)},onError:S=>me.error(S.message)}),b=!!p;return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx(Bn,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Mass Email",b?e.jsxs(st,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(xi,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(st,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(gr,{children:"Set the email address where replies from your campaigns will be sent. If you haven't customized it yet, we'll use your profile email."})]})]})}),e.jsx(Oe,{className:"space-y-3",children:b&&!r?e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:f||"No display name"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>n(!0),children:[e.jsx(Ra,{className:"h-3 w-3 mr-1"})," Edit"]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Display Name"}),e.jsx(ze,{placeholder:"e.g. 🏡 Karen Hall",value:l,onChange:S=>i(S.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How your name appears in the recipient's inbox"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(ze,{type:"email",placeholder:"your@email.com",value:a,onChange:S=>o(S.target.value)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",onClick:()=>g.mutate(),disabled:g.isPending||!a.trim(),children:[e.jsx(qc,{className:"h-4 w-4 mr-1"})," Save"]}),r&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{n(!1),o(p),i(f)},children:[e.jsx(Rr,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]})})]})}function vks(){const{isAdmin:t}=Ds(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),{data:c,isLoading:u}=mt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:L,error:I}=await H.from("gmail_integrations").select("*").maybeSingle();if(I)throw I;return L}}),{data:p}=mt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:L}}=await H.auth.getUser();if(!L)return[];const{data:I,error:O}=await H.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(O)throw O;return I}}),f=async()=>{n(!0);try{const{data:L,error:I}=await H.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(I)throw I;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Gmail OAuth error:",L),me.error("Failed to start Gmail connection"),n(!1)}},g=async()=>{o(!0);try{const{data:L,error:I}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(I)throw I;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Meta OAuth error:",L),me.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},b=async()=>{i(!0);try{const{data:L,error:I}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(I)throw I;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(L){console.error("LinkedIn OAuth error:",L),me.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},_=Lt({mutationFn:async L=>{const{error:I}=await H.from("gmail_integrations").delete().eq("id",L);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),me.success("Gmail disconnected")},onError:()=>{me.error("Failed to disconnect Gmail")}}),j=Lt({mutationFn:async L=>{const{error:I}=await H.from("social_accounts").delete().eq("id",L);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),me.success("Account disconnected")},onError:()=>{me.error("Failed to disconnect account")}}),w=!!(c!=null&&c.is_active),N=(p==null?void 0:p.filter(L=>L.platform==="facebook"))||[],S=(p==null?void 0:p.filter(L=>L.platform==="instagram"))||[],M=(p==null?void 0:p.filter(L=>L.platform==="linkedin"))||[];return e.jsx(Ms,{children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6 animate-fade-in",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Integrations"}),e.jsx("p",{className:"text-muted-foreground",children:"Connect third-party services to supercharge your Agent OS workflow."})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-destructive/10 flex items-center justify-center",children:e.jsx(cr,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Gmail",w&&e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(gr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Send personalized emails from your Gmail account"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Automatically log emails as activity touchpoints"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),w?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:c.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect Gmail?"}),e.jsx(sc,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>_.mutate(c.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:f,disabled:r||u,children:[r?e.jsx(Go,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(cr,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(Qa,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(Su,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?N.length>0?e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(st,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(gr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[N.length>0&&e.jsx("div",{className:"space-y-2",children:N.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Su,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.page_name||L.platform_username||"Facebook Page"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect Facebook?"}),e.jsx(sc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>j.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:g,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-pink-500/10 flex items-center justify-center",children:e.jsx(Mu,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?S.length>0?e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(st,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(gr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["@",L.platform_username||"Instagram Account"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect Instagram?"}),e.jsx(sc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>j.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:g,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),"Connect Instagram Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Instagram Business accounts must be connected to a Facebook Page."})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-700/10 flex items-center justify-center",children:e.jsx(Mp,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?M.length>0?e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(st,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(gr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[M.length>0&&e.jsx("div",{className:"space-y-2",children:M.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx($a,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mp,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.platform_username||"LinkedIn Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect LinkedIn?"}),e.jsx(sc,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>j.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:b,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(gks,{}),e.jsx(yks,{}),t&&e.jsx(Clt,{})]})})}function bks(){const[t]=Cc(),s=fr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your Gmail account...");return k.useEffect(()=>{(async()=>{const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:f,error:g}=await H.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(g)throw g;if(f!=null&&f.success)n("success"),o(f.message||"Gmail connected successfully!"),me.success("Gmail connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Gmail OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Gmail"),me.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function _ks(){const t=fr();return k.useEffect(()=>{const s=setTimeout(()=>{t("/mission-control/integrations",{replace:!0})},1500);return()=>clearTimeout(s)},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Finishing Canva connection…"})]})})}function wks(){const[t]=Cc(),s=fr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing your connection...");return k.useEffect(()=>{(async()=>{var f;const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:g,error:b}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(b)throw b;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||0} account(s)!`),me.success("Social accounts connected successfully!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect accounts"),me.error("Failed to connect: "+(g instanceof Error?g.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const Mlt=new Date().getFullYear(),jks=Array.from({length:5},(t,s)=>Mlt-s);function Nks(){const[t,s]=k.useState(Mlt),r=fr(),{data:n,isLoading:a}=r8t();return a?e.jsx(Ms,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(ys,{className:"h-24"},o))}),e.jsx(ys,{className:"h-96"})]})}):e.jsx(Ms,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Scorecard Admin"}),e.jsx("p",{className:"text-muted-foreground",children:"View agent performance and scorecards"})]}),e.jsxs(Ks,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Hs,{className:"w-[120px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:jks.map(o=>e.jsx(Mt,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Agents Tracking"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(No,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with transactions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Agents with Scorecards"}),e.jsx(gr,{children:"Click to view individual agent scorecards"})]}),e.jsx(Oe,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(No,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Email"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:n.map(o=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:o.name}),e.jsx(dt,{className:"text-muted-foreground",children:o.email}),e.jsx(dt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(Ln,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const Tlt=new Date().getFullYear(),kks=Array.from({length:10},(t,s)=>Tlt-s);function vze(){var _;const{userId:t}=yo(),s=fr(),n=id().pathname.startsWith("/mission-control"),[a,o]=k.useState(Tlt),{data:l,isLoading:i}=mt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:j,error:w}=await H.from("profiles").select("id, name, email").eq("id",t).single();if(w)throw w;return j},enabled:!!t}),{data:c,isLoading:u}=CNe(a,t),{yearStats:p,lifetimeStats:f,showCommission:g}=hXe(a,t),{data:b}=uXe(a,t);return i?e.jsx(Ms,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(j=>e.jsx(ys,{className:"h-24"},j))})]})}):e.jsx(Ms,{title:`${l==null?void 0:l.name}'s Scorecard`,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s(n?"/mission-control/scorecard":"/admin/scorecard"),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:l==null?void 0:l.name}),e.jsx("p",{className:"text-muted-foreground",children:l==null?void 0:l.email})]})]}),e.jsxs(Ks,{value:String(a),onValueChange:j=>o(Number(j)),children:[e.jsx(Hs,{className:"w-[120px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:kks.map(j=>e.jsx(Mt,{value:String(j),children:j},j))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[p.buyerCount,"/",p.sellerCount]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ac,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Zl(p.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ul,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Zl(p.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((_=p.topLeadSource)==null?void 0:_.name)||"-"})]})})]}),b&&e.jsx(Gat,{goals:b,stats:p,year:a,showCommission:g}),e.jsxs(ba,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"transactions",children:"Transactions"}),e.jsx(ns,{value:"charts",children:"Charts"}),e.jsxs(ns,{value:"map",children:[e.jsx(ma,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(bs,{value:"transactions",children:e.jsx(dSe,{transactions:c||[],showCommission:g,isLoading:u})}),e.jsx(bs,{value:"charts",children:e.jsx(uSe,{stats:p,year:a})}),e.jsx(bs,{value:"map",children:e.jsx(hSe,{transactions:c||[],isLoading:u})})]})]})})}function Sks(){const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState("all");BZe();const{data:o,refetch:l}=mt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:L}=await H.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(L==null?void 0:L.enabled)??!1}}),{data:i,isLoading:c}=mt({queryKey:["admin-listings"],queryFn:async()=>{const{data:L,error:I}=await H.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 L}}),{data:u}=mt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:L}=await H.from("listings").select("id, is_approved, status"),{data:I}=await H.from("listing_shares").select("id"),{data:O}=await H.from("listing_views").select("id");return{total:(L==null?void 0:L.length)||0,pending:(L==null?void 0:L.filter(q=>!q.is_approved).length)||0,active:(L==null?void 0:L.filter(q=>q.status==="active").length)||0,totalShares:(I==null?void 0:I.length)||0,totalViews:(O==null?void 0:O.length)||0}}}),p=async(L,I,O="submit_url")=>{try{const{data:{session:q}}=await H.auth.getSession();if(!q)return;const{data:U,error:B}=await H.functions.invoke("google-indexing",{body:{action:O,listing_id:L,listing_slug:I}});if(B)throw B;if((U==null?void 0:U.configured)===!1)return;U!=null&&U.success&&me.success("Submitted to Google for indexing")}catch(q){console.error("Google indexing submission failed:",q)}},f=Lt({mutationFn:async()=>{const{data:{session:L}}=await H.auth.getSession();if(!L)throw new Error("Not authenticated");const{data:I,error:O}=await H.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(O)throw O;return I},onSuccess:L=>{if((L==null?void 0:L.configured)===!1){me.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}me.success(`Submitted ${(L==null?void 0:L.succeeded)||0} URLs to Google (${(L==null?void 0:L.failed)||0} failed)`)},onError:L=>{me.error("Failed to submit to Google"),console.error(L)}}),g=Lt({mutationFn:async({id:L,approved:I,slug:O})=>{const{error:q}=await H.from("listings").update({is_approved:I}).eq("id",L);if(q)throw q;return{id:L,approved:I,slug:O}},onSuccess:L=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success(L.approved?"Listing approved":"Listing unapproved"),L.approved?p(L.id,L.slug||null,"submit_url"):p(L.id,L.slug||null,"remove_url")}}),b=Lt({mutationFn:async({id:L,featured:I})=>{const{error:O}=await H.from("listings").update({is_featured:I}).eq("id",L);if(O)throw O},onSuccess:(L,{featured:I})=>{t.invalidateQueries({queryKey:["admin-listings"]}),me.success(I?"Listing featured":"Listing unfeatured")}}),_=Lt({mutationFn:async L=>{const{error:I}=await H.from("listings").delete().eq("id",L);if(I)throw I},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success("Listing deleted")}}),j=Lt({mutationFn:async L=>{const{error:I}=await H.from("feature_flags").update({enabled:L}).eq("key","listing_exchange_enabled");if(I)throw I},onSuccess:()=>{l(),me.success("Feature flag updated")}}),w=o??!1,N=i==null?void 0:i.filter(L=>{var q,U,B,V;const I=((q=L.city)==null?void 0:q.toLowerCase().includes(s.toLowerCase()))||((B=(U=L.agent)==null?void 0:U.name)==null?void 0:B.toLowerCase().includes(s.toLowerCase()))||((V=L.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),O=n==="all"||n==="pending"&&!L.is_approved||n==="approved"&&L.is_approved;return I&&O}),S=L=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(L),M=L=>{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[L]||I.active};return e.jsx(Ms,{title:"Listing Exchange Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage community listings"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(su,{className:"h-4 w-4"}),"Submit All to Google"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Feature visible to agents"}),e.jsx(qr,{checked:w,onCheckedChange:L=>j.mutate(L)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Listings"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.total)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ul,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Active"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.active)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Pending Review"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.pending)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ln,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Views"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalViews)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wd,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Shares"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalShares)||0})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by city, address, or agent...",value:s,onChange:L=>r(L.target.value),className:"pl-9"})]}),e.jsx(ba,{value:n,onValueChange:L=>a(L),children:e.jsxs(pa,{children:[e.jsx(ns,{value:"all",children:"All"}),e.jsx(ns,{value:"pending",children:"Pending"}),e.jsx(ns,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{children:["Listings (",(N==null?void 0:N.length)||0,")"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Property"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Price"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-center",children:"Approved"}),e.jsx(St,{className:"text-center",children:"Featured"}),e.jsx(St,{children:"Views"}),e.jsx(St,{children:"Shares"}),e.jsx(St,{children:"Date"}),e.jsx(St,{})]})}),e.jsx(zn,{children:c?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(N==null?void 0:N.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):N==null?void 0:N.map(L=>{var I,O,q,U,B;return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(O=(I=L.photos)==null?void 0:I[0])!=null&&O.photo_url?e.jsx("img",{src:L.photos[0].photo_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(ka,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.property_address||`${L.city}, ${L.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(q=L.property_type)==null?void 0:q.replace("_"," ")})]})]})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm",children:((U=L.agent)==null?void 0:U.name)||"Unknown"})}),e.jsx(dt,{className:"font-medium",children:S(L.price)}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",className:M(L.status),children:(B=L.status)==null?void 0:B.replace("_"," ")})}),e.jsx(dt,{className:"text-center",children:e.jsx(qr,{checked:L.is_approved??!1,onCheckedChange:V=>g.mutate({id:L.id,approved:V,slug:L.slug})})}),e.jsx(dt,{className:"text-center",children:e.jsx(qr,{checked:L.is_featured??!1,onCheckedChange:V=>b.mutate({id:L.id,featured:V})})}),e.jsx(dt,{children:L.view_count||0}),e.jsx(dt,{children:L.share_count||0}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ms(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(fx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Ma,{onClick:()=>window.open(`/mission-control/listings/${L.id}`,"_blank"),children:[e.jsx(Ln,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Ma,{onClick:()=>b.mutate({id:L.id,featured:!L.is_featured}),children:[e.jsx(Jn,{className:"h-4 w-4 mr-2"}),L.is_featured?"Unfeature":"Feature"]}),e.jsxs(Ma,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&_.mutate(L.id)},children:[e.jsx(Rr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},L.id)})})]})})})]})]})})}const Cks=()=>{var f,g;const[t,s]=k.useState(""),[r,n]=k.useState(null),{data:a,isLoading:o}=mt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:b,error:_}=await H.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(_)throw _;const j=(b==null?void 0:b.map(S=>S.user_id))||[],{data:w}=await H.from("profiles").select("id, name, email").in("id",j);return b==null?void 0:b.map(S=>({...S,profiles:(w==null?void 0:w.find(M=>M.id===S.user_id))||null}))}}),l=a==null?void 0:a.filter(b=>{var j,w,N,S,M;const _=t.toLowerCase();return((w=(j=b.profiles)==null?void 0:j.name)==null?void 0:w.toLowerCase().includes(_))||((S=(N=b.profiles)==null?void 0:N.email)==null?void 0:S.toLowerCase().includes(_))||((M=b.review_text)==null?void 0:M.toLowerCase().includes(_))}),i=a!=null&&a.length?(a.reduce((b,_)=>b+_.rating,0)/a.length).toFixed(1):"0.0",c=a==null?void 0:a.reduce((b,_)=>(b[_.rating]=(b[_.rating]||0)+1,b),{}),u=(a==null?void 0:a.filter(b=>b.posted_to_google).length)||0,p=b=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(_=>e.jsx(Jn,{className:It("h-4 w-4",b>=_?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},_))});return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Membership Reviews",description:"View and manage feedback from LevelUp members"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Total Reviews"}),e.jsx(Rt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Average Rating"}),e.jsxs(Rt,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(Jn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"5-Star Reviews"}),e.jsx(Rt,{className:"text-3xl",children:(c==null?void 0:c[5])||0})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Posted to Google"}),e.jsxs(Rt,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(tn,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or review...",value:t,onChange:b=>s(b.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Member"}),e.jsx(St,{children:"Rating"}),e.jsx(St,{className:"hidden md:table-cell",children:"Review"}),e.jsx(St,{children:"Google"}),e.jsx(St,{children:"Date"})]})}),e.jsx(zn,{children:o?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(b=>{var _,j;return e.jsxs(Ss,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(b),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((_=b.profiles)==null?void 0:_.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(j=b.profiles)==null?void 0:j.email})]})}),e.jsx(dt,{children:p(b.rating)}),e.jsx(dt,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:b.review_text||"-"})}),e.jsx(dt,{children:b.posted_to_google?e.jsx(st,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(st,{variant:"outline",children:"No"})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ms(new Date(b.created_at),"MMM d, yyyy")})]},b.id)})})]})})}),e.jsx(fs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Review Details"})}),r&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:((f=r.profiles)==null?void 0:f.name)||"Unknown Member"}),((g=r.profiles)==null?void 0:g.email)&&e.jsxs("a",{href:`mailto:${r.profiles.email}`,className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-primary",children:[e.jsx(cr,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[p(r.rating),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.rating," out of 5 stars"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Review"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.review_text||"No written review provided."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4"}),ms(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(st,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(tn,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(st,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},Mks=[{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"}],Tks=Array.from({length:24},(t,s)=>({value:String(s),label:s===0?"12:00 AM":s<12?`${s}:00 AM`:s===12?"12:00 PM":`${s-12}:00 PM`}));function Aks(){const t=Qt(),{user:s}=Ds(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),{data:c,isLoading:u}=mt({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:U,error:B}=await H.from("weekly_digest_settings").select("*").single();if(B)throw B;return U}}),{data:p,isLoading:f}=mt({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:U,error:B}=await H.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(B)throw B;return U}}),{data:g}=mt({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:U,error:B}=await H.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(B)throw B;return U||0}}),{data:b,refetch:_}=mt({queryKey:["digest-queue-status"],queryFn:async()=>{const U=new Date;U.setUTCHours(0,0,0,0);const[B,V,Y,Q]=await Promise.all([H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",U.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",U.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",U.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",U.toISOString())]);return{pending:B.count||0,processing:V.count||0,sent:Y.count||0,failed:Q.count||0,total:(B.count||0)+(V.count||0)+(Y.count||0)+(Q.count||0)}},refetchInterval:5e3});k.useEffect(()=>{if(b&&(b.pending>0||b.processing>0)){const U=setInterval(()=>{_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(U)}},[b,_,t]);const{data:j=0}=mt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const U=new Date;U.setUTCHours(0,0,0,0);const{count:B,error:V}=await H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",U.toISOString());if(V)throw V;return B||0}}),w=Lt({mutationFn:async U=>{const{error:B}=await H.from("weekly_digest_settings").update(U).eq("id",c==null?void 0:c.id);if(B)throw B},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),me.success("Settings updated")},onError:U=>{me.error("Failed to update settings: "+U.message)}}),N=async()=>{n(!0);try{const{data:U,error:B}=await H.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(B)throw B;U.queued?me.success(`${U.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):U.sent!==void 0&&me.success(`Digest sent! ${U.sent} emails delivered, ${U.failed} failed`),_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(U){me.error("Failed to send digest: "+U.message)}finally{n(!1)}},S=async()=>{var U,B,V,Y,Q,ee;if(!(s!=null&&s.email)){me.error("No email found for your account");return}o(!0);try{const{data:X,error:ie}=await H.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(ie)throw ie;const re=X==null?void 0:X.resendId,oe=X==null?void 0:X.resendDetails,ce=oe==null?void 0:oe.status,ge=((U=oe==null?void 0:oe.body)==null?void 0:U.status)||((V=(B=oe==null?void 0:oe.body)==null?void 0:B.data)==null?void 0:V.status),ye=((Q=(Y=oe==null?void 0:oe.body)==null?void 0:Y.error)==null?void 0:Q.message)||((ee=oe==null?void 0:oe.body)==null?void 0:ee.message);me.success(re?`Preview accepted by email provider (id: ${re})${ce?`, status check: ${ce}`:""}${ge?`, provider: ${ge}`:""}${ye?` (${ye})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(X){me.error("Failed to send preview: "+X.message)}finally{o(!1)}},M=async()=>{i(!0);try{const{data:U,error:B}=await H.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(B)throw B;U.queued===0||U.sent===0&&U.failed===0&&!U.queued?me.info("No failed emails to retry"):U.queued?me.success(`${U.queued} emails queued for retry!`):me.success(`Retry complete! ${U.sent} emails delivered, ${U.failed} failed`),_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch(U){me.error("Failed to retry: "+U.message)}finally{i(!1)}},L=b!=null&&b.total?Math.round((b.sent+b.failed)/b.total*100):0,I=((b==null?void 0:b.pending)||0)>0||((b==null?void 0:b.processing)||0)>0,{data:O}=mt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var ee,X;const U=new Date;U.setUTCHours(0,0,0,0);const[B,V,Y,Q]=await Promise.all([H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",U.toISOString()),H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",U.toISOString()),H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",U.toISOString()),H.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:B.count||0,totalFailed:V.count||0,agentOsEngaged:Y.count||0,lastSent:((X=(ee=Q.data)==null?void 0:ee[0])==null?void 0:X.sent_at)||null}},refetchInterval:I?5e3:!1}),q={totalSent:(O==null?void 0:O.totalSent)||0,totalFailed:(O==null?void 0:O.totalFailed)||0,lastSent:O==null?void 0:O.lastSent,agentOsEngaged:(O==null?void 0:O.agentOsEngaged)||0};return u?e.jsx(Ms,{title:"Weekly Digest",description:"Manage automated weekly email digests",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-32 bg-muted rounded-lg"}),e.jsx("div",{className:"h-64 bg-muted rounded-lg"})]})}):e.jsx(Ms,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(ba,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(ns,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(No,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(bs,{value:"settings",className:"space-y-6",children:[I&&b&&e.jsx(Ee,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(ws,{className:"h-5 w-5 animate-spin text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Sending emails..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[b.sent.toLocaleString()," sent, ",b.pending.toLocaleString()," pending",b.failed>0&&`, ${b.failed} failed`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[L,"%"]})]}),e.jsx(Bi,{value:L,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Processing ~80 emails per minute. Estimated time remaining: ~",Math.ceil(b.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(pr,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:g}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribers"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10",children:e.jsx(sa,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-destructive/10",children:e.jsx(vc,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(un,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.lastSent?ms(new Date(q.lastSent),"MMM d"):"Never"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Sent"})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(gr,{children:"Configure when the digest is sent"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(qr,{checked:c==null?void 0:c.is_enabled,onCheckedChange:U=>w.mutate({is_enabled:U})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Cron Frequency"}),e.jsxs(Ks,{value:(c==null?void 0:c.cron_frequency)||"daily",onValueChange:U=>w.mutate({cron_frequency:U}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(Mt,{value:"hourly",children:"Hourly (checks every hour)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(c==null?void 0:c.cron_frequency)==="hourly"?"Cron runs every hour; digest sends when day & hour match.":"Cron runs once daily at the selected hour (UTC)."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Day of Week"}),e.jsxs(Ks,{value:String(c==null?void 0:c.send_day),onValueChange:U=>w.mutate({send_day:parseInt(U)}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Mks.map(U=>e.jsx(Mt,{value:U.value,children:U.label},U.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Time (UTC)"}),e.jsxs(Ks,{value:String(c==null?void 0:c.send_hour),onValueChange:U=>w.mutate({send_hour:parseInt(U)}),disabled:(c==null?void 0:c.cron_frequency)==="daily",children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Tks.map(U=>e.jsx(Mt,{value:U.value,children:U.label},U.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{onClick:S,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(Ln,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:N,disabled:r,className:"flex-1",children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),j>0&&e.jsxs(K,{onClick:M,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(Go,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${j} Failed`]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(gr,{children:"Choose what to include in the digest"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"New Resources"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_new_resources,onCheckedChange:U=>w.mutate({include_new_resources:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"Community Highlights"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_community_posts,onCheckedChange:U=>w.mutate({include_community_posts:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(No,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"Agent OS Stats"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_agent_os_stats,onCheckedChange:U=>w.mutate({include_agent_os_stats:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"Upcoming Events"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_upcoming_events,onCheckedChange:U=>w.mutate({include_upcoming_events:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"Goals Progress"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_goals_progress,onCheckedChange:U=>w.mutate({include_goals_progress:U})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Custom Introduction"}),e.jsx(gr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Oe,{children:e.jsx(Er,{placeholder:"Here's what's new this week to help you grow your business...",value:(c==null?void 0:c.custom_intro_text)||"",onChange:U=>w.mutate({custom_intro_text:U.target.value||null}),rows:3})})]})]}),e.jsx(bs,{value:"stats",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(gr,{children:"Recent digest emails sent to members"})]}),e.jsx(Oe,{children:f?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(U=>e.jsx("div",{className:"h-12 bg-muted rounded"},U))}):p&&p.length>0?e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Sent At"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Resources"}),e.jsx(St,{children:"Agent OS"})]})}),e.jsx(zn,{children:p.map(U=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:U.email_sent_to}),e.jsx(dt,{children:ms(new Date(U.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:e.jsx(st,{variant:U.delivery_status==="sent"?"default":"destructive",children:U.delivery_status})}),e.jsx(dt,{children:U.resources_count}),e.jsx(dt,{children:U.has_agent_os_activity?e.jsx(st,{variant:"secondary",children:"Active"}):e.jsx(st,{variant:"outline",children:"Not Started"})})]},U.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(cr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No digests sent yet"}),e.jsx("p",{className:"text-sm",children:"Send your first digest to see delivery stats"})]})})]})})]})})}const Eks={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 Pks(){var pe,_e,$e;const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(!0),[j,w]=k.useState(!1),[N,S]=k.useState(""),[M,L]=k.useState(null),{data:I,isLoading:O}=mt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Ae,error:Ie}=await H.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Ie)throw Ie;const Ce=(Ae==null?void 0:Ae.map(Le=>Le.user_id))||[],{data:xe}=await H.from("profiles").select("id, name, email").in("id",Ce),we=new Map((xe==null?void 0:xe.map(Le=>[Le.id,{name:Le.name,email:Le.email}]))||[]);return Ae==null?void 0:Ae.map(Le=>({...Le,profile:we.get(Le.user_id)||null}))}}),{data:q}=mt({queryKey:["all-profiles-for-points",I],queryFn:async()=>{const Ie=[];let Ce=0;for(;;){const{data:xe,error:we}=await H.from("profiles").select("id, name, email").order("name").range(Ce,Ce+1e3-1);if(we)throw we;if(Ie.push(...xe),!xe||xe.length<1e3)break;Ce+=1e3}return Ie}}),B=((q==null?void 0:q.filter(Ae=>!(I!=null&&I.some(Ie=>Ie.user_id===Ae.id))))||[]).filter(Ae=>{var Ce,xe;if(!N)return!0;const Ie=N.toLowerCase();return((Ce=Ae.name)==null?void 0:Ce.toLowerCase().includes(Ie))||((xe=Ae.email)==null?void 0:xe.toLowerCase().includes(Ie))}),{data:V,isLoading:Y}=mt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ae,error:Ie}=await H.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Ie)throw Ie;return Ae},enabled:!!(n!=null&&n.user_id)&&i}),{data:Q}=mt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ae,error:Ie}=await H.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Ie)throw Ie;return Ae},enabled:!!(n!=null&&n.user_id)}),ee=Lt({mutationFn:async({userId:Ae,points:Ie,reason:Ce})=>{const{error:xe}=await H.from("agent_points").insert({user_id:Ae,points:Ie,reason:Ce});if(xe)throw xe;const{data:we}=await H.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Ae).maybeSingle(),Le=((we==null?void 0:we.total_points)||0)+Ie,tt=((we==null?void 0:we.spendable_points)||0)+Ie,{error:Te}=await H.from("agent_attendance_stats").upsert({user_id:Ae,total_points:Math.max(0,Le),spendable_points:Math.max(0,tt),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(Te)throw Te},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),p(""),g(""),me.success(b?"Points awarded successfully!":"Points deducted successfully!")},onError:Ae=>{console.error("Error modifying points:",Ae),me.error("Failed to modify points")}}),X=()=>{if(!n||!u||!f){me.error("Please fill in all fields");return}const Ae=parseInt(u);if(isNaN(Ae)||Ae<=0){me.error("Please enter a valid positive number");return}ee.mutate({userId:n.user_id,points:b?Ae:-Ae,reason:f})},ie=()=>{if(!M||!u||!f){me.error("Please fill in all fields");return}const Ae=parseInt(u);if(isNaN(Ae)||Ae<=0){me.error("Please enter a valid positive number");return}ee.mutate({userId:M.id,points:Ae,reason:f},{onSuccess:()=>{w(!1),L(null),S("")}})},re=(Ae,Ie)=>{a(Ae),_(Ie),l(!0)},oe=Ae=>{a(Ae),c(!0)},ce=I==null?void 0:I.filter(Ae=>{var we,Le,tt,Te;const Ie=((Le=(we=Ae.profile)==null?void 0:we.name)==null?void 0:Le.toLowerCase())||"",Ce=((Te=(tt=Ae.profile)==null?void 0:tt.email)==null?void 0:Te.toLowerCase())||"",xe=s.toLowerCase();return Ie.includes(xe)||Ce.includes(xe)}),ge=(I==null?void 0:I.reduce((Ae,Ie)=>Ae+Ie.total_points,0))||0,ye=(I==null?void 0:I.length)||0,ue=ye>0?Math.round(ge/ye):0;return O?e.jsx(Ms,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Ae=>e.jsx(ys,{className:"h-24"},Ae))}),e.jsx(ys,{className:"h-96"})]})}):e.jsx(Ms,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Agent Points Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Track, view, and manage agent gamification points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ye}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ge.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ul,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Average Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ue}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"per agent"})]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:s,onChange:Ae=>r(Ae.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>w(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Agent Leaderboard"}),e.jsx(gr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Oe,{children:!ce||ce.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(xo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Total Points"}),e.jsx(St,{className:"text-center",children:"Spendable"}),e.jsx(St,{className:"text-center",children:"Events"}),e.jsx(St,{className:"text-center",children:"Streak"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:ce.map((Ae,Ie)=>{var Ce,xe,we,Le;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:Ie<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Ie===0?"bg-yellow-100 text-yellow-700":Ie===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Ie+1}):e.jsx("span",{className:"text-muted-foreground",children:Ie+1})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{children:((xe=(Ce=Ae.profile)==null?void 0:Ce.name)==null?void 0:xe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((we=Ae.profile)==null?void 0:we.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Le=Ae.profile)==null?void 0:Le.email})]})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Ae.total_points]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(ko,{className:"h-3 w-3 mr-1"}),Ae.spendable_points||0]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3 text-muted-foreground"}),Ae.total_events_attended]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(eh,{className:"h-3 w-3 text-orange-500"}),Ae.current_streak]})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(Ae,!0),title:"Award points",children:e.jsx($s,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(Ae,!1),title:"Deduct points",children:e.jsx(f0,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>oe(Ae),title:"View history",children:e.jsx(IM,{className:"h-4 w-4"})})]})})]},Ae.user_id)})})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:b?"Award Points":"Deduct Points"}),e.jsxs(Gr,{children:[b?"Award":"Deduct"," points ",b?"to":"from"," ",((pe=n==null?void 0:n.profile)==null?void 0:pe.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"points",children:"Points Amount"}),e.jsx(ze,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Ae=>p(Ae.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"reason",children:"Reason"}),e.jsx(Er,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:Ae=>g(Ae.target.value)})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:X,disabled:ee.isPending,className:b?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:ee.isPending?"Saving...":b?"Award Points":"Deduct Points"})]})]})}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsxs(vs,{children:["Point History: ",(_e=n==null?void 0:n.profile)==null?void 0:_e.name]}),e.jsx(Gr,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(ba,{defaultValue:"history",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsx(ns,{value:"history",children:"Point History"}),e.jsx(ns,{value:"badges",children:"Badges"})]}),e.jsx(bs,{value:"history",className:"mt-4",children:Y?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Ae=>e.jsx(ys,{className:"h-12"},Ae))}):!V||V.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(IM,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No point history yet"})]}):e.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:V.map(Ae=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:Ae.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ms(new Date(Ae.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(st,{variant:Ae.points>=0?"default":"destructive",className:Ae.points>=0?"bg-green-100 text-green-800":"",children:[Ae.points>=0?"+":"",Ae.points]})]},Ae.id))})}),e.jsx(bs,{value:"badges",className:"mt-4",children:!Q||Q.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Nc,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No badges earned yet"})]}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Q.map(Ae=>e.jsxs("div",{className:`p-3 rounded-lg ${Eks[Ae.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:Ae.badge_name})]}),Ae.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:Ae.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",ms(new Date(Ae.earned_at),"MMM d, yyyy")]})]},Ae.id))})})]})]})}),e.jsx(fs,{open:j,onOpenChange:Ae=>{w(Ae),Ae||(L(null),S(""),p(""),g(""))},children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Award Points to New Agent"}),e.jsx(Gr,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:M?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(Nn,{className:"h-10 w-10",children:e.jsx(kn,{children:(($e=M.name)==null?void 0:$e.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:M.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:M.email})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>L(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(ze,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Ae=>p(Ae.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Er,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:Ae=>g(Ae.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:N,onChange:Ae=>S(Ae.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:B.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(pr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:N?"No matching agents found":"All agents already have points"})]}):B.slice(0,20).map(Ae=>{var Ie;return e.jsxs("button",{onClick:()=>L(Ae),className:"w-full flex items-center gap-3 p-3 hover:bg-muted/50 transition-colors border-b last:border-b-0 text-left",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{children:((Ie=Ae.name)==null?void 0:Ie.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Ae.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ae.email})]})]},Ae.id)})})]})}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),M&&e.jsxs(K,{onClick:ie,disabled:ee.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function Iks(){const{data:t,isLoading:s}=dkt(),[r,n]=k.useState(null),[a,o]=k.useState(!1),[l,i]=k.useState(""),[c,u]=k.useState("all"),[p,f]=k.useState("newest"),[g,b]=k.useState("table"),_=k.useMemo(()=>(t==null?void 0:t.map(M=>M.user_id))||[],[t]),j=k.useMemo(()=>(t==null?void 0:t.map(M=>M.id))||[],[t]),{data:w}=mt({queryKey:["card-profiles-lookup",_],queryFn:async()=>{if(_.length===0)return{};const{data:M}=await H.from("profiles").select("id, name, email").in("id",_),L={};return M==null||M.forEach(I=>{L[I.id]={name:I.name||"",email:I.email||""}}),L},enabled:_.length>0}),{data:N}=mt({queryKey:["card-stats-all",j],queryFn:async()=>{if(j.length===0)return{};const M={};j.forEach(O=>{M[O]={views:0,leads:0}});const{data:L}=await H.from("agent_card_interactions").select("card_id").in("card_id",j).eq("interaction_type","card_view");L==null||L.forEach(O=>{M[O.card_id]&&M[O.card_id].views++});const{data:I}=await H.from("agent_card_leads").select("card_id").in("card_id",j);return I==null||I.forEach(O=>{M[O.card_id]&&M[O.card_id].leads++}),M},enabled:j.length>0}),S=k.useMemo(()=>{if(!t)return[];let M=[...t];if(c==="live"?M=M.filter(L=>L.is_published):c==="draft"&&(M=M.filter(L=>!L.is_published)),l.trim()){const L=l.toLowerCase();M=M.filter(I=>{var q,U;const O=w==null?void 0:w[I.user_id];return I.slug.toLowerCase().includes(L)||((q=O==null?void 0:O.name)==null?void 0:q.toLowerCase().includes(L))||((U=O==null?void 0:O.email)==null?void 0:U.toLowerCase().includes(L))})}return p==="newest"?M.sort((L,I)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="oldest"?M.sort((L,I)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="name"?M.sort((L,I)=>{var O,q;return(((O=w==null?void 0:w[L.user_id])==null?void 0:O.name)||"").localeCompare(((q=w==null?void 0:w[I.user_id])==null?void 0:q.name)||"")}):p==="slug"?M.sort((L,I)=>L.slug.localeCompare(I.slug)):p==="views_desc"?M.sort((L,I)=>{var O,q;return(((O=N==null?void 0:N[I.id])==null?void 0:O.views)||0)-(((q=N==null?void 0:N[L.id])==null?void 0:q.views)||0)}):p==="views_asc"?M.sort((L,I)=>{var O,q;return(((O=N==null?void 0:N[L.id])==null?void 0:O.views)||0)-(((q=N==null?void 0:N[I.id])==null?void 0:q.views)||0)}):p==="leads_desc"?M.sort((L,I)=>{var O,q;return(((O=N==null?void 0:N[I.id])==null?void 0:O.leads)||0)-(((q=N==null?void 0:N[L.id])==null?void 0:q.leads)||0)}):p==="leads_asc"&&M.sort((L,I)=>{var O,q;return(((O=N==null?void 0:N[L.id])==null?void 0:O.leads)||0)-(((q=N==null?void 0:N[I.id])==null?void 0:q.leads)||0)}),M},[t,c,l,p,w]);return e.jsxs(Ms,{title:"Digital Agent Cards",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Digital Agent Cards"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage agent digital business cards"})]}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create Card"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or slug...",value:l,onChange:M=>i(M.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:c,onValueChange:u,children:[e.jsx(Hs,{className:"w-full sm:w-36",children:e.jsx(Ys,{placeholder:"Status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"live",children:"Live"}),e.jsx(Mt,{value:"draft",children:"Draft"})]})]}),e.jsxs(Ks,{value:p,onValueChange:f,children:[e.jsx(Hs,{className:"w-full sm:w-44",children:e.jsx(Ys,{placeholder:"Sort by"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"newest",children:"Newest First"}),e.jsx(Mt,{value:"oldest",children:"Oldest First"}),e.jsx(Mt,{value:"name",children:"Name A–Z"}),e.jsx(Mt,{value:"slug",children:"Slug A–Z"}),e.jsx(Mt,{value:"views_desc",children:"Most Views"}),e.jsx(Mt,{value:"views_asc",children:"Fewest Views"}),e.jsx(Mt,{value:"leads_desc",children:"Most Leads"}),e.jsx(Mt,{value:"leads_asc",children:"Fewest Leads"})]})]}),e.jsxs("div",{className:"flex border rounded-md",children:[e.jsx(K,{variant:g==="table"?"default":"ghost",size:"sm",onClick:()=>b("table"),className:"rounded-r-none",children:e.jsx(qM,{className:"h-4 w-4"})}),e.jsx(K,{variant:g==="grid"?"default":"ghost",size:"sm",onClick:()=>b("grid"),className:"rounded-l-none",children:e.jsx(Cp,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",S.length," of ",t.length," cards"]}),s?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(M=>e.jsx(ys,{className:"h-48"},M))}):S.length>0?g==="table"?e.jsx(Lks,{cards:S,cardProfiles:w,cardStats:N,onEdit:n,sortBy:p,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:S.map(M=>e.jsx(Dks,{card:M,onEdit:()=>n(M),stats:N==null?void 0:N[M.id]},M.id))}):t&&t.length>0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(cn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No matching cards"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your search or filters"})]})}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(pr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No cards yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first digital agent card"}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(Oks,{open:a,onOpenChange:o}),r&&e.jsx(Rks,{card:r,open:!!r,onOpenChange:M=>!M&&n(null)})]})}function Lks({cards:t,cardProfiles:s,cardStats:r,onEdit:n,sortBy:a,setSortBy:o}){const l=c=>{a===`${c}_desc`?o(`${c}_asc`):o(`${c}_desc`)},i=({field:c})=>a===`${c}_desc`?e.jsx(Wh,{className:"h-3 w-3"}):a===`${c}_asc`?e.jsx(ku,{className:"h-3 w-3"}):e.jsx(bd,{className:"h-3 w-3 opacity-40"});return e.jsx(Ee,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"text-left p-3 font-medium",children:e.jsxs("button",{onClick:()=>{o(a==="name"?"newest":"name")},className:"flex items-center gap-1 hover:text-foreground text-muted-foreground",children:["Agent ",a==="name"&&e.jsx(ku,{className:"h-3 w-3"})]})}),e.jsx("th",{className:"text-left p-3 font-medium text-muted-foreground hidden md:table-cell",children:"Slug"}),e.jsx("th",{className:"text-center p-3 font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("views"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Views ",e.jsx(i,{field:"views"})]})}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("leads"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Leads ",e.jsx(i,{field:"leads"})]})}),e.jsx("th",{className:"text-right p-3 font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(c=>{const u=s==null?void 0:s[c.user_id],p=r==null?void 0:r[c.id],f=`https://cards.relevelup.com/${c.slug}`;return e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:(u==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u==null?void 0:u.email)||""})]})}),e.jsx("td",{className:"p-3 hidden md:table-cell",children:e.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["/",c.slug]})}),e.jsx("td",{className:"p-3 text-center",children:e.jsx(st,{variant:c.is_published?"default":"secondary",className:"text-xs",children:c.is_published?"Live":"Draft"})}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>n(c),className:"h-8 w-8 p-0",children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(f),me.success("Link copied!")},children:e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",asChild:!0,children:e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{className:"h-3.5 w-3.5"})})})]})})]},c.id)})})]})})})}function Dks({card:t,onEdit:s,stats:r}){const[n,a]=k.useState(null);k.useEffect(()=>{(async()=>{const{data:c}=await H.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:p}=await H.storage.from("avatars").list(`${t.user_id}`);if(p&&p.length>0){const{data:f}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=f.publicUrl}}catch{}a({name:(c==null?void 0:c.name)||"Unknown",avatar_url:u})})()},[t.user_id]);const o=`https://cards.relevelup.com/${t.slug}`,l=()=>{navigator.clipboard.writeText(o),me.success("Link copied!")};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(kn,{children:((n==null?void 0:n.name)||"U")[0]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold truncate",children:(n==null?void 0:n.name)||"Loading..."}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["/card/",t.slug]})]}),e.jsx(st,{variant:t.is_published?"default":"secondary",children:t.is_published?"Live":"Draft"})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ln,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.views)??0," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pr,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.leads)??0," leads"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx(Ra,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:e.jsx(gi,{className:"h-3 w-3"})}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{className:"h-3 w-3"})})})]})]})})}function Oks({open:t,onOpenChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState(!1),p=iGe(),f=l.trim(),{data:g}=mt({queryKey:["profiles-search-for-cards",f],queryFn:async()=>{let S=H.from("profiles").select("id, name, email").order("name").limit(50);f.length>=2&&(S=S.or(`name.ilike.%${f}%,email.ilike.%${f}%`));const{data:M}=await S;return M||[]},enabled:t}),[b,_]=k.useState(null),j=(g==null?void 0:g.find(S=>S.id===r))||b,w=()=>{if(!r||!a.trim()){me.error("Select an agent and enter a slug");return}p.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},N=S=>{var L;n(S),u(!1);const M=g==null?void 0:g.find(I=>I.id===S);M&&(_(M),o(((L=M.name)==null?void 0:L.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create Agent Card"}),e.jsx(Gr,{children:"Select an agent and set their card URL slug."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Agent"}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":c,className:"w-full justify-between font-normal",children:[j?`${j.name} (${j.email})`:"Search for an agent...",e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Dx,{shouldFilter:!1,children:[e.jsx(Ox,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(Rx,{children:[e.jsx(Fx,{children:"No agents found."}),e.jsx(zx,{children:(g||[]).map(S=>e.jsxs(bp,{value:S.id,onSelect:N,children:[e.jsx(va,{className:It("mr-2 h-4 w-4",r===S.id?"opacity-100":"opacity-0")}),S.name," (",S.email,")"]},S.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"URL Slug"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"/card/"}),e.jsx(ze,{value:a,onChange:S=>o(S.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{onClick:w,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function Rks({card:t,open:s,onOpenChange:r}){const n=oGe(),{data:a}=lGe(t.id),o=Qt(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(!1),[g,b]=k.useState(""),[_,j]=k.useState(t.slug),[w,N]=k.useState(!1),[S,M]=k.useState({is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",custom_cta_url:t.custom_cta_url||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56});k.useEffect(()=>{s&&(async()=>{try{const{data:V}=await H.storage.from("avatars").list(`${t.user_id}`);if(V&&V.length>0){const{data:Y}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${V[0].name}`);i(`${Y.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const L=B=>{var Q;const V=(Q=B.target.files)==null?void 0:Q[0];if(!V)return;if(!V.type.startsWith("image/")){me.error("Please select an image file");return}if(V.size>5*1024*1024){me.error("Image must be under 5MB");return}const Y=new FileReader;Y.onloadend=()=>{b(Y.result),f(!0)},Y.readAsDataURL(V),B.target.value=""},I=async B=>{u(!0);try{const{data:V}=await H.storage.from("avatars").list(`${t.user_id}`);V&&V.length>0&&await H.storage.from("avatars").remove(V.map(ie=>`${t.user_id}/${ie.name}`));const Y=`${t.user_id}/avatar.jpg`,{error:Q}=await H.storage.from("avatars").upload(Y,B,{upsert:!0,contentType:"image/jpeg"});if(Q)throw Q;const{data:ee}=H.storage.from("avatars").getPublicUrl(Y),X=`${ee.publicUrl}?t=${Date.now()}`;i(X),await H.from("profiles").update({avatar_url:X}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),me.success("Photo updated!")}catch(V){me.error(V.message||"Upload failed")}finally{u(!1)}},O=async()=>{const B=_.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!B){me.error("Please enter a valid URL");return}if(B===t.slug){me.info("No changes to save");return}N(!0);try{const{data:V}=await H.from("agent_cards").select("id").eq("slug",B).neq("id",t.id).maybeSingle();if(V){me.error("This URL is already taken. Try another one.");return}const{error:Y}=await H.from("agent_cards").update({slug:B}).eq("id",t.id);if(Y)throw Y;j(B),o.invalidateQueries({queryKey:["agent-cards-admin"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{N(!1)}},q=async(B,V)=>{var Q;const Y=(Q=B.target.files)==null?void 0:Q[0];if(Y){if(!Y.type.startsWith("image/")){me.error("Please select an image file");return}try{const ee=Y.name.split(".").pop()||"png",X=V==="brokerage_logo_url"?"brokerage-logo":"team-logo",ie=`${t.user_id}/${X}.${ee}`,{error:re}=await H.storage.from("card-logos").upload(ie,Y,{upsert:!0});if(re)throw re;const{data:oe}=H.storage.from("card-logos").getPublicUrl(ie),ce=oe.publicUrl+"?t="+Date.now();M(V==="brokerage_logo_url"?ge=>({...ge,[V]:ce,brokerage_display_name:""}):ge=>({...ge,[V]:ce,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{B.target.value=""}}},U=()=>{n.mutate({id:t.id,...S,title:S.title||null,positioning_statement:S.positioning_statement||null,bio:S.bio||null,review_snippet:S.review_snippet||null,review_source_url:S.review_source_url||null,booking_url:S.booking_url||null,custom_cta_label:S.custom_cta_label||null,custom_cta_url:S.custom_cta_url||null,brokerage_display_name:S.brokerage_display_name||null,brokerage_logo_url:S.brokerage_logo_url||null,brokerage_logo_size:S.brokerage_logo_size,team_name:S.team_name||null,team_logo_url:S.team_logo_url||null,team_logo_size:S.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Agent Card"}),e.jsxs(Gr,{children:["/card/",t.slug]})]}),e.jsxs(ba,{defaultValue:"content",children:[e.jsxs(pa,{className:"w-full",children:[e.jsx(ns,{value:"content",className:"flex-1",children:"Content"}),e.jsx(ns,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(ns,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(ns,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(bs,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Published"}),e.jsx(qr,{checked:S.is_published,onCheckedChange:B=>M(V=>({...V,is_published:B}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(Nn,{className:"h-16 w-16",children:[e.jsx($a,{src:l||void 0}),e.jsx(kn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:L,disabled:c}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:c,children:e.jsx("span",{children:c?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Card Address"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("div",{className:"flex flex-1",children:[e.jsx("span",{className:"inline-flex items-center px-3 rounded-l-md border border-r-0 bg-muted text-muted-foreground text-xs whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(ze,{value:_,onChange:B=>j(B.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:O,disabled:w||_===t.slug,className:"shrink-0",children:w?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Theme"}),e.jsxs(Ks,{value:S.theme,onValueChange:B=>M(V=>({...V,theme:B})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(Mt,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(Mt,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(Mt,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Title / Tagline"}),e.jsx(ze,{value:S.title,onChange:B=>M(V=>({...V,title:B.target.value})),placeholder:"e.g. Luxury Real Estate Specialist"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Shown below the agent's name on the card"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Positioning Statement"}),e.jsx(ze,{value:S.positioning_statement,onChange:B=>M(V=>({...V,positioning_statement:B.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Bio"}),e.jsx(Er,{value:S.bio,onChange:B=>M(V=>({...V,bio:B.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Review Snippet"}),e.jsx(ze,{value:S.review_snippet,onChange:B=>M(V=>({...V,review_snippet:B.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Review Source URL"}),e.jsx(ze,{value:S.review_source_url,onChange:B=>M(V=>({...V,review_source_url:B.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(ze,{value:S.booking_url,onChange:B=>M(V=>({...V,booking_url:B.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Custom CTA Label (optional)"}),e.jsx(ze,{value:S.custom_cta_label,onChange:B=>M(V=>({...V,custom_cta_label:B.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Custom CTA URL (optional)"}),e.jsx(ze,{value:S.custom_cta_url,onChange:B=>M(V=>({...V,custom_cta_url:B.target.value})),placeholder:"https://example.com/landing"})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(be,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{value:S.brokerage_display_name,onChange:B=>M(V=>({...V,brokerage_display_name:B.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!S.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${S.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>M(B=>({...B,brokerage_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(li,{className:"h-3.5 w-3.5"}),S.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>q(B,"brokerage_logo_url")})]})]}),S.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.brokerage_logo_size||56,"px"]})]}),e.jsx(Kg,{value:[S.brokerage_logo_size||56],onValueChange:([B])=>M(V=>({...V,brokerage_logo_size:B})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(be,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{value:S.team_name,onChange:B=>M(V=>({...V,team_name:B.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!S.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.team_logo_url,alt:"Team logo",style:{height:`${S.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>M(B=>({...B,team_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(li,{className:"h-3.5 w-3.5"}),S.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>q(B,"team_logo_url")})]})]}),S.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.team_logo_size||56,"px"]})]}),e.jsx(Kg,{value:[S.team_logo_size||56],onValueChange:([B])=>M(V=>({...V,team_logo_size:B})),min:24,max:120,step:4})]})]})]})]}),e.jsx(bs,{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:B,label:V,hint:Y})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(be,{children:V}),Y&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[Y," ",B==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(qr,{checked:S[B],onCheckedChange:Q=>M(ee=>({...ee,[B]:Q}))})]},B))}),e.jsx(bs,{value:"blocks",className:"mt-4",children:e.jsx(flt,{cardId:t.id})}),e.jsx(bs,{value:"analytics",className:"mt-4",children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.views}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Views"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.clicks}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Clicks"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.leads.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Leads"})]})})]}),a.leads.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Recent Leads"}),e.jsx("div",{className:"space-y-2",children:a.leads.slice(0,5).map(B=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:B.name}),B.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",B.phone]}),B.intent&&e.jsx(st,{variant:"secondary",className:"ml-2 text-xs",children:B.intent})]},B.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(K,{onClick:U,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(wke,{open:p,onClose:()=>f(!1),imageSrc:g,onCropComplete:I,aspectRatio:1})]})}const uT={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"},uCe={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 hCe(t=!0){return mt({queryKey:["marketplace-categories",t],queryFn:async()=>{let s=H.from("marketplace_categories").select("*").order("sort_order",{ascending:!0});t&&(s=s.eq("is_active",!0));const{data:r,error:n}=await s;if(n)throw n;return r}})}function Fks(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category created successfully")},onError:s=>{me.error("Failed to create category: "+s.message)}})}function zks(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("marketplace_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category updated successfully")},onError:s=>{me.error("Failed to update category: "+s.message)}})}function Bks(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("marketplace_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category deleted successfully")},onError:s=>{me.error("Failed to delete category: "+s.message)}})}function Alt(t,s=!0){return mt({queryKey:["marketplace-products",t,s],queryFn:async()=>{let r=H.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).order("sort_order",{ascending:!0});t&&(r=r.eq("category_id",t)),s&&(r=r.eq("is_active",!0));const{data:n,error:a}=await r;if(a)throw a;return n}})}function $ks(t){return mt({queryKey:["marketplace-product",t],queryFn:async()=>{const{data:s,error:r}=await H.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function qks(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_products").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),me.success("Product created successfully")},onError:s=>{me.error("Failed to create product: "+s.message)}})}function Uks(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("marketplace_products").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.id]}),me.success("Product updated successfully")},onError:s=>{me.error("Failed to update product: "+s.message)}})}function Vks(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("marketplace_products").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),me.success("Product deleted successfully")},onError:s=>{me.error("Failed to delete product: "+s.message)}})}function Hks(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_product_images").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]})}})}function Wks(){const t=Qt();return Lt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await H.from("marketplace_product_images").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Image deleted successfully")},onError:s=>{me.error("Failed to delete image: "+s.message)}})}function Gks(){const t=Qt();return Lt({mutationFn:async({imageId:s,productId:r})=>{const{error:n}=await H.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",r);if(n)throw n;const{error:a}=await H.from("marketplace_product_images").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Primary image updated")},onError:s=>{me.error("Failed to set primary image: "+s.message)}})}function Kks(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_product_variants").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]}),me.success("Variant added successfully")}})}function Zks(){const t=Qt();return Lt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await H.from("marketplace_product_variants").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Variant deleted successfully")}})}function Yks(){const t=Qt();return Lt({mutationFn:async({productId:s,videoUrl:r})=>{await H.from("marketplace_product_videos").delete().eq("product_id",s);const{data:n,error:a}=await H.from("marketplace_product_videos").insert({product_id:s,video_url:r}).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.productId]}),me.success("Video updated successfully")}})}function Xks(t){const{isAdmin:s}=Ds();return mt({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=H.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).order("created_at",{ascending:!1});const{data:n,error:a}=await r;if(a)throw a;if(s&&n){const o=[...new Set(n.map(c=>c.user_id))],{data:l}=await H.from("profiles").select("id, name, email").in("id",o),i=new Map((l==null?void 0:l.map(c=>[c.id,c]))||[]);return n.map(c=>({...c,user:i.get(c.user_id)}))}return n}})}function Qks(){const{user:t}=Ds();return mt({queryKey:["my-marketplace-orders",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("user_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function Jks(t){return mt({queryKey:["marketplace-order",t],queryFn:async()=>{const{data:s,error:r}=await H.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function e4s(){const t=Qt(),{user:s}=Ds();return Lt({mutationFn:async({orderId:r,status:n,notes:a,trackingNumber:o,trackingUrl:l,previousStatus:i})=>{const c={status:n};o!==void 0&&(c.tracking_number=o),l!==void 0&&(c.tracking_url=l);const{error:u}=await H.from("marketplace_orders").update(c).eq("id",r);if(u)throw u;const{error:p}=await H.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(p)throw p;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await H.functions.invoke("marketplace-order-notify",{body:{orderId:r,notificationType:n==="shipped"?"shipped":"status_update",newStatus:n,trackingNumber:o,trackingUrl:l}})}catch(g){console.error("Failed to send notification email:",g)}},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",n.orderId]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Order status updated")},onError:r=>{me.error("Failed to update order: "+r.message)}})}function t4s(){const t=Qt();return Lt({mutationFn:async({itemId:s,proofUrl:r,proofNotes:n,orderId:a})=>{const{error:o}=await H.from("marketplace_order_items").update({proof_url:r,proof_notes:n,proof_status:"pending"}).eq("id",s);if(o)throw o;await H.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await H.functions.invoke("marketplace-order-notify",{body:{orderId:a,notificationType:"proof_ready"}})}catch(l){console.error("Failed to send proof notification:",l)}return a},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof uploaded & customer notified")}})}function s4s(){const t=Qt();return Lt({mutationFn:async({itemId:s,orderId:r})=>{const{error:n}=await H.from("marketplace_order_items").update({proof_status:"approved"}).eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof approved")}})}function r4s(){const t=Qt();return Lt({mutationFn:async({itemId:s,orderId:r,reason:n})=>{const{error:a}=await H.from("marketplace_order_items").update({proof_status:"rejected",proof_notes:n}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof rejected - please upload a new proof")}})}function n4s(){const{data:t,isLoading:s}=hCe(!1),r=Fks(),n=zks(),a=Bks(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),f=()=>{p({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),c(null)},g=j=>{c(j),p({name:j.name,description:j.description||"",image_url:j.image_url||"",sort_order:j.sort_order,is_active:j.is_active}),l(!0)},b=async j=>{j.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},_=async j=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(j)};return s?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(ys,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(j=>e.jsx(ys,{className:"h-12 w-full"},j))})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"Categories"}),e.jsxs(fs,{open:o,onOpenChange:j=>{l(j),j||f()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:i?"Edit Category":"Add Category"})}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:u.name,onChange:j=>p({...u,name:j.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:u.description,onChange:j=>p({...u,description:j.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"image_url",children:"Image URL"}),e.jsx(ze,{id:"image_url",value:u.image_url,onChange:j=>p({...u,image_url:j.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(ze,{id:"sort_order",type:"number",value:u.sort_order,onChange:j=>p({...u,sort_order:parseInt(j.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:u.is_active,onCheckedChange:j=>p({...u,is_active:j})}),e.jsx(be,{htmlFor:"is_active",children:"Active"})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Sort Order"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:t.map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:j.name}),e.jsx(dt,{className:"max-w-xs truncate",children:j.description}),e.jsx(dt,{children:j.sort_order}),e.jsx(dt,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${j.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:j.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(j),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(j.id),disabled:a.isPending,children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},j.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function a4s(){var ue,pe;const{data:t,isLoading:s}=Alt(void 0,!1),{data:r}=hCe(!1),n=qks(),a=Uks(),o=Vks(),l=Hks(),i=Wks(),c=Gks(),u=Kks(),p=Zks(),f=Yks(),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(!1),[S,M]=k.useState(null),[L,I]=k.useState(null),[O,q]=k.useState(!1),[U,B]=k.useState({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),[V,Y]=k.useState({name:"",price_adjustment:0}),[Q,ee]=k.useState(""),X=()=>{B({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),M(null)},ie=_e=>{M(_e),B({name:_e.name,description:_e.description||"",base_price:Number(_e.base_price),shipping_fee:Number(_e.shipping_fee),category_id:_e.category_id||"",allow_artwork_upload:_e.allow_artwork_upload,requires_proof_approval:_e.requires_proof_approval,is_active:_e.is_active,sort_order:_e.sort_order}),b(!0)},re=async _e=>{_e.preventDefault();const $e={...U,category_id:U.category_id||null};S?await a.mutateAsync({id:S.id,...$e}):await n.mutateAsync($e),b(!1),X()},oe=async _e=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(_e)},ce=async _e=>{if(!L||!_e.target.files||_e.target.files.length===0)return;q(!0);const $e=_e.target.files[0],Ae=$e.name.split(".").pop(),Ie=`products/${L.id}/${Date.now()}.${Ae}`;try{const{error:Ce}=await H.storage.from("marketplace").upload(Ie,$e);if(Ce)throw Ce;const{data:{publicUrl:xe}}=H.storage.from("marketplace").getPublicUrl(Ie);await l.mutateAsync({product_id:L.id,image_url:xe,is_primary:!L.images||L.images.length===0}),me.success("Image uploaded successfully")}catch(Ce){me.error("Failed to upload image: "+Ce.message)}finally{q(!1)}},ge=async _e=>{_e.preventDefault(),L&&(await u.mutateAsync({product_id:L.id,name:V.name,price_adjustment:V.price_adjustment}),Y({name:"",price_adjustment:0}))},ye=async()=>{!L||!Q||(await f.mutateAsync({productId:L.id,videoUrl:Q}),ee(""))};return s?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(ys,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(_e=>e.jsx(ys,{className:"h-64 w-full"},_e))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"Products"}),e.jsxs(fs,{open:g,onOpenChange:_e=>{b(_e),_e||X()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:S?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:re,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Product Name"}),e.jsx(ze,{id:"name",value:U.name,onChange:_e=>B({...U,name:_e.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"category",children:"Category"}),e.jsxs(Ks,{value:U.category_id,onValueChange:_e=>B({...U,category_id:_e}),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:r==null?void 0:r.map(_e=>e.jsx(Mt,{value:_e.id,children:_e.name},_e.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:U.description,onChange:_e=>B({...U,description:_e.target.value}),rows:4})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(ze,{id:"base_price",type:"number",step:"0.01",min:"0",value:U.base_price,onChange:_e=>B({...U,base_price:parseFloat(_e.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(ze,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:U.shipping_fee,onChange:_e=>B({...U,shipping_fee:parseFloat(_e.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(ze,{id:"sort_order",type:"number",value:U.sort_order,onChange:_e=>B({...U,sort_order:parseInt(_e.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"allow_artwork_upload",checked:U.allow_artwork_upload,onCheckedChange:_e=>B({...U,allow_artwork_upload:_e})}),e.jsx(be,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"requires_proof_approval",checked:U.requires_proof_approval,onCheckedChange:_e=>B({...U,requires_proof_approval:_e})}),e.jsx(be,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:U.is_active,onCheckedChange:_e=>B({...U,is_active:_e})}),e.jsx(be,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:S?"Update Product":"Create Product"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(_e=>{var $e,Ae;return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[_e.images&&_e.images.length>0?e.jsx("img",{src:(($e=_e.images.find(Ie=>Ie.is_primary))==null?void 0:$e.image_url)||_e.images[0].image_url,alt:_e.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:"No image"}),!_e.is_active&&e.jsx(st,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:_e.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Ae=_e.category)==null?void 0:Ae.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(_e.base_price).toFixed(2)]}),Number(_e.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(_e.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[_e.allow_artwork_upload&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),_e.requires_proof_approval&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Proof Required"}),_e.variants&&_e.variants.length>0&&e.jsxs(st,{variant:"outline",className:"text-xs",children:[_e.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ie(_e),children:[e.jsx(Ra,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{I(_e),j(!0)},children:[e.jsx(o1,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{I(_e),N(!0)},children:[e.jsx(Fm,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>oe(_e.id),children:e.jsx(Nr,{className:"h-3 w-3 text-destructive"})})]})]})]},_e.id)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No products yet. Create your first product to get started."})})]}),e.jsx(fs,{open:_,onOpenChange:j,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Manage Images - ",L==null?void 0:L.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(ue=L==null?void 0:L.images)==null?void 0:ue.map(_e=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:_e.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),_e.is_primary&&e.jsx(st,{className:"absolute top-2 left-2",variant:"default",children:"Primary"}),e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[!_e.is_primary&&e.jsx(K,{variant:"secondary",size:"icon",onClick:async()=>{var $e;await c.mutateAsync({imageId:_e.id,productId:L.id}),I({...L,images:($e=L.images)==null?void 0:$e.map(Ae=>({...Ae,is_primary:Ae.id===_e.id}))})},disabled:c.isPending,title:"Set as primary",children:e.jsx(Jn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"destructive",size:"icon",onClick:async()=>{var Ae;await i.mutateAsync({id:_e.id,productId:L.id});const $e=t==null?void 0:t.find(Ie=>Ie.id===L.id);$e&&I({...$e,images:(Ae=$e.images)==null?void 0:Ae.filter(Ie=>Ie.id!==_e.id)})},disabled:i.isPending,children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},_e.id))}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:ce,className:"hidden",id:"image-upload",disabled:O}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(o1,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:O?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(be,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(ze,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:Q,onChange:_e=>ee(_e.target.value)}),e.jsxs(K,{onClick:ye,disabled:!Q,children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(L==null?void 0:L.video)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",L.video.video_url]})]})]})]})}),e.jsx(fs,{open:w,onOpenChange:N,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Manage Variants - ",L==null?void 0:L.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:ge,className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Variant name (e.g., 500 count)",value:V.name,onChange:_e=>Y({...V,name:_e.target.value}),required:!0}),e.jsx(ze,{type:"number",step:"0.01",placeholder:"Price adj.",value:V.price_adjustment,onChange:_e=>Y({...V,price_adjustment:parseFloat(_e.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(pe=L==null?void 0:L.variants)==null?void 0:pe.map(_e=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:_e.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(_e.price_adjustment)>=0?"+":"","$",Number(_e.price_adjustment).toFixed(2)]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:_e.id,productId:L.id}),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]},_e.id)),(!(L!=null&&L.variants)||L.variants.length===0)&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:'No variants yet. Add variants like "250 count", "500 count", etc.'})]})]})]})})]})}const i4s=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function o4s(){var j,w,N;const{data:t,isLoading:s}=Xks(),r=e4s(),n=t4s(),[a,o]=k.useState(null),[l,i]=k.useState(!1),[c,u]=k.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=k.useState(!1),g=S=>{o(S),u({status:S.status,notes:"",trackingNumber:S.tracking_number||"",trackingUrl:S.tracking_url||""}),i(!0)},b=async()=>{a&&(await r.mutateAsync({orderId:a.id,status:c.status,notes:c.notes,trackingNumber:c.trackingNumber,trackingUrl:c.trackingUrl,previousStatus:a.status}),i(!1))},_=async(S,M)=>{if(!a||!S.target.files||S.target.files.length===0)return;f(!0);const L=S.target.files[0],I=L.name.split(".").pop(),O=`proofs/${a.id}/${M}/${Date.now()}.${I}`;try{const{error:q}=await H.storage.from("marketplace").upload(O,L);if(q)throw q;const{data:{publicUrl:U}}=H.storage.from("marketplace").getPublicUrl(O);await n.mutateAsync({itemId:M,proofUrl:U,orderId:a.id}),me.success("Proof uploaded successfully")}catch(q){me.error("Failed to upload proof: "+q.message)}finally{f(!1)}};return s?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(ys,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(S=>e.jsx(ys,{className:"h-16 w-full"},S))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Orders"})}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Order #"}),e.jsx(St,{children:"Customer"}),e.jsx(St,{children:"Date"}),e.jsx(St,{children:"Total"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:t.map(S=>{var M,L;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono",children:S.order_number}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((M=S.user)==null?void 0:M.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(L=S.user)==null?void 0:L.email})]})}),e.jsx(dt,{children:ms(new Date(S.created_at),"MMM d, yyyy")}),e.jsxs(dt,{className:"font-bold",children:["$",Number(S.total).toFixed(2)]}),e.jsx(dt,{children:e.jsx(st,{className:uCe[S.status],children:uT[S.status]})}),e.jsx(dt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>g(S),children:[e.jsx(Ln,{className:"h-4 w-4 mr-1"}),"View"]})})]},S.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Order ",a==null?void 0:a.order_number]})}),a&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Customer"}),e.jsx("p",{children:(j=a.user)==null?void 0:j.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(w=a.user)==null?void 0:w.email})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),e.jsx("p",{children:a.shipping_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,e.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),e.jsx("div",{className:"space-y-3",children:(N=a.items)==null?void 0:N.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(S.unit_price).toFixed(2)," x ",S.quantity]})]}),S.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(st,{variant:S.proof_status==="approved"?"default":"secondary",children:S.proof_status||"No proof yet"})]}),S.proof_url?e.jsx("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:M=>_(M,S.id),className:"hidden",id:`proof-${S.id}`,disabled:p}),e.jsx("label",{htmlFor:`proof-${S.id}`,children:e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(li,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},S.id))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Status"}),e.jsxs(Ks,{value:c.status,onValueChange:S=>u({...c,status:S}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:i4s.map(S=>e.jsx(Mt,{value:S,children:uT[S]},S))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Tracking Number"}),e.jsx(ze,{value:c.trackingNumber,onChange:S=>u({...c,trackingNumber:S.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Tracking URL"}),e.jsx(ze,{value:c.trackingUrl,onChange:S=>u({...c,trackingUrl:S.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Notes (optional)"}),e.jsx(Er,{value:c.notes,onChange:S=>u({...c,notes:S.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{onClick:b,disabled:r.isPending,className:"w-full",children:[e.jsx(Ml,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),e.jsx("div",{className:"space-y-2",children:a.status_history.map(S=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(st,{variant:"outline",children:uT[S.status]}),S.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:S.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ms(new Date(S.created_at),"MMM d, h:mm a")})]},S.id))})]})]})]})})]})}function l4s(){const[t,s]=k.useState("products"),r=fr();return e.jsx(Ms,{title:"Marketplace Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Marketplace Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage products, categories, and orders"})]}),e.jsxs(K,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(ba,{value:t,onValueChange:s,children:[e.jsxs(pa,{className:"grid w-full grid-cols-3",children:[e.jsxs(ns,{value:"products",className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"h-4 w-4"}),"Products"]}),e.jsxs(ns,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Om,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(ns,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(vp,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(bs,{value:"products",children:e.jsx(a4s,{})}),e.jsx(bs,{value:"categories",children:e.jsx(n4s,{})}),e.jsx(bs,{value:"orders",children:e.jsx(o4s,{})})]})]})})}function Elt(){return mt({queryKey:["reward-categories"],queryFn:async()=>{const{data:t,error:s}=await H.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(s)throw s;return t}})}function c4s(t){return mt({queryKey:["reward-items",t],queryFn:async()=>{let s=H.from("reward_store_items").select(` *, category:reward_store_categories(*) `).order("created_at",{ascending:!1});const{data:r,error:n}=await s;if(n)throw n;return r}})}function d4s(t){return mt({queryKey:["active-reward-items",t],queryFn:async()=>{let s=H.from("reward_store_items").select(` *, category:reward_store_categories(*) `).eq("is_active",!0).order("created_at",{ascending:!1});t&&(s=s.eq("category_id",t));const{data:r,error:n}=await s;if(n)throw n;return r}})}function u4s(t){return mt({queryKey:["user-purchases",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).eq("user_id",t).order("purchased_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function h4s(){return mt({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:t,error:s}=await H.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).order("purchased_at",{ascending:!1});if(s)throw s;if(!t||t.length===0)return[];const r=[...new Set(t.map(l=>l.user_id))],{data:n,error:a}=await H.from("profiles").select("id, name, email").in("id",r);if(a)throw a;const o=new Map((n==null?void 0:n.map(l=>[l.id,l]))||[]);return t.map(l=>({...l,user:o.get(l.user_id)||null}))}})}function m4s(t){return mt({queryKey:["spendable-points",t],queryFn:async()=>{if(!t)return 0;const{data:s,error:r}=await H.from("agent_attendance_stats").select("spendable_points").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return(s==null?void 0:s.spendable_points)||0},enabled:!!t})}function p4s(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.rpc("purchase_reward_item",{p_item_id:s});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error||"Purchase failed");return a},onSuccess:()=>{t.invalidateQueries({queryKey:["user-purchases"]}),t.invalidateQueries({queryKey:["spendable-points"]}),t.invalidateQueries({queryKey:["active-reward-items"]}),t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["homereel-credits"]})}})}function f4s(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("reward_store_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function x4s(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("reward_store_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function g4s(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("reward_store_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function y4s(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("reward_store_items").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function v4s(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("reward_store_items").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function b4s(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("reward_store_items").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function _4s(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function Tye(t,s){const r=_4s(t);if(r)try{const{data:n,error:a}=await H.storage.from(r.bucket).download(r.path);if(a){console.error("Error downloading file:",a),me.error("Failed to download file");return}const o=URL.createObjectURL(n),l=document.createElement("a");l.href=o,l.download=s||r.path.split("/").pop()||"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(n){console.error("Download error:",n),me.error("Failed to download file")}else try{const a=await(await fetch(t)).blob(),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=s||t.split("/").pop()||"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(n){console.error("External download error:",n),me.error("Failed to download file")}}function Plt(){return mt({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:t,error:s}=await H.from("point_reward_settings").select("*").order("action_name");if(s)throw s;return t}})}function w4s(){const t=Qt();return Lt({mutationFn:async({id:s,points:r,is_active:n})=>{const a={points:r};n!==void 0&&(a.is_active=n);const{data:o,error:l}=await H.from("point_reward_settings").update(a).eq("id",s).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["point-reward-settings"]})}})}function j4s(){const{user:t}=Ds(),[s,r]=k.useState("items"),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(null),[j,w]=k.useState(!1),[N,S]=k.useState(null),[M,L]=k.useState(""),[I,O]=k.useState(""),[q,U]=k.useState(null),[B,V]=k.useState(""),[Y,Q]=k.useState("file"),[ee,X]=k.useState(""),[ie,re]=k.useState(""),[oe,ce]=k.useState(""),[ge,ye]=k.useState(!0),[ue,pe]=k.useState(null),[_e,$e]=k.useState(!1),[Ae,Ie]=k.useState(!1),Ce=k.useRef(null),xe=k.useRef(null),{data:we,isLoading:Le}=Elt(),{data:tt,isLoading:Te}=c4s(),{data:pt,isLoading:fe}=h4s(),{data:qe,isLoading:at}=Plt(),et=f4s(),Me=x4s(),rt=g4s(),He=y4s(),ct=v4s(),Ue=b4s(),Ze=w4s(),[Qe,We]=k.useState({}),Je=xt=>{xt?(l(xt),c(xt.name),p(xt.description||""),g(xt.icon||"")):(l(null),c(""),p(""),g("")),a(!0)},it=async()=>{if(!i.trim()){me.error("Please enter a category name");return}try{o?(await Me.mutateAsync({id:o.id,name:i,description:u||null,icon:f||null}),me.success("Category updated successfully")):(await et.mutateAsync({name:i,description:u||null,icon:f||null,sort_order:((we==null?void 0:we.length)||0)+1}),me.success("Category created successfully")),a(!1)}catch(xt){console.error("Error saving category:",xt),me.error("Failed to save category")}},Dt=async()=>{if(b)try{await rt.mutateAsync(b),me.success("Category deleted successfully"),_(null)}catch(xt){console.error("Error deleting category:",xt),me.error("Failed to delete category")}},Vt=xt=>{var Es;xt?(S(xt),L(xt.name),O(xt.description||""),U(xt.category_id),V(xt.points_cost.toString()),Q(xt.item_type),X(xt.file_url||""),re(xt.preview_image_url||""),ce(((Es=xt.max_quantity)==null?void 0:Es.toString())||""),ye(xt.is_active)):(S(null),L(""),O(""),U(null),V(""),Q("file"),X(""),re(""),ce(""),ye(!0)),w(!0)},hs=async(xt,Es)=>{Es==="file"?$e(!0):Ie(!0);try{const ur=xt.name.split(".").pop(),Mr=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ur}`,Lr=`${Es==="file"?"items":"previews"}/${Mr}`,{error:fn}=await H.storage.from("reward-store").upload(Lr,xt);if(fn)throw fn;const{data:{publicUrl:ki}}=H.storage.from("reward-store").getPublicUrl(Lr);Es==="file"?X(ki):re(ki),me.success("File uploaded successfully")}catch(ur){console.error("Error uploading file:",ur),me.error("Failed to upload file")}finally{Es==="file"?$e(!1):Ie(!1)}},Ts=async()=>{if(!M.trim()){me.error("Please enter an item name");return}if(!B||parseInt(B)<0){me.error("Please enter a valid points cost");return}try{const xt={name:M,description:I||null,category_id:q,points_cost:parseInt(B),item_type:Y,file_url:ee||null,preview_image_url:ie||null,max_quantity:oe?parseInt(oe):null,current_quantity:oe?parseInt(oe):null,is_active:ge,created_by:t==null?void 0:t.id};N?(await ct.mutateAsync({id:N.id,...xt,current_quantity:N.max_quantity!==(oe?parseInt(oe):null)?oe?parseInt(oe):null:N.current_quantity}),me.success("Item updated successfully")):(await He.mutateAsync(xt),me.success("Item created successfully")),w(!1)}catch(xt){console.error("Error saving item:",xt),me.error("Failed to save item")}},Cs=async()=>{if(ue)try{await Ue.mutateAsync(ue),me.success("Item deleted successfully"),pe(null)}catch(xt){console.error("Error deleting item:",xt),me.error("Failed to delete item")}},cs=async(xt,Es)=>{const ur=Qe[xt];if(ur===void 0||ur===Es.toString())return;const Mr=parseInt(ur);if(isNaN(Mr)||Mr<0){me.error("Please enter a valid positive number");return}try{await Ze.mutateAsync({id:xt,points:Mr}),me.success("Points updated successfully"),We(Lr=>{const fn={...Lr};return delete fn[xt],fn})}catch(Lr){console.error("Error updating points:",Lr),me.error("Failed to update points")}};return Le||Te||fe||at?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx(ys,{className:"h-96"})]})}):e.jsxs(Ms,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Reward Store Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage store items that agents can purchase with their points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ml,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Items"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(tt==null?void 0:tt.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(tt==null?void 0:tt.filter(xt=>xt.is_active).length)||0," active"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Om,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(we==null?void 0:we.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg. Cost"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[tt&&tt.length>0?Math.round(tt.reduce((xt,Es)=>xt+Es.points_cost,0)/tt.length):0," pts"]})]})})]}),e.jsxs(ba,{value:s,onValueChange:r,children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"items",children:"Items"}),e.jsx(ns,{value:"categories",children:"Categories"}),e.jsx(ns,{value:"purchases",children:"Purchases"}),e.jsx(ns,{value:"point-settings",children:"Point Settings"})]}),e.jsx(bs,{value:"items",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Store Items"}),e.jsx(gr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>Vt(),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Oe,{children:!tt||tt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ko,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No items yet. Add your first reward item!"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Item"}),e.jsx(St,{children:"Category"}),e.jsx(St,{className:"text-center",children:"Cost"}),e.jsx(St,{className:"text-center",children:"Type"}),e.jsx(St,{className:"text-center",children:"Quantity"}),e.jsx(St,{className:"text-center",children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:tt.map(xt=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[xt.preview_image_url?e.jsx("img",{src:xt.preview_image_url,alt:xt.name,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded bg-muted flex items-center justify-center",children:e.jsx(ko,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:xt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:xt.description||"No description"})]})]})}),e.jsx(dt,{children:xt.category?e.jsx(st,{variant:"outline",children:xt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),xt.points_cost]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[xt.item_type==="file"?e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:xt.item_type})]})}),e.jsx(dt,{className:"text-center",children:xt.max_quantity!==null?e.jsxs("span",{className:xt.current_quantity===0?"text-red-500":"",children:[xt.current_quantity,"/",xt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(dt,{className:"text-center",children:e.jsx(st,{variant:xt.is_active?"default":"secondary",children:xt.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Vt(xt),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>pe(xt.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},xt.id))})]})})]})}),e.jsx(bs,{value:"categories",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Categories"}),e.jsx(gr,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>Je(),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Oe,{children:!we||we.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Om,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"text-center",children:"Items"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(zn,{children:we.map(xt=>e.jsxs(Ss,{children:[e.jsxs(dt,{className:"font-medium",children:[xt.icon&&e.jsx("span",{className:"mr-2",children:xt.icon}),xt.name]}),e.jsx(dt,{className:"text-muted-foreground",children:xt.description||"—"}),e.jsx(dt,{className:"text-center",children:(tt==null?void 0:tt.filter(Es=>Es.category_id===xt.id).length)||0}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Je(xt),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(xt.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},xt.id))})]})})]})}),e.jsx(bs,{value:"purchases",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vp,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(gr,{children:"View all reward redemptions by agents"})]}),e.jsx(Oe,{children:!pt||pt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(vp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Date"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Item"}),e.jsx(St,{className:"text-center",children:"Points Spent"})]})}),e.jsx(zn,{children:pt.map(xt=>{var Es,ur,Mr,Lr;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-muted-foreground",children:ms(new Date(xt.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(to,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Es=xt.user)==null?void 0:Es.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((ur=xt.user)==null?void 0:ur.email)||"—"})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Mr=xt.item)!=null&&Mr.preview_image_url?e.jsx("img",{src:xt.item.preview_image_url,alt:xt.item.name,className:"h-8 w-8 rounded object-cover"}):e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center",children:e.jsx(ko,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((Lr=xt.item)==null?void 0:Lr.name)||"Deleted item"})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),xt.points_spent]})})]},xt.id)})})]})})]})})]})]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:o?"Edit Category":"Add Category"}),e.jsx(Gr,{children:o?"Update the category details":"Create a new category for your store items"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"categoryName",children:"Name"}),e.jsx(ze,{id:"categoryName",value:i,onChange:xt=>c(xt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Er,{id:"categoryDescription",value:u,onChange:xt=>p(xt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(ze,{id:"categoryIcon",value:f,onChange:xt=>g(xt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:it,disabled:et.isPending||Me.isPending,children:et.isPending||Me.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:j,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:N?"Edit Item":"Add Item"}),e.jsx(Gr,{children:N?"Update the item details":"Create a new reward item for agents to purchase"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemName",children:"Name *"}),e.jsx(ze,{id:"itemName",value:M,onChange:xt=>L(xt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Er,{id:"itemDescription",value:I,onChange:xt=>O(xt.target.value),placeholder:"Describe the item..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(Ks,{value:q||"none",onValueChange:xt=>U(xt==="none"?null:xt),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No category"}),we==null?void 0:we.map(xt=>e.jsxs(Mt,{value:xt.id,children:[xt.icon&&`${xt.icon} `,xt.name]},xt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(ze,{id:"itemPointsCost",type:"number",min:"0",value:B,onChange:xt=>V(xt.target.value),placeholder:"e.g., 100"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemType",children:"Type"}),e.jsxs(Ks,{value:Y,onValueChange:Q,children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"file",children:"File Download"}),e.jsx(Mt,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(ze,{id:"itemMaxQuantity",type:"number",min:"1",value:oe,onChange:xt=>ce(xt.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:ee,onChange:xt=>X(xt.target.value),placeholder:Y==="file"?"Upload a file or paste URL":"Paste external link"}),Y==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var xt;return(xt=Ce.current)==null?void 0:xt.click()},disabled:_e,children:e.jsx(li,{className:"h-4 w-4"})}),e.jsx("input",{ref:Ce,type:"file",className:"hidden",onChange:xt=>{var ur;const Es=(ur=xt.target.files)==null?void 0:ur[0];Es&&hs(Es,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:ie,onChange:xt=>re(xt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var xt;return(xt=xe.current)==null?void 0:xt.click()},disabled:Ae,children:e.jsx(gl,{className:"h-4 w-4"})}),e.jsx("input",{ref:xe,type:"file",accept:"image/*",className:"hidden",onChange:xt=>{var ur;const Es=(ur=xt.target.files)==null?void 0:ur[0];Es&&hs(Es,"preview")}})]}),ie&&e.jsx("img",{src:ie,alt:"Preview",className:"mt-2 h-24 rounded object-cover"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"itemIsActive",checked:ge,onCheckedChange:ye}),e.jsx(be,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:Ts,disabled:He.isPending||ct.isPending,children:He.isPending||ct.isPending?"Saving...":"Save"})]})]})}),e.jsx(kc,{open:!!b,onOpenChange:()=>_(null),children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete Category"}),e.jsx(sc,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:Dt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(kc,{open:!!ue,onOpenChange:()=>pe(null),children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete Item"}),e.jsx(sc,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:Cs,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Ee,{className:"mt-4",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Point Reward Settings"}),e.jsx(gr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Oe,{children:!qe||qe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Xo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"text-center w-32",children:"Points"}),e.jsx(St,{className:"text-right w-24",children:"Save"})]})}),e.jsx(zn,{children:qe.map(xt=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx("p",{className:"font-medium",children:xt.action_name})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:xt.description})}),e.jsx(dt,{className:"text-center",children:e.jsx(ze,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:Qe[xt.id]??xt.points.toString(),onChange:Es=>We(ur=>({...ur,[xt.id]:Es.target.value}))})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:Qe[xt.id]===void 0||Qe[xt.id]===xt.points.toString()||Ze.isPending,onClick:()=>cs(xt.id,xt.points),children:e.jsx(qc,{className:"h-4 w-4"})})})]},xt.id))})]})})]})]})}const bze=()=>e.jsxs("svg",{viewBox:"0 0 100 100",className:"h-5 w-5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{width:"100",height:"100",rx:"20",fill:"#7D2AE8"}),e.jsx("path",{d:"M50 20C33.43 20 20 33.43 20 50C20 66.57 33.43 80 50 80C66.57 80 80 66.57 80 50C80 33.43 66.57 20 50 20ZM63.5 63.5C58.3 68.7 50 70.6 43.1 67.6C36.2 64.6 32 57.6 32 50C32 42.4 36.2 35.4 43.1 32.4C50 29.4 58.3 31.3 63.5 36.5L59.3 40.7C55.8 37.2 50.7 35.8 46 37.3C41.3 38.8 37.7 42.8 36.6 47.6C35.5 52.4 37 57.4 40.4 60.8C43.8 64.2 48.8 65.7 53.6 64.6C58.4 63.5 62.4 59.9 63.9 55.2L68.7 56.7C66.9 61.3 65.5 61.5 63.5 63.5Z",fill:"white"})]}),_ze=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function N4s(){const t=Qt(),[s,r]=k.useState(!1),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=mt({queryKey:["canva-integration"],queryFn:async()=>{const{data:S,error:M}=await H.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(M)throw M;return S}}),{data:f}=mt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:S,error:M}=await H.from("brokerages").select("id, name").order("name");if(M)throw M;return S}}),{data:g}=mt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:S,error:M}=await H.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(M)throw M;return S}}),b=async()=>{var S;r(!0);try{const{data:M}=await H.auth.getSession(),L=(S=M==null?void 0:M.session)==null?void 0:S.access_token;if(!L)throw new Error("Not authenticated");const q=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),U=await q.json();if(!q.ok||U!=null&&U.error)throw new Error((U==null?void 0:U.error)||"Failed to get authorization URL");if(U!=null&&U.authUrl){localStorage.setItem("canva_code_verifier",U.codeVerifier),localStorage.setItem("canva_oauth_state",U.state);const B=window.open(U.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!B){me.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const V=Q=>{var ee,X;Q.origin===window.location.origin&&(((ee=Q.data)==null?void 0:ee.type)==="canva-oauth-success"?(window.removeEventListener("message",V),me.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((X=Q.data)==null?void 0:X.type)==="canva-oauth-error"&&(window.removeEventListener("message",V),me.error("Canva connection failed: "+(Q.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",V);const Y=setInterval(()=>{B.closed&&(clearInterval(Y),window.removeEventListener("message",V),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(M){console.error("Canva connect error:",M);const L=(M==null?void 0:M.message)||"";L.includes("CANVA_CLIENT_ID")?me.error("Canva app credentials not configured yet."):me.error(L||"Failed to start Canva connection"),r(!1)}},_=Lt({mutationFn:async S=>{var B;const{data:M}=await H.auth.getSession(),L=(B=M==null?void 0:M.session)==null?void 0:B.access_token;if(!L)throw new Error("Not authenticated");const q=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:S})}),U=await q.json();if(!q.ok||U!=null&&U.error)throw new Error((U==null?void 0:U.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),me.success("Canva disconnected")},onError:S=>{me.error(S.message||"Failed to disconnect Canva")}}),j=Lt({mutationFn:async S=>{const{error:M}=await H.from("canva_brokerage_folders").insert({brokerage_id:S.brokerage_id,folder_id:S.folder_id.trim(),folder_name:S.folder_name.trim(),folder_type:S.folder_type,description:S.description.trim()||null,sort_order:(g==null?void 0:g.length)||0});if(M)throw M},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder added"),l(!1),c({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>me.error("Failed to add folder")}),w=Lt({mutationFn:async S=>{const{error:M}=await H.from("canva_brokerage_folders").delete().eq("id",S);if(M)throw M},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder removed")},onError:()=>me.error("Failed to remove folder")}),N=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-accent flex items-center justify-center",children:e.jsx(bze,{})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",N&&e.jsx(st,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(st,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(gr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"OAuth 2.0 + PKCE for secure authorization"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Map brokerage folders to auto-share with agents on connection"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(xi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Multiple folders per brokerage (templates, brand assets, listings)"})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-muted border border-dashed",children:[e.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Canva App Redirect URL"}),e.jsx("code",{className:"text-xs text-muted-foreground break-all select-all",children:"https://dashboard.relevelup.com/canva-callback.html"})]}),N?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:u.canva_team_id?`Team: ${u.canva_team_id}`:"Canva Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.expires_at?`Token expires ${new Date(u.expires_at).toLocaleDateString()}`:"Platform integration active"})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect Canva?"}),e.jsx(sc,{children:"This will remove the Canva platform integration. Agents who have already connected will not be affected, but new folder sharing will stop."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>_.mutate(u.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}),e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center justify-between p-3 text-sm font-medium hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Om,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",g&&g.length>0&&e.jsx(st,{variant:"secondary",className:"text-xs",children:g.length})]}),n?e.jsx(ff,{className:"h-4 w-4"}):e.jsx(Eo,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[g&&g.length>0?g.map(S=>{var M,L;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:S.folder_name}),e.jsx(st,{variant:"outline",className:"text-xs shrink-0",children:((M=_ze.find(I=>I.value===S.folder_type))==null?void 0:M.label)||S.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(L=S.brokerages)==null?void 0:L.name," · ID: ",e.jsx("span",{className:"font-mono",children:S.folder_id})]})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>w.mutate(S.id),children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]},S.id)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx($s,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:b,disabled:s||p,children:[s?e.jsx(Go,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(bze,{})}),"Connect Canva",e.jsx(Qa,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add Brokerage Folder Mapping"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Brokerage"}),e.jsxs(Ks,{value:i.brokerage_id,onValueChange:S=>c(M=>({...M,brokerage_id:S})),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select a brokerage…"})}),e.jsx(Ws,{children:f==null?void 0:f.map(S=>e.jsx(Mt,{value:S.id,children:S.name},S.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Canva Folder ID"}),e.jsx(ze,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:S=>c(M=>({...M,folder_id:S.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Folder Display Name"}),e.jsx(ze,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:S=>c(M=>({...M,folder_name:S.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Folder Type"}),e.jsxs(Ks,{value:i.folder_type,onValueChange:S=>c(M=>({...M,folder_type:S})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:_ze.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(be,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(ze,{placeholder:"What's in this folder?",value:i.description,onChange:S=>c(M=>({...M,description:S.target.value}))})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>j.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||j.isPending,children:[j.isPending?e.jsx(Go,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function k4s(){return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(oh,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(N4s,{}),e.jsx(Clt,{})]})})}const S4s={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 hI(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function C4s(){var Y,Q,ee,X,ie;const t=Qt(),[s,r]=k.useState("Test Push"),[n,a]=k.useState("Testing web push notification"),[o,l]=k.useState("/community"),[i,c]=k.useState(!1),[u,p]=k.useState(!1),[f,g]=k.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[b,_]=k.useState(null),[j,w]=k.useState(null),{data:N,isLoading:S}=mt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:re,error:oe}=await H.from("push_notification_settings").select("*").order("setting_key");if(oe)throw oe;return re}}),{data:M,isLoading:L}=mt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:re,error:oe}=await H.from("push_subscriptions").select("*",{count:"exact",head:!0});if(oe)throw oe;return{totalSubscriptions:re||0}}}),I=Lt({mutationFn:async({settingKey:re,isEnabled:oe})=>{const{error:ce}=await H.from("push_notification_settings").update({is_enabled:oe}).eq("setting_key",re);if(ce)throw ce},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),me.success("Notification setting updated")},onError:re=>{me.error("Failed to update setting: "+re.message)}}),O=k.useMemo(()=>{var re,oe;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((re=f.serviceWorker)==null?void 0:re.activeState)??"unknown"} · sub=${(oe=f.subscription)!=null&&oe.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);k.useEffect(()=>{let re=!0;const oe=async()=>{var ue,pe,_e,$e,Ae,Ie,Ce;const ge="serviceWorker"in navigator&&"PushManager"in window,ye={isSupported:ge,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((ue=navigator.serviceWorker)!=null&&ue.controller)};if(!ge){re&&g(ye);return}try{const{data:xe,error:we}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(we)throw we;ye.vapidPublicKey=xe==null?void 0:xe.vapidPublicKey;const tt=(await navigator.serviceWorker.getRegistrations()).find(Te=>{var fe,qe,at;return(((fe=Te.active)==null?void 0:fe.scriptURL)||((qe=Te.waiting)==null?void 0:qe.scriptURL)||((at=Te.installing)==null?void 0:at.scriptURL)||"").includes("/sw.js")});if(tt){ye.pushWorkerScriptUrl=((pe=tt.active)==null?void 0:pe.scriptURL)||((_e=tt.waiting)==null?void 0:_e.scriptURL)||(($e=tt.installing)==null?void 0:$e.scriptURL),ye.serviceWorker={scope:tt.scope,activeState:(Ae=tt.active)==null?void 0:Ae.state};const Te=await tt.pushManager.getSubscription();if(Te){const pt=Te.toJSON();ye.subscription={endpoint:pt.endpoint,p256dh:(Ie=pt.keys)==null?void 0:Ie.p256dh,auth:(Ce=pt.keys)==null?void 0:Ce.auth}}}}catch(xe){ye.error=(xe==null?void 0:xe.message)||String(xe)}re&&g(ye)};oe();const ce=window.setInterval(oe,4e3);return()=>{re=!1,window.clearInterval(ce)}},[]);const q=async()=>{if(typeof Notification>"u"){me.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){me.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),me.success("Triggered a local notification (not push).")}catch(re){me.error(`Local notification failed: ${(re==null?void 0:re.message)||String(re)}`)}},U=async()=>{c(!0),_(null);try{const{data:re,error:oe}=await H.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(oe)throw oe;_({sent:re==null?void 0:re.sent,failed:re==null?void 0:re.failed,expiredCleaned:re==null?void 0:re.expiredCleaned,vapidPublicKey:re==null?void 0:re.vapidPublicKey}),(re==null?void 0:re.sent)>0?me.success(`Test notification sent to ${re.sent} subscriber(s)`):(re==null?void 0:re.failed)>0?me.warning(`Notification failed for ${re.failed} subscriber(s). ${re.expired||0} expired subscriptions cleaned up.`):me.info("No active subscriptions to send to")}catch(re){console.error("Error sending test notification:",re),_({error:(re==null?void 0:re.message)||String(re)}),me.error("Failed to send test notification: "+(re.message||"Unknown error"))}finally{c(!1)}},B=async()=>{p(!0),w(null);try{const{data:re,error:oe}=await H.functions.invoke("generate-vapid-keys",{body:{}});if(oe)throw oe;const ce=re==null?void 0:re.publicKey,ge=re==null?void 0:re.privateKey;if(!ce||!ge)throw new Error("generate-vapid-keys did not return keys");w({publicKey:ce,privateKey:ge}),me.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(re){console.error("Error generating VAPID keys:",re),me.error("Failed to generate VAPID keys: "+((re==null?void 0:re.message)||"Unknown error"))}finally{p(!1)}},V=Lt({mutationFn:async()=>{const{error:re}=await H.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(re)throw re},onSuccess:()=>{me.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:re=>{me.error("Failed to clear subscriptions: "+re.message)}});return e.jsx(Ms,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(gr,{children:"Current active push notification subscriptions"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:L?"...":(M==null?void 0:M.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(gr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Oe,{children:S?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:N==null?void 0:N.map(re=>{const oe=S4s[re.setting_key]||{label:re.setting_key,icon:"🔔"};return e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:oe.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:oe.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:re.description})]})]}),e.jsx(qr,{checked:re.is_enabled,onCheckedChange:ce=>I.mutate({settingKey:re.setting_key,isEnabled:ce}),disabled:I.isPending})]},re.id)})})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Lm,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(gr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Client push debug"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:O}),f.error&&e.jsx("div",{className:"mt-2 text-destructive",children:f.error}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Backend VAPID public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:f.vapidPublicKey?hI(f.vapidPublicKey):"(not loaded)"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Service worker"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["scope: ",(Y=f.serviceWorker)!=null&&Y.scope?hI(f.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((Q=f.serviceWorker)==null?void 0:Q.activeState)??"none"]})]})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Current browser subscription"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["endpoint: ",(ee=f.subscription)!=null&&ee.endpoint?hI(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(X=f.subscription)!=null&&X.p256dh?hI(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(ie=f.subscription)!=null&&ie.auth?hI(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(K,{variant:"outline",onClick:q,children:"Local notification test"}),e.jsx(K,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(ze,{id:"test-title",value:s,onChange:re=>r(re.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(Er,{id:"test-body",value:n,onChange:re=>a(re.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(ze,{id:"test-url",value:o,onChange:re=>l(re.target.value),placeholder:"/community or full URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where users will be taken when they click the notification"})]}),e.jsxs(K,{onClick:U,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),b&&e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Last send debug"}),b.error?e.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",b.error]}):e.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[e.jsxs("div",{children:["Result: ",b.sent??0," sent, ",b.failed??0," failed, ",b.expiredCleaned??0," expired cleaned"]}),b.vapidPublicKey?e.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",e.jsx("span",{className:"font-mono",children:b.vapidPublicKey})]}):e.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Nr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(gr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you've recently updated the VAPID keys, existing subscriptions will no longer work. Use this to clear all subscriptions so users can re-subscribe with the new keys."}),e.jsxs(K,{variant:"destructive",onClick:()=>V.mutate(),disabled:V.isPending,children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),V.isPending?"Clearing...":"Clear All Subscriptions"]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"VAPID key rotation helper"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:"If you suspect the backend public/private keys don’t match, generate a fresh pair, update backend secrets, then clear subscriptions and have users re-enable push."}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(K,{variant:"outline",onClick:B,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),j&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",e.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",e.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:j.publicKey})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:j.privateKey})]})]})]})]})]})]})})}function M4s(){const{toast:t}=Ua(),[s,r]=k.useState([]),[n,a]=k.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=k.useState(!0),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=QO("presentation_count","desc"),f=p(s,{name:_=>{var j;return((j=_.name)==null?void 0:j.toLowerCase())||""},presentations:_=>_.presentation_count,views:_=>_.total_views,leads:_=>_.total_leads,cta_clicks:_=>_.total_cta_clicks,conversion:_=>_.total_views>0?_.total_leads/_.total_views*100:0});k.useEffect(()=>{g()},[]);const g=async()=>{try{l(!0);const{data:_,error:j}=await H.rpc("get_admin_presentation_stats");if(j)throw j;if(!_||_.length===0){l(!1);return}const w=_.map(I=>I.owner_user_id),{data:N,error:S}=await H.from("profiles").select("id, name, email, avatar_url").in("id",w);if(S)throw S;const M=new Map((N==null?void 0:N.map(I=>[I.id,I]))||[]),L=_.map(I=>{const O=M.get(I.owner_user_id);return{owner_user_id:I.owner_user_id,name:(O==null?void 0:O.name)||"Unknown",email:(O==null?void 0:O.email)||"",avatar_url:(O==null?void 0:O.avatar_url)||null,presentation_count:Number(I.presentation_count),total_views:Number(I.total_views),total_leads:Number(I.total_leads),total_cta_clicks:Number(I.total_cta_clicks)}});r(L),r(L),a({totalPresentations:L.reduce((I,O)=>I+O.presentation_count,0),totalViews:L.reduce((I,O)=>I+O.total_views,0),totalLeads:L.reduce((I,O)=>I+O.total_leads,0),totalCtaClicks:L.reduce((I,O)=>I+O.total_cta_clicks,0),agentsUsing:L.length})}catch(_){console.error("Error loading presentation stats:",_),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},b=[{label:"Agents Using",value:n.agentsUsing,icon:pr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:ey,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:Ln,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:Tl,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:Jg,color:"text-rose-600"}];return e.jsx(Ms,{title:"Presentation Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Presentation Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track Smart Presentations usage and engagement across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:b.map(_=>e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:_.label}),e.jsx(_.icon,{className:`h-4 w-4 ${_.color}`})]}),e.jsx(Oe,{children:o?e.jsx(ys,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:_.value.toLocaleString()})})]},_.label))}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ul,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((_,j)=>e.jsx(ys,{className:"h-12 w-full"},j))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(yl,{sortKey:"name",currentSortKey:i,currentDirection:c,onSort:u,children:"Agent"}),e.jsx(yl,{sortKey:"presentations",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(yl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Views"}),e.jsx(yl,{sortKey:"leads",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Leads"}),e.jsx(yl,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(yl,{sortKey:"conversion",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(zn,{children:f.map(_=>{var w,N;const j=_.total_views>0?(_.total_leads/_.total_views*100).toFixed(1):"0.0";return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:_.avatar_url?e.jsx("img",{src:_.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((N=(w=_.name)==null?void 0:w.charAt(0))==null?void 0:N.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:_.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:_.email})]})]})}),e.jsx(dt,{className:"text-center font-medium",children:_.presentation_count}),e.jsx(dt,{className:"text-center",children:_.total_views.toLocaleString()}),e.jsx(dt,{className:"text-center",children:_.total_leads>0?e.jsx(st,{variant:"secondary",children:_.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:_.total_cta_clicks}),e.jsx(dt,{className:"text-center",children:e.jsxs("span",{className:Number(j)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[j,"%"]})})]},_.owner_user_id)})})]})})]})]})})}function T4s(){const{toast:t}=Ua(),[s,r]=k.useState([]),[n,a]=k.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=k.useState(!0);k.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:p}=await H.rpc("get_admin_guest_book_stats");if(p)throw p;if(!u||u.length===0){l(!1);return}const f=u.map(w=>w.agent_id),{data:g,error:b}=await H.from("profiles").select("id, name, email, avatar_url").in("id",f);if(b)throw b;const _=new Map((g==null?void 0:g.map(w=>[w.id,w]))||[]),j=u.map(w=>{const N=_.get(w.agent_id);return{agent_id:w.agent_id,name:(N==null?void 0:N.name)||"Unknown",email:(N==null?void 0:N.email)||"",avatar_url:(N==null?void 0:N.avatar_url)||null,open_house_count:Number(w.open_house_count),total_visitors:Number(w.total_visitors),total_leads:Number(w.total_leads),active_count:Number(w.active_count)}});j.sort((w,N)=>N.total_visitors-w.total_visitors),r(j),a({totalOpenHouses:j.reduce((w,N)=>w+N.open_house_count,0),totalVisitors:j.reduce((w,N)=>w+N.total_visitors,0),totalLeads:j.reduce((w,N)=>w+N.total_leads,0),activeOpenHouses:j.reduce((w,N)=>w+N.active_count,0),agentsUsing:j.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},c=[{label:"Agents Using",value:n.agentsUsing,icon:pr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:bn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:xi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:Ln,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:Tl,color:"text-rose-600"}];return e.jsx(Ms,{title:"Guest Book Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Guest Book Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track open house sign-in usage and lead generation across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:c.map(u=>e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Oe,{children:o?e.jsx(ys,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:u.value.toLocaleString()})})]},u.label))}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ul,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(ys,{className:"h-12 w-full"},p))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Open Houses"}),e.jsx(St,{className:"text-center",children:"Active"}),e.jsx(St,{className:"text-center",children:"Visitors"}),e.jsx(St,{className:"text-center",children:"Leads"}),e.jsx(St,{className:"text-center",children:"Conversion"})]})}),e.jsx(zn,{children:s.map(u=>{var f,g;const p=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:u.avatar_url?e.jsx("img",{src:u.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((g=(f=u.name)==null?void 0:f.charAt(0))==null?void 0:g.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:u.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:u.email})]})]})}),e.jsx(dt,{className:"text-center font-medium",children:u.open_house_count}),e.jsx(dt,{className:"text-center",children:u.active_count>0?e.jsx(st,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(dt,{className:"text-center",children:u.total_leads>0?e.jsx(st,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:e.jsxs("span",{className:Number(p)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[p,"%"]})})]},u.agent_id)})})]})})]})]})})}function A4s(){const[t]=Cc(),s=fr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing connection...");return k.useEffect(()=>{(async()=>{const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Failed to connect: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("Failed to connect: No authorization code");return}try{const{data:f,error:g}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(g)throw g;if(f!=null&&f.success)n("success"),o(f.message||"Accounts connected successfully!"),me.success(f.message||"Social accounts connected!");else throw new Error((f==null?void 0:f.error)||"Failed to connect accounts")}catch(f){console.error("Callback error:",f),n("error"),o(f.message||"Failed to complete connection"),me.error(f.message||"Failed to connect accounts")}})()},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Rt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function E4s(){const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState([]),i=k.useRef(null),{data:c,isLoading:u}=mt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:w,error:N}=await H.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(N)throw N;return w}}),p={total:(c==null?void 0:c.length)||0,sent:(c==null?void 0:c.filter(w=>w.status==="sent").length)||0,converted:(c==null?void 0:c.filter(w=>w.status==="converted").length)||0,conversionRate:c!=null&&c.length?Math.round(c.filter(w=>w.status==="converted").length/c.length*100):0},f=Lt({mutationFn:async w=>{const{data:N,error:S}=await H.functions.invoke("send-prospect-email",{body:{emails:w}});if(S)throw S;return N},onSuccess:w=>{t.invalidateQueries({queryKey:["prospect-emails"]}),me.success(`${w.sent} email${w.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:w=>{me.error("Failed to send: "+w.message)}}),g=Lt({mutationFn:async()=>{var M,L;const{data:{user:w}}=await H.auth.getUser();if(!(w!=null&&w.email))throw new Error("Could not get your email");const{data:N,error:S}=await H.functions.invoke("send-prospect-email",{body:{emails:[{email:w.email,first_name:(L=(M=w.user_metadata)==null?void 0:M.name)==null?void 0:L.split(" ")[0]}],test_mode:!0}});if(S)throw S;return N},onSuccess:()=>{me.success("Test email sent to your inbox!")},onError:w=>{me.error("Failed to send test: "+w.message)}}),b=()=>{if(!s.trim()){me.error("Please enter an email address");return}if(c==null?void 0:c.find(N=>N.email.toLowerCase()===s.trim().toLowerCase())){me.error("This email has already been prospected");return}f.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},_=w=>{var M;const N=(M=w.target.files)==null?void 0:M[0];if(!N)return;const S=new FileReader;S.onload=L=>{var B,V;const O=((B=L.target)==null?void 0:B.result).split(` `).filter(Y=>Y.trim()),q=[],U=(V=O[0])!=null&&V.toLowerCase().includes("email")?1:0;for(let Y=U;Yie.trim().replace(/"/g,"")),ee=Q[0],X=Q[1];ee&&ee.includes("@")&&q.push({email:ee,first_name:X||void 0})}l(q),me.success(`${q.length} entries loaded from CSV`)},S.readAsText(N),i.current&&(i.current.value="")},j=()=>{if(o.length===0){me.error("No entries to send");return}const w=new Set((c==null?void 0:c.map(S=>S.email.toLowerCase()))||[]),N=o.filter(S=>!w.has(S.email.toLowerCase()));if(N.length===0){me.error("All emails have already been prospected");return}N.lengthg.mutate(),disabled:g.isPending,className:"gap-2 ml-4 shrink-0",children:[g.isPending?e.jsx(ws,{className:"h-3 w-3 animate-spin"}):e.jsx(cr,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Oe,{children:e.jsxs(ba,{defaultValue:"single",children:[e.jsxs(pa,{className:"mb-4",children:[e.jsxs(ns,{value:"single",children:[e.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(ns,{value:"bulk",children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(bs,{value:"single",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(ze,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:w=>r(w.target.value),onKeyDown:w=>w.key==="Enter"&&b()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(be,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(ze,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:w=>a(w.target.value),onKeyDown:w=>w.key==="Enter"&&b()})]}),e.jsxs(K,{onClick:b,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(bs,{value:"bulk",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{ref:i,type:"file",accept:".csv",onChange:_,className:"hidden"}),e.jsxs(K,{variant:"outline",onClick:()=>{var w;return(w=i.current)==null?void 0:w.click()},className:"gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"}),"Upload CSV"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Format: email, first_name (one per line)"})]}),o.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(pr,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Rr,{className:"h-4 w-4"}),"Clear"]})]}),e.jsxs("div",{className:"max-h-40 overflow-y-auto border rounded-lg p-3 bg-muted/30 text-sm font-mono space-y-1",children:[o.slice(0,20).map((w,N)=>e.jsxs("div",{className:"text-muted-foreground",children:[w.email,w.first_name?` — ${w.first_name}`:""]},N)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:j,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Bn,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(gr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((w,N)=>e.jsx(ys,{className:"h-12 w-full"},N))}):c&&c.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Sent"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Converted"})]})}),e.jsx("tbody",{children:c.map(w=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:w.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:ms(new Date(w.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:w.status==="converted"?e.jsxs(st,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.converted_at?ms(new Date(w.converted_at),"MMM d, yyyy"):"—"})]},w.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(zm,{className:"h-12 w-12 text-muted-foreground/30 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No prospects yet. Send your first invite above!"})]})})]})]})})}function vme(t){const s=Qt(),{toast:r}=Ua(),n=mt({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:c,error:u}=await H.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(u)throw u;return c},enabled:!!t}),a=mt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const c=1e3;let u=[],p=0,f=!0;for(;f;){const{data:g,error:b}=await H.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1}).range(p,p+c-1);if(b)throw b;u=u.concat(g),f=g.length===c,p+=c}return u},enabled:!!t}),o=Lt({mutationFn:async c=>{const{data:{user:u}}=await H.auth.getUser();if(!u)throw new Error("Not authenticated");const p={first_name:c.first_name||"",last_name:c.last_name||null,email:c.email||null,phone:c.phone||null,current_brokerage:c.current_brokerage||null,license_number:c.license_number||null,experience_years:c.experience_years??null,annual_production:c.annual_production||null,source:c.source||"manual",notes:c.notes||null,stage_id:c.stage_id||null,brokerage_id:t,created_by:u.id,address:c.address||null,city:c.city||null,state:c.state||null,zip_code:c.zip_code||null,last_year_volume:c.last_year_volume||null,last_year_transactions:c.last_year_transactions??null,avg_sale_price:c.avg_sale_price||null,specialties:c.specialties||null,linkedin_url:c.linkedin_url||null,website_url:c.website_url||null,instagram_handle:c.instagram_handle||null,facebook_url:c.facebook_url||null,birthday:c.birthday||null,spouse_name:c.spouse_name||null,interests:c.interests||null,referred_by:c.referred_by||null},{data:f,error:g}=await H.from("recruit_prospects").insert(p).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect added"})},onError:c=>r({title:"Error",description:c.message,variant:"destructive"})}),l=Lt({mutationFn:async({id:c,...u})=>{const{data:p,error:f}=await H.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",c).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:c=>r({title:"Error",description:c.message,variant:"destructive"})}),i=Lt({mutationFn:async c=>{const{error:u}=await H.from("recruit_prospects").delete().eq("id",c);if(u)throw u},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect removed"})}});return{stages:n.data||[],prospects:a.data||[],isLoading:n.isLoading||a.isLoading,addProspect:o,updateProspect:l,deleteProspect:i}}function P4s(t){const s=Qt(),{toast:r}=Ua(),n=mt({queryKey:["recruit-activities",t],queryFn:async()=>{if(!t)return[];const{data:o,error:l}=await H.from("recruit_activities").select("*").eq("prospect_id",t).order("created_at",{ascending:!1});if(l)throw l;return o},enabled:!!t}),a=Lt({mutationFn:async o=>{const{data:{user:l}}=await H.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:c}=await H.from("recruit_activities").insert({...o,created_by:l.id}).select().single();if(c)throw c;return i},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-activities",t]}),r({title:"Activity logged"})},onError:o=>r({title:"Error",description:o.message,variant:"destructive"})});return{activities:n.data||[],isLoading:n.isLoading,addActivity:a}}const wze=(t,s)=>{var r;return{first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",license_number:"",experience_years:"",annual_production:"",source:"manual",notes:"",stage_id:t||((r=s==null?void 0:s[0])==null?void 0:r.id)||"",address:"",city:"",state:"",zip_code:"",last_year_volume:"",last_year_transactions:"",avg_sale_price:"",specialties:"",linkedin_url:"",website_url:"",instagram_handle:"",facebook_url:"",birthday:"",spouse_name:"",interests:"",referred_by:""}};function Ilt({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=k.useState(wze(n,r)),c=p=>f=>i(g=>({...g,[p]:f.target.value})),u=p=>{p.preventDefault(),a({...l,experience_years:l.experience_years?parseInt(l.experience_years):null,last_year_transactions:l.last_year_transactions?parseInt(l.last_year_transactions):null,stage_id:l.stage_id||null}),i(wze(n,r)),s(!1)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(ba,{defaultValue:"basic",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-4",children:[e.jsx(ns,{value:"basic",children:"Basic Info"}),e.jsx(ns,{value:"production",children:"Production"}),e.jsx(ns,{value:"social",children:"Social & Web"}),e.jsx(ns,{value:"personal",children:"Personal"})]}),e.jsxs(bs,{value:"basic",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"First Name *"}),e.jsx(ze,{required:!0,value:l.first_name,onChange:c("first_name")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Last Name"}),e.jsx(ze,{value:l.last_name,onChange:c("last_name")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Email"}),e.jsx(ze,{type:"email",value:l.email,onChange:c("email")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Phone"}),e.jsx(ze,{value:l.phone,onChange:c("phone")})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Current Brokerage"}),e.jsx(ze,{value:l.current_brokerage,onChange:c("current_brokerage")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"License #"}),e.jsx(ze,{value:l.license_number,onChange:c("license_number")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Experience (years)"}),e.jsx(ze,{type:"number",min:"0",value:l.experience_years,onChange:c("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Address"}),e.jsx(ze,{placeholder:"Street address",value:l.address,onChange:c("address")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"City"}),e.jsx(ze,{value:l.city,onChange:c("city")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"State"}),e.jsx(ze,{value:l.state,onChange:c("state")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Zip"}),e.jsx(ze,{value:l.zip_code,onChange:c("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Pipeline Stage"}),e.jsxs(Ks,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:r.map(p=>e.jsx(Mt,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Referred By"}),e.jsx(ze,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:c("referred_by")})]})]}),e.jsxs(bs,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Annual Production Volume"}),e.jsx(ze,{placeholder:"e.g. $5M, 20 transactions",value:l.annual_production,onChange:c("annual_production")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Last Year Volume"}),e.jsx(ze,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:c("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Last Year Transactions"}),e.jsx(ze,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:c("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Avg Sale Price"}),e.jsx(ze,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:c("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Specialties / Niche"}),e.jsx(ze,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:c("specialties")})]})]}),e.jsxs(bs,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"LinkedIn URL"}),e.jsx(ze,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:c("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Website URL"}),e.jsx(ze,{type:"url",placeholder:"https://...",value:l.website_url,onChange:c("website_url")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Instagram Handle"}),e.jsx(ze,{placeholder:"@handle",value:l.instagram_handle,onChange:c("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Facebook URL"}),e.jsx(ze,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:c("facebook_url")})]})]}),e.jsxs(bs,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Birthday"}),e.jsx(ze,{type:"date",value:l.birthday,onChange:c("birthday")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Spouse / Partner Name"}),e.jsx(ze,{value:l.spouse_name,onChange:c("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Interests / Hobbies"}),e.jsx(ze,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:c("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Notes"}),e.jsx(Er,{value:l.notes,onChange:c("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const uwe=[{value:"why_switch",label:"Why Switch Brokerages"},{value:"commission",label:"Commission & Splits"},{value:"culture",label:"Culture & Team"},{value:"follow_up",label:"Follow Up"},{value:"general",label:"General Pitch"}];function I4s(t){return mt({queryKey:["recruit-videos",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_videos").select(` *, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("brokerage_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function L4s(t){return mt({queryKey:["recruit-videos-prospect",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_videos").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("prospect_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function D4s(){const t=Qt(),{toast:s}=Ua();return Lt({mutationFn:async r=>{const{data:{user:n}}=await H.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("recruit_videos").insert({prospect_id:r.prospect_id,video_id:r.video_id,brokerage_id:r.brokerage_id,message:r.message||null,created_by:n.id}).select("*, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status)").single();if(o)throw o;return a},onSuccess:r=>{t.invalidateQueries({queryKey:["recruit-videos"]}),t.invalidateQueries({queryKey:["recruit-videos-prospect",r.prospect_id]}),s({title:"Video linked to prospect"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function Llt(){const t=Qt();return Lt({mutationFn:async({id:s,sent_via:r})=>{const{error:n}=await H.from("recruit_videos").update({sent_at:new Date().toISOString(),sent_via:r,updated_at:new Date().toISOString()}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-videos"]})}})}function Dlt(t){return mt({queryKey:["recruit-video-scripts",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_video_scripts").select("*").or(`brokerage_id.eq.${t},is_global.eq.true`).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function O4s(){const t=Qt(),{toast:s}=Ua();return Lt({mutationFn:async r=>{const{data:{user:n}}=await H.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("recruit_video_scripts").insert({...r,created_by:n.id}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]}),s({title:"Script saved"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function R4s(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("recruit_video_scripts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]})}})}function F4s({prospectId:t,prospectName:s,brokerageId:r}){var B;const{data:n=[],isLoading:a}=L4s(t),{data:o=[]}=Dlt(r),l=D4s(),i=CC(),c=Llt(),[u,p]=k.useState("idle"),[f,g]=k.useState(0),[b,_]=k.useState(0),[j,w]=k.useState(""),[N,S]=k.useState(""),[M,L]=k.useState(!1),I=((B=o.find(V=>V.id===j))==null?void 0:B.script_text)||"",O=()=>{p("idle"),g(0),_(0),w(""),S("")},q=k.useCallback(async(V,Y)=>{p("uploading");try{const Q=`Recruiting: ${s}`,{videoId:ee,libraryId:X}=await xR(Q),{uploadUrl:ie,apiKey:re}=await gR(ee),oe=new XMLHttpRequest;oe.upload.onprogress=Ae=>{Ae.lengthComputable&&g(Ae.loaded/Ae.total*100)},await new Promise((Ae,Ie)=>{oe.onload=()=>oe.status>=200&&oe.status<300?Ae():Ie(new Error("Upload failed")),oe.onerror=()=>Ie(new Error("Upload failed")),oe.open("PUT",ie),oe.setRequestHeader("AccessKey",re),oe.send(V)}),p("processing");let ce=0;const ge=Date.now(),ye=9e4,ue=`https://iframe.mediadelivery.net/embed/${X}/${ee}`;for(;ce<4&&(await new Promise(Ie=>setTimeout(Ie,3e3)),!(Date.now()-ge>ye));){const Ae=await wA(ee);if(ce=Ae.status,_(Ae.encodeProgress||0),ce===5||ce===6)throw new Error("Video processing failed")}const pe=await wA(ee),_e=(pe.storageSize||V.size)/(1024*1024),$e=await i.mutateAsync({bunny_video_id:ee,playback_url:pe.directPlayUrl||ue,thumbnail_url:pe.thumbnailUrl,preview_url:pe.previewUrl||null,duration_seconds:pe.length||Y,file_size_mb:_e,title:Q,status:ce>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:$e.id,brokerage_id:r,message:N||void 0}),p("done"),me.success("Video recorded and linked to prospect!"),setTimeout(()=>{L(!1),O()},1500)}catch(Q){me.error(Q.message||"Failed to upload video"),p("record")}},[t,s,r,N,i,l]),U=V=>{V&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${V}`),me.success("Share link copied"))};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-1.5",children:[e.jsx(An,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(fs,{open:M,onOpenChange:V=>{!V&&(u==="uploading"||u==="processing")||(L(V),V||O())},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>p("script"),children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(vs,{children:["Record Video for ",s]})}),u==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(Ks,{value:j,onValueChange:w,children:[e.jsx(Hs,{className:"mt-1",children:e.jsx(Ys,{placeholder:"No script — speak freely"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No script"}),o.map(V=>{var Y;return e.jsx(Mt,{value:V.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[V.title,e.jsx(st,{variant:"outline",className:"text-[9px] ml-1",children:(Y=uwe.find(Q=>Q.value===V.category))==null?void 0:Y.label})]})},V.id)})]})]}),I&&e.jsx("div",{className:"mt-2 p-3 bg-muted/50 rounded-md text-sm max-h-32 overflow-y-auto whitespace-pre-wrap",children:I})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Er,{value:N,onChange:V=>S(V.target.value),placeholder:`Hi ${s.split(" ")[0]}, I'd love to chat about what we're building here...`,rows:3,className:"mt-1"})]}),e.jsxs(K,{onClick:()=>p("record"),className:"w-full",children:[e.jsx(An,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(yme,{maxDurationSeconds:60,onRecordingComplete:q,teleprompterContent:I||void 0}),u==="uploading"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Uploading video…"}),e.jsx(Bi,{value:f,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(f),"%"]})]}),u==="processing"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Processing video…"}),e.jsx(Bi,{value:b,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(b),"%"]})]}),u==="done"&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-3",children:e.jsx(nl,{className:"h-6 w-6 text-emerald-600"})}),e.jsx("p",{className:"font-medium text-emerald-600",children:"Video ready!"})]})]})]})]}),a?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent mx-auto"})}):n.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No videos sent yet"}):e.jsx("div",{className:"space-y-2",children:n.map(V=>{var Y,Q;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md border text-sm",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:(Y=V.video)!=null&&Y.thumbnail_url?e.jsx("img",{src:V.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs truncate",children:((Q=V.video)==null?void 0:Q.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[V.view_count>0?e.jsxs(st,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(Ln,{className:"h-2.5 w-2.5 mr-0.5"}),V.view_count]}):V.sent_at?e.jsxs(st,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Bn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(st,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(un,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ms(new Date(V.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>U(V.share_token),children:e.jsx(gi,{className:"h-3 w-3"})}),!V.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c.mutate({id:V.id,sent_via:"email"}),children:e.jsx(Bn,{className:"h-3 w-3"})})]})]},V.id)})})]})}function z4s(t){return mt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_campaign_sends").select("id, prospect_id, subject, email_number, status, sent_at, opened_at, clicked_at, error_message, created_at").eq("prospect_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}const jze=[{value:"call",label:"Phone Call",icon:Un},{value:"email",label:"Email",icon:cr},{value:"text",label:"Text Message",icon:so},{value:"meeting",label:"Meeting",icon:hn},{value:"note",label:"Note",icon:Sn},{value:"campaign_email",label:"Campaign Email",icon:Bn}];function Yp({label:t,value:s,icon:r}){return s?e.jsxs("div",{children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r&&e.jsx(r,{className:"h-3 w-3"})," ",t]}),e.jsx("p",{className:"font-medium text-sm",children:s})]}):null}function s9({label:t,url:s,icon:r}){return s?e.jsxs("a",{href:s.startsWith("http")?s:`https://${s}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[e.jsx(r,{className:"h-3.5 w-3.5"})," ",t," ",e.jsx(tn,{className:"h-3 w-3 opacity-50"})]}):null}function mc({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:t}),e.jsx(ze,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function Olt({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:c}=P4s((t==null?void 0:t.id)||null),{data:u=[]}=z4s((t==null?void 0:t.id)||null),[p,f]=k.useState({type:"note",title:"",description:""}),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState({});if(!t)return null;const S=()=>{var Q,ee;N({first_name:t.first_name||"",last_name:t.last_name||"",email:t.email||"",phone:t.phone||"",current_brokerage:t.current_brokerage||"",license_number:t.license_number||"",experience_years:((Q=t.experience_years)==null?void 0:Q.toString())||"",notes:t.notes||"",source:t.source||"",address:t.address||"",city:t.city||"",state:t.state||"",zip_code:t.zip_code||"",last_year_volume:t.last_year_volume||"",last_year_transactions:((ee=t.last_year_transactions)==null?void 0:ee.toString())||"",avg_sale_price:t.avg_sale_price||"",specialties:t.specialties||"",annual_production:t.annual_production||"",linkedin_url:t.linkedin_url||"",website_url:t.website_url||"",instagram_handle:t.instagram_handle||"",facebook_url:t.facebook_url||"",birthday:t.birthday||"",spouse_name:t.spouse_name||"",interests:t.interests||"",referred_by:t.referred_by||""}),j(!0)},M=()=>{const Q={id:t.id};for(const[ee,X]of Object.entries(w))ee==="experience_years"||ee==="last_year_transactions"?Q[ee]=X?parseInt(X):null:Q[ee]=X||null;o(Q),j(!1)},L=()=>j(!1),I=Q=>ee=>N(X=>({...X,[Q]:ee})),O=()=>{p.title.trim()&&(c.mutate({prospect_id:t.id,activity_type:p.type,title:p.title,description:p.description||null}),f({type:"note",title:"",description:""}),b(!1))},q=s.find(Q=>Q.id===t.stage_id),U=t.address||t.city||t.state,B=t.last_year_volume||t.last_year_transactions||t.avg_sale_price||t.specialties||t.annual_production,V=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,Y=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(eE,{open:n,onOpenChange:Q=>{Q||j(!1),a(Q)},children:e.jsx(vC,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Gi,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(tE,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(sE,{className:"text-xl",children:[t.first_name," ",t.last_name]}),q&&e.jsx(st,{variant:"outline",style:{borderColor:q.color,color:q.color},className:"mt-1",children:q.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[_?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:L,children:e.jsx(Rr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:M,children:e.jsx(qc,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:S,title:"Edit prospect",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete prospect?"}),e.jsx(sc,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>{l(t.id),a(!1)},children:"Delete"})]})]})]})]})]})}),!_&&e.jsxs("div",{className:"space-y-1.5 text-sm",children:[t.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," ",t.email]}),t.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," ",t.phone]}),U&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ma,{className:"h-3.5 w-3.5"}),[t.address,t.city,t.state,t.zip_code].filter(Boolean).join(", ")]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(Ks,{value:t.stage_id||"",onValueChange:Q=>o({id:t.id,stage_id:Q}),children:[e.jsx(Hs,{className:"mt-1",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:s.map(Q=>e.jsx(Mt,{value:Q.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Q.color}}),Q.name]})},Q.id))})]})]}),e.jsxs(ba,{defaultValue:"details",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(ns,{value:"details",className:"text-xs",children:"Details"}),e.jsx(ns,{value:"production",className:"text-xs",children:"Production"}),e.jsx(ns,{value:"social",className:"text-xs",children:"Social"}),e.jsx(ns,{value:"personal",className:"text-xs",children:"Personal"})]}),_?e.jsxs(e.Fragment,{children:[e.jsxs(bs,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(mc,{label:"First Name",value:w.first_name,onChange:I("first_name")}),e.jsx(mc,{label:"Last Name",value:w.last_name,onChange:I("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(mc,{label:"Email",value:w.email,onChange:I("email"),type:"email"}),e.jsx(mc,{label:"Phone",value:w.phone,onChange:I("phone")})]}),e.jsx(mc,{label:"Current Brokerage",value:w.current_brokerage,onChange:I("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(mc,{label:"License #",value:w.license_number,onChange:I("license_number")}),e.jsx(mc,{label:"Experience (years)",value:w.experience_years,onChange:I("experience_years"),type:"number"})]}),e.jsx(mc,{label:"Address",value:w.address,onChange:I("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(mc,{label:"City",value:w.city,onChange:I("city")}),e.jsx(mc,{label:"State",value:w.state,onChange:I("state")}),e.jsx(mc,{label:"Zip",value:w.zip_code,onChange:I("zip_code")})]}),e.jsx(mc,{label:"Source",value:w.source,onChange:I("source")}),e.jsx(mc,{label:"Referred By",value:w.referred_by,onChange:I("referred_by")}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Notes"}),e.jsx(Er,{value:w.notes,onChange:Q=>N(ee=>({...ee,notes:Q.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(bs,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(mc,{label:"Annual Production",value:w.annual_production,onChange:I("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(mc,{label:"Last Year Volume",value:w.last_year_volume,onChange:I("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(mc,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:I("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(mc,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:I("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(mc,{label:"Specialties / Niche",value:w.specialties,onChange:I("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(bs,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(mc,{label:"LinkedIn URL",value:w.linkedin_url,onChange:I("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(mc,{label:"Website URL",value:w.website_url,onChange:I("website_url"),type:"url",placeholder:"https://..."}),e.jsx(mc,{label:"Instagram Handle",value:w.instagram_handle,onChange:I("instagram_handle"),placeholder:"@handle"}),e.jsx(mc,{label:"Facebook URL",value:w.facebook_url,onChange:I("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(bs,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(mc,{label:"Birthday",value:w.birthday,onChange:I("birthday"),type:"date"}),e.jsx(mc,{label:"Spouse / Partner",value:w.spouse_name,onChange:I("spouse_name")}),e.jsx(mc,{label:"Interests / Hobbies",value:w.interests,onChange:I("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(bs,{value:"details",className:"mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(Yp,{label:"License #",value:t.license_number}),e.jsx(Yp,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(Yp,{label:"Referred By",value:t.referred_by}),e.jsx(Yp,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.notes})]})]}),e.jsx(bs,{value:"production",className:"mt-3",children:B?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Annual Production",value:t.annual_production}),e.jsx(Yp,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(Yp,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(Yp,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(Yp,{label:"Specialties / Niche",value:t.specialties})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No production data added yet"})}),e.jsx(bs,{value:"social",className:"mt-3",children:V?e.jsxs("div",{className:"space-y-2",children:[e.jsx(s9,{label:"LinkedIn",url:t.linkedin_url,icon:Mp}),e.jsx(s9,{label:"Website",url:t.website_url,icon:su}),t.instagram_handle&&e.jsx(s9,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:Mu}),e.jsx(s9,{label:"Facebook",url:t.facebook_url,icon:Su})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx(bs,{value:"personal",className:"mt-3",children:Y?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Birthday",value:t.birthday?ms(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:ko}),e.jsx(Yp,{label:"Spouse / Partner",value:t.spouse_name,icon:ni}),e.jsx("div",{className:"col-span-2",children:e.jsx(Yp,{label:"Interests / Hobbies",value:t.interests})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No personal details added yet"})})]})]}),e.jsx(F4s,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(rl,{}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Activity Log"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>b(!g),children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"})," Log Activity"]})]}),g&&e.jsxs("div",{className:"border rounded-lg p-3 mb-4 space-y-3 bg-muted/30",children:[e.jsxs(Ks,{value:p.type,onValueChange:Q=>f(ee=>({...ee,type:Q})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:jze.map(Q=>e.jsx(Mt,{value:Q.value,children:Q.label},Q.value))})]}),e.jsx(ze,{placeholder:"Subject / Title",value:p.title,onChange:Q=>f(ee=>({...ee,title:Q.target.value}))}),e.jsx(Er,{placeholder:"Details (optional)",value:p.description,onChange:Q=>f(ee=>({...ee,description:Q.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{size:"sm",onClick:O,disabled:!p.title.trim(),children:"Save"})]})]}),e.jsx("div",{className:"space-y-3",children:(()=>{const Q=[...i.map(ee=>({type:"manual",data:ee,date:ee.created_at})),...u.map(ee=>({type:"campaign_email",data:ee,date:ee.sent_at||ee.created_at}))].sort((ee,X)=>new Date(X.date).getTime()-new Date(ee.date).getTime());return Q.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}):Q.map(ee=>{if(ee.type==="manual"){const ie=ee.data,re=jze.find(ce=>ce.value===ie.activity_type),oe=(re==null?void 0:re.icon)||Sn;return e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center",children:e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:ie.title}),ie.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:ie.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ms(new Date(ie.created_at),"MMM d, yyyy h:mm a")})]})]},`activity-${ie.id}`)}const X=ee.data;return e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-7 w-7 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Bn,{className:"h-3.5 w-3.5 text-primary"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium",children:["Campaign Email #",X.email_number]}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:X.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[X.status==="failed"?e.jsx(st,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4",children:"Failed"}):e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-green-500 text-green-600",children:[e.jsx(Bn,{className:"h-2.5 w-2.5 mr-0.5"})," Sent"]}),X.opened_at?e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-blue-500 text-blue-600",children:[e.jsx(Ln,{className:"h-2.5 w-2.5 mr-0.5"})," Opened ",ms(new Date(X.opened_at),"MMM d, h:mm a")]}):X.status!=="failed"?e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-muted-foreground",children:"Not opened"}):null,X.clicked_at&&e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-purple-500 text-purple-600",children:[e.jsx(wh,{className:"h-2.5 w-2.5 mr-0.5"})," Clicked ",ms(new Date(X.clicked_at),"MMM d, h:mm a")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ms(new Date(X.sent_at||X.created_at),"MMM d, yyyy h:mm a")})]})]},`send-${X.id}`)})})()})]})]})})})})}const B4s=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes","address","city","state","zip_code","last_year_volume","last_year_transactions","avg_sale_price","linkedin_url","website_url","specialties","referred_by"];function Rlt({open:t,onOpenChange:s,brokerageId:r,stages:n}){var V;const{toast:a}=Ua(),o=Qt(),l=k.useRef(null),[i,c]=k.useState([]),[u,p]=k.useState([]),[f,g]=k.useState({}),[b,_]=k.useState(((V=n[0])==null?void 0:V.id)||""),[j,w]=k.useState(!1),[N,S]=k.useState("upload"),[M,L]=k.useState(0),I=()=>{c([]),p([]),g({}),S("upload"),L(0)},O=Y=>{var X;const Q=(X=Y.target.files)==null?void 0:X[0];if(!Q)return;const ee=new FileReader;ee.onload=ie=>{var pe;const oe=((pe=ie.target)==null?void 0:pe.result).split(/\r?\n/).filter(_e=>_e.trim());if(oe.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const ce=q(oe[0]);p(ce);const ge={},ye=new Set;ce.forEach((_e,$e)=>{const Ae=_e.toLowerCase().replace(/[^a-z0-9]/g,"");let Ie=null;/^firstname$/.test(Ae)||Ae==="first"?Ie="first_name":/^lastname$/.test(Ae)||Ae==="last"?Ie="last_name":/^email$/.test(Ae)||Ae==="emailaddress"?Ie="email":/^mobile$|^phone$|^cellphone$|^mobilephone$/.test(Ae)?Ie="phone":/officename|currentbrokerage|brokerage|company/.test(Ae)?Ie="current_brokerage":/membernumber|licensenumber|license/.test(Ae)?Ie="license_number":/experienceyears|yearsexperience/.test(Ae)?Ie="experience_years":/^totalvolume$|annualproduction/.test(Ae)?Ie="annual_production":/^address$/.test(Ae)?Ie="address":/^city$/.test(Ae)?Ie="city":/^state$/.test(Ae)?Ie="state":/^postalcode$|^zip$|^zipcode$/.test(Ae)?Ie="zip_code":/listsidevolume|lastyearvolume/.test(Ae)?Ie="last_year_volume":/^totalcount$|lastyeartransactions/.test(Ae)?Ie="last_year_transactions":/avgsaleprice|averageprice/.test(Ae)?Ie="avg_sale_price":/linkedin/.test(Ae)?Ie="linkedin_url":/website/.test(Ae)?Ie="website_url":/specialt/.test(Ae)?Ie="specialties":/referr/.test(Ae)?Ie="referred_by":/^notes$|^note$/.test(Ae)&&(Ie="notes"),Ie&&!ye.has(Ie)&&(ge[String($e)]=Ie,ye.add(Ie))}),g(ge);const ue=oe.slice(1).map(_e=>{const $e=q(_e),Ae={};return ce.forEach((Ie,Ce)=>{Ae[String(Ce)]=$e[Ce]||""}),Ae});c(ue),S("map")},ee.readAsText(Q)},q=Y=>{const Q=[];let ee="",X=!1;for(const ie of Y)ie==='"'?X=!X:ie===","&&!X?(Q.push(ee.trim()),ee=""):ee+=ie;return Q.push(ee.trim()),Q},U=async()=>{w(!0);try{const{data:{user:Y}}=await H.auth.getUser();if(!Y)throw new Error("Not authenticated");const Q=i.map(X=>{const ie={brokerage_id:r,created_by:Y.id,stage_id:b,source:"csv_import",first_name:"Unknown"};return Object.entries(f).forEach(([re,oe])=>{var ge;const ce=(ge=X[re])==null?void 0:ge.trim();ce&&(oe==="experience_years"||oe==="last_year_transactions"?ie[oe]=parseInt(ce.replace(/[^0-9.-]/g,""))||null:oe==="annual_production"||oe==="last_year_volume"||oe==="avg_sale_price"?ie[oe]=ce.replace(/[^0-9.$,.-]/g,""):ie[oe]=ce)}),ie});let ee=0;for(let X=0;X{const Y=`first_name,last_name,email,phone,current_brokerage,license_number,experience_years,annual_production,notes Jane,Smith,jane@example.com,555-0100,ABC Realty,RE12345,8,$5M,Met at conference`,Q=new Blob([Y],{type:"text/csv"}),ee=URL.createObjectURL(Q),X=document.createElement("a");X.href=ee,X.download="recruit-prospects-template.csv",X.click(),URL.revokeObjectURL(ee)};return e.jsx(fs,{open:t,onOpenChange:Y=>{Y||I(),s(Y)},children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Import Prospects from CSV"})}),N==="upload"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx(a1,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upload a CSV file with prospect data"}),e.jsx("input",{ref:l,type:"file",accept:".csv",className:"hidden",onChange:O}),e.jsxs(K,{onClick:()=>{var Y;return(Y=l.current)==null?void 0:Y.click()},children:[e.jsx(li,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:B,children:"Download CSV template"})]}),N==="map"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," rows found"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"Import to stage:"}),e.jsxs(Ks,{value:b,onValueChange:_,children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:n.map(Y=>e.jsx(Mt,{value:Y.id,children:Y.name},Y.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[140px]",children:"CSV Column"}),e.jsx(St,{className:"w-[160px]",children:"Map To"}),e.jsx(St,{children:"Preview"})]})}),e.jsx(zn,{children:u.map((Y,Q)=>{var ee;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium text-xs",children:Y}),e.jsx(dt,{children:e.jsxs(Ks,{value:f[String(Q)]||"skip",onValueChange:X=>g(ie=>({...ie,[String(Q)]:X==="skip"?"":X})),children:[e.jsx(Hs,{className:"h-8 text-xs",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"skip",children:"— Skip —"}),B4s.map(X=>e.jsx(Mt,{value:X,children:X.replace(/_/g," ")},X))]})]})}),e.jsx(dt,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((ee=i[0])==null?void 0:ee[String(Q)])||"—"})]},Q)})})]})}),!Object.values(f).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(kl,{className:"h-4 w-4"}),' Map at least "first name" to proceed']}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>{I()},children:"Back"}),e.jsx(K,{onClick:U,disabled:j||!Object.values(f).includes("first_name"),children:j?"Importing...":`Import ${i.length} Prospects`})]})]}),N==="done"&&e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center mx-auto",children:e.jsx(va,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[M," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{I(),s(!1)},children:"Close"})]})]})})}function Flt({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=vme(t),[i,c]=k.useState(!1),[u,p]=k.useState(),[f,g]=k.useState(null),[b,_]=k.useState(!1),[j,w]=k.useState(!1),[N,S]=k.useState(null);if(n)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const M=B=>r.filter(V=>V.stage_id===B),L=(B,V)=>{S(V),B.dataTransfer.effectAllowed="move"},I=B=>{B.preventDefault(),B.dataTransfer.dropEffect="move"},O=(B,V)=>{B.preventDefault(),N&&(o.mutate({id:N,stage_id:V}),S(null))},q=B=>{p(B),c(!0)},U=B=>{g(B),_(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.length," prospect",r.length!==1?"s":""]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(li,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>{p(void 0),c(!0)},children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(Gi,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(B=>{const V=M(B.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:I,onDrop:Y=>O(Y,B.id),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:B.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:B.name}),e.jsx(st,{variant:"secondary",className:"text-xs h-5 px-1.5",children:V.length})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>q(B.id),children:e.jsx($s,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"space-y-2 min-h-[200px] bg-muted/30 rounded-lg p-2",children:V.map(Y=>e.jsx(Ee,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:B.color},draggable:!0,onDragStart:Q=>L(Q,Y.id),onClick:()=>U(Y),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(to,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[Y.first_name," ",Y.last_name]})]}),Y.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ka,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:Y.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Y.email&&e.jsx(cr,{className:"h-3 w-3 text-muted-foreground"}),Y.phone&&e.jsx(Un,{className:"h-3 w-3 text-muted-foreground"}),Y.experience_years!=null&&e.jsxs(st,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[Y.experience_years,"yr"]})]})]})]})},Y.id))})]},B.id)})}),e.jsx(aue,{orientation:"horizontal"})]}),e.jsx(Ilt,{open:i,onOpenChange:c,stages:s,defaultStageId:u,onSubmit:B=>a.mutate(B),isSubmitting:a.isPending}),e.jsx(Olt,{prospect:f,stages:s,brokerageId:t,open:b,onOpenChange:_,onUpdate:B=>{o.mutate(B),g(V=>V?{...V,...B}:null)},onDelete:B=>l.mutate(B)}),e.jsx(Rlt,{open:j,onOpenChange:w,brokerageId:t,stages:s})]})}function sde({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=vme(t),{user:i}=Ds(),c=Qt(),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState(!1),[j,w]=k.useState(!1),[N,S]=k.useState(""),[M,L]=k.useState("all"),[I,O]=k.useState("all"),[q,U]=k.useState("all"),[B,V]=k.useState(null),[Y,Q]=k.useState("asc"),[ee,X]=k.useState(new Set),[ie,re]=k.useState(!1),[oe,ce]=k.useState(""),ge=k.useMemo(()=>{const Te=new Set;return r.forEach(pt=>{pt.current_brokerage&&Te.add(pt.current_brokerage)}),Array.from(Te).sort()},[r]),{data:ye=[]}=mt({queryKey:["recruit-campaigns-list",t],queryFn:async()=>{const{data:Te,error:pt}=await H.from("recruit_campaigns").select("id, name, warmth_level").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("name");if(pt)throw pt;return Te}}),{data:ue=[]}=mt({queryKey:["recruit-campaign-assignments-lookup",t],queryFn:async()=>{let pt=[],fe=0;for(;;){const{data:qe,error:at}=await H.from("recruit_campaign_assignments").select("prospect_id, campaign_id, status").eq("brokerage_id",t).range(fe,fe+1e3-1);if(at)throw at;if(pt=pt.concat(qe??[]),!qe||qe.length<1e3)break;fe+=1e3}return pt}}),pe=k.useMemo(()=>{const Te=new Map;return ue.forEach(pt=>{Te.has(pt.prospect_id)||Te.set(pt.prospect_id,new Set),Te.get(pt.prospect_id).add(pt.campaign_id)}),Te},[ue]),_e=Te=>{B===Te?Q(pt=>pt==="asc"?"desc":"asc"):(V(Te),Q("asc"))},$e=({column:Te})=>B!==Te?e.jsx(bd,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):Y==="asc"?e.jsx(ku,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Wh,{className:"h-3.5 w-3.5 ml-1 text-primary"}),Ae=Te=>s.find(pt=>pt.id===Te),Ie=k.useMemo(()=>{let Te=r.filter(pt=>{var Me,rt,He;const fe=!N||`${pt.first_name} ${pt.last_name}`.toLowerCase().includes(N.toLowerCase())||((Me=pt.email)==null?void 0:Me.toLowerCase().includes(N.toLowerCase()))||((rt=pt.current_brokerage)==null?void 0:rt.toLowerCase().includes(N.toLowerCase())),qe=M==="all"||pt.stage_id===M,at=I==="all"||pt.current_brokerage===I;let et=!0;return q==="in_campaign"?et=pe.has(pt.id):q==="not_in_campaign"?et=!pe.has(pt.id):q!=="all"&&(et=((He=pe.get(pt.id))==null?void 0:He.has(q))??!1),fe&&qe&&at&&et});return B&&(Te=[...Te].sort((pt,fe)=>{var Me,rt;let qe=null,at=null;switch(B){case"name":qe=`${pt.first_name} ${pt.last_name||""}`.toLowerCase(),at=`${fe.first_name} ${fe.last_name||""}`.toLowerCase();break;case"stage":qe=((Me=Ae(pt.stage_id))==null?void 0:Me.sort_order)??999,at=((rt=Ae(fe.stage_id))==null?void 0:rt.sort_order)??999;break;case"brokerage":qe=(pt.current_brokerage||"").toLowerCase(),at=(fe.current_brokerage||"").toLowerCase();break;case"experience":qe=pt.experience_years??-1,at=fe.experience_years??-1;break;case"production":qe=(pt.annual_production||"").toLowerCase(),at=(fe.annual_production||"").toLowerCase();break;case"source":qe=(pt.source||"").toLowerCase(),at=(fe.source||"").toLowerCase();break;default:return 0}if(qe===at)return 0;if(qe==null)return 1;if(at==null)return-1;const et=qe0&&Ie.every(Te=>ee.has(Te.id)),xe=Ie.some(Te=>ee.has(Te.id)),we=()=>{X(Ce?new Set:new Set(Ie.map(Te=>Te.id)))},Le=Te=>{X(pt=>{const fe=new Set(pt);return fe.has(Te)?fe.delete(Te):fe.add(Te),fe})},tt=Lt({mutationFn:async()=>{if(!oe||!(i!=null&&i.id))throw new Error("Select a campaign");const Te=new Set(ue.filter(qe=>qe.campaign_id===oe).map(qe=>qe.prospect_id)),pt=Array.from(ee).filter(qe=>!Te.has(qe)).map(qe=>({prospect_id:qe,campaign_id:oe,brokerage_id:t,assigned_by:i.id,status:"active",current_email_number:0}));if(pt.length===0)throw new Error("All selected prospects are already in this campaign");const{error:fe}=await H.from("recruit_campaign_assignments").insert(pt);if(fe)throw fe;return pt.length},onSuccess:Te=>{me.success(`${Te} prospect(s) added to campaign`),re(!1),X(new Set),ce(""),c.invalidateQueries({queryKey:["recruit-campaign-assignments-lookup"]})},onError:Te=>me.error(Te.message)});return n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm min-w-[200px]",children:[e.jsx(cn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search prospects...",value:N,onChange:Te=>S(Te.target.value),className:"pl-8"})]}),e.jsxs("div",{className:"flex gap-2",children:[ee.size>0&&e.jsxs(K,{variant:"secondary",onClick:()=>re(!0),className:"gap-1.5",children:[e.jsx(Bn,{className:"h-4 w-4"})," Add ",ee.size," to Campaign"]}),e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(li,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>p(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Qg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Ks,{value:M,onValueChange:L,children:[e.jsx(Hs,{className:"w-[160px] h-8 text-xs",children:e.jsx(Ys,{placeholder:"All stages"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All stages"}),s.map(Te=>e.jsx(Mt,{value:Te.id,children:Te.name},Te.id))]})]}),e.jsxs(Ks,{value:I,onValueChange:O,children:[e.jsxs(Hs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(ka,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Ys,{placeholder:"All brokerages"})]}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All brokerages"}),ge.map(Te=>e.jsx(Mt,{value:Te,children:Te},Te))]})]}),e.jsxs(Ks,{value:q,onValueChange:U,children:[e.jsxs(Hs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Ys,{placeholder:"Campaign status"})]}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All contacts"}),e.jsx(Mt,{value:"in_campaign",children:"In any campaign"}),e.jsx(Mt,{value:"not_in_campaign",children:"Not in any campaign"}),ye.map(Te=>e.jsxs(Mt,{value:Te.id,children:["In: ",Te.name]},Te.id))]})]}),(M!=="all"||I!=="all"||q!=="all")&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 text-xs text-muted-foreground",onClick:()=>{L("all"),O("all"),U("all")},children:"Clear filters"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:Ce,onCheckedChange:we,"aria-label":"Select all",...xe&&!Ce?{"data-state":"indeterminate"}:{}})}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>_e("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx($e,{column:"name"})]})}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>_e("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx($e,{column:"stage"})]})}),e.jsx(St,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>_e("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx($e,{column:"brokerage"})]})}),e.jsx(St,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(St,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>_e("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx($e,{column:"experience"})]})}),e.jsx(St,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>_e("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx($e,{column:"production"})]})}),e.jsx(St,{className:"hidden lg:table-cell",children:"Campaigns"}),e.jsx(St,{className:"w-[50px]"})]})}),e.jsx(zn,{children:Ie.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):Ie.map(Te=>{const pt=Ae(Te.stage_id),fe=pe.get(Te.id),qe=(fe==null?void 0:fe.size)??0;return e.jsxs(Ss,{className:"cursor-pointer",onClick:()=>{g(Te),_(!0)},children:[e.jsx(dt,{onClick:at=>at.stopPropagation(),children:e.jsx(Oo,{checked:ee.has(Te.id),onCheckedChange:()=>Le(Te.id),"aria-label":`Select ${Te.first_name}`})}),e.jsxs(dt,{className:"font-medium",children:[Te.first_name," ",Te.last_name]}),e.jsx(dt,{children:pt?e.jsxs(st,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:pt.color,color:pt.color,backgroundColor:`${pt.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:pt.color}}),pt.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:Te.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(ka,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:Te.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Te.email&&e.jsx(cr,{className:"h-3.5 w-3.5 text-muted-foreground"}),Te.phone&&e.jsx(Un,{className:"h-3.5 w-3.5 text-muted-foreground"}),!Te.email&&!Te.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(dt,{className:"hidden lg:table-cell",children:Te.experience_years!=null?`${Te.experience_years} yr`:"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:Te.annual_production||"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:qe>0?e.jsxs(st,{variant:"secondary",className:"text-xs",children:[qe," campaign",qe>1?"s":""]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"None"})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:at=>{at.stopPropagation(),l.mutate(Te.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})})]},Te.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ee.size>0&&e.jsxs("span",{className:"font-medium text-foreground",children:[ee.size," selected · "]}),Ie.length," of ",r.length," prospects"]}),e.jsx(fs,{open:ie,onOpenChange:re,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Add to Campaign"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Add ",e.jsx("span",{className:"font-medium text-foreground",children:ee.size})," selected prospect(s) to a recruiting campaign drip."]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Campaign"}),e.jsxs(Ks,{value:oe,onValueChange:ce,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select a campaign..."})}),e.jsx(Ws,{children:ye.map(Te=>e.jsxs(Mt,{value:Te.id,children:[Te.name," ",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",Te.warmth_level,")"]})]},Te.id))})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>tt.mutate(),disabled:!oe||tt.isPending,children:tt.isPending?"Adding...":"Add to Campaign"})]})]})}),e.jsx(Ilt,{open:u,onOpenChange:p,stages:s,onSubmit:Te=>a.mutate(Te),isSubmitting:a.isPending}),e.jsx(Olt,{prospect:f,stages:s,brokerageId:t,open:b,onOpenChange:_,onUpdate:Te=>{o.mutate(Te),g(pt=>pt?{...pt,...Te}:null)},onDelete:Te=>l.mutate(Te)}),e.jsx(Rlt,{open:j,onOpenChange:w,brokerageId:t,stages:s})]})}function zlt({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=vme(t),a=k.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(N=>N.name==="Signed"),i=s.find(N=>N.name==="Onboarded"),c=r.filter(N=>N.stage_id===(l==null?void 0:l.id)||N.stage_id===(i==null?void 0:i.id)).length,u=o>0?(c/o*100).toFixed(1):"0",p=new Date,f=o>0?Math.round(r.reduce((N,S)=>N+ly(p,new Date(S.created_at)),0)/o):0,g=s.map(N=>({...N,count:r.filter(S=>S.stage_id===N.id).length})),b={};r.forEach(N=>{const S=N.source||"unknown";b[S]=(b[S]||0)+1});const _=Object.entries(b).sort((N,S)=>S[1]-N[1]),j=new Date;j.setDate(j.getDate()-30);const w=r.filter(N=>new Date(N.created_at)>=j).length;return{total:o,signed:c,conversionRate:u,avgDays:f,byStage:g,bySrc:_,recentCount:w}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(pr,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Prospects"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:e.jsx(ul,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.conversionRate,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Conversion Rate"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(un,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.avgDays,"d"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Avg Days in Pipeline"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-violet-500/10 flex items-center justify-center",children:e.jsx(zm,{className:"h-5 w-5 text-violet-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.recentCount}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Added (30 days)"})]})]})})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Oe,{className:"space-y-3",children:a.byStage.map(o=>{const l=a.total>0?o.count/a.total*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:o.color}}),e.jsx("span",{children:o.name})]}),e.jsx("span",{className:"font-medium",children:o.count})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${l}%`,backgroundColor:o.color}})})]},o.id)})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(st,{variant:"secondary",className:"capitalize",children:o.replace(/_/g," ")}),e.jsx("span",{className:"text-sm font-medium",children:l})]},o)),a.bySrc.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No source data"})]})]})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No prospect data yet. Add prospects to see metrics."})}const Nze=[{id:"value-prop",category:"Outreach",title:"Value Proposition Introduction",subject:"A Better Way to Grow Your Real Estate Business",body:`Hi [First Name], I hope this message finds you well. I've been following your work in [Area/Market] and I'm impressed by what you've accomplished. I'm reaching out because I believe our brokerage offers unique tools and support that could help take your business to the next level: • Industry-leading commission splits • Full marketing suite with customizable templates • Advanced CRM and lead generation tools • Ongoing training and mentorship programs • Collaborative team environment I'd love to share more about how we're helping agents like you grow their business. Would you be open to a brief conversation this week? Best regards, [Your Name]`},{id:"follow-up",category:"Follow-up",title:"Gentle Follow-up",subject:"Following Up – Quick Chat?",body:`Hi [First Name], I wanted to follow up on my previous message. I understand you're busy – that's the sign of a successful agent! I'd love just 15 minutes of your time to show you what makes our brokerage different. Many agents who've made the switch tell us they wish they'd done it sooner. Would [Day/Time] work for a quick call or coffee? Looking forward to connecting, [Your Name]`},{id:"interview-invite",category:"Interview",title:"Interview / Meeting Invitation",subject:"Invitation to Learn More About [Brokerage Name]",body:`Hi [First Name], Thank you for your interest in exploring opportunities with [Brokerage Name]! I'd love to set up a time for us to meet and discuss how we can support your career goals. Here's what we'll cover: • Our commission structure and agent benefits • Technology and marketing tools available to you • Training and professional development opportunities • Culture and team dynamics • Your questions and goals I have availability on: • [Date/Time Option 1] • [Date/Time Option 2] • [Date/Time Option 3] Please let me know which time works best, or suggest an alternative that suits your schedule. Warm regards, [Your Name]`},{id:"offer",category:"Offer",title:"Formal Offer / Welcome",subject:"Welcome to the Team – Your Offer Details",body:`Hi [First Name], I'm thrilled to extend a formal invitation to join [Brokerage Name]! Based on our conversations, I'm confident this will be a great fit for both of us. Here's a summary of your offer: • Commission Split: [Details] • Start Date: [Date] • Desk/Office: [Details] • Technology Package: [Details] • Additional Benefits: [Details] Next steps: 1. Review the attached agreement 2. Complete the onboarding paperwork 3. Schedule your first-week orientation Please feel free to reach out with any questions. We're excited to have you on the team! Welcome aboard, [Your Name]`},{id:"referral-ask",category:"Referral",title:"Agent Referral Request",subject:"Know Any Great Agents Looking for a Change?",body:`Hi [First Name], Hope you're having a great [week/month]! I'm reaching out because our brokerage is growing and we're looking for talented agents to join our team. Since you know the industry well, I was wondering if you know any agents who might be: • Looking for better technology and support • Seeking a more collaborative environment • Ready to take their business to the next level We offer a referral bonus of [Amount/Details] for any successful placement. It's a great way to help a colleague while earning something extra. If anyone comes to mind, I'd appreciate the introduction! Thanks, [Your Name]`},{id:"market-update",category:"Outreach",title:"Market Insights Outreach",subject:"Market Update + Growth Opportunity",body:`Hi [First Name], With the recent changes in [local market conditions], I wanted to share some insights on how top-performing agents are adapting: 📊 [Market Stat 1] 📈 [Market Stat 2] 🏠 [Market Stat 3] At [Brokerage Name], we're equipping our agents with cutting-edge tools to thrive in this market: • AI-powered lead generation • Automated marketing campaigns • Real-time market analytics dashboard I'd love to share how our agents are outperforming the market. Do you have 15 minutes this week? Best, [Your Name]`}];function Blt({brokerageId:t}){const{toast:s}=Ua(),[r,n]=k.useState(null),[a,o]=k.useState(null),l=(c,u)=>{navigator.clipboard.writeText(c),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(Nze.map(c=>c.category))];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pre-built email templates for recruiting outreach. Click to expand and copy."}),i.map(c=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4"})," ",c]}),Nze.filter(u=>u.category===c).map(u=>e.jsxs(Ee,{className:`cursor-pointer transition-all ${a===u.id?"ring-2 ring-primary/20":"hover:shadow-sm"}`,onClick:()=>o(a===u.id?null:u.id),children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(st,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Oe,{className:"pt-0 space-y-3",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subject Line:"}),e.jsx("p",{className:"text-sm mb-3",children:u.subject}),e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Body:"}),e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans",children:u.body})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:p=>{p.stopPropagation(),l(u.subject,u.id+"-subject")},children:[r===u.id+"-subject"?e.jsx(va,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Subject"]}),e.jsxs(K,{size:"sm",onClick:p=>{p.stopPropagation(),l(u.body,u.id+"-body")},children:[r===u.id+"-body"?e.jsx(va,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},c))]})}const kze={call:Un,email:cr,text:so,meeting:hn,note:Sn};function $lt({brokerageId:t}){const{data:s,isLoading:r}=mt({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await H.from("recruit_prospects").select("id, created_by").eq("brokerage_id",t);if(a)throw a;const o=(n==null?void 0:n.map(b=>b.id))||[];if(o.length===0)return{recruiters:[],recentActivities:[]};const{data:l,error:i}=await H.from("recruit_activities").select("*").in("prospect_id",o).order("created_at",{ascending:!1});if(i)throw i;const c=[...new Set([...n.map(b=>b.created_by),...(l||[]).map(b=>b.created_by)])],{data:u}=await H.from("profiles").select("id, name, email").in("id",c),p=Object.fromEntries((u||[]).map(b=>[b.id,b])),f=mie(new Date,30);return{recruiters:c.map(b=>{var S,M;const _=(l||[]).filter(L=>L.created_by===b),j=_.filter(L=>new Date(L.created_at)>=f),w={};j.forEach(L=>{w[L.activity_type]=(w[L.activity_type]||0)+1});const N=n.filter(L=>L.created_by===b).length;return{id:b,name:((S=p[b])==null?void 0:S.name)||"Unknown",email:((M=p[b])==null?void 0:M.email)||"",totalActivities:_.length,recentActivities:j.length,byType:w,prospectsCreated:N}}).sort((b,_)=>_.recentActivities-b.recentActivities),recentActivities:(l||[]).slice(0,20)}},enabled:!!t});return r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):s!=null&&s.recruiters.length?e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Oe,{className:"space-y-4",children:s.recruiters.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-primary/10 text-primary font-bold text-sm",children:a+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-sm",children:n.name})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(n.byType).map(([o,l])=>{const i=kze[o]||Sn;return e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(i,{className:"h-2.5 w-2.5"})," ",l," ",o,l!==1?"s":""]},o)})})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.recentActivities}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"activities"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.prospectsCreated}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"prospects"})]})]},n.id))})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Recent Activity"})}),e.jsx(Oe,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=kze[n.activity_type]||Sn;return e.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(a,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:n.title}),n.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:ms(new Date(n.created_at),"MMM d, h:mm a")})]})]},n.id)})})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No recruiter activity yet."})}function qlt({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:c}=mt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:w,error:N}=await H.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(N)throw N;return w}}),u=[...new Set(i.map(w=>w.referred_by))],{data:p=[]}=mt({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:w}=await H.from("profiles").select("id, name, email").in("id",u);return w||[]},enabled:u.length>0}),f=Object.fromEntries(p.map(w=>[w.id,w])),g=Lt({mutationFn:async w=>{const{data:{user:N}}=await H.auth.getUser();if(!N)throw new Error("Not authenticated");const{error:S}=await H.from("recruit_referrals").insert({brokerage_id:t,referred_by:N.id,referee_first_name:w.first_name,referee_last_name:w.last_name||null,referee_email:w.email||null,referee_phone:w.phone||null,referee_current_brokerage:w.current_brokerage||null,notes:w.notes||null});if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),b=Lt({mutationFn:async({id:w,status:N,incentive_status:S})=>{const M={updated_at:new Date().toISOString()};N&&(M.status=N),S&&(M.incentive_status=S);const{error:L}=await H.from("recruit_referrals").update(M).eq("id",w);if(L)throw L},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),_=w=>w==="approved"||w==="signed"?e.jsx(va,{className:"h-3 w-3"}):w==="rejected"?e.jsx(vc,{className:"h-3 w-3"}):e.jsx(un,{className:"h-3 w-3"}),j=w=>w==="approved"||w==="signed"||w==="paid"?"bg-green-500/10 text-green-600 border-green-200":w==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return c?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," referral",i.length!==1?"s":""]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(Tl,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(w=>{var N;return e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium",children:[w.referee_first_name," ",w.referee_last_name]}),e.jsxs(st,{variant:"outline",className:j(w.status),children:[_(w.status)," ",w.status]}),w.incentive_status&&e.jsxs(st,{variant:"outline",className:j(w.incentive_status),children:[e.jsx(ko,{className:"h-3 w-3 mr-1"})," ",w.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[w.referee_email&&e.jsx("p",{children:w.referee_email}),w.referee_phone&&e.jsx("p",{children:w.referee_phone}),w.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",w.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((N=f[w.referred_by])==null?void 0:N.name)||"Unknown"," • ",ms(new Date(w.created_at),"MMM d, yyyy")]})]}),w.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:w.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Ks,{value:w.status,onValueChange:S=>b.mutate({id:w.id,status:S}),children:[e.jsx(Hs,{className:"h-7 text-xs w-[110px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"pending",children:"Pending"}),e.jsx(Mt,{value:"contacted",children:"Contacted"}),e.jsx(Mt,{value:"approved",children:"Approved"}),e.jsx(Mt,{value:"signed",children:"Signed"}),e.jsx(Mt,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(Ks,{value:w.incentive_status||"pending",onValueChange:S=>b.mutate({id:w.id,incentive_status:S}),children:[e.jsx(Hs,{className:"h-7 text-xs w-[100px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"pending",children:"Unpaid"}),e.jsx(Mt,{value:"paid",children:"Paid"}),e.jsx(Mt,{value:"n/a",children:"N/A"})]})]})]})]})},w.id)})}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:w=>{w.preventDefault(),g.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"First Name *"}),e.jsx(ze,{required:!0,value:o.first_name,onChange:w=>l(N=>({...N,first_name:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Last Name"}),e.jsx(ze,{value:o.last_name,onChange:w=>l(N=>({...N,last_name:w.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Email"}),e.jsx(ze,{type:"email",value:o.email,onChange:w=>l(N=>({...N,email:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Phone"}),e.jsx(ze,{value:o.phone,onChange:w=>l(N=>({...N,phone:w.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Current Brokerage"}),e.jsx(ze,{value:o.current_brokerage,onChange:w=>l(N=>({...N,current_brokerage:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Notes"}),e.jsx(Er,{value:o.notes,onChange:w=>l(N=>({...N,notes:w.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:g.isPending,children:"Submit"})]})]})]})})]})}function Ult({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),[n,a]=k.useState(!1),{data:o}=mt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:g,error:b}=await H.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(b)throw b;return g}}),{data:l=[]}=mt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:g,error:b}=await H.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(b)throw b;return g}}),i=Lt({mutationFn:async g=>{const{error:b}=await H.from("brokerages").update({recruit_form_enabled:g}).eq("id",t);if(b)throw b},onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-recruit-form",t]}),s({title:o!=null&&o.recruit_form_enabled?"Form disabled":"Form enabled"})}}),c=Lt({mutationFn:async({id:g,status:b})=>{const{error:_}=await H.from("recruit_interest_submissions").update({status:b}).eq("id",g);if(_)throw _},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-interest-submissions",t]})}),u=`https://bestbrokerage.relevelup.com/join-brokerage/${(o==null?void 0:o.recruit_form_slug)||""}`,p=()=>{navigator.clipboard.writeText(u),a(!0),s({title:"Link copied!"}),setTimeout(()=>a(!1),2e3)},f=g=>g==="contacted"||g==="converted"?"bg-green-500/10 text-green-600":g==="dismissed"?"bg-red-500/10 text-red-600":"bg-blue-500/10 text-blue-600";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Enable Public Form"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow agents to express interest in joining via a public link"})]}),e.jsx(qr,{checked:(o==null?void 0:o.recruit_form_enabled)||!1,onCheckedChange:g=>i.mutate(g)})]}),(o==null?void 0:o.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("code",{className:"text-xs flex-1 truncate",children:u}),e.jsx(K,{size:"sm",variant:"outline",onClick:p,children:n?e.jsx(va,{className:"h-3.5 w-3.5"}):e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Oe,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Tl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No submissions yet"})]}):e.jsx("div",{className:"space-y-3",children:l.map(g=>e.jsxs("div",{className:"flex items-start justify-between gap-4 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium text-sm",children:[g.first_name," ",g.last_name]}),e.jsx(st,{variant:"outline",className:f(g.status),children:g.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[g.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3"}),g.email]}),g.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),g.phone]}),g.current_brokerage&&e.jsxs("span",{children:["From: ",g.current_brokerage]}),g.experience_years&&e.jsxs("span",{children:[g.experience_years,"yr exp"]})]}),g.why_interested&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 italic",children:['"',g.why_interested,'"']}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:ms(new Date(g.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Ks,{value:g.status,onValueChange:b=>c.mutate({id:g.id,status:b}),children:[e.jsx(Hs,{className:"h-7 text-xs w-[110px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"new",children:"New"}),e.jsx(Mt,{value:"contacted",children:"Contacted"}),e.jsx(Mt,{value:"converted",children:"Converted"}),e.jsx(Mt,{value:"dismissed",children:"Dismissed"})]})]})]},g.id))})})]})]})}function Vlt({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState({prospect_id:"",title:"",description:"",due_date:ms(Pl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,c]=k.useState("pending"),{data:u=[]}=mt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:I,error:O}=await H.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(O)throw O;return I}}),{data:p=[],isLoading:f}=mt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const I=u.map(U=>U.id);if(!I.length)return[];const{data:O,error:q}=await H.from("recruit_follow_ups").select("*").in("prospect_id",I).order("due_date");if(q)throw q;return O},enabled:u.length>0}),g=Object.fromEntries(u.map(I=>[I.id,I])),b=Lt({mutationFn:async I=>{const{data:{user:O}}=await H.auth.getUser();if(!O)throw new Error("Not authenticated");const{error:q}=await H.from("recruit_follow_ups").insert({prospect_id:I.prospect_id,assigned_to:O.id,title:I.title,description:I.description||null,due_date:new Date(I.due_date).toISOString()});if(q)throw q},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:ms(Pl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:I=>s({title:"Error",description:I.message,variant:"destructive"})}),_=Lt({mutationFn:async({id:I,completed:O})=>{const{error:q}=await H.from("recruit_follow_ups").update({completed_at:O?new Date().toISOString():null}).eq("id",I);if(q)throw q},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),j=p.filter(I=>i==="pending"?!I.completed_at:i==="completed"?!!I.completed_at:!0),w=j.filter(I=>!I.completed_at&&w0(new Date(I.due_date))&&!bu(new Date(I.due_date))),N=j.filter(I=>!I.completed_at&&bu(new Date(I.due_date))),S=j.filter(I=>!I.completed_at&&!w0(new Date(I.due_date))&&!bu(new Date(I.due_date))),M=j.filter(I=>!!I.completed_at),L=I=>{const O=g[I.prospect_id],q=!I.completed_at&&w0(new Date(I.due_date))&&!bu(new Date(I.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Oo,{checked:!!I.completed_at,onCheckedChange:U=>_.mutate({id:I.id,completed:U}),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${I.completed_at?"line-through text-muted-foreground":""}`,children:I.title}),I.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:I.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[O&&e.jsxs(st,{variant:"secondary",className:"text-[10px]",children:[O.first_name," ",O.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${q?"text-destructive font-medium":""}`,children:[q?e.jsx(kl,{className:"h-3 w-3"}):e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(I.due_date),"MMM d, h:mm a")]}),I.is_automated&&e.jsx(st,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},I.id)};return f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:["pending","completed","all"].map(I=>e.jsxs(K,{size:"sm",variant:i===I?"default":"outline",onClick:()=>c(I),className:"capitalize text-xs",children:[I," ",I==="pending"&&w.length+N.length+S.length>0&&`(${w.length+N.length+S.length})`]},I))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&w.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-destructive flex items-center gap-1",children:[e.jsx(kl,{className:"h-3.5 w-3.5"})," Overdue (",w.length,")"]}),w.map(L)]}),i!=="completed"&&N.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-600 flex items-center gap-1",children:[e.jsx(un,{className:"h-3.5 w-3.5"})," Today (",N.length,")"]}),N.map(L)]}),i!=="completed"&&S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(hn,{className:"h-3.5 w-3.5"})," Upcoming (",S.length,")"]}),S.map(L)]}),i!=="pending"&&M.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(va,{className:"h-3.5 w-3.5"})," Completed (",M.length,")"]}),M.map(L)]}),j.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:I=>{I.preventDefault(),b.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Prospect *"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",required:!0,value:o.prospect_id,onChange:I=>l(O=>({...O,prospect_id:I.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(I=>e.jsxs("option",{value:I.id,children:[I.first_name," ",I.last_name]},I.id))]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Task *"}),e.jsx(ze,{required:!0,value:o.title,onChange:I=>l(O=>({...O,title:I.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Details"}),e.jsx(Er,{value:o.description,onChange:I=>l(O=>({...O,description:I.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Due Date *"}),e.jsx(ze,{type:"datetime-local",required:!0,value:o.due_date,onChange:I=>l(O=>({...O,due_date:I.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:b.isPending,children:"Schedule"})]})]})]})})]})}const $4s=[{title:"Competitive Splits",description:"Industry-leading commission structure",icon:"💰"},{title:"Tech & Tools",description:"CRM, marketing automation, and more",icon:"🛠️"},{title:"Training & Support",description:"Ongoing mentorship and education",icon:"📚"}];function Hlt({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),[n,a]=k.useState(null),{data:o,isLoading:l}=mt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:w,error:N}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(N)throw N;return w}}),[i,c]=k.useState({brokerage_id:t,hero_headline:"Join Our Team",hero_subtext:"Take your real estate career to the next level.",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",benefits:$4s,testimonials:[],gallery_images:[]});k.useEffect(()=>{o&&c({id:o.id,brokerage_id:o.brokerage_id,hero_headline:o.hero_headline,hero_subtext:o.hero_subtext||"",hero_image_url:o.hero_image_url,logo_url:o.logo_url,primary_color:o.primary_color,accent_color:o.accent_color,benefits:o.benefits||[],testimonials:o.testimonials||[],gallery_images:o.gallery_images||[]})},[o]);const u=Lt({mutationFn:async()=>{const w={brokerage_id:t,hero_headline:i.hero_headline,hero_subtext:i.hero_subtext,hero_image_url:i.hero_image_url,logo_url:i.logo_url,primary_color:i.primary_color,accent_color:i.accent_color,benefits:JSON.parse(JSON.stringify(i.benefits)),testimonials:JSON.parse(JSON.stringify(i.testimonials)),gallery_images:JSON.parse(JSON.stringify(i.gallery_images)),updated_at:new Date().toISOString()};if(i.id){const{error:N}=await H.from("recruit_landing_page_settings").update(w).eq("id",i.id);if(N)throw N}else{const{error:N}=await H.from("recruit_landing_page_settings").insert(w);if(N)throw N}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),p=async(w,N)=>{const S=w.name.split(".").pop(),M=`${t}/${N}-${Date.now()}.${S}`,{error:L}=await H.storage.from("recruit-landing").upload(M,w);if(L)throw L;const{data:{publicUrl:I}}=H.storage.from("recruit-landing").getPublicUrl(M);return I},f=async(w,N)=>{var M;const S=(M=w.target.files)==null?void 0:M[0];if(S){a(N);try{const L=await p(S,N);c(I=>({...I,[N]:L})),s({title:"Image uploaded!"})}catch(L){s({title:"Upload failed",description:L.message,variant:"destructive"})}finally{a(null)}}},g=async w=>{var S;const N=(S=w.target.files)==null?void 0:S[0];if(N){a("gallery");try{const M=await p(N,"gallery");c(L=>({...L,gallery_images:[...L.gallery_images,M]})),s({title:"Gallery image added!"})}catch(M){s({title:"Upload failed",description:M.message,variant:"destructive"})}finally{a(null)}}},b=async(w,N)=>{var M;const S=(M=w.target.files)==null?void 0:M[0];if(S){a(`testimonial-${N}`);try{const L=await p(S,`testimonial-${N}`);c(I=>{const O=[...I.testimonials];return O[N]={...O[N],photo_url:L},{...I,testimonials:O}})}catch(L){s({title:"Upload failed",description:L.message,variant:"destructive"})}finally{a(null)}}},{data:_}=mt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:w,error:N}=await H.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(N)throw N;return w}}),j=`https://bestbrokerage.relevelup.com/join-brokerage/${(_==null?void 0:_.recruit_form_slug)||""}`;return l?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[(_==null?void 0:_.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Live page:"}),e.jsx("code",{className:"text-xs flex-1 truncate",children:j}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:j,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Branding"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.logo_url&&e.jsx("img",{src:i.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="logo_url",children:e.jsxs("span",{children:[e.jsx(li,{className:"h-3.5 w-3.5 mr-1"}),n==="logo_url"?"Uploading...":"Upload Logo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:w=>f(w,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.primary_color,onChange:w=>c(N=>({...N,primary_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:i.primary_color,onChange:w=>c(N=>({...N,primary_color:w.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.accent_color,onChange:w=>c(N=>({...N,accent_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:i.accent_color,onChange:w=>c(N=>({...N,accent_color:w.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Headline"}),e.jsx(ze,{value:i.hero_headline,onChange:w=>c(N=>({...N,hero_headline:w.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Subtext"}),e.jsx(Er,{value:i.hero_subtext,onChange:w=>c(N=>({...N,hero_subtext:w.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.hero_image_url&&e.jsx("img",{src:i.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(li,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:w=>f(w,"hero_image_url")})]}),i.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(w=>({...w,hero_image_url:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(w=>({...w,benefits:[...w.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.benefits.map((w,N)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Cu,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(ze,{value:w.icon,onChange:S=>{const M=[...i.benefits];M[N]={...w,icon:S.target.value},c(L=>({...L,benefits:M}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{value:w.title,onChange:S=>{const M=[...i.benefits];M[N]={...w,title:S.target.value},c(L=>({...L,benefits:M}))},placeholder:"Benefit title"}),e.jsx(ze,{value:w.description,onChange:S=>{const M=[...i.benefits];M[N]={...w,description:S.target.value},c(L=>({...L,benefits:M}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(S=>({...S,benefits:S.benefits.filter((M,L)=>L!==N)})),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},N)),i.benefits.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No benefits added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(w=>({...w,testimonials:[...w.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.testimonials.map((w,N)=>{var S;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[w.photo_url?e.jsx("img",{src:w.photo_url,alt:w.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((S=w.name)==null?void 0:S[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${N}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:M=>b(M,N)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{value:w.name,onChange:M=>{const L=[...i.testimonials];L[N]={...w,name:M.target.value},c(I=>({...I,testimonials:L}))},placeholder:"Name"}),e.jsx(ze,{value:w.role,onChange:M=>{const L=[...i.testimonials];L[N]={...w,role:M.target.value},c(I=>({...I,testimonials:L}))},placeholder:"Role / Title"})]}),e.jsx(Er,{value:w.quote,onChange:M=>{const L=[...i.testimonials];L[N]={...w,quote:M.target.value},c(I=>({...I,testimonials:L}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(M=>({...M,testimonials:M.testimonials.filter((L,I)=>I!==N)})),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},N)}),i.testimonials.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No testimonials added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(gl,{className:"h-3.5 w-3.5 mr-1"}),n==="gallery"?"Uploading...":"Add Photo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:g})]})]}),e.jsx(Oe,{children:i.gallery_images.length>0?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:i.gallery_images.map((w,N)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:w,alt:`Gallery ${N+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(S=>({...S,gallery_images:S.gallery_images.filter((M,L)=>L!==N)})),children:e.jsx(Nr,{className:"h-3 w-3"})})]},N))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No gallery images added yet"})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function q4s(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function U4s({video:t}){return t.cta_clicked_at?e.jsx(st,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(st,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(Ln,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(st,{variant:"secondary",children:[e.jsx(Bn,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(st,{variant:"outline",children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"Draft"]})}function Wlt({brokerageId:t}){const{data:s=[],isLoading:r}=I4s(t),{data:n=[]}=Dlt(t),a=O4s(),o=R4s(),l=Llt(),[i,c]=k.useState(""),[u,p]=k.useState(!1),[f,g]=k.useState({title:"",script_text:"",category:"general"}),b=s.filter(S=>{var L,I,O,q;return i?`${((L=S.prospect)==null?void 0:L.first_name)||""} ${((I=S.prospect)==null?void 0:I.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||((q=(O=S.video)==null?void 0:O.title)==null?void 0:q.toLowerCase().includes(i.toLowerCase())):!0}),_={total:s.length,sent:s.filter(S=>S.sent_at).length,viewed:s.filter(S=>S.view_count>0).length,ctaClicked:s.filter(S=>S.cta_clicked_at).length},j=k.useCallback(S=>{if(!S)return;const M=`${window.location.origin}/recruit-video/${S}`;navigator.clipboard.writeText(M),me.success("Share link copied")},[]),w=k.useCallback((S,M)=>{l.mutate({id:S,sent_via:M})},[l]),N=()=>{!f.title.trim()||!f.script_text.trim()||a.mutate({brokerage_id:t,...f},{onSuccess:()=>{g({title:"",script_text:"",category:"general"}),p(!1)}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Total Videos",value:_.total,icon:An,color:"text-primary"},{label:"Sent",value:_.sent,icon:Bn,color:"text-blue-500"},{label:"Viewed",value:_.viewed,icon:Ln,color:"text-amber-500"},{label:"CTA Clicked",value:_.ctaClicked,icon:sa,color:"text-emerald-500"}].map(S=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${S.color}`,children:e.jsx(S.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})]})},S.label))}),e.jsxs(ba,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"videos",children:[e.jsx(An,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(ns,{value:"scripts",children:[e.jsx(Sn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(ns,{value:"analytics",children:[e.jsx(No,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(bs,{value:"videos",children:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or title...",value:i,onChange:S=>c(S.target.value),className:"pl-9"})]})]})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):b.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(An,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No video outreach yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Record a personalized video from any prospect's profile card"})]}):e.jsx("div",{className:"space-y-3",children:b.map(S=>{var M,L,I,O,q,U;return e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-card hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"relative h-16 w-28 rounded-md overflow-hidden bg-muted flex-shrink-0",children:[(M=S.video)!=null&&M.thumbnail_url?e.jsx("img",{src:S.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(An,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1 rounded",children:q4s(((L=S.video)==null?void 0:L.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(I=S.prospect)==null?void 0:I.first_name," ",(O=S.prospect)==null?void 0:O.last_name]}),e.jsx(U4s,{video:S})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:((q=S.video)==null?void 0:q.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ms(new Date(S.created_at),"MMM d, yyyy"),((U=S.prospect)==null?void 0:U.current_brokerage)&&` · ${S.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(S.share_token),title:"Copy share link",children:e.jsx(gi,{className:"h-4 w-4"})}),!S.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(S.id,"email"),title:"Mark as sent",children:e.jsx(Bn,{className:"h-4 w-4"})}),S.share_token&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${S.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(tn,{className:"h-4 w-4"})})]})]},S.id)})})})]})}),e.jsx(bs,{value:"scripts",children:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx($s,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:f.title,onChange:S=>g(M=>({...M,title:S.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Category"}),e.jsxs(Ks,{value:f.category,onValueChange:S=>g(M=>({...M,category:S})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:uwe.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Script"}),e.jsx(Er,{value:f.script_text,onChange:S=>g(M=>({...M,script_text:S.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:N,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Oe,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Sn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(S=>{var L;const M=((L=uwe.find(I=>I.value===S.category))==null?void 0:L.label)||S.category;return e.jsx(Ee,{className:"relative group",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{variant:"outline",className:"text-[10px] mb-2",children:M}),e.jsx("h4",{className:"font-medium text-sm",children:S.title})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>o.mutate(S.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:S.script_text}),S.is_global&&e.jsx(st,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},S.id)})})})]})}),e.jsx(bs,{value:"analytics",children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"space-y-4",children:[{label:"Videos Created",count:_.total,pct:100,color:"bg-primary"},{label:"Sent to Prospects",count:_.sent,pct:_.total?Math.round(_.sent/_.total*100):0,color:"bg-blue-500"},{label:"Viewed by Prospect",count:_.viewed,pct:_.sent?Math.round(_.viewed/_.sent*100):0,color:"bg-amber-500"},{label:"CTA Clicked",count:_.ctaClicked,pct:_.viewed?Math.round(_.ctaClicked/_.viewed*100):0,color:"bg-emerald-500"}].map(S=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:S.label}),e.jsxs("span",{className:"font-medium",children:[S.count," (",S.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${S.color} rounded-full transition-all`,style:{width:`${S.pct}%`}})})]},S.label))}),s.filter(S=>S.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(S=>S.view_count>0).sort((S,M)=>M.view_count-S.view_count).slice(0,5).map(S=>{var M,L;return e.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-md bg-muted/30",children:[e.jsxs("span",{className:"font-medium",children:[(M=S.prospect)==null?void 0:M.first_name," ",(L=S.prospect)==null?void 0:L.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ln,{className:"h-3.5 w-3.5"})," ",S.view_count]}),S.cta_clicked_at&&e.jsx(sa,{className:"h-4 w-4 text-emerald-500"})]})]},S.id)})})]})]})]})})]})]})}function Glt({brokerageId:t}){const{toast:s}=Ua(),r=Qt(),{stages:n,prospects:a}=vme(t),[o,l]=k.useState(!1),[i,c]=k.useState({title:"",target_count:"10",target_stage_id:"",period_start:ms(new Date,"yyyy-MM-dd"),period_end:ms(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=mt({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:_,error:j}=await H.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(j)throw j;return _}}),f=Lt({mutationFn:async _=>{const{data:{user:j}}=await H.auth.getUser();if(!j)throw new Error("Not authenticated");const{error:w}=await H.from("recruit_goals").insert({brokerage_id:t,title:_.title,target_count:parseInt(_.target_count),target_stage_id:_.target_stage_id||null,period_start:_.period_start,period_end:_.period_end,created_by:j.id});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:_=>s({title:"Error",description:_.message,variant:"destructive"})}),g=Lt({mutationFn:async _=>{const{error:j}=await H.from("recruit_goals").delete().eq("id",_);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),b=_=>{const j=n.find(N=>N.id===_.target_stage_id);return{count:a.filter(N=>Fg(new Date(N.created_at),{start:new Date(_.period_start),end:new Date(_.period_end)})?_.target_stage_id?N.stage_id===_.target_stage_id:!0:!1).length,stage:j}};return p?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," goal",u.length!==1?"s":""]}),e.jsxs(K,{size:"sm",onClick:()=>l(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(zm,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No goals set. Create a recruiting target to track progress."})]}):e.jsx("div",{className:"grid md:grid-cols-2 gap-4",children:u.map(_=>{const{count:j,stage:w}=b(_),N=Math.min(100,j/_.target_count*100),S=Fg(new Date,{start:new Date(_.period_start),end:new Date(_.period_end)});return e.jsxs(Ee,{className:S?"":"opacity-60",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{className:"text-sm",children:_.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ms(new Date(_.period_start),"MMM d")," – ",ms(new Date(_.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[S?e.jsx(st,{className:"text-[10px]",children:"Active"}):e.jsx(st,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>g.mutate(_.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[w&&e.jsxs(st,{variant:"outline",className:"text-[10px]",style:{borderColor:w.color,color:w.color},children:["Stage: ",w.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:j}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",_.target_count]})]}),e.jsx(Bi,{value:N,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[N.toFixed(0),"% complete"]})]})]},_.id)})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:_=>{_.preventDefault(),f.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Goal Title *"}),e.jsx(ze,{required:!0,value:i.title,onChange:_=>c(j=>({...j,title:_.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Target Count *"}),e.jsx(ze,{type:"number",min:"1",required:!0,value:i.target_count,onChange:_=>c(j=>({...j,target_count:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Target Stage (optional)"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:i.target_stage_id,onChange:_=>c(j=>({...j,target_stage_id:_.target.value})),children:[e.jsx("option",{value:"",children:"All stages (total prospects)"}),n.map(_=>e.jsx("option",{value:_.id,children:_.name},_.id))]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Count prospects that reach this stage"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Start Date"}),e.jsx(ze,{type:"date",required:!0,value:i.period_start,onChange:_=>c(j=>({...j,period_start:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"End Date"}),e.jsx(ze,{type:"date",required:!0,value:i.period_end,onChange:_=>c(j=>({...j,period_end:_.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:f.isPending,children:"Create Goal"})]})]})]})})]})}const V4s={first_name:"Sarah",brokerage_name:"ABC Realty",city:"Austin",sender_name:"Jeremy"};function Klt({email:t,mergeValues:s=V4s,selectedSubjectIndex:r,onClose:n}){var c;const a=u=>u.replace(/\{\{first_name\}\}/g,s.first_name).replace(/\{\{brokerage_name\}\}/g,s.brokerage_name).replace(/\{\{city\}\}/g,s.city).replace(/\{\{sender_name\}\}/g,s.sender_name).replace(/\{\{landing_page_link\}\}/g,"https://bestbrokerage.relevelup.com/join-brokerage/your-slug"),o=((c=t.subject_line_options)==null?void 0:c.length)>0?t.subject_line_options:[t.subject_line],l=r??0,i=o[l]||t.subject_line;return e.jsx(fs,{open:!0,onOpenChange:()=>n(),children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] overflow-y-auto p-0",children:[e.jsxs(_s,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(vs,{className:"text-base",children:["Email #",t.email_number," — ",t.title]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsxs(st,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),t.email_number===1?"Sent immediately":`Day ${t.delay_days}`]}),o.length>1&&e.jsxs(st,{variant:"secondary",className:"text-xs",children:[o.length," subject variants"]})]})]}),e.jsxs("div",{className:"space-y-0",children:[o.length>1&&e.jsxs("div",{className:"px-6 py-3 border-b bg-muted/20",children:[e.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Subject Line Options"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:o.map((u,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[10px] font-bold uppercase px-1.5 py-0.5 rounded ${p===l?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:p===l?"Selected":p===0?"Primary":`Alt ${p}`}),e.jsx("span",{className:"text-sm",children:a(u)})]},p))})]}),e.jsxs("div",{className:"border-b",children:[e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-14",children:"From:"}),e.jsxs("span",{children:[s.sender_name," "]})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground border-t",children:[e.jsx("span",{className:"font-medium w-14",children:"To:"}),e.jsxs("span",{children:[s.first_name," "]})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs border-t",children:[e.jsx("span",{className:"font-medium w-14 text-muted-foreground",children:"Subject:"}),e.jsx("span",{className:"font-medium",children:a(i)})]})]}),e.jsx("div",{className:"bg-white px-8 py-6",children:e.jsx("div",{className:"prose prose-sm max-w-none [&_p]:my-3 [&_p+p]:mt-4 [&_br]:block [&_br]:mt-2",style:{fontSize:"15px",lineHeight:"1.75",color:"#1a1a1a"},dangerouslySetInnerHTML:{__html:a(t.body_html)}})})]})]})})}function mCe({brokerageId:t}){const s=Qt(),[r,n]=k.useState({brokerage_id:t,sender_name:"LevelUp",sender_email:"recruiting@relevelup.com",reply_to_email:"",merge_fields:{city:"",broker_name:""}}),{data:a}=mt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:c,error:u}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(u)throw u;return c}}),{data:o}=mt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:c,error:u}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(u)throw u;return c}});k.useEffect(()=>{a?n({...a,merge_fields:a.merge_fields||{city:"",broker_name:""}}):o&&n(c=>({...c,merge_fields:{...c.merge_fields,brokerage_name:o.name,city:o.city||""}}))},[a,o]);const l=Lt({mutationFn:async()=>{const c={brokerage_id:t,sender_name:r.sender_name,sender_email:r.sender_email,reply_to_email:r.reply_to_email||null,merge_fields:r.merge_fields,updated_at:new Date().toISOString()};if(a!=null&&a.id){const{error:u}=await H.from("brokerage_recruit_settings").update(c).eq("id",a.id);if(u)throw u}else{const{error:u}=await H.from("brokerage_recruit_settings").insert(c);if(u)throw u}},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-recruit-settings",t]}),me.success("Recruiting email settings saved!")},onError:c=>me.error(c.message)}),i=(c,u)=>{n(p=>({...p,merge_fields:{...p.merge_fields,[c]:u}}))};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the sender identity and merge fields for recruiting emails sent to this brokerage's prospects."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Sender Display Name"}),e.jsx(ze,{value:r.sender_name,onChange:c=>n({...r,sender_name:c.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Sender Email Address"}),e.jsx(ze,{value:r.sender_email,onChange:c=>n({...r,sender_email:c.target.value}),placeholder:"recruiting@relevelup.com"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Must be a verified SES identity"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Reply-To Email (optional)"}),e.jsx(ze,{value:r.reply_to_email,onChange:c=>n({...r,reply_to_email:c.target.value}),placeholder:"jeremy@relevelup.com"})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Default Merge Fields"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"These values will auto-fill in campaign emails for this brokerage."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"{{brokerage_name}}"}),e.jsx(ze,{value:r.merge_fields.brokerage_name||"",onChange:c=>i("brokerage_name",c.target.value),placeholder:(o==null?void 0:o.name)||"Brokerage Name"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"{{city}}"}),e.jsx(ze,{value:r.merge_fields.city||"",onChange:c=>i("city",c.target.value),placeholder:"e.g. Austin"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"{{sender_name}}"}),e.jsx(ze,{value:r.merge_fields.sender_name||"",onChange:c=>i("sender_name",c.target.value),placeholder:"e.g. Jeremy"})]})]})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",children:[e.jsx(qc,{className:"h-4 w-4 mr-1"})," Save Settings"]})]})}const H4s=cy.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Hc(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Sze=[{key:"first_name",label:"First Name",preview:"Sarah"},{key:"brokerage_name",label:"Brokerage Name",preview:"ABC Realty"},{key:"city",label:"City",preview:"Austin"},{key:"sender_name",label:"Sender Name",preview:"Jeremy"},{key:"landing_page_link",label:"Landing Page URL",preview:"https://bestbrokerage.relevelup.com/join-brokerage/your-slug"}];function fh({onClick:t,active:s,disabled:r,icon:n,tooltip:a}){return e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:r,className:`h-8 w-8 p-0 ${s?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(n,{className:"h-4 w-4"})})}),e.jsx(Xl,{side:"bottom",className:"text-xs",children:a})]})}function W4s({content:t,onChange:s}){const r=ake({extensions:[oke.configure({heading:{levels:[1,2,3]}}),H4s,gke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}),yke.configure({types:["heading","paragraph"]}),vke,Nat],content:t,editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[350px] px-5 py-4",style:"font-size: 15px; line-height: 1.75; color: #1a1a1a;"}},onUpdate:({editor:o})=>{s(o.getHTML())}});k.useEffect(()=>{r&&t!==r.getHTML()&&r.commands.setContent(t)},[t,r]);const n=k.useCallback(()=>{if(!r)return;const o=r.getAttributes("link").href,l=window.prompt("Enter URL",o);if(l!==null){if(l===""){r.chain().focus().extendMarkRange("link").unsetLink().run();return}r.chain().focus().extendMarkRange("link").setLink({href:l}).run()}},[r]),a=k.useCallback(o=>{r&&r.chain().focus().insertContent(`{{${o}}}`).run()},[r]);return r?e.jsx(B1,{delayDuration:300,children:e.jsxs("div",{className:"border rounded-xl overflow-hidden bg-background shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30",children:[e.jsx(fh,{onClick:()=>r.chain().focus().toggleBold().run(),active:r.isActive("bold"),icon:Y4,tooltip:"Bold"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleItalic().run(),active:r.isActive("italic"),icon:sS,tooltip:"Italic"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleUnderline().run(),active:r.isActive("underline"),icon:OL,tooltip:"Underline"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleStrike().run(),active:r.isActive("strike"),icon:EL,tooltip:"Strikethrough"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleHeading({level:1}).run(),active:r.isActive("heading",{level:1}),icon:EM,tooltip:"Heading 1"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleHeading({level:2}).run(),active:r.isActive("heading",{level:2}),icon:PM,tooltip:"Heading 2"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleHeading({level:3}).run(),active:r.isActive("heading",{level:3}),icon:uL,tooltip:"Heading 3"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleBulletList().run(),active:r.isActive("bulletList"),icon:Mh,tooltip:"Bullet List"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleOrderedList().run(),active:r.isActive("orderedList"),icon:p0,tooltip:"Numbered List"}),e.jsx(fh,{onClick:()=>r.chain().focus().toggleBlockquote().run(),active:r.isActive("blockquote"),icon:H_,tooltip:"Blockquote"}),e.jsx(fh,{onClick:()=>r.chain().focus().setHorizontalRule().run(),icon:f0,tooltip:"Divider"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:()=>r.chain().focus().setTextAlign("left").run(),active:r.isActive({textAlign:"left"}),icon:G4,tooltip:"Align Left"}),e.jsx(fh,{onClick:()=>r.chain().focus().setTextAlign("center").run(),active:r.isActive({textAlign:"center"}),icon:W4,tooltip:"Align Center"}),e.jsx(fh,{onClick:()=>r.chain().focus().setTextAlign("right").run(),active:r.isActive({textAlign:"right"}),icon:K4,tooltip:"Align Right"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:n,active:r.isActive("link"),icon:Bo,tooltip:"Insert Link"}),e.jsx(rl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(fh,{onClick:()=>r.chain().focus().undo().run(),disabled:!r.can().undo(),icon:xS,tooltip:"Undo"}),e.jsx(fh,{onClick:()=>r.chain().focus().redo().run(),disabled:!r.can().redo(),icon:mS,tooltip:"Redo"}),e.jsx("div",{className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",onClick:()=>{r&&r.chain().focus().insertContent('

Learn More About Us

').run()},children:"🔘 CTA Button"}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",children:[e.jsx(VM,{className:"h-3.5 w-3.5"}),"Merge Tags"]})}),e.jsx(Bd,{align:"end",className:"w-56",children:Sze.map(o=>e.jsxs(Ma,{onClick:()=>a(o.key),className:"flex flex-col items-start gap-0.5",children:[e.jsx("span",{className:"font-medium text-sm",children:o.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:`{{${o.key}}}`})]},o.key))})]})]}),e.jsx("div",{className:"bg-white",children:e.jsx(rke,{editor:r,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[350px] [&_.ProseMirror_p]:my-3 [&_.ProseMirror_ul]:my-3 [&_.ProseMirror_ol]:my-3 [&_.ProseMirror_blockquote]:my-3 [&_.ProseMirror_h1]:my-4 [&_.ProseMirror_h2]:my-3 [&_.ProseMirror_h3]:my-2"})}),e.jsx("div",{className:"border-t px-4 py-2.5 bg-muted/20",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Tags:"}),Sze.map(o=>e.jsx(st,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 font-mono text-[10px] px-2 py-0.5",onClick:()=>a(o.key),children:`{{${o.key}}}`},o.key))]})})]})}):null}const Cze={cold:{icon:a0,color:"text-blue-500",bg:"bg-blue-50 dark:bg-blue-950/30",label:"Cold — Curiosity"},warm:{icon:p1,color:"text-amber-500",bg:"bg-amber-50 dark:bg-amber-950/30",label:"Warm — Growth"},hot:{icon:eh,color:"text-red-500",bg:"bg-red-50 dark:bg-red-950/30",label:"Hot — Private Invite"}};function Zlt({brokerageId:t}){var $e,Ae,Ie,Ce;const{user:s}=Ds(),r=Qt(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(null),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState("editor"),[j,w]=k.useState(null),[N,S]=k.useState({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""}),{data:M}=mt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:xe,error:we}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(we)throw we;return xe}}),{data:L}=mt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:xe,error:we}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(we)throw we;return xe}}),I={first_name:"Sarah",brokerage_name:(($e=L==null?void 0:L.merge_fields)==null?void 0:$e.brokerage_name)||(M==null?void 0:M.name)||"Your Brokerage",city:((Ae=L==null?void 0:L.merge_fields)==null?void 0:Ae.city)||(M==null?void 0:M.city)||"Your City",sender_name:((Ie=L==null?void 0:L.merge_fields)==null?void 0:Ie.sender_name)||(L==null?void 0:L.sender_name)||"Your Name"},O=xe=>xe.replace(/\{\{first_name\}\}/g,I.first_name).replace(/\{\{brokerage_name\}\}/g,I.brokerage_name).replace(/\{\{city\}\}/g,I.city).replace(/\{\{sender_name\}\}/g,I.sender_name),{data:q=[],isLoading:U}=mt({queryKey:["recruit-campaigns",t],queryFn:async()=>{const{data:xe,error:we}=await H.from("recruit_campaigns").select("*").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("sort_order");if(we)throw we;return xe}}),{data:B={}}=mt({queryKey:["recruit-campaign-emails",t],enabled:q.length>0,queryFn:async()=>{const xe=q.map(Te=>Te.id),{data:we,error:Le}=await H.from("recruit_campaign_emails").select("*").in("campaign_id",xe).order("email_number");if(Le)throw Le;const tt={};return we.forEach(Te=>{tt[Te.campaign_id]||(tt[Te.campaign_id]=[]),tt[Te.campaign_id].push(Te)}),tt}}),V=Object.values(B).flat().map(xe=>xe.id),{data:Y=[]}=mt({queryKey:["recruit-subject-overrides",t],enabled:V.length>0,queryFn:async()=>{const{data:xe,error:we}=await H.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(we)throw we;return xe}}),Q={};Y.forEach(xe=>{Q[xe.campaign_email_id]=xe.selected_subject_index});const ee=Lt({mutationFn:async({campaignEmailId:xe,selectedIndex:we})=>{const{error:Le}=await H.from("recruit_brokerage_subject_overrides").upsert({brokerage_id:t,campaign_email_id:xe,selected_subject_index:we,updated_at:new Date().toISOString()},{onConflict:"brokerage_id,campaign_email_id"});if(Le)throw Le},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-subject-overrides",t]}),me.success("Subject line updated for your brokerage")},onError:xe=>me.error(xe.message)}),X=Lt({mutationFn:async xe=>{const{error:we}=await H.from("recruit_campaign_emails").update({title:xe.title,subject_line:xe.subject_line,subject_line_options:xe.subject_line_options,body_html:xe.body_html,body_text:xe.body_text,delay_days:xe.delay_days,updated_at:new Date().toISOString()}).eq("id",xe.id);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email template saved!"),l(null)},onError:xe=>me.error(xe.message)}),ie=Lt({mutationFn:async()=>{const xe=N.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),{data:we,error:Le}=await H.from("recruit_campaigns").insert({name:N.name,slug:xe,description:N.description||null,theme:N.theme||null,goal:N.goal||null,primary_cta:N.primary_cta||"Learn more",warmth_level:N.warmth_level,brokerage_id:t,created_by:s==null?void 0:s.id,sender_name:N.sender_name||null,sender_email:N.sender_email||null,reply_to_email:N.reply_to_email||null,is_active:!0,sort_order:q.length+1}).select().single();if(Le)throw Le;const tt=[{email_number:1,title:"Introduction",subject_line:"Hey {{first_name}}, quick question",delay_days:0},{email_number:2,title:"Follow Up",subject_line:"Following up, {{first_name}}",delay_days:7},{email_number:3,title:"Value Add",subject_line:"{{first_name}}, thought you'd want to see this",delay_days:14},{email_number:4,title:"Final Touch",subject_line:"Last note, {{first_name}}",delay_days:21}],{error:Te}=await H.from("recruit_campaign_emails").insert(tt.map(pt=>({campaign_id:we.id,...pt,body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",subject_line_options:[],is_active:!0})));if(Te)throw Te;return we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Campaign created with 4 starter emails!"),g(!1),S({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""})},onError:xe=>me.error(xe.message)}),re=Lt({mutationFn:async xe=>{const{error:we}=await H.from("recruit_campaigns").update({name:xe.name,description:xe.description,theme:xe.theme,goal:xe.goal,primary_cta:xe.primary_cta,warmth_level:xe.warmth_level,sender_name:xe.sender_name,sender_email:xe.sender_email,reply_to_email:xe.reply_to_email,updated_at:new Date().toISOString()}).eq("id",xe.id);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),me.success("Campaign settings saved!"),w(null)},onError:xe=>me.error(xe.message)}),oe=Lt({mutationFn:async xe=>{var fe,qe;const{data:we}=await H.from("recruit_campaign_emails").select("email_number, delay_days").eq("campaign_id",xe).order("email_number",{ascending:!1}).limit(1),Le=((fe=we==null?void 0:we[0])==null?void 0:fe.email_number)??0,tt=((qe=we==null?void 0:we[0])==null?void 0:qe.delay_days)??0,Te=Le+1,{error:pt}=await H.from("recruit_campaign_emails").insert({campaign_id:xe,email_number:Te,title:`Email ${Te}`,subject_line:"Hey {{first_name}}",subject_line_options:[],body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",delay_days:tt+7,is_active:!0});if(pt)throw pt},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email added to campaign!")},onError:xe=>me.error(xe.message)}),ce=Lt({mutationFn:async xe=>{const{error:we}=await H.from("recruit_campaigns").delete().eq("id",xe);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Campaign deleted")},onError:xe=>me.error(xe.message)}),ge=Lt({mutationFn:async xe=>{const{error:we}=await H.from("recruit_campaign_emails").delete().eq("id",xe);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email removed from campaign")},onError:xe=>me.error(xe.message)}),ye=Lt({mutationFn:async({emailId:xe,delay_days:we})=>{const{error:Le}=await H.from("recruit_campaign_emails").update({delay_days:we,updated_at:new Date().toISOString()}).eq("id",xe);if(Le)throw Le},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Send delay updated")},onError:xe=>me.error(xe.message)});if(U)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const ue=q.filter(xe=>!xe.brokerage_id),pe=q.filter(xe=>xe.brokerage_id===t);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Recruiting Campaigns"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System campaigns + custom campaigns · Each can have its own email settings"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-1.5",children:[e.jsx(Xo,{className:"h-4 w-4"})," Default Settings"]}),e.jsxs(K,{size:"sm",onClick:()=>g(!0),className:"gap-1.5",children:[e.jsx($s,{className:"h-4 w-4"})," New Campaign"]})]})]}),e.jsx(Ee,{className:"border-primary/20 bg-primary/5",children:e.jsx(Oe,{className:"py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(pn,{className:"h-5 w-5 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-semibold",children:"Per-Campaign Email Settings"}),e.jsxs("p",{className:"text-muted-foreground",children:["Each campaign can override the default sender name, email, and reply-to. Click the ",e.jsx(Xo,{className:"inline h-3.5 w-3.5"})," icon on any campaign to customize."]})]})]})})}),pe.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(mL,{className:"h-4 w-4"})," Your Custom Campaigns"]}),e.jsx("div",{className:"space-y-3",children:pe.map(xe=>_e(xe,!0))})]}),ue.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(pn,{className:"h-4 w-4"})," System Campaigns"]}),e.jsx("div",{className:"space-y-3",children:ue.map(xe=>_e(xe,!1))})]}),q.length===0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(cr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No campaigns yet. Create your first campaign to start automated outreach."}),e.jsxs(K,{className:"mt-4",onClick:()=>g(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})}),i&&e.jsx(Klt,{email:i,mergeValues:I,selectedSubjectIndex:Q[i.id],onClose:()=>c(null)}),e.jsx(fs,{open:!!o,onOpenChange:xe=>!xe&&l(null),children:e.jsxs(ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs(_s,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx($_,{className:"h-5 w-5 text-primary"}),"Edit Email #",o==null?void 0:o.email_number]}),e.jsx(Gr,{children:o==null?void 0:o.title})]}),o&&e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Title"}),e.jsx(ze,{value:o.title,onChange:xe=>l({...o,title:xe.target.value}),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Delay (days after previous)"}),e.jsx(ze,{type:"number",min:0,max:90,value:o.delay_days,onChange:xe=>l({...o,delay_days:parseInt(xe.target.value)||7}),className:"h-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Subject Line"}),e.jsx(ze,{value:o.subject_line,onChange:xe=>l({...o,subject_line:xe.target.value}),placeholder:"e.g. Hey {{first_name}}, quick question...",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Alternative Subject Lines ",e.jsx("span",{className:"text-muted-foreground font-normal normal-case",children:"(one per line, for A/B testing)"})]}),e.jsx(Er,{value:((Ce=o.subject_line_options)==null?void 0:Ce.join(` `))||"",onChange:xe=>l({...o,subject_line_options:xe.target.value.split(` `).filter(Boolean)}),rows:2,className:"text-sm resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Body"}),e.jsx(ba,{value:b,onValueChange:xe=>_(xe),children:e.jsxs(pa,{className:"h-7",children:[e.jsx(ns,{value:"editor",className:"text-xs px-3 h-6",children:"Editor"}),e.jsx(ns,{value:"preview",className:"text-xs px-3 h-6",children:"Preview"})]})})]}),b==="editor"?e.jsx(W4s,{content:o.body_html,onChange:xe=>l({...o,body_html:xe})}):e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"bg-muted/50 px-4 py-2 border-b space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-12",children:"From:"}),e.jsxs("span",{children:[I.sender_name," "]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-12",children:"To:"}),e.jsxs("span",{children:[I.first_name," "]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium w-12 text-muted-foreground",children:"Subject:"}),e.jsx("span",{className:"font-medium",children:O(o.subject_line)})]})]}),e.jsx("div",{className:"bg-white p-6",children:e.jsx("div",{className:"prose prose-sm max-w-none",style:{fontSize:"15px",lineHeight:"1.75",color:"#1a1a1a"},dangerouslySetInnerHTML:{__html:O(o.body_html)}})})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Changes are saved to this campaign's templates"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:()=>X.mutate(o),disabled:X.isPending,className:"gap-1.5",children:[e.jsx(qc,{className:"h-3.5 w-3.5"})," Save Changes"]})]})]})]})]})}),e.jsx(fs,{open:f,onOpenChange:g,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx($s,{className:"h-5 w-5 text-primary"})," Create Custom Campaign"]}),e.jsx(Gr,{children:"Build your own recruiting email sequence with custom sender settings."})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Campaign Name *"}),e.jsx(ze,{value:N.name,onChange:xe=>S({...N,name:xe.target.value}),placeholder:"e.g. Q2 Agent Outreach"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Ks,{value:N.warmth_level,onValueChange:xe=>S({...N,warmth_level:xe}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"cold",children:"❄️ Cold — Curiosity"}),e.jsx(Mt,{value:"warm",children:"☀️ Warm — Growth"}),e.jsx(Mt,{value:"hot",children:"🔥 Hot — Private Invite"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Primary CTA"}),e.jsx(ze,{value:N.primary_cta,onChange:xe=>S({...N,primary_cta:xe.target.value}),placeholder:"Learn more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Description"}),e.jsx(Er,{value:N.description,onChange:xe=>S({...N,description:xe.target.value}),placeholder:"What is this campaign about?",rows:2})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Goal"}),e.jsx(ze,{value:N.goal,onChange:xe=>S({...N,goal:xe.target.value}),placeholder:"e.g. Convert warm leads to meetings"})]}),e.jsxs(yf,{children:[e.jsx(vf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs font-medium text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email Settings Override"]}),e.jsx(Eo,{className:"h-3.5 w-3.5"})]})}),e.jsxs(bf,{className:"space-y-3 pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave blank to use brokerage defaults."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Sender Name"}),e.jsx(ze,{value:N.sender_name,onChange:xe=>S({...N,sender_name:xe.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Sender Email"}),e.jsx(ze,{value:N.sender_email,onChange:xe=>S({...N,sender_email:xe.target.value}),placeholder:"e.g. recruiting@send.relevelup.com"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Must be a verified sending domain"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Reply-To Email"}),e.jsx(ze,{value:N.reply_to_email,onChange:xe=>S({...N,reply_to_email:xe.target.value}),placeholder:"e.g. jeremy@mybrokerage.com"})]})]})]}),e.jsxs(K,{className:"w-full",disabled:!N.name.trim()||ie.isPending,onClick:()=>ie.mutate(),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})]})}),e.jsx(fs,{open:!!j,onOpenChange:xe=>!xe&&w(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5 text-primary"})," Campaign Email Settings"]}),e.jsx(Gr,{children:"Override the default sender for this campaign. Leave blank to use brokerage defaults."})]}),j&&e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Campaign Name"}),e.jsx(ze,{value:j.name,onChange:xe=>w({...j,name:xe.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Ks,{value:j.warmth_level,onValueChange:xe=>w({...j,warmth_level:xe}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"cold",children:"❄️ Cold"}),e.jsx(Mt,{value:"warm",children:"☀️ Warm"}),e.jsx(Mt,{value:"hot",children:"🔥 Hot"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Goal"}),e.jsx(ze,{value:j.goal||"",onChange:xe=>w({...j,goal:xe.target.value})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsxs("p",{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(cr,{className:"h-4 w-4 text-primary"})," Email Sender Override"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Sender Name"}),e.jsx(ze,{value:j.sender_name||"",onChange:xe=>w({...j,sender_name:xe.target.value}),placeholder:"Uses brokerage default"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Sender Email"}),e.jsx(ze,{value:j.sender_email||"",onChange:xe=>w({...j,sender_email:xe.target.value}),placeholder:"Uses brokerage default"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Must be a verified sending domain"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Reply-To Email"}),e.jsx(ze,{value:j.reply_to_email||"",onChange:xe=>w({...j,reply_to_email:xe.target.value}),placeholder:"Uses brokerage default"})]})]}),e.jsxs(K,{className:"w-full",onClick:()=>re.mutate(j),disabled:re.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-1"})," Save Campaign Settings"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Default Recruiting Email Settings"}),e.jsx(Gr,{children:"These defaults apply to campaigns without their own overrides."})]}),e.jsx(mCe,{brokerageId:t})]})})]});function _e(xe,we){const Le=Cze[xe.warmth_level]||Cze.cold,tt=Le.icon,Te=B[xe.id]||[],pt=n===xe.id,fe=!!(xe.sender_name||xe.sender_email||xe.reply_to_email);return e.jsxs(Ee,{className:"overflow-hidden transition-shadow hover:shadow-md",children:[e.jsx(Pt,{className:"cursor-pointer hover:bg-muted/40 transition-colors py-4",onClick:()=>a(pt?null:xe.id),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`h-11 w-11 rounded-xl ${Le.bg} flex items-center justify-center`,children:e.jsx(tt,{className:`h-5 w-5 ${Le.color}`})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[xe.name,e.jsx(st,{variant:xe.is_active?"default":"secondary",className:"text-[10px] px-1.5",children:xe.is_active?"Active":"Draft"}),we&&e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5",children:"Custom"}),fe&&e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 border-primary/30 text-primary",children:[e.jsx(cr,{className:"h-2.5 w-2.5 mr-0.5"})," Custom Sender"]})]}),e.jsx(gr,{className:"text-xs mt-0.5",children:xe.theme||xe.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:qe=>{qe.stopPropagation(),w({...xe})},children:e.jsx(Xo,{className:"h-4 w-4 text-muted-foreground"})}),we&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:qe=>{qe.stopPropagation(),confirm("Delete this campaign and all its emails? This cannot be undone.")&&ce.mutate(xe.id)},children:e.jsx(Nr,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[Te.length," emails"]})]}),e.jsx("div",{className:"h-7 w-7 rounded-md flex items-center justify-center",children:pt?e.jsx(ff,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Eo,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),pt&&e.jsxs(Oe,{className:"pt-0 pb-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-3 rounded-lg bg-muted/40 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Goal"}),e.jsx("p",{className:"mt-0.5",children:xe.goal||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Primary CTA"}),e.jsx("p",{className:"mt-0.5",children:xe.primary_cta||"—"})]})]}),fe&&e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-sm",children:[e.jsxs("p",{className:"text-xs font-semibold text-primary mb-1 flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3"})," Campaign Sender Override"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-muted-foreground",children:[xe.sender_name&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",xe.sender_name]}),xe.sender_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Email:"})," ",xe.sender_email]}),xe.reply_to_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Reply-To:"})," ",xe.reply_to_email]})]})]}),e.jsx("div",{className:"relative",children:Te.map((qe,at)=>{var et,Me;return e.jsxs("div",{className:"relative flex gap-4 pb-4 last:pb-0",children:[atrt.stopPropagation(),onBlur:rt=>{const He=parseInt(rt.target.value)||0;He!==qe.delay_days&&ye.mutate({emailId:qe.id,delay_days:He})},onKeyDown:rt=>{rt.key==="Enter"&&rt.target.blur()}}),"days"]})]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),qe.email_number===1?"Sent immediately":`Day ${qe.delay_days}`]}),e.jsx("span",{className:"text-border",children:"•"}),e.jsxs("span",{className:"truncate",children:["Subject: ",O(((et=qe.subject_line_options)==null?void 0:et.length)>0&&qe.subject_line_options[Q[qe.id]??0]||qe.subject_line)]})]}),((Me=qe.subject_line_options)==null?void 0:Me.length)>1&&e.jsx("div",{className:"mt-2",children:e.jsxs(Ks,{value:String(Q[qe.id]??0),onValueChange:rt=>ee.mutate({campaignEmailId:qe.id,selectedIndex:parseInt(rt)}),children:[e.jsx(Hs,{className:"h-7 text-xs w-full max-w-sm",children:e.jsx(Ys,{placeholder:"Choose subject line"})}),e.jsx(Ws,{children:qe.subject_line_options.map((rt,He)=>e.jsxs(Mt,{value:String(He),className:"text-xs",children:[e.jsxs("span",{className:"font-medium mr-1.5",children:[He===0?"Primary":`Alt ${He}`,":"]}),O(rt)]},He))})]})})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>c(qe),children:e.jsx(Ln,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{l({...qe}),_("editor")},children:e.jsx(Ra,{className:"h-4 w-4"})}),we&&Te.length>1&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>{confirm("Delete this email from the sequence?")&&ge.mutate(qe.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})})]},qe.id)})}),we&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>oe.mutate(xe.id),disabled:oe.isPending,children:[e.jsx($s,{className:"h-3.5 w-3.5"})," Add Email to Sequence"]})]})]},xe.id)}}const Mze={active:{icon:nl,color:"bg-green-500/10 text-green-600",label:"Active"},paused:{icon:Rm,color:"bg-amber-500/10 text-amber-600",label:"Paused"},completed:{icon:xi,color:"bg-blue-500/10 text-blue-600",label:"Completed"},cancelled:{icon:vc,color:"bg-red-500/10 text-red-600",label:"Cancelled"}},Tze={sent:{icon:cr,color:"text-blue-500"},opened:{icon:Ln,color:"text-amber-500"},clicked:{icon:Jg,color:"text-green-500"},failed:{icon:Ku,color:"text-destructive"}};function Ylt({brokerageId:t}){var pe,_e,$e,Ae,Ie;const{user:s}=Ds(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,c]=k.useState(new Set),[u,p]=k.useState("assignments"),[f,g]=k.useState(null),[b,_]=k.useState(""),{data:j={}}=mt({queryKey:["recruit-campaign-emails-for-preview",t],queryFn:async()=>{const{data:Ce,error:xe}=await H.from("recruit_campaign_emails").select("*").order("email_number");if(xe)throw xe;const we={};return(Ce??[]).forEach(Le=>{we[Le.campaign_id]||(we[Le.campaign_id]=[]),we[Le.campaign_id].push(Le)}),we}}),{data:w}=mt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:Ce,error:xe}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(xe)throw xe;return Ce}}),{data:N}=mt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:Ce,error:xe}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(xe)throw xe;return Ce}}),{data:S=[]}=mt({queryKey:["recruit-subject-overrides",t],queryFn:async()=>{const{data:Ce,error:xe}=await H.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(xe)throw xe;return Ce}}),M={};S.forEach(Ce=>{M[Ce.campaign_email_id]=Ce.selected_subject_index});const L={first_name:((pe=f==null?void 0:f.prospect)==null?void 0:pe.first_name)||"Sarah",brokerage_name:((_e=N==null?void 0:N.merge_fields)==null?void 0:_e.brokerage_name)||(w==null?void 0:w.name)||"Your Brokerage",city:(($e=N==null?void 0:N.merge_fields)==null?void 0:$e.city)||(w==null?void 0:w.city)||"Your City",sender_name:((Ae=N==null?void 0:N.merge_fields)==null?void 0:Ae.sender_name)||(N==null?void 0:N.sender_name)||"Your Name"},I=Ce=>{const xe=j[Ce.campaign_id]||[],we=Ce.current_email_number+1;return xe.find(Le=>Le.email_number===we)||null},{data:O=[],isLoading:q}=mt({queryKey:["recruit-campaign-assignments",t],queryFn:async()=>{let xe=[],we=0;for(;;){const{data:Le,error:tt}=await H.from("recruit_campaign_assignments").select(` *, prospect:recruit_prospects(first_name, last_name, email), campaign:recruit_campaigns(name, warmth_level) `).eq("brokerage_id",t).order("created_at",{ascending:!1}).range(we,we+1e3-1);if(tt)throw tt;if(xe=xe.concat(Le??[]),!Le||Le.length<1e3)break;we+=1e3}return xe}}),{data:U=[]}=mt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{const{data:Ce,error:xe}=await H.from("recruit_campaign_sends").select(` *, prospect:recruit_prospects(first_name, last_name, email), campaign_email:recruit_campaign_emails(title) `).eq("brokerage_id",t).order("sent_at",{ascending:!1}).limit(100);if(xe)throw xe;return Ce}}),{data:B=[]}=mt({queryKey:["recruit-campaigns"],queryFn:async()=>{const{data:Ce,error:xe}=await H.from("recruit_campaigns").select("id, name, warmth_level").eq("is_active",!0).order("sort_order");if(xe)throw xe;return Ce}}),{data:V=[]}=mt({queryKey:["recruit-prospects-for-assign",t],queryFn:async()=>{let xe=[],we=0;for(;;){const{data:Le,error:tt}=await H.from("recruit_prospects").select("id, first_name, last_name, email").eq("brokerage_id",t).order("first_name").range(we,we+1e3-1);if(tt)throw tt;if(xe=xe.concat(Le??[]),!Le||Le.length<1e3)break;we+=1e3}return xe}}),Y=new Set(O.map(Ce=>`${Ce.prospect_id}-${Ce.campaign_id}`)),Q=Lt({mutationFn:async()=>{if(!o||i.size===0)throw new Error("Select a campaign and at least one prospect");const Ce=new Date,xe=Array.from(i).filter(Le=>!Y.has(`${Le}-${o}`)).map(Le=>({prospect_id:Le,campaign_id:o,brokerage_id:t,assigned_by:s.id,status:"active",current_email_number:0,next_send_at:Ce.toISOString(),started_at:Ce.toISOString()}));if(xe.length===0)throw new Error("All selected prospects are already assigned to this campaign");const{error:we}=await H.from("recruit_campaign_assignments").insert(xe);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success(`Campaign assigned to ${i.size} prospect(s)!`),a(!1),l(""),c(new Set)},onError:Ce=>me.error(Ce.message)}),ee=Lt({mutationFn:async({id:Ce,newStatus:xe})=>{const{error:we}=await H.from("recruit_campaign_assignments").update({status:xe,updated_at:new Date().toISOString()}).eq("id",Ce);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success("Assignment updated")}}),X=Lt({mutationFn:async()=>{const{data:Ce,error:xe}=await H.functions.invoke("ses-recruit-drip",{body:{action:"process_drips"}});if(xe)throw xe;return Ce},onSuccess:Ce=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),r.invalidateQueries({queryKey:["recruit-campaign-sends",t]}),me.success(`Wave sent! ${Ce.sent} emails delivered, ${Ce.skipped} skipped, ${Ce.failed} failed`)},onError:Ce=>me.error(`Send failed: ${Ce.message}`)}),ie=O.filter(Ce=>Ce.status==="active").length;O.filter(Ce=>Ce.status==="completed").length;const re=O.filter(Ce=>Ce.status==="active"&&Ce.next_send_at&&new Date(Ce.next_send_at)<=new Date).length,oe=U.length,ce=U.filter(Ce=>Ce.opened_at).length,ge=U.filter(Ce=>Ce.clicked_at).length,ye=oe>0?Math.round(ce/oe*100):0,ue=oe>0?Math.round(ge/oe*100):0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Campaign Assignments"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Assign recruiting campaigns to prospects — emails auto-send weekly via SES"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[re>0&&e.jsxs(K,{variant:"outline",onClick:()=>X.mutate(),disabled:X.isPending,className:"border-amber-500/50 text-amber-600 hover:bg-amber-500/10",children:[e.jsx(Zh,{className:"h-4 w-4 mr-1"}),X.isPending?"Sending...":`Send Next Wave (${re})`]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx(Bn,{className:"h-4 w-4 mr-1"})," Assign Campaign"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(pr,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:O.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assigned"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(nl,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:ie}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(cr,{className:"h-7 w-7 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:oe}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emails Sent"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Ln,{className:"h-7 w-7 text-amber-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[ye,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Open Rate"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Jg,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[ue,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click Rate"})]})]})})]}),e.jsxs(ba,{value:u,onValueChange:p,children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"assignments",children:["Active Drips (",ie,")"]}),e.jsxs(ns,{value:"history",children:["Send History (",oe,")"]})]}),e.jsx(bs,{value:"assignments",className:"mt-4",children:q?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):O.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Bn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No campaigns assigned yet"}),e.jsx("p",{className:"text-sm",children:"Assign a recruiting campaign to your prospects to start automated outreach"})]})}):e.jsx("div",{className:"space-y-2",children:O.map(Ce=>{var pt,fe,qe,at;const xe=Mze[Ce.status]||Mze.active,we=xe.icon,tt=(j[Ce.campaign_id]||[]).length||4,Te=I(Ce);return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(st,{className:`text-xs ${xe.color} border-0`,children:[e.jsx(we,{className:"h-3 w-3 mr-1"}),xe.label]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(pt=Ce.prospect)==null?void 0:pt.first_name," ",(fe=Ce.prospect)==null?void 0:fe.last_name,e.jsx("span",{className:"text-muted-foreground font-normal ml-2",children:(qe=Ce.prospect)==null?void 0:qe.email})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(at=Ce.campaign)==null?void 0:at.name," · Email ",Ce.current_email_number,"/",tt,Ce.next_send_at&&Ce.status==="active"&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx(un,{className:"h-3 w-3 inline"})," Next: ",ms(new Date(Ce.next_send_at),"MMM d, h:mm a"),new Date(Ce.next_send_at)<=new Date&&e.jsx(st,{variant:"outline",className:"ml-1 text-[10px] px-1 py-0 border-amber-500 text-amber-600",children:"DUE"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[Te&&e.jsx(K,{variant:"ghost",size:"sm",title:"Preview next email",onClick:()=>g(Ce),children:e.jsx(Ln,{className:"h-3.5 w-3.5"})}),Ce.status==="active"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ee.mutate({id:Ce.id,newStatus:"paused"}),children:e.jsx(Rm,{className:"h-3.5 w-3.5"})}),Ce.status==="paused"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ee.mutate({id:Ce.id,newStatus:"active"}),children:e.jsx(nl,{className:"h-3.5 w-3.5"})}),(Ce.status==="active"||Ce.status==="paused")&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>ee.mutate({id:Ce.id,newStatus:"cancelled"}),children:e.jsx(vc,{className:"h-3.5 w-3.5"})})]})]},Ce.id)})})}),e.jsx(bs,{value:"history",className:"mt-4",children:U.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(cr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No emails sent yet"}),e.jsx("p",{className:"text-sm",children:"Emails will appear here once campaigns start sending"})]})}):e.jsx("div",{className:"space-y-1",children:U.map(Ce=>{var Le,tt;const xe=Tze[Ce.status]||Tze.sent,we=xe.icon;return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(we,{className:`h-4 w-4 flex-shrink-0 ${xe.color}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[(Le=Ce.prospect)==null?void 0:Le.first_name," ",(tt=Ce.prospect)==null?void 0:tt.last_name,e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["Email #",Ce.email_number]})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ce.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-shrink-0",children:[Ce.opened_at&&e.jsxs("span",{className:"flex items-center gap-1 text-amber-500",children:[e.jsx(Ln,{className:"h-3 w-3"})," ",ms(new Date(Ce.opened_at),"MMM d")]}),Ce.clicked_at&&e.jsxs("span",{className:"flex items-center gap-1 text-green-500",children:[e.jsx(Jg,{className:"h-3 w-3"})," ",ms(new Date(Ce.clicked_at),"MMM d")]}),Ce.status==="failed"&&e.jsx("span",{className:"text-destructive text-xs",children:"Failed"}),e.jsx("span",{children:ms(new Date(Ce.sent_at),"MMM d, h:mm a")})]})]},Ce.id)})})})]}),e.jsx(fs,{open:n,onOpenChange:Ce=>{a(Ce),Ce||(_(""),c(new Set),l(""))},children:e.jsxs(ps,{className:"max-w-lg max-h-[85vh] flex flex-col p-0",children:[e.jsxs(_s,{className:"px-6 pt-6 pb-4",children:[e.jsx(vs,{children:"Assign Campaign to Prospects"}),e.jsx(Gr,{children:"Select a campaign and choose which prospects to enroll. The first email will be sent automatically."})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 space-y-4 pb-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"1. Select Campaign"}),e.jsxs(Ks,{value:o,onValueChange:l,children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Choose a campaign..."})}),e.jsx(Ws,{children:B.map(Ce=>e.jsx(Mt,{value:Ce.id,children:Ce.name},Ce.id))})]})]}),o&&(()=>{const Ce=b.toLowerCase(),xe=V.filter(tt=>`${tt.first_name} ${tt.last_name}`.toLowerCase().includes(Ce)||tt.email.toLowerCase().includes(Ce)),we=xe.filter(tt=>!Y.has(`${tt.id}-${o}`)),Le=we.length>0&&we.every(tt=>i.has(tt.id));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-sm font-medium",children:"2. Select Prospects"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[i.size," selected"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:b,onChange:tt=>_(tt.target.value),className:"pl-9 h-9"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-9 whitespace-nowrap",onClick:()=>{if(Le){const tt=new Set(i);we.forEach(Te=>tt.delete(Te.id)),c(tt)}else{const tt=new Set(i);we.forEach(Te=>tt.add(Te.id)),c(tt)}},children:[e.jsx(sL,{className:"h-3.5 w-3.5 mr-1"}),Le?"Deselect All":`Select All (${we.length})`]})]}),e.jsx("div",{className:"border rounded-lg max-h-60 overflow-y-auto divide-y",children:xe.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:b?"No prospects match your search":"No prospects found for this brokerage"}):xe.map(tt=>{const Te=Y.has(`${tt.id}-${o}`);return e.jsxs("label",{className:`flex items-center gap-3 p-2.5 hover:bg-muted/50 cursor-pointer ${Te?"opacity-40":""}`,children:[e.jsx(Oo,{checked:i.has(tt.id),disabled:Te,onCheckedChange:pt=>{const fe=new Set(i);pt?fe.add(tt.id):fe.delete(tt.id),c(fe)}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[tt.first_name," ",tt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:tt.email})]}),Te&&e.jsx(st,{variant:"outline",className:"text-[10px] shrink-0",children:"Already assigned"})]},tt.id)})}),xe.length>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Showing ",xe.length," of ",V.length," prospects",we.length0&&e.jsx(Ee,{className:"bg-primary/5 border-primary/20",children:e.jsxs(Oe,{className:"pt-3 pb-2 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-primary",children:["✅ Ready to assign ",i.size," prospect",i.size>1?"s":""]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["• Campaign: ",e.jsx("strong",{children:(Ie=B.find(Ce=>Ce.id===o))==null?void 0:Ie.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"• First email sends immediately · follow-ups every 7 days"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"• You can pause or cancel any assignment at any time"})]})})]}),e.jsxs(qn,{className:"px-6 py-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>Q.mutate(),disabled:Q.isPending||!o||i.size===0,children:[e.jsx(Bn,{className:"h-4 w-4 mr-1"}),Q.isPending?"Assigning...":`Assign & Start (${i.size})`]})]})]})}),f&&(()=>{const Ce=I(f);return Ce?e.jsx(Klt,{email:Ce,mergeValues:L,selectedSubjectIndex:M[Ce.id],onClose:()=>g(null)}):null})()]})}function Xlt({brokerageId:t}){const s=Qt(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState(!1),c=k.useRef(!1),{data:u,isLoading:p}=mt({queryKey:["recruit-stages-editor",t],queryFn:async()=>{const{data:w,error:N}=await H.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(N)throw N;return w},enabled:!!t});k.useEffect(()=>{if(u){if(c.current){c.current=!1;return}n(u.map(w=>({id:w.id,name:w.name,color:w.color,sort_order:w.sort_order}))),o([]),i(!1)}},[u]);const f=Lt({mutationFn:async()=>{for(const S of a){const{error:M}=await H.from("recruit_pipeline_stages").delete().eq("id",S);if(M)throw M}const w=r.filter(S=>S.id&&!S.isNew),N=r.filter(S=>!S.id||S.isNew);for(const S of w){const{error:M}=await H.from("recruit_pipeline_stages").update({name:S.name,color:S.color,sort_order:S.sort_order}).eq("id",S.id);if(M)throw M}if(N.length>0){const{error:S}=await H.from("recruit_pipeline_stages").insert(N.map(M=>({brokerage_id:t,name:M.name,color:M.color,sort_order:M.sort_order})));if(S)throw S}},onSuccess:()=>{o([]),s.invalidateQueries({queryKey:["recruit-stages-editor",t]}),s.invalidateQueries({queryKey:["recruit-stages",t]}),me.success("Pipeline stages saved!"),i(!1)},onError:w=>me.error(w.message)}),g=(w,N,S)=>{n(M=>M.map((L,I)=>I===w?{...L,[N]:S}:L)),i(!0)},b=()=>{const w=r.length>0?Math.max(...r.map(N=>N.sort_order)):0;n(N=>[...N,{name:"",color:"#6366f1",sort_order:w+1,isNew:!0}]),i(!0)},_=w=>{const N=r[w];N.id&&!N.isNew&&o(S=>[...S,N.id]),n(S=>S.filter((M,L)=>L!==w)),i(!0)},j=(w,N)=>{const S=w+N;if(S<0||S>=r.length)return;const M=[...r];[M[w],M[S]]=[M[S],M[w]],M.forEach((L,I)=>L.sort_order=I+1),n(M),i(!0)};return p?e.jsx("div",{className:"text-sm text-muted-foreground py-8 text-center",children:"Loading stages…"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Customize the recruiting pipeline stages for this brokerage. Changes will apply to the Kanban board and all prospect tracking."})]}),e.jsx("div",{className:"space-y-2",children:r.map((w,N)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>j(N,-1),disabled:N===0,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▲"}),e.jsx("button",{type:"button",onClick:()=>j(N,1),disabled:N===r.length-1,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▼"})]}),e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground/50 shrink-0"}),e.jsx("input",{type:"color",value:w.color,onChange:S=>g(N,"color",S.target.value),className:"h-8 w-8 rounded cursor-pointer border-0 p-0 shrink-0"}),e.jsx(ze,{value:w.name,onChange:S=>g(N,"name",S.target.value),placeholder:"Stage name…",className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground w-6 text-center shrink-0",children:N+1}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(N),className:"text-destructive hover:text-destructive shrink-0 h-8 w-8",children:e.jsx(Nr,{className:"h-4 w-4"})})]},w.id||`new-${N}`))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:b,className:"gap-1",children:[e.jsx($s,{className:"h-4 w-4"})," Add Stage"]}),l&&e.jsxs(K,{size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-1",children:[e.jsx(qc,{className:"h-4 w-4"})," Save Changes"]})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No stages configured. Add stages to build your recruiting pipeline."})]})}function G4s(){var i;const[t,s]=k.useState(""),[r,n]=k.useState("board"),{data:a=[],isLoading:o}=mt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:c,error:u}=await H.from("brokerages").select("id, name").order("name");if(u)throw u;return c}}),l=t||((i=a[0])==null?void 0:i.id)||"";return o?e.jsx(Ms,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsx(Ms,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[a.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage:"}),e.jsxs(Ks,{value:l,onValueChange:s,children:[e.jsxs(Hs,{className:"w-[280px]",children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),e.jsx(Ys,{placeholder:"Select brokerage"})]}),e.jsx(Ws,{children:a.map(c=>e.jsx(Mt,{value:c.id,children:c.name},c.id))})]})]}),l?e.jsxs(ba,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(pa,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ns,{value:"pipeline",children:"Pipeline"}),e.jsxs(ns,{value:"contacts",children:[e.jsx(pr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ns,{value:"video-outreach",children:[e.jsx(An,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ns,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"interest",children:"Interest Form"}),e.jsx(ns,{value:"landing-page",children:"Landing Page"}),e.jsx(ns,{value:"goals",children:"Goals"}),e.jsx(ns,{value:"metrics",children:"Metrics"}),e.jsx(ns,{value:"templates",children:"Email Templates"}),e.jsxs(ns,{value:"campaigns",children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ns,{value:"drip-assignments",children:[e.jsx(Bn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ns,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ns,{value:"email-settings",children:[e.jsx(Xo,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ns,{value:"pipeline-stages",children:[e.jsx(W_,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]})]}),e.jsxs(bs,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(Cp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx(UM,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(Flt,{brokerageId:l}):e.jsx(sde,{brokerageId:l})]}),e.jsx(bs,{value:"contacts",children:e.jsx(sde,{brokerageId:l})}),e.jsx(bs,{value:"video-outreach",children:e.jsx(Wlt,{brokerageId:l})}),e.jsx(bs,{value:"follow-ups",children:e.jsx(Vlt,{brokerageId:l})}),e.jsx(bs,{value:"referrals",children:e.jsx(qlt,{brokerageId:l})}),e.jsx(bs,{value:"interest",children:e.jsx(Ult,{brokerageId:l})}),e.jsx(bs,{value:"landing-page",children:e.jsx(Hlt,{brokerageId:l})}),e.jsx(bs,{value:"goals",children:e.jsx(Glt,{brokerageId:l})}),e.jsx(bs,{value:"metrics",children:e.jsx(zlt,{brokerageId:l})}),e.jsx(bs,{value:"templates",children:e.jsx(Blt,{brokerageId:l})}),e.jsx(bs,{value:"campaigns",children:e.jsx(Zlt,{brokerageId:l})}),e.jsx(bs,{value:"drip-assignments",children:e.jsx(Ylt,{brokerageId:l})}),e.jsx(bs,{value:"activity",children:e.jsx($lt,{brokerageId:l})}),e.jsx(bs,{value:"email-settings",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Email Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Configure sender identity, merge fields, and brokerage location for recruiting emails."}),e.jsx(mCe,{brokerageId:l})]})}),e.jsx(bs,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(Xlt,{brokerageId:l})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ka,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function K4s(){var l;const{managedBrokerages:t,selectedBrokerageId:s,setSelectedBrokerageId:r}=Ds(),[n,a]=k.useState("board"),o=s||((l=t[0])==null?void 0:l.id)||"";return t.length===0?e.jsx(Ms,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ka,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages assigned to you. Contact an admin for access."})]})}):e.jsx(Ms,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[t.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage:"}),e.jsxs(Ks,{value:o,onValueChange:r,children:[e.jsxs(Hs,{className:"w-[280px]",children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),e.jsx(Ys,{placeholder:"Select brokerage"})]}),e.jsx(Ws,{children:t.map(i=>e.jsx(Mt,{value:i.id,children:i.name},i.id))})]})]}),o?e.jsxs(ba,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(pa,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ns,{value:"pipeline",children:"Pipeline"}),e.jsxs(ns,{value:"contacts",children:[e.jsx(pr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ns,{value:"video-outreach",children:[e.jsx(An,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ns,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"interest",children:"Interest Form"}),e.jsx(ns,{value:"landing-page",children:"Landing Page"}),e.jsx(ns,{value:"goals",children:"Goals"}),e.jsx(ns,{value:"metrics",children:"Metrics"}),e.jsx(ns,{value:"templates",children:"Email Templates"}),e.jsxs(ns,{value:"campaigns",children:[e.jsx(cr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ns,{value:"drip-assignments",children:[e.jsx(Bn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ns,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ns,{value:"email-settings",children:[e.jsx(Xo,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ns,{value:"pipeline-stages",children:[e.jsx(W_,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]})]}),e.jsxs(bs,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:n==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("board"),children:[e.jsx(Cp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:n==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("table"),children:[e.jsx(UM,{className:"h-3.5 w-3.5"})," Table"]})]})}),n==="board"?e.jsx(Flt,{brokerageId:o}):e.jsx(sde,{brokerageId:o})]}),e.jsx(bs,{value:"contacts",children:e.jsx(sde,{brokerageId:o})}),e.jsx(bs,{value:"video-outreach",children:e.jsx(Wlt,{brokerageId:o})}),e.jsx(bs,{value:"follow-ups",children:e.jsx(Vlt,{brokerageId:o})}),e.jsx(bs,{value:"referrals",children:e.jsx(qlt,{brokerageId:o})}),e.jsx(bs,{value:"interest",children:e.jsx(Ult,{brokerageId:o})}),e.jsx(bs,{value:"landing-page",children:e.jsx(Hlt,{brokerageId:o})}),e.jsx(bs,{value:"goals",children:e.jsx(Glt,{brokerageId:o})}),e.jsx(bs,{value:"metrics",children:e.jsx(zlt,{brokerageId:o})}),e.jsx(bs,{value:"templates",children:e.jsx(Blt,{brokerageId:o})}),e.jsx(bs,{value:"campaigns",children:e.jsx(Zlt,{brokerageId:o})}),e.jsx(bs,{value:"drip-assignments",children:e.jsx(Ylt,{brokerageId:o})}),e.jsx(bs,{value:"activity",children:e.jsx($lt,{brokerageId:o})}),e.jsx(bs,{value:"email-settings",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Email Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Configure sender identity, merge fields, and brokerage location for recruiting emails."}),e.jsx(mCe,{brokerageId:o})]})}),e.jsx(bs,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(Xlt,{brokerageId:o})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ka,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found."})]})]})})}function Z4s(){const[t,s]=k.useState(""),{data:r,isLoading:n}=mt({queryKey:["admin-brokerage-content-activity"],queryFn:async()=>{const{data:i}=await H.from("brokerages").select("id, name");if(!i)return[];const{data:c}=await H.from("brokerage_content").select("id, brokerage_id, content_type, created_at"),{data:u}=await H.from("brokerage_content_categories").select("id, brokerage_id"),p=c||[],f=u||[],g=i.map(b=>{const _=p.filter(N=>N.brokerage_id===b.id),j=f.filter(N=>N.brokerage_id===b.id),w=_.length>0?_.reduce((N,S)=>S.created_at>N?S.created_at:N,_[0].created_at):null;return{brokerage_id:b.id,brokerage_name:b.name,total_items:_.length,videos:_.filter(N=>N.content_type==="video").length,pdfs:_.filter(N=>N.content_type==="pdf").length,links:_.filter(N=>N.content_type==="link"||N.content_type==="canva_link").length,events:_.filter(N=>N.content_type==="event").length,graphics:_.filter(N=>N.content_type==="graphic").length,latest_item_date:w,categories:j.length}});return g.sort((b,_)=>_.total_items-b.total_items),g}}),a=(r||[]).filter(i=>i.brokerage_name.toLowerCase().includes(t.toLowerCase())),o=a.reduce((i,c)=>i+c.total_items,0),l=a.filter(i=>i.total_items>0).length;return e.jsx(Ms,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oh,{title:"Brokerage Content Activity",description:"See which brokerages are creating custom content for their agents"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with content uploaded"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"across all brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"registered"})]})]})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Brokerage"}),e.jsx(St,{className:"text-center",children:"Total"}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(An,{className:"h-3 w-3"})," Videos"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(dl,{className:"h-3 w-3"})," Links"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Od,{className:"h-3 w-3"})," Events"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(gl,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(St,{className:"text-center",children:"Categories"}),e.jsx(St,{children:"Last Upload"})]})}),e.jsx(zn,{children:n?e.jsx(Ss,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(Ss,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:i.brokerage_name})]})}),e.jsx(dt,{className:"text-center",children:i.total_items>0?e.jsx(st,{variant:"secondary",className:"font-bold",children:i.total_items}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:i.videos||"–"}),e.jsx(dt,{className:"text-center",children:i.pdfs||"–"}),e.jsx(dt,{className:"text-center",children:i.links||"–"}),e.jsx(dt,{className:"text-center",children:i.events||"–"}),e.jsx(dt,{className:"text-center",children:i.graphics||"–"}),e.jsx(dt,{className:"text-center",children:i.categories||"–"}),e.jsx(dt,{children:i.latest_item_date?e.jsx("span",{className:"text-sm text-muted-foreground",children:ms(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function Y4s(t,s){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const r=document.implementation.createHTMLDocument(),n=r.createElement("base"),a=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(a),s&&(n.href=s),a.href=t,a.href}const X4s=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function aw(t){const s=[];for(let r=0,n=t.length;rXp||t.height>Xp)&&(t.width>Xp&&t.height>Xp?t.width>t.height?(t.height*=Xp/t.width,t.width=Xp):(t.width*=Xp/t.height,t.height=Xp):t.width>Xp?(t.height*=Xp/t.width,t.width=Xp):(t.width*=Xp/t.height,t.height=Xp))}function nde(t){return new Promise((s,r)=>{const n=new Image;n.onload=()=>{n.decode().then(()=>{requestAnimationFrame(()=>s(n))})},n.onerror=r,n.crossOrigin="anonymous",n.decoding="async",n.src=t})}async function sSs(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function rSs(t,s,r){const n="http://www.w3.org/2000/svg",a=document.createElementNS(n,"svg"),o=document.createElementNS(n,"foreignObject");return a.setAttribute("width",`${s}`),a.setAttribute("height",`${r}`),a.setAttribute("viewBox",`0 0 ${s} ${r}`),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("externalResourcesRequired","true"),a.appendChild(o),o.appendChild(t),sSs(a)}const Ap=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||Ap(r,s)};function nSs(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function aSs(t,s){return Qlt(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function iSs(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?nSs(r):aSs(r,n);return document.createTextNode(`${a}{${o}}`)}function Aze(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=X4s();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(iSs(l,r,a,n)),s.appendChild(i)}function oSs(t,s,r){Aze(t,s,":before",r),Aze(t,s,":after",r)}const Eze="application/font-woff",Pze="image/jpeg",lSs={woff:Eze,woff2:Eze,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Pze,jpeg:Pze,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function cSs(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function pCe(t){const s=cSs(t).toLowerCase();return lSs[s]||""}function dSs(t){return t.split(/,/)[1]}function hwe(t){return t.search(/^(data:)/)!==-1}function uSs(t,s){return`data:${s};base64,${t}`}async function ect(t,s,r){const n=await fetch(t,s);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const a=await n.blob();return new Promise((o,l)=>{const i=new FileReader;i.onerror=l,i.onloadend=()=>{try{o(r({res:n,result:i.result}))}catch(c){l(c)}},i.readAsDataURL(a)})}const Aye={};function hSs(t,s,r){let n=t.replace(/\?.*/,"");return r&&(n=t),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),s?`[${s}]${n}`:n}async function fCe(t,s,r){const n=hSs(t,s,r.includeQueryParams);if(Aye[n]!=null)return Aye[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await ect(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),dSs(i)));a=uSs(o,s)}catch(o){a=r.imagePlaceholder||"";let l=`Failed to fetch resource: ${t}`;o&&(l=typeof o=="string"?o:o.message),l&&console.warn(l)}return Aye[n]=a,a}async function mSs(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):nde(s)}async function pSs(t,s){if(t.currentSrc){const o=document.createElement("canvas"),l=o.getContext("2d");o.width=t.clientWidth,o.height=t.clientHeight,l==null||l.drawImage(t,0,0,o.width,o.height);const i=o.toDataURL();return nde(i)}const r=t.poster,n=pCe(r),a=await fCe(r,n,s);return nde(a)}async function fSs(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await bme(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function xSs(t,s){return Ap(t,HTMLCanvasElement)?mSs(t):Ap(t,HTMLVideoElement)?pSs(t,s):Ap(t,HTMLIFrameElement)?fSs(t,s):t.cloneNode(tct(t))}const gSs=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",tct=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function ySs(t,s,r){var n,a;if(tct(s))return s;let o=[];return gSs(t)&&t.assignedNodes?o=aw(t.assignedNodes()):Ap(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=aw(t.contentDocument.body.childNodes):o=aw(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||Ap(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>bme(i,r)).then(c=>{c&&s.appendChild(c)}),Promise.resolve()),s}function vSs(t,s,r){const n=s.style;if(!n)return;const a=window.getComputedStyle(t);a.cssText?(n.cssText=a.cssText,n.transformOrigin=a.transformOrigin):Qlt(r).forEach(o=>{let l=a.getPropertyValue(o);o==="font-size"&&l.endsWith("px")&&(l=`${Math.floor(parseFloat(l.substring(0,l.length-2)))-.1}px`),Ap(t,HTMLIFrameElement)&&o==="display"&&l==="inline"&&(l="block"),o==="d"&&s.getAttribute("d")&&(l=`path(${s.getAttribute("d")})`),n.setProperty(o,l,a.getPropertyPriority(o))})}function bSs(t,s){Ap(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),Ap(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function _Ss(t,s){if(Ap(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function wSs(t,s,r){return Ap(s,Element)&&(vSs(t,s,r),oSs(t,s,r),bSs(t,s),_Ss(t,s)),s}async function jSs(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oxSs(n,s)).then(n=>ySs(t,n,s)).then(n=>wSs(t,n,s)).then(n=>jSs(n,s))}const sct=/url\((['"]?)([^'"]+?)\1\)/g,NSs=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,kSs=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function SSs(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function CSs(t){const s=[];return t.replace(sct,(r,n,a)=>(s.push(a),r)),s.filter(r=>!hwe(r))}async function MSs(t,s,r,n,a){try{const o=r?Y4s(s,r):s,l=pCe(s);let i;return a||(i=await fCe(o,l,n)),t.replace(SSs(s),`$1${i}$3`)}catch{}return t}function TSs(t,{preferredFontFormat:s}){return s?t.replace(kSs,r=>{for(;;){const[n,,a]=NSs.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function rct(t){return t.search(sct)!==-1}async function nct(t,s,r){if(!rct(t))return t;const n=TSs(t,r);return CSs(n).reduce((o,l)=>o.then(i=>MSs(i,l,s,r)),Promise.resolve(n))}async function O5(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await nct(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function ASs(t,s){await O5("background",t,s)||await O5("background-image",t,s),await O5("mask",t,s)||await O5("-webkit-mask",t,s)||await O5("mask-image",t,s)||await O5("-webkit-mask-image",t,s)}async function ESs(t,s){const r=Ap(t,HTMLImageElement);if(!(r&&!hwe(t.src))&&!(Ap(t,SVGImageElement)&&!hwe(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await fCe(n,pCe(n),s);await new Promise((o,l)=>{t.onload=o,t.onerror=s.onImageErrorHandler?(...c)=>{try{o(s.onImageErrorHandler(...c))}catch(u){l(u)}}:l;const i=t;i.decode&&(i.decode=o),i.loading==="lazy"&&(i.loading="eager"),r?(t.srcset="",t.src=a):t.href.baseVal=a})}async function PSs(t,s){const n=aw(t.childNodes).map(a=>act(a,s));await Promise.all(n).then(()=>t)}async function act(t,s){Ap(t,Element)&&(await ASs(t,s),await ESs(t,s),await PSs(t,s))}function ISs(t,s){const{style:r}=t;s.backgroundColor&&(r.backgroundColor=s.backgroundColor),s.width&&(r.width=`${s.width}px`),s.height&&(r.height=`${s.height}px`);const n=s.style;return n!=null&&Object.keys(n).forEach(a=>{r[a]=n[a]}),t}const Ize={};async function Lze(t){let s=Ize[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},Ize[t]=s,s}async function Dze(t,s){let r=t.cssText;const n=/url\(["']?([^"')]+)["']?\)/g,o=(r.match(/url\([^)]+\)/g)||[]).map(async l=>{let i=l.replace(n,"$1");return i.startsWith("https://")||(i=new URL(i,t.url).href),ect(i,s.fetchRequestInit,({result:c})=>(r=r.replace(l,`url(${c})`),[l,c]))});return Promise.all(o).then(()=>r)}function Oze(t){if(t==null)return[];const s=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=t.replace(r,"");const a=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=a.exec(n);if(c===null)break;s.push(c[0])}n=n.replace(a,"");const o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",i=new RegExp(l,"gi");for(;;){let c=o.exec(n);if(c===null){if(c=i.exec(n),c===null)break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;s.push(c[0])}return s}async function LSs(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{aw(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const c=o.href,u=Lze(c).then(p=>Dze(p,s)).then(p=>Oze(p).forEach(f=>{try{a.insertRule(f,f.startsWith("@import")?i+=1:a.cssRules.length)}catch(g){console.error("Error inserting rule from remote css",{rule:f,error:g})}})).catch(p=>{console.error("Error loading remote css",p.toString())});n.push(u)}})}catch(o){const l=t.find(i=>i.href==null)||document.styleSheets[0];a.href!=null&&n.push(Lze(a.href).then(i=>Dze(i,s)).then(i=>Oze(i).forEach(c=>{l.insertRule(c,l.cssRules.length)})).catch(i=>{console.error("Error loading remote stylesheet",i)})),console.error("Error inlining remote css file",o)}}),Promise.all(n).then(()=>(t.forEach(a=>{if("cssRules"in a)try{aw(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function DSs(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>rct(s.style.getPropertyValue("src")))}async function OSs(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=aw(t.ownerDocument.styleSheets),n=await LSs(r,s);return DSs(n)}function ict(t){return t.trim().replace(/["']/g,"")}function RSs(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(ict(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function FSs(t,s){const r=await OSs(t,s),n=RSs(t);return(await Promise.all(r.filter(o=>n.has(ict(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return nct(o.cssText,l,s)}))).join(` `)}async function zSs(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await FSs(t,s);if(r){const n=document.createElement("style"),a=document.createTextNode(r);n.appendChild(a),t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}}async function BSs(t,s={}){const{width:r,height:n}=Jlt(t,s),a=await bme(t,s,!0);return await zSs(a,s),await act(a,s),ISs(a,s),await rSs(a,r,n)}async function $Ss(t,s={}){const{width:r,height:n}=Jlt(t,s),a=await BSs(t,s),o=await nde(a),l=document.createElement("canvas"),i=l.getContext("2d"),c=s.pixelRatio||eSs(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*c,l.height=p*c,s.skipAutoScale||tSs(l),l.style.width=`${u}`,l.style.height=`${p}`,s.backgroundColor&&(i.fillStyle=s.backgroundColor,i.fillRect(0,0,l.width,l.height)),i.drawImage(o,0,0,l.width,l.height),l}async function qSs(t,s={}){return(await $Ss(t,s)).toDataURL()}const LA=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),_me={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},r9={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},USs=({branding:t,dim:s})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{marginTop:s.w*.03,borderTop:"2px solid rgba(201,168,76,0.4)",paddingTop:s.w*.025,display:"flex",alignItems:"center",gap:s.w*.025},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.12,height:s.w*.12,borderRadius:"50%",objectFit:"cover",border:"3px solid rgba(201,168,76,0.7)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.038,fontWeight:700,letterSpacing:"0.03em"},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.026,opacity:.8,marginTop:s.w*.005},children:t.brokerage})]})]}),oct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(f=t.photos)==null?void 0:f[a],u=_me[s],p=[t.bedrooms?`${t.bedrooms} Bed`:null,t.bathrooms?`${t.bathrooms} Bath`:null,t.sqft?`${t.sqft.toLocaleString()} Sq Ft`:null].filter(Boolean).join(" • ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#FFFFFF"},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(180deg, rgba(10,10,30,0.3) 0%, rgba(10,10,30,0.85) 100%)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",padding:l.w*.06},children:[e.jsx("div",{children:e.jsx("div",{style:{display:"inline-block",background:"linear-gradient(135deg, #C9A84C, #E8D48B)",color:"#1A1A2E",padding:`${l.w*.012}px ${l.w*.035}px`,fontSize:l.w*.032,fontWeight:700,letterSpacing:"0.25em",textTransform:"uppercase"},children:u})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:l.w*.07,fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,textShadow:"0 2px 12px rgba(0,0,0,0.5)"},children:LA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",LA(t.soldPrice)]}),e.jsx("div",{style:{fontSize:l.w*.028,opacity:.9,marginBottom:l.w*.008},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.7,marginBottom:l.w*.02},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"flex",gap:l.w*.015,fontSize:l.w*.022,letterSpacing:"0.05em",borderTop:"1px solid rgba(201,168,76,0.4)",paddingTop:l.w*.02},children:e.jsx("span",{children:p})}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.02,background:"rgba(201,168,76,0.15)",border:"1px solid rgba(201,168,76,0.4)",padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.024,letterSpacing:"0.1em",display:"inline-block"},children:"SAT & SUN • 1–4 PM"}),e.jsx(USs,{branding:n,dim:l})]})]})]})});oct.displayName="LuxuryDarkTemplate";const VSs=({branding:t,dim:s,accentColor:r})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{borderTop:"2px solid #E5E7EB",paddingTop:s.w*.025,display:"flex",alignItems:"center",justifyContent:"center",gap:s.w*.025},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.14,height:s.w*.14,borderRadius:"50%",objectFit:"cover",border:`3px solid ${r}`,flexShrink:0}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.042,fontWeight:800,color:"#1A1A1A"},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.028,color:"#6B7280",marginTop:s.w*.005},children:t.brokerage})]})]}),lct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var b;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(b=t.photos)==null?void 0:b[a],u=_me[s],p=r==="instagram-story",f=r==="facebook-post",g=s==="just-sold"?"#7C3AED":s==="open-house"?"#2563EB":s==="price-drop"?"#DC2626":"#059669";return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Helvetica Neue', Arial, sans-serif",color:"#1A1A1A",background:"#FFFFFF",display:"flex",flexDirection:f?"row":"column"},children:[e.jsxs("div",{style:{width:f?"55%":"100%",height:f?"100%":p?"50%":"52%",position:"relative",overflow:"hidden",flexShrink:0},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",top:l.w*.04,left:0,background:g,color:"#FFFFFF",padding:`${l.w*.012}px ${l.w*.04}px`,fontSize:l.w*.026,fontWeight:800,letterSpacing:"0.15em"},children:u})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05},children:[e.jsx("div",{style:{fontSize:l.w*(f?.055:.065),fontWeight:800,lineHeight:1.1,color:g,marginBottom:l.w*.012},children:LA(t.price)}),e.jsx("div",{style:{fontSize:l.w*.026,fontWeight:600,marginBottom:l.w*.006},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.02,color:"#6B7280",marginBottom:l.w*.02},children:[t.city,", ",t.state," ",t.zip]}),e.jsxs("div",{style:{display:"flex",gap:l.w*.03,marginBottom:l.w*.02},children:[t.bedrooms>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.bedrooms}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Beds"})]}),t.bathrooms>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.bathrooms}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Baths"})]}),t.sqft>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.sqft.toLocaleString()}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Sq Ft"})]})]}),s==="open-house"&&e.jsx("div",{style:{background:`${g}10`,border:`2px solid ${g}`,borderRadius:l.w*.01,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,color:g,display:"inline-block",marginBottom:l.w*.015},children:"SAT & SUN • 1–4 PM"}),e.jsx(VSs,{branding:n,dim:l,accentColor:g})]})]})});lct.displayName="ModernCleanTemplate";const HSs=({branding:t,dim:s})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{marginTop:s.w*.025,display:"flex",alignItems:"center",gap:s.w*.02},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.12,height:s.w*.12,borderRadius:"50%",objectFit:"cover",border:"3px solid rgba(255,255,255,0.5)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.035,fontWeight:900},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.024,opacity:.8,marginTop:s.w*.004,fontFamily:"'Helvetica Neue', sans-serif",fontWeight:400},children:t.brokerage})]})]}),cct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var g;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(g=t.photos)==null?void 0:g[a],u=_me[s],p={"just-listed":"linear-gradient(135deg, #059669, #10B981)","just-sold":"linear-gradient(135deg, #7C3AED, #A855F7)","open-house":"linear-gradient(135deg, #2563EB, #3B82F6)","price-drop":"linear-gradient(135deg, #DC2626, #F43F5E)"},f=[t.bedrooms?`${t.bedrooms} BD`:null,t.bathrooms?`${t.bathrooms} BA`:null,t.sqft?`${t.sqft.toLocaleString()} SF`:null].filter(Boolean).join(" | ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Arial Black', 'Helvetica Neue', sans-serif",color:"#FFFFFF"},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",padding:l.w*.05},children:[e.jsx("div",{style:{background:p[s],padding:`${l.w*.025}px ${l.w*.04}px`,fontSize:l.w*.055,fontWeight:900,letterSpacing:"0.08em",alignSelf:"flex-start",borderRadius:l.w*.01,boxShadow:"0 8px 32px rgba(0,0,0,0.3)",transform:"rotate(-2deg)",marginBottom:l.w*.03},children:u}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{background:"rgba(0,0,0,0.65)",backdropFilter:"blur(10px)",borderRadius:l.w*.015,padding:l.w*.04},children:[e.jsx("div",{style:{fontSize:l.w*.08,fontWeight:900,lineHeight:1,marginBottom:l.w*.01},children:LA(t.price)}),e.jsx("div",{style:{fontSize:l.w*.028,fontWeight:700,marginBottom:l.w*.005},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.8,marginBottom:l.w*.015},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"inline-block",background:"rgba(255,255,255,0.15)",borderRadius:l.w*.008,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,letterSpacing:"0.08em"},children:f}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.015,background:p["open-house"],borderRadius:l.w*.008,padding:`${l.w*.012}px ${l.w*.025}px`,fontSize:l.w*.024,fontWeight:800,display:"inline-block",marginLeft:l.w*.01},children:"SAT & SUN 1–4 PM"}),e.jsx(HSs,{branding:n,dim:l})]})]})]})});cct.displayName="BoldColorfulTemplate";const WSs=({branding:t,dim:s})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{marginTop:"auto",display:"flex",alignItems:"center",gap:s.w*.02},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.11,height:s.w*.11,borderRadius:"50%",objectFit:"cover",border:"3px solid #8B7355"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.032,fontWeight:700,color:"#1A1A1A"},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.022,color:"#8B7355",marginTop:s.w*.004},children:t.brokerage})]})]}),dct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(f=t.photos)==null?void 0:f[a],u=_me[s],p=r==="instagram-story";return e.jsx("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#1A1A1A",background:"#F5F0EB"},children:e.jsxs("div",{style:{display:"flex",flexDirection:p?"column":"row",height:"100%"},children:[e.jsxs("div",{style:{width:p?"100%":"42%",height:p?"40%":"100%",display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05,order:p?2:1},children:[e.jsx("div",{style:{fontSize:l.w*.016,letterSpacing:"0.3em",textTransform:"uppercase",color:"#8B7355",borderBottom:"2px solid #8B7355",paddingBottom:l.w*.01,marginBottom:l.w*.025,display:"inline-block",alignSelf:"flex-start"},children:u}),e.jsx("div",{style:{fontSize:l.w*(p?.06:.055),fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,fontStyle:"italic"},children:LA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",LA(t.soldPrice)]}),e.jsxs("div",{style:{fontSize:l.w*.022,lineHeight:1.5,marginBottom:l.w*.02},children:[t.address,e.jsx("br",{}),t.city,", ",t.state," ",t.zip]}),e.jsxs("div",{style:{display:"flex",gap:l.w*.02,fontSize:l.w*.016,color:"#6B5D4E",borderTop:"1px solid #D1C7B7",paddingTop:l.w*.015,marginBottom:l.w*.015,flexWrap:"wrap"},children:[t.bedrooms>0&&e.jsxs("span",{children:[t.bedrooms," Bedrooms"]}),t.bedrooms>0&&t.bathrooms>0&&e.jsx("span",{children:"·"}),t.bathrooms>0&&e.jsxs("span",{children:[t.bathrooms," Bathrooms"]}),t.sqft>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[t.sqft.toLocaleString()," Sq Ft"]})]})]}),s==="open-house"&&e.jsx("div",{style:{fontSize:l.w*.018,fontStyle:"italic",color:"#8B7355",marginBottom:l.w*.01},children:"Open House: Saturday & Sunday, 1–4 PM"}),e.jsx(WSs,{branding:n,dim:l})]}),e.jsxs("div",{style:{width:p?"100%":"58%",height:p?"60%":"100%",position:"relative",overflow:"hidden",order:p?1:2},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:l.w*.02,border:"1px solid rgba(255,255,255,0.4)",pointerEvents:"none"}})]})]})})});dct.displayName="EditorialTemplate";const GSs=[{value:"just-listed",label:"Just Listed",icon:"🏠"},{value:"just-sold",label:"Just Sold",icon:"🎉"},{value:"open-house",label:"Open House",icon:"🚪"},{value:"price-drop",label:"Price Drop",icon:"📉"}],Rze=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(Mu,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(Mu,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(Su,{className:"h-4 w-4"})}],KSs=[{value:"luxury-dark",label:"Luxury Dark",description:"Dark & gold, high-end feel",preview:"🌙"},{value:"modern-clean",label:"Modern Clean",description:"White, bold, contemporary",preview:"✨"},{value:"bold-colorful",label:"Bold & Vibrant",description:"Energetic gradients & punch",preview:"🔥"},{value:"editorial",label:"Editorial",description:"Magazine-style sophistication",preview:"📰"}],Fze=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),zze={"luxury-dark":oct,"modern-clean":lct,"bold-colorful":cct,editorial:dct};function ZSs(){const[t,s]=k.useState(""),[r,n]=k.useState("address"),[a,o]=k.useState(!1),[l,i]=k.useState([]),[c,u]=k.useState(null),[p,f]=k.useState(0),[g,b]=k.useState("just-listed"),[_,j]=k.useState(["instagram-square"]),[w,N]=k.useState("luxury-dark"),[S,M]=k.useState(!1),[L,I]=k.useState(""),[O,q]=k.useState(""),[U,B]=k.useState(""),[V,Y]=k.useState(!1),[Q,ee]=k.useState(!1),[X,ie]=k.useState([]),[re,oe]=k.useState("search"),ce=k.useRef({});k.useEffect(()=>{(async()=>{const{data:{user:xe}}=await H.auth.getUser();if(!xe)return;const{data:we}=await H.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",xe.id).single();if(we){I(we.name||""),B(we.avatar_url||"");const Le=we.brokerages;q((Le==null?void 0:Le.name)||"")}})()},[]);const ge=async()=>{var Ce;if(t.trim()){o(!0),i([]);try{const{data:xe,error:we}=await H.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(we)throw we;if(xe.error)throw new Error(xe.error);i(xe.listings||[]),((Ce=xe.listings)==null?void 0:Ce.length)===0&&me.info("No listings found. Try a different search.")}catch(xe){me.error(xe.message||"Search failed")}finally{o(!1)}}},ye=Ce=>{var xe;u(Ce),f(0),oe("customize"),Ce.soldDate||(xe=Ce.status)!=null&&xe.toLowerCase().includes("sold")?b("just-sold"):b("just-listed")},ue=Ce=>{j(xe=>xe.includes(Ce)?xe.filter(we=>we!==Ce):[...xe,Ce])},pe=k.useCallback(async()=>{if(!(!c||_.length===0)){Y(!0),ie([]),oe("generate");try{await new Promise(xe=>setTimeout(xe,500));const Ce=[];for(const xe of _){const we=`${w}-${xe}`,Le=ce.current[we];if(!Le)continue;const tt=r9[xe],Te=await qSs(Le,{width:tt.width,height:tt.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Ce.push({format:xe,imageUrl:Te})}ie(Ce),me.success(`Generated ${Ce.length} social post${Ce.length>1?"s":""}!`)}catch(Ce){me.error(Ce.message||"Generation failed")}finally{Y(!1)}}},[c,_,w,p,S,L,O,U,g]),_e=async()=>{if(!(!c||_.length===0)){Y(!0),ie([]),oe("generate");try{const Ce={...c,photos:c.photos.length>0?[c.photos[p]]:[]},xe=[];for(const we of _){const{data:Le,error:tt}=await H.functions.invoke("generate-listing-social-post",{body:{listing:Ce,postType:g,format:we,branding:S?{enabled:!0,agentName:L,brokerage:O}:{enabled:!1}}});if(tt)throw tt;if(Le.error)throw new Error(Le.error);xe.push({format:we,imageUrl:Le.imageUrl})}ie(xe),me.success(`Generated ${xe.length} AI post${xe.length>1?"s":""}!`)}catch(Ce){me.error(Ce.message||"AI generation failed")}finally{Y(!1)}}},$e=()=>Q?_e():pe(),Ae=(Ce,xe)=>{var Le;const we=document.createElement("a");we.href=Ce,we.download=`${((Le=c==null?void 0:c.address)==null?void 0:Le.replace(/\s+/g,"-"))||"listing"}-${g}-${xe}.png`,document.body.appendChild(we),we.click(),document.body.removeChild(we)},Ie=c?{listing:c,postType:g,format:"instagram-square",branding:S?{enabled:!0,agentName:L,brokerage:O,agentPhotoUrl:U||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(oh,{title:"Social Post Generator",description:"Search MLS listings and generate stunning social media posts"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsxs("button",{onClick:()=>oe("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${re==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(cn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>c&&oe("customize"),disabled:!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${re==="customize"?"bg-primary text-primary-foreground":c?"bg-muted text-muted-foreground hover:text-foreground":"bg-muted text-muted-foreground/50 cursor-not-allowed"}`,children:[e.jsx(pn,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full ${re==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(gl,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),re==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(iXe,{})]}),e.jsx(gr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(ba,{value:r,onValueChange:Ce=>n(Ce),children:e.jsxs(pa,{children:[e.jsxs(ns,{value:"address",children:[e.jsx(ma,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(ns,{value:"mls",children:[e.jsx(Fm,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:t,onChange:Ce=>s(Ce.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Ce=>Ce.key==="Enter"&&ge()}),e.jsxs(K,{onClick:ge,disabled:a||!t.trim(),children:[a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(cn,{className:"h-4 w-4"})," Search"]})]})]})]}),l.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-muted-foreground",children:[l.length," listing",l.length!==1?"s":""," found"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:l.map((Ce,xe)=>{var we;return e.jsx(Ee,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>ye(Ce),children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-32 h-28 flex-shrink-0 bg-muted rounded-l-lg overflow-hidden",children:(we=Ce.photos)!=null&&we[0]?e.jsx("img",{src:Ce.photos[0],alt:Ce.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(bn,{className:"h-8 w-8 text-muted-foreground/40"})})}),e.jsxs("div",{className:"flex-1 p-3 min-w-0",children:[e.jsx("p",{className:"font-bold text-foreground",children:Fze(Ce.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Ce.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ce.city,", ",Ce.state," ",Ce.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Ce.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Z4,{className:"h-3 w-3"})," ",Ce.bedrooms]}),Ce.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ju,{className:"h-3 w-3"})," ",Ce.bathrooms]}),Ce.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(lS,{className:"h-3 w-3"})," ",Ce.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"outline",className:"text-[10px]",children:Ce.mlsNumber}),e.jsx(st,{variant:"outline",className:"text-[10px]",children:Ce.status})]})]})]})})},Ce.mlsNumber||xe)})})]})]}),re==="customize"&&c&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Oe,{className:"space-y-3",children:[c.photos.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[4/3] rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:c.photos[p],alt:"Listing photo",className:"w-full h-full object-cover"})}),c.photos.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Ce=>Math.max(0,Ce-1)),disabled:p===0,children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p+1," of ",c.photos.length]}),e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Ce=>Math.min(c.photos.length-1,Ce+1)),disabled:p===c.photos.length-1,children:e.jsx(da,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:Fze(c.price)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.city,", ",c.state," ",c.zip]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[c.bedrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:c.bedrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Beds"})]}),c.bathrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:c.bathrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Baths"})]}),c.sqft>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:c.sqft.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Sq Ft"})]})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{oe("search"),u(null)},children:[e.jsx(m1,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Ee,{className:"lg:col-span-2",children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(gr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ic,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:Q?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Q?"Uses AI credits for unique designs":"Instant, no credits used"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Use AI"}),e.jsx(qr,{checked:Q,onCheckedChange:ee}),Q&&e.jsx(qv,{className:"h-4 w-4 text-purple-500"})]})]}),!Q&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ic,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:KSs.map(Ce=>e.jsxs("button",{onClick:()=>N(Ce.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${w===Ce.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Ce.preview}),e.jsx("span",{className:"text-sm font-medium",children:Ce.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Ce.description})]},Ce.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:GSs.map(Ce=>e.jsxs("button",{onClick:()=>b(Ce.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${g===Ce.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Ce.icon})," ",Ce.label]},Ce.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:Rze.map(Ce=>e.jsxs("button",{onClick:()=>ue(Ce.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${_.includes(Ce.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Ce.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Ce.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Ce.dimensions})]})]},Ce.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(qr,{checked:S,onCheckedChange:M})]}),S&&e.jsxs("div",{className:"space-y-3 pl-6 border-l-2 border-primary/20",children:[U&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:U,alt:"Agent",className:"w-12 h-12 rounded-full object-cover border-2 border-primary/30"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Profile photo will appear on the post"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(ze,{value:L,onChange:Ce=>I(Ce.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(ze,{value:O,onChange:Ce=>q(Ce.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!Q&&Ie&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Preview"}),e.jsx("div",{className:"bg-muted/30 rounded-lg p-4 flex justify-center overflow-hidden",children:e.jsx("div",{style:{width:400,height:400*(r9[_[0]||"instagram-square"].height/r9[_[0]||"instagram-square"].width)},children:(()=>{const Ce=zze[w],xe=_[0]||"instagram-square";return e.jsx(Ce,{...Ie,format:xe})})()})})]}),e.jsx(K,{onClick:$e,disabled:_.length===0||V,size:"lg",className:"w-full gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-5 w-5 animate-spin"})," Generating ",_.length," post",_.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[Q?e.jsx(qv,{className:"h-5 w-5"}):e.jsx(pn,{className:"h-5 w-5"}),"Generate ",_.length," Social Post",_.length>1?"s":"",Q&&e.jsx(st,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),re==="generate"&&e.jsxs("div",{className:"space-y-4",children:[V&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(ws,{className:"h-12 w-12 animate-spin text-primary mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:"Generating your social posts..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Q?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),X.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Generated Posts"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>oe("customize"),children:[e.jsx(m1,{className:"h-3.5 w-3.5 mr-1.5"})," Regenerate"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:X.map((Ce,xe)=>{const we=Rze.find(Le=>Le.value===Ce.format);return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Ce.imageUrl,alt:`${Ce.format} social post`,className:"w-full rounded"})}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[we==null?void 0:we.icon,e.jsx("span",{className:"text-sm font-medium",children:we==null?void 0:we.label})]}),e.jsx(st,{variant:"outline",className:"text-[10px]",children:we==null?void 0:we.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>Ae(Ce.imageUrl,Ce.format),children:[e.jsx(yi,{className:"h-3.5 w-3.5"})," Download"]})]})]},xe)})})]})]}),re==="generate"&&!Q&&c&&Ie&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:_.map(Ce=>{const xe=zze[w],we=r9[Ce];return e.jsx("div",{style:{width:we.width,height:we.height},children:e.jsx(xe,{ref:Le=>{ce.current[`${w}-${Ce}`]=Le},...Ie,format:Ce})},`${w}-${Ce}`)})})]})})}function YSs(){return mt({queryKey:["lms-courses-admin"],queryFn:async()=>{const{data:t,error:s}=await H.from("lms_courses").select("*, modules:lms_modules(count), access:lms_course_access(*)").order("sort_order");if(s)throw s;return t}})}function XSs(t){return mt({queryKey:["lms-course-admin",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*)), access:lms_course_access(*)").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function QSs(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("lms_courses").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function uct(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("lms_courses").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-courses-admin"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function JSs(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("lms_courses").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function eCs(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("lms_modules").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function tCs(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("lms_modules").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function sCs(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("lms_modules").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function rCs(){const t=Qt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("lms_module_resources").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function nCs(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("lms_module_resources").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function aCs(){const t=Qt();return Lt({mutationFn:async({courseId:s,accessRules:r})=>{const{error:n}=await H.from("lms_course_access").delete().eq("course_id",s);if(n)throw n;if(r.length>0){const a=r.map(l=>({...l,course_id:s})),{error:o}=await H.from("lms_course_access").insert(a);if(o)throw o}},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]})}})}function iCs(){return mt({queryKey:["lms-courses-agent"],queryFn:async()=>{const{data:t,error:s}=await H.from("lms_courses").select("*, modules:lms_modules(id)").eq("is_published",!0).order("sort_order");if(s)throw s;return t}})}function oCs(t){return mt({queryKey:["lms-course-agent",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*))").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function hct(t){return mt({queryKey:["lms-progress",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("lms_progress").select("*").eq("course_id",t);if(r)throw r;return s},enabled:!!t})}function lCs(){const t=Qt();return Lt({mutationFn:async({courseId:s,moduleId:r,userId:n})=>{const{data:a,error:o}=await H.from("lms_progress").upsert({user_id:n,course_id:s,module_id:r,completed:!0,completed_at:new Date().toISOString()},{onConflict:"user_id,module_id"}).select().single();if(o)throw o;return a},onSuccess:()=>t.invalidateQueries({queryKey:["lms-progress"]})})}function cCs(){const{user:t}=Ds(),s=fr(),{data:r,isLoading:n}=YSs(),a=QSs(),o=uct(),l=JSs(),[i,c]=k.useState(!1),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(!0),j=async()=>{if(!(!u.trim()||!t))try{const S=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:b,created_by:t.id});me.success("Course created"),c(!1),p(""),g(""),_(!0),s(`/admin/lms/${S.id}`)}catch{me.error("Failed to create course")}},w=async S=>{try{await o.mutateAsync({id:S.id,is_published:!S.is_published}),me.success(S.is_published?"Course unpublished":"Course published")}catch{me.error("Failed to update course")}},N=async S=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(S),me.success("Course deleted")}catch{me.error("Failed to delete")}};return e.jsxs(Ms,{title:"LevelUp U - Admin",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(Kh,{className:"h-7 w-7 text-primary"}),"LevelUp U — Course Manager"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create and manage training courses for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>s("/admin/lms/stats"),children:[e.jsx(No,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(K,{onClick:()=>c(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"New Course"]})]})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[1,2,3].map(S=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Pt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]})},S))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:r.map(S=>{var O,q;const M=((q=(O=S.modules)==null?void 0:O[0])==null?void 0:q.count)??0,L=S.access||[],I=L.length===0?"No access set":L.some(U=>U.access_type==="all")?"All agents":`${L.length} rule(s)`;return e.jsxs(Ee,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${S.id}`),children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-base truncate",children:S.title}),S.description&&e.jsx(gr,{className:"mt-1 line-clamp-2",children:S.description})]}),e.jsx(st,{variant:S.is_published?"default":"secondary",className:"ml-2 shrink-0",children:S.is_published?"Published":"Draft"})]})}),e.jsxs(Oe,{className:"pt-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sh,{className:"h-3.5 w-3.5"}),M," module",M!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[S.is_sequential?e.jsx(p0,{className:"h-3.5 w-3.5"}):e.jsx(pS,{className:"h-3.5 w-3.5"}),S.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pr,{className:"h-3.5 w-3.5"}),I]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(K,{size:"sm",variant:"ghost",onClick:U=>{U.stopPropagation(),w(S)},children:[S.is_published?e.jsx(kp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Ln,{className:"h-3.5 w-3.5 mr-1"}),S.is_published?"Unpublish":"Publish"]}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:U=>{U.stopPropagation(),N(S.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"})]})]})]},S.id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Sh,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"No courses yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first training course to get started"}),e.jsxs(K,{onClick:()=>c(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create New Course"}),e.jsx(Gr,{children:"Set up a new training course for your agents"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Course Title"}),e.jsx(ze,{value:u,onChange:S=>p(S.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{value:f,onChange:S=>g(S.target.value),placeholder:"What will agents learn?",rows:3})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order"})]}),e.jsx(qr,{checked:b,onCheckedChange:_})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:j,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function dCs(){const{courseId:t}=yo(),s=fr(),{data:r,isLoading:n}=XSs(t),a=uct(),o=eCs(),l=tCs(),i=sCs(),c=rCs(),u=nCs(),p=aCs(),{data:f}=mt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:Ue}=await H.from("brokerages").select("id, name").order("name");return Ue||[]}}),[g,b]=k.useState(null),[_,j]=k.useState(!1),[w,N]=k.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[S,M]=k.useState(null),[L,I]=k.useState({title:"",resource_type:"link",url:""}),[O,q]=k.useState(new Set),[U,B]=k.useState(null),[V,Y]=k.useState(0),[Q,ee]=k.useState(!1),X=k.useRef(null),ie=k.useRef(null),[re,oe]=k.useState(!1),[ce,ge]=k.useState(""),[ye,ue]=k.useState(""),[pe,_e]=k.useState(""),[$e,Ae]=k.useState(!1);if(n)return e.jsx(Ms,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})});if(!r)return e.jsx(Ms,{title:"Course Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/admin/lms"),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Ie=r.modules||[],Ce=r.access||[],xe=Ce.some(Ue=>Ue.access_type==="all"),we=Ce.filter(Ue=>Ue.access_type==="brokerage").map(Ue=>Ue.brokerage_id),Le=(f||[]).filter(Ue=>Ue.name.toLowerCase().includes(ce.toLowerCase())),tt=Ue=>{const Ze=new Set(O);Ze.has(Ue)?Ze.delete(Ue):Ze.add(Ue),q(Ze)},Te=async()=>{if(!U)return null;ee(!0),Y(0);try{const{data:Ue,error:Ze}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:U.name}});if(Ze)throw new Error(Ze.message);const{videoId:Qe,libraryId:We}=Ue,{data:Je,error:it}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Qe,libraryId:We}});if(it)throw new Error(it.message);const Dt=new XMLHttpRequest;return await new Promise((Vt,hs)=>{Dt.upload.onprogress=Ts=>{Ts.lengthComputable&&Y(Math.round(Ts.loaded/Ts.total*100))},Dt.onload=()=>Dt.status>=200&&Dt.status<300?Vt():hs(new Error(`Upload failed: ${Dt.status}`)),Dt.onerror=()=>hs(new Error("Upload failed")),Dt.open("PUT",Je.uploadUrl),Dt.setRequestHeader("AccessKey",Je.apiKey),Dt.send(U)}),`https://iframe.mediadelivery.net/embed/${We}/${Qe}`}catch(Ue){return console.error("Bunny upload error:",Ue),me.error("Video upload failed"),null}finally{ee(!1),Y(0)}},pt=async()=>{if(w.title.trim())try{let Ue=w.video_url.trim()||void 0;if(U){const Ze=await Te();if(!Ze)return;Ue=Ze}await o.mutateAsync({course_id:r.id,title:w.title.trim(),description:w.description.trim()||void 0,video_url:Ue,text_content:w.text_content.trim()||void 0,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):void 0,sort_order:Ie.length}),me.success("Module added"),j(!1),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),B(null)}catch{me.error("Failed to add module")}},fe=async()=>{if(g)try{let Ue=w.video_url.trim()||null;if(U){const Ze=await Te();if(!Ze)return;Ue=Ze}await l.mutateAsync({id:g.id,title:w.title.trim(),description:w.description.trim()||null,video_url:Ue,text_content:w.text_content.trim()||null,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):null}),me.success("Module updated"),b(null),B(null)}catch{me.error("Failed to update")}},qe=async Ue=>{if(confirm("Delete this module?"))try{await i.mutateAsync(Ue),me.success("Module deleted")}catch{me.error("Failed to delete")}},at=async Ue=>{if(L.title.trim())try{await c.mutateAsync({module_id:Ue,title:L.title.trim(),resource_type:L.resource_type,url:L.url.trim()||void 0}),me.success("Resource added"),M(null),I({title:"",resource_type:"link",url:""})}catch{me.error("Failed to add resource")}},et=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),me.success("Access updated: All brokerages / all agents")}catch{me.error("Failed to update access")}},Me=async Ue=>{const Ze=Ce.filter(it=>it.access_type==="brokerage").map(it=>it.brokerage_id),Qe=Ze.includes(Ue);let We;Qe?We=Ze.filter(it=>it!==Ue):We=[...Ze,Ue];const Je=We.map(it=>({access_type:"brokerage",brokerage_id:it}));try{await p.mutateAsync({courseId:r.id,accessRules:Je}),me.success(Qe?"Brokerage removed":"Brokerage added")}catch{me.error("Failed to update access")}},rt=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),me.success("Access cleared")}catch{me.error("Failed")}},He=async(Ue,Ze)=>{const Qe=Ze==="up"?Ue-1:Ue+1;if(!(Qe<0||Qe>=Ie.length))try{await Promise.all([l.mutateAsync({id:Ie[Ue].id,sort_order:Qe}),l.mutateAsync({id:Ie[Qe].id,sort_order:Ue})])}catch{me.error("Failed to reorder")}},ct=async()=>{try{await a.mutateAsync({id:r.id,title:ye,description:pe||null}),me.success("Course updated"),Ae(!1)}catch{me.error("Failed to update")}};return e.jsxs(Ms,{title:r.title,children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin/lms"),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:r.title}),e.jsx(st,{variant:r.is_published?"default":"secondary",children:r.is_published?"Published":"Draft"})]}),r.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:r.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[r.is_sequential?e.jsx(p0,{className:"h-3.5 w-3.5"}):e.jsx(pS,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Ie.length," module",Ie.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{ue(r.title),_e(r.description||""),Ae(!0)},children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"})," Edit"]}),e.jsxs(K,{variant:r.is_published?"secondary":"default",size:"sm",onClick:()=>a.mutateAsync({id:r.id,is_published:!r.is_published}).then(()=>me.success(r.is_published?"Unpublished":"Published")),children:[r.is_published?e.jsx(kp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Ln,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(ba,{defaultValue:"modules",className:"w-full",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"modules",children:"Modules"}),e.jsx(ns,{value:"access",children:"Access & Permissions"}),e.jsx(ns,{value:"settings",children:"Settings"})]}),e.jsxs(bs,{value:"modules",className:"mt-6 space-y-4",children:[Ie.map((Ue,Ze)=>e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>tt(Ue.id),children:[e.jsx("span",{className:"flex items-center gap-1 text-muted-foreground",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),He(Ze,"up")},disabled:Ze===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(ff,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),He(Ze,"down")},disabled:Ze===Ie.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Eo,{className:"h-3.5 w-3.5"})})]})}),e.jsx(st,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Ze+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:Ue.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[Ue.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(An,{className:"h-3 w-3"})," Video"]}),Ue.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Sn,{className:"h-3 w-3"})," Text"]}),Ue.duration_minutes&&e.jsxs("span",{children:[Ue.duration_minutes," min"]}),Ue.resources&&Ue.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(dl,{className:"h-3 w-3"})," ",Ue.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:Qe=>{var We;Qe.stopPropagation(),b(Ue),N({title:Ue.title,description:Ue.description||"",video_url:Ue.video_url||"",text_content:Ue.text_content||"",duration_minutes:((We=Ue.duration_minutes)==null?void 0:We.toString())||""})},children:e.jsx(Ra,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:Qe=>{Qe.stopPropagation(),qe(Ue.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]}),O.has(Ue.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[Ue.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:Ue.description}),Ue.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:Ue.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:Ue.video_url})]}),Ue.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:Ue.text_content}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Resources"}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{M(Ue.id),I({title:"",resource_type:"link",url:""})},children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),Ue.resources&&Ue.resources.length>0?e.jsx("div",{className:"space-y-1",children:Ue.resources.map(Qe=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(st,{variant:"outline",className:"text-[10px]",children:Qe.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:Qe.title}),Qe.url&&e.jsx("a",{href:Qe.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"Open"}),e.jsx(K,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>u.mutateAsync(Qe.id),children:e.jsx(Rr,{className:"h-3 w-3"})})]},Qe.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},Ue.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{j(!0),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(bs,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:It("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",xe?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:et,children:[e.jsx("div",{className:It("h-10 w-10 rounded-full flex items-center justify-center shrink-0",xe?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.jsx(su,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:"All Brokerages / All Agents"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Every agent on the platform can access this course"})]}),e.jsx(qr,{checked:xe,onCheckedChange:et})]}),!xe&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Select Brokerages"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:we.length===0?"No brokerages selected — agents won't see this course":`${we.length} brokerage${we.length!==1?"s":""} selected`})]}),we.length>0&&e.jsx(K,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:rt,children:"Clear all"})]}),e.jsx(ze,{placeholder:"Search brokerages...",value:ce,onChange:Ue=>ge(Ue.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:Le.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):Le.map(Ue=>{const Ze=we.includes(Ue.id);return e.jsxs("div",{className:It("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Ze?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Me(Ue.id),children:[e.jsx("div",{className:It("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Ze?"bg-primary border-primary":"border-muted-foreground/30"),children:Ze&&e.jsx("svg",{className:"h-3 w-3 text-primary-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx(ka,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:Ue.name}),Ze&&e.jsx(st,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},Ue.id)})})]})]})]})}),e.jsxs(bs,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-start gap-6",children:[r.thumbnail_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:r.thumbnail_url,alt:"Course thumbnail",className:"w-48 h-28 object-cover rounded-lg border"}),e.jsx("button",{onClick:()=>a.mutateAsync({id:r.id,thumbnail_url:null}).then(()=>me.success("Thumbnail removed")),className:"absolute -top-2 -right-2 bg-destructive text-destructive-foreground rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"w-48 h-28 rounded-lg border-2 border-dashed border-muted-foreground/25 flex flex-col items-center justify-center text-muted-foreground",children:[e.jsx(o1,{className:"h-8 w-8 mb-1 opacity-50"}),e.jsx("span",{className:"text-xs",children:"No thumbnail"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a thumbnail image for this course. Recommended: 800×450px (16:9)."}),e.jsx("input",{ref:ie,type:"file",accept:"image/*",className:"hidden",onChange:async Ue=>{var Qe;const Ze=(Qe=Ue.target.files)==null?void 0:Qe[0];if(!(!Ze||!r)){oe(!0);try{const We=Ze.name.split(".").pop(),Je=`${r.id}/thumbnail.${We}`,{error:it}=await H.storage.from("lms-thumbnails").upload(Je,Ze,{upsert:!0});if(it)throw it;const{data:Dt}=H.storage.from("lms-thumbnails").getPublicUrl(Je),Vt=`${Dt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:Vt}),me.success("Thumbnail uploaded")}catch{me.error("Failed to upload thumbnail")}finally{oe(!1),ie.current&&(ie.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:re,onClick:()=>{var Ue;return(Ue=ie.current)==null?void 0:Ue.click()},children:[re?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(li,{className:"h-4 w-4 mr-2"}),re?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Course Settings"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order before advancing"})]}),e.jsx(qr,{checked:r.is_sequential,onCheckedChange:Ue=>a.mutateAsync({id:r.id,is_sequential:Ue}).then(()=>me.success("Updated"))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this course visible to agents with access"})]}),e.jsx(qr,{checked:r.is_published,onCheckedChange:Ue=>a.mutateAsync({id:r.id,is_published:Ue}).then(()=>me.success("Updated"))})]})]})]})]})]})]}),e.jsx(fs,{open:_||!!g,onOpenChange:Ue=>{Ue||(j(!1),b(null))},children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:g?"Edit Module":"Add Module"}),e.jsx(Gr,{children:"Configure the module content"})]}),e.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-auto",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:w.title,onChange:Ue=>N(Ze=>({...Ze,title:Ue.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{value:w.description,onChange:Ue=>N(Ze=>({...Ze,description:Ue.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:It("border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors hover:border-primary/50",U?"border-primary bg-primary/5":"border-muted-foreground/25"),onClick:()=>{var Ue;return(Ue=X.current)==null?void 0:Ue.click()},children:[e.jsx("input",{ref:X,type:"file",accept:"video/*",className:"hidden",onChange:Ue=>{var Qe;const Ze=(Qe=Ue.target.files)==null?void 0:Qe[0];Ze&&(B(Ze),N(We=>({...We,video_url:""})))}}),U?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(An,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:U.name}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:Ue=>{Ue.stopPropagation(),B(null)},children:e.jsx(Rr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(li,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),Q&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(ws,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",V,"%"]})]}),e.jsx(Bi,{value:V,className:"h-1.5"})]}),!U&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{children:"or paste a URL"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx(ze,{value:w.video_url,onChange:Ue=>N(Ze=>({...Ze,video_url:Ue.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Text Content"}),e.jsx(Er,{value:w.text_content,onChange:Ue=>N(Ze=>({...Ze,text_content:Ue.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Duration (minutes)"}),e.jsx(ze,{type:"number",value:w.duration_minutes,onChange:Ue=>N(Ze=>({...Ze,duration_minutes:Ue.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{j(!1),b(null),B(null)},children:"Cancel"}),e.jsxs(K,{onClick:g?fe:pt,disabled:!w.title.trim()||Q,children:[Q?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qc,{className:"h-4 w-4 mr-2"}),Q?"Uploading...":g?"Save Changes":"Add Module"]})]})]})}),e.jsx(fs,{open:!!S,onOpenChange:Ue=>{Ue||M(null)},children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Add Resource"}),e.jsx(Gr,{children:"Add a link, document, or other resource to this module"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:L.title,onChange:Ue=>I(Ze=>({...Ze,title:Ue.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Type"}),e.jsxs(Ks,{value:L.resource_type,onValueChange:Ue=>I(Ze=>({...Ze,resource_type:Ue})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"link",children:"Link"}),e.jsx(Mt,{value:"pdf",children:"PDF"}),e.jsx(Mt,{value:"template",children:"Template"}),e.jsx(Mt,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"URL"}),e.jsx(ze,{value:L.url,onChange:Ue=>I(Ze=>({...Ze,url:Ue.target.value})),placeholder:"https://..."})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>M(null),children:"Cancel"}),e.jsx(K,{onClick:()=>S&&at(S),disabled:!L.title.trim(),children:"Add Resource"})]})]})}),e.jsx(fs,{open:$e,onOpenChange:Ae,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Edit Course"}),e.jsx(Gr,{children:"Update the course title and description"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:ye,onChange:Ue=>ue(Ue.target.value)})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{value:pe,onChange:Ue=>_e(Ue.target.value),rows:3})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ae(!1),children:"Cancel"}),e.jsx(K,{onClick:ct,disabled:!ye.trim(),children:"Save"})]})]})})]})}function uCs(){return mt({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await H.rpc("get_lms_stats");if(s)throw s;return t}})}function hCs(){return mt({queryKey:["lms-stats-courses"],queryFn:async()=>{const{data:t,error:s}=await H.rpc("get_lms_course_stats");if(s)throw s;return t||[]}})}function mCs(t){return mt({queryKey:["lms-stats-agents",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.rpc("get_lms_agent_progress",{p_course_id:t});if(r)throw r;return s||[]},enabled:!!t})}function pCs(){const t=fr(),{data:s,isLoading:r}=uCs(),{data:n,isLoading:a}=hCs(),[o,l]=k.useState(null),{data:i,isLoading:c}=mCs(o),[u,p]=k.useState(""),f=n==null?void 0:n.find(_=>_.course_id===o),g=i==null?void 0:i.filter(_=>{var j,w;return!u||((j=_.agent_name)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))||((w=_.email)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))}),b=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:Sh,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:sa,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:pr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:xo,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:ul,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:No,color:"text-rose-500"}];return e.jsx(Ms,{title:"LevelUp U - Stats",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/admin/lms"),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(Kh,{className:"h-7 w-7 text-primary"}),"LevelUp U — Analytics"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:"Track enrollment, progress, and completion across all courses"})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3",children:b.map(_=>e.jsx(Ee,{className:It("transition-all",r&&"animate-pulse"),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(_.icon,{className:It("h-4 w-4",_.color)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:_.label})]}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r?"—":_.value})]})},_.label))}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-5 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(No,{className:"h-5 w-5 text-primary"}),"Course Breakdown"]}),a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-16 bg-muted rounded"})})},_))}):n!=null&&n.length?e.jsx("div",{className:"space-y-2",children:n.map(_=>{const j=o===_.course_id;return e.jsx(Ee,{className:It("cursor-pointer transition-all hover:shadow-md",j?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(j?null:_.course_id),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground truncate",children:_.course_title}),e.jsx(st,{variant:_.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:_.is_published?"Live":"Draft"})]})}),e.jsx(da,{className:It("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",j&&"rotate-90")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.enrolled_agents}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Enrolled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.total_completions}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Completed"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.total_modules}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Modules"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg. Completion"}),e.jsxs("span",{className:"font-semibold text-foreground",children:[_.avg_completion_pct,"%"]})]}),e.jsx(Bi,{value:_.avg_completion_pct,className:"h-2"})]})]})},_.course_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No courses created yet"})})})]}),e.jsxs("div",{className:"xl:col-span-3 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(G_,{className:"h-5 w-5 text-primary"}),f?`Agent Progress — ${f.course_title}`:"Agent Progress"]}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:u,onChange:_=>p(_.target.value),placeholder:"Search agents...",className:"pl-9"})]}),c?e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(_=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-12 bg-muted rounded"})})},_))}):g!=null&&g.length?e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto pr-1",children:g.map((_,j)=>{const w=_.completion_pct>=100;return e.jsx(Ee,{className:It("transition-all",w&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:It("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",j===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":j===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":j===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:j+1}),e.jsxs(Nn,{className:"h-9 w-9 shrink-0",children:[e.jsx($a,{src:_.avatar_url||void 0}),e.jsx(kn,{className:"text-xs bg-primary/10 text-primary",children:(_.agent_name||_.email||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:_.agent_name||_.email}),w&&e.jsxs(st,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(sa,{className:"h-3 w-3 mr-0.5"})," Complete"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[_.modules_completed,"/",_.total_modules," modules"]}),_.last_activity&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(_.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:It("text-sm font-bold",w?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[_.completion_pct,"%"]}),e.jsx(Bi,{value:_.completion_pct,className:"h-1.5 mt-1"})]})]})})},_.user_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:u?"No agents match your search":"No agents have started this course yet"})})})]}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"py-16 text-center",children:[e.jsx(pr,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Select a course to view agent progress"})]})})]})]})]})})}function fCs(){const{user:t}=Ds(),s=fr(),{data:r,isLoading:n}=iCs();return e.jsx(Ms,{title:"LevelUp U",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/10 via-primary/5 to-background border p-8",children:[e.jsx("div",{className:"relative z-10",children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-primary/15 flex items-center justify-center",children:e.jsx(Kh,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"LevelUp U"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your training & development hub"})]})]})}),e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-primary/5 rounded-full -translate-y-1/2 translate-x-1/2"})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-3"})]})},a))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(a=>e.jsx(xCs,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Sh,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No courses available yet"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Check back soon for new training content"})]})})]})})}function xCs({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=hct(t.id),o=(a==null?void 0:a.filter(c=>c.completed).length)??0,l=n>0?Math.round(o/n*100):0;return e.jsxs(Ee,{className:"group cursor-pointer hover:shadow-lg transition-all hover:border-primary/50 overflow-hidden",onClick:r,children:[t.thumbnail_url?e.jsx("div",{className:"aspect-video bg-muted overflow-hidden",children:e.jsx("img",{src:t.thumbnail_url,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})}):e.jsx("div",{className:"aspect-video bg-gradient-to-br from-primary/15 via-primary/5 to-muted flex items-center justify-center",children:e.jsx(Kh,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors line-clamp-1",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sh,{className:"h-3.5 w-3.5"}),n," module",n!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[t.is_sequential?e.jsx(p0,{className:"h-3.5 w-3.5"}):e.jsx(pS,{className:"h-3.5 w-3.5"}),t.is_sequential?"In order":"Any order"]})]}),n>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:[o," of ",n," completed"]}),e.jsxs("span",{className:"font-medium text-foreground",children:[l,"%"]})]}),e.jsx(Bi,{value:l,className:"h-1.5"})]}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("span",{className:"text-xs text-primary font-medium flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[l===100?"Review":l>0?"Continue":"Start"," Course",e.jsx(da,{className:"h-3.5 w-3.5"})]})})]})]})}function gCs(){const{courseId:t}=yo(),s=fr(),{user:r}=Ds(),{data:n,isLoading:a}=oCs(t),{data:o}=hct(t),l=lCs(),[i,c]=k.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(S=>S.completed).map(S=>S.module_id))||[]),f=p.size,g=u.length>0?Math.round(f/u.length*100):0;k.useEffect(()=>{if(u.length>0&&!i){const S=u.find(M=>!p.has(M.id));c((S==null?void 0:S.id)||u[0].id)}},[u,i,p]);const b=u.find(S=>S.id===i),_=u.findIndex(S=>S.id===i),j=(S,M)=>{if(!(n!=null&&n.is_sequential)||M===0)return!1;for(let L=0;L{if(!(!b||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:b.id,userId:r.id}),me.success("Module completed! 🎉"),_{const M=S.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(M)return`https://www.youtube.com/embed/${M[1]}`;const L=S.match(/vimeo\.com\/(\d+)/);if(L)return`https://player.vimeo.com/video/${L[1]}`;const I=S.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return I?`https://iframe.mediadelivery.net/embed/${I[1]}/${I[2]}?responsive=true`:S};return a?e.jsx(Ms,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):n?e.jsx(Ms,{title:n.title,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-bold text-foreground truncate",children:n.title}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[f,"/",u.length," completed"]}),e.jsxs("span",{children:[g,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(Bi,{value:g,className:"h-2"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] gap-4 items-start",children:[e.jsx(Ee,{className:"lg:sticky lg:top-4",children:e.jsxs(Oe,{className:"p-0",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Modules"})}),e.jsx(Gi,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((S,M)=>{const L=j(S,M),I=p.has(S.id),O=S.id===i;return e.jsxs("button",{disabled:L,onClick:()=>!L&&c(S.id),className:It("w-full flex items-center gap-3 p-3 rounded-lg text-left transition-all text-sm",O?"bg-primary/10 text-primary":"hover:bg-muted/50",L&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:L?e.jsx(Th,{className:"h-4 w-4 text-muted-foreground"}):I?e.jsx(sa,{className:"h-4 w-4 text-green-500"}):e.jsx(_d,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:It("font-medium truncate",O&&"text-primary"),children:[M+1,". ",S.title]}),S.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(un,{className:"h-3 w-3"})," ",S.duration_minutes," min"]})]})]},S.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:b?e.jsxs(e.Fragment,{children:[b.video_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:N(b.video_url),className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:b.title}),b.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:b.description})]}),p.has(b.id)?e.jsxs(st,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(sa,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:w,disabled:l.isPending,children:[e.jsx(sa,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),b.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:b.text_content}),b.resources&&b.resources.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Resources"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:b.resources.map(S=>e.jsxs("a",{href:S.url||S.file_url||"#",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-sm",children:[S.resource_type==="pdf"?e.jsx(Sn,{className:"h-4 w-4 text-red-500 shrink-0"}):S.resource_type==="template"?e.jsx(Kh,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(dl,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:S.title}),e.jsx(tn,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},S.id))})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-4",children:[e.jsxs(K,{variant:"outline",size:"sm",disabled:_===0,onClick:()=>_>0&&c(u[_-1].id),children:[e.jsx(Ja,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),_c(u[_+1].id),children:["Next ",e.jsx(da,{className:"h-3.5 w-3.5 ml-1"})]}):g===100&&e.jsx(st,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(Ms,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/levelup-u"),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function yCs({headline:t,subtext:s,primaryColor:r,accentColor:n,heroImageUrl:a,logoUrl:o,brokerageName:l}){return e.jsxs("section",{className:"relative min-h-screen flex items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0",style:{background:`linear-gradient(160deg, ${n} 0%, ${r} 50%, ${n}ee 100%)`}}),a&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center opacity-20",style:{backgroundImage:`url(${a})`}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px), radial-gradient(circle at 75% 75%, white 1px, transparent 1px)",backgroundSize:"60px 60px"}}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-32 bg-gradient-to-t from-white to-transparent"}),e.jsxs("div",{className:"relative z-10 text-center max-w-4xl mx-auto px-6 py-24",children:[o&&e.jsx(Gs.img,{src:o,alt:l,className:"h-14 md:h-20 w-auto mx-auto mb-10 drop-shadow-2xl",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.8,delay:.2}}),e.jsx(Gs.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.3},children:e.jsx("span",{className:"inline-block text-white/70 text-sm md:text-base font-medium tracking-[0.2em] uppercase mb-6",children:"Your Next Chapter Starts Here"})}),e.jsx(Gs.h1,{className:"text-4xl md:text-6xl lg:text-7xl font-bold text-white mb-8 leading-[1.1] tracking-tight",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.9,delay:.5},children:t}),e.jsx(Gs.p,{className:"text-lg md:text-xl text-white/80 mb-12 max-w-2xl mx-auto leading-relaxed font-light",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.7},children:s}),e.jsxs(Gs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.7,delay:.9},className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"#apply",className:"group inline-flex items-center gap-3 px-10 py-4 rounded-full text-lg font-semibold shadow-2xl transition-all duration-300 hover:scale-105 hover:shadow-3xl",style:{backgroundColor:"white",color:n},children:["Get In Touch",e.jsx(Qa,{className:"h-5 w-5 transition-transform group-hover:translate-x-1"})]}),e.jsx("a",{href:"#benefits",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-base font-medium text-white/90 border border-white/30 backdrop-blur-sm transition-all duration-300 hover:bg-white/10 hover:border-white/50",children:"Learn More"})]})]}),e.jsx(Gs.div,{className:"absolute bottom-8 left-1/2 -translate-x-1/2 z-10",animate:{y:[0,8,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:e.jsx("div",{className:"w-6 h-10 border-2 border-white/40 rounded-full flex justify-center pt-2",children:e.jsx("div",{className:"w-1.5 h-3 bg-white/60 rounded-full"})})})]})}function _w({children:t,className:s="",delay:r=0,direction:n="up"}){const a=k.useRef(null),o=jEt(a,{once:!0,margin:"-80px"}),l={hidden:{opacity:0,y:n==="up"?40:0,x:n==="left"?-40:n==="right"?40:0},visible:{opacity:1,y:0,x:0}};return e.jsx(Gs.div,{ref:a,initial:"hidden",animate:o?"visible":"hidden",variants:l,transition:{duration:.7,delay:r,ease:[.25,.46,.45,.94]},className:s,children:t})}function vCs({benefits:t,accentColor:s,primaryColor:r}){return t.length===0?null:e.jsx("section",{id:"benefits",className:"py-24 md:py-32 px-6 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(_w,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("span",{className:"text-sm font-semibold tracking-[0.15em] uppercase mb-4 block",style:{color:r},children:"Why Top Agents Choose Us"}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold mb-4 tracking-tight",style:{color:s},children:"Built For Your Success"}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full mt-6",style:{backgroundColor:r}})]})}),e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8",children:t.map((n,a)=>e.jsx(_w,{delay:a*.1,children:e.jsxs("div",{className:"group relative p-8 rounded-2xl border border-gray-100 bg-white hover:border-transparent hover:shadow-2xl transition-all duration-500 h-full",children:[e.jsx("div",{className:"absolute inset-0 rounded-2xl opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{background:`linear-gradient(135deg, ${r}08, ${s}05)`}}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center text-2xl mb-5 transition-transform duration-300 group-hover:scale-110",style:{backgroundColor:`${r}12`},children:n.icon}),e.jsx("h3",{className:"text-xl font-bold mb-3 tracking-tight",style:{color:s},children:n.title}),e.jsx("p",{className:"text-gray-500 leading-relaxed text-[15px]",children:n.description})]})]})},a))})]})})}function bCs({images:t,primaryColor:s,accentColor:r}){const[n,a]=k.useState(null);return t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"py-24 md:py-32 px-6 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(_w,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white border border-gray-200 mb-6",children:[e.jsx(pr,{className:"h-4 w-4",style:{color:s}}),e.jsx("span",{className:"text-sm font-medium text-gray-600",children:"Life at Our Brokerage"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold tracking-tight",style:{color:r},children:"Our Team & Culture"})]})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 md:gap-4",children:t.map((o,l)=>e.jsx(_w,{delay:l*.08,children:e.jsxs("button",{onClick:()=>a(l),className:"relative w-full aspect-[4/3] overflow-hidden rounded-xl group cursor-pointer",children:[e.jsx("img",{src:o,alt:`Team ${l+1}`,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-all duration-500"})]})},l))})]})}),n!==null&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4 cursor-pointer",onClick:()=>a(null),children:[e.jsx("button",{onClick:()=>a(null),className:"absolute top-6 right-6 text-white/80 hover:text-white transition-colors",children:e.jsx(Rr,{className:"h-8 w-8"})}),e.jsx("img",{src:t[n],alt:"Gallery",className:"max-w-full max-h-[85vh] object-contain rounded-lg",onClick:o=>o.stopPropagation()})]})]})}function _Cs({testimonials:t,primaryColor:s,accentColor:r}){return t.length===0?null:e.jsx("section",{className:"py-24 md:py-32 px-6 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(_w,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("span",{className:"text-sm font-semibold tracking-[0.15em] uppercase mb-4 block",style:{color:s},children:"Agent Testimonials"}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold tracking-tight",style:{color:r},children:"Hear From Our Agents"}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full mt-6",style:{backgroundColor:s}})]})}),e.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:t.map((n,a)=>{var o;return e.jsx(_w,{delay:a*.15,direction:a%2===0?"left":"right",children:e.jsxs("div",{className:"relative p-8 md:p-10 rounded-2xl bg-gray-50 border border-gray-100 h-full",children:[e.jsx(H_,{className:"h-8 w-8 mb-5 opacity-20",style:{color:s}}),e.jsxs("p",{className:"text-gray-700 text-lg leading-relaxed mb-8 font-light italic",children:['"',n.quote,'"']}),e.jsxs("div",{className:"flex items-center gap-4",children:[n.photo_url?e.jsx("img",{src:n.photo_url,alt:n.name,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white shadow-md"}):e.jsx("div",{className:"h-12 w-12 rounded-full flex items-center justify-center text-white text-base font-bold shadow-md",style:{background:`linear-gradient(135deg, ${s}, ${r})`},children:((o=n.name)==null?void 0:o[0])||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-base",style:{color:r},children:n.name}),n.role&&e.jsx("p",{className:"text-sm text-gray-500",children:n.role})]})]})]})},a)})})]})})}function wCs({form:t,setForm:s,onSubmit:r,isPending:n,primaryColor:a,accentColor:o}){return e.jsxs("section",{id:"apply",className:"py-24 md:py-32 px-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 top-0 h-1/2",style:{background:`linear-gradient(160deg, ${o}, ${a})`}}),e.jsx("div",{className:"absolute inset-0 top-1/2 bg-gray-50"}),e.jsxs("div",{className:"relative z-10 max-w-xl mx-auto",children:[e.jsx(_w,{children:e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-3 tracking-tight",children:"Want to Learn More?"}),e.jsx("p",{className:"text-white/70 text-lg font-light",children:"Drop your info below and we'll share more about what makes us different."})]})}),e.jsx(_w,{delay:.2,children:e.jsxs("form",{onSubmit:l=>{l.preventDefault(),r()},className:"bg-white rounded-3xl shadow-2xl p-8 md:p-10 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(ze,{required:!0,value:t.first_name,onChange:l=>s(i=>({...i,first_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"John"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(ze,{value:t.last_name,onChange:l=>s(i=>({...i,last_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Smith"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(ze,{type:"email",required:!0,value:t.email,onChange:l=>s(i=>({...i,email:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"john@email.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Phone"}),e.jsx(ze,{value:t.phone,onChange:l=>s(i=>({...i,phone:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(ze,{value:t.current_brokerage,onChange:l=>s(i=>({...i,current_brokerage:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Your current brokerage name"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"License #"}),e.jsx(ze,{value:t.license_number,onChange:l=>s(i=>({...i,license_number:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(ze,{type:"number",min:"0",value:t.experience_years,onChange:l=>s(i=>({...i,experience_years:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(ze,{value:t.annual_production,onChange:l=>s(i=>({...i,annual_production:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"e.g. $5M, 20 transactions"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Why are you interested?"}),e.jsx(Er,{value:t.why_interested,onChange:l=>s(i=>({...i,why_interested:l.target.value})),rows:3,className:"rounded-lg border-gray-200 focus:border-gray-400 transition-colors resize-none",placeholder:"Tell us about your goals and what you're looking for..."})]}),e.jsx(K,{type:"submit",className:"w-full h-13 text-base font-semibold rounded-xl group transition-all duration-300 hover:shadow-lg",style:{background:`linear-gradient(135deg, ${a}, ${o})`},disabled:n,children:n?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"Submitting..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Send My Info",e.jsx(Qa,{className:"h-4 w-4 transition-transform group-hover:translate-x-1"})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-gray-400 pt-1",children:[e.jsx(th,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Your information is confidential and will not be shared."})]})]})})]})]})}function jCs(){const{slug:t}=yo(),{toast:s}=Ua(),[r,n]=k.useState(!1),[a,o]=k.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""}),{data:l,isLoading:i,error:c}=mt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:M,error:L}=await H.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(L)throw L;return M},enabled:!!t}),{data:u}=mt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:M,error:L}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(L&&L.code!=="PGRST116")throw L;return M},enabled:!!(l!=null&&l.id)}),p=Lt({mutationFn:async()=>{const M={brokerage_id:l.id,first_name:a.first_name,last_name:a.last_name||null,email:a.email,phone:a.phone||null,current_brokerage:a.current_brokerage||null,experience_years:a.experience_years?parseInt(a.experience_years):null,annual_production:a.annual_production||null,license_number:a.license_number||null,why_interested:a.why_interested||null},{error:L}=await H.from("recruit_interest_submissions").insert(M);if(L)throw L;H.functions.invoke("recruit-lead-notify",{body:{lead:M,brokerage_id:l.id}}).catch(I=>console.error("Lead notification error:",I))},onSuccess:()=>n(!0),onError:M=>s({title:"Error",description:M.message,variant:"destructive"})});if(i)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-3 border-gray-200 border-t-gray-800"}),e.jsx("span",{className:"text-sm text-gray-400 tracking-wide",children:"Loading..."})]})});if(c||!l||!l.recruit_form_enabled)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"max-w-md w-full mx-4 text-center",children:[e.jsx(ka,{className:"h-10 w-10 mx-auto text-gray-300 mb-4"}),e.jsx("p",{className:"text-gray-400 text-lg",children:"This page is not available."})]})});const f=u,g=(f==null?void 0:f.primary_color)||"#406E71",b=(f==null?void 0:f.accent_color)||"#2a4c64",_=(f==null?void 0:f.benefits)||[],j=(f==null?void 0:f.testimonials)||[],w=(f==null?void 0:f.gallery_images)||[],N=(f==null?void 0:f.hero_headline)||`Join ${l.name}`,S=(f==null?void 0:f.hero_subtext)||"Take your real estate career to the next level with a brokerage that invests in your growth.";return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs(Gs.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{duration:.6},className:"max-w-md w-full mx-4 text-center",children:[e.jsx("div",{className:"h-20 w-20 rounded-full flex items-center justify-center mx-auto mb-6 shadow-lg",style:{background:`linear-gradient(135deg, ${g}, ${b})`},children:e.jsx(va,{className:"h-10 w-10 text-white"})}),e.jsx("h2",{className:"text-3xl font-bold mb-3 tracking-tight",style:{color:b},children:"Thank You!"}),e.jsxs("p",{className:"text-gray-500 text-lg leading-relaxed mb-8",children:["Your interest in joining ",e.jsx("span",{className:"font-semibold",style:{color:b},children:l.name})," has been received. A member of our recruitment team will be in touch shortly."]}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full",style:{backgroundColor:g}})]})}):e.jsxs("div",{className:"min-h-screen bg-white",style:{"--recruit-primary":g,"--recruit-accent":b},children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-40 bg-white/80 backdrop-blur-lg border-b border-gray-100/50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 h-14 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(f==null?void 0:f.logo_url)&&e.jsx("img",{src:f.logo_url,alt:l.name,className:"h-8 w-auto"}),e.jsx("span",{className:"font-semibold text-sm tracking-tight",style:{color:b},children:l.name})]}),e.jsxs("a",{href:"#apply",className:"inline-flex items-center gap-2 px-5 py-2 rounded-full text-sm font-semibold text-white transition-all duration-300 hover:shadow-md hover:scale-105",style:{background:`linear-gradient(135deg, ${g}, ${b})`},children:["Apply Now ",e.jsx(Qa,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(yCs,{headline:N,subtext:S,primaryColor:g,accentColor:b,heroImageUrl:f==null?void 0:f.hero_image_url,logoUrl:f==null?void 0:f.logo_url,brokerageName:l.name}),e.jsx(vCs,{benefits:_,accentColor:b,primaryColor:g}),e.jsx(bCs,{images:w,primaryColor:g,accentColor:b}),e.jsx(_Cs,{testimonials:j,primaryColor:g,accentColor:b}),e.jsx(wCs,{form:a,setForm:o,onSubmit:()=>p.mutate(),isPending:p.isPending,primaryColor:g,accentColor:b}),e.jsx("footer",{className:"py-10 text-center bg-white border-t border-gray-100",children:e.jsxs("p",{className:"text-sm text-gray-400",children:["© ",new Date().getFullYear()," ",l.name,". All rights reserved."]})})]})}function NCs(t){const s=t.match(/(?:iframe\.mediadelivery\.net\/(?:embed|play)\/|video\.bunnycdn\.com\/play\/)(\d+)\/([a-f0-9-]+)/i);return s?`https://iframe.mediadelivery.net/embed/${s[1]}/${s[2]}?autoplay=false&responsive=true`:t}function kCs(){var g,b,_,j;const{shareToken:t}=yo(),s=k.useRef(!1),{data:r,isLoading:n,error:a}=mt({queryKey:["public-recruit-video",t],queryFn:async()=>{var I;if(!t)throw new Error("No token");const{data:w,error:N}=await H.from("recruit_videos").select(` *, prospect:recruit_prospects(first_name, last_name), video:agent_videos(id, title, playback_url, thumbnail_url, duration_seconds, owner_user_id) `).eq("share_token",t).single();if(N)throw N;const{data:S}=await H.from("profiles").select("name, avatar_url, title").eq("id",(I=w.video)==null?void 0:I.owner_user_id).single(),{data:M}=await H.from("brokerages").select("name").eq("id",w.brokerage_id).single(),{data:L}=await H.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",w.brokerage_id).maybeSingle();return{rv:w,profile:S,brokerage:M,settings:L}},enabled:!!t});if(k.useEffect(()=>{var w;!((w=r==null?void 0:r.rv)!=null&&w.id)||s.current||(s.current=!0,H.rpc("log_recruit_video_view",{p_recruit_video_id:r.rv.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null}).then(()=>{}))},[(g=r==null?void 0:r.rv)==null?void 0:g.id]),n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});if(a||!r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("p",{className:"text-muted-foreground",children:"This video is no longer available."})});const{rv:o,profile:l,brokerage:i,settings:c}=r,u=(c==null?void 0:c.primary_color)||"#3b82f6",p=((b=o.prospect)==null?void 0:b.first_name)||"there",f=(_=o.video)!=null&&_.playback_url?NCs(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(Sc,{children:e.jsx("title",{children:i!=null&&i.name?`${i.name} — A Message For You`:"Personal Video Message"})}),e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100",children:[e.jsx("header",{className:"border-b bg-white/80 backdrop-blur-sm",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-4 flex items-center gap-3",children:[(c==null?void 0:c.logo_url)&&e.jsx("img",{src:c.logo_url,alt:"",className:"h-8 object-contain"}),e.jsx("span",{className:"font-semibold text-sm",style:{color:u},children:(i==null?void 0:i.name)||"Recruiting"})]})}),e.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground",children:["Hey ",p,", ",l==null?void 0:l.name," has a message for you"]}),o.message&&e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:o.message})]}),f&&e.jsx("div",{className:"rounded-xl overflow-hidden shadow-xl bg-black",children:e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:f,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border p-6 flex items-center gap-4",children:[l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"",className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"h-14 w-14 rounded-full flex items-center justify-center text-white text-lg font-bold",style:{backgroundColor:u},children:((j=l==null?void 0:l.name)==null?void 0:j.charAt(0))||"?"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold",children:l==null?void 0:l.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(l==null?void 0:l.title)||"Recruiter"," · ",i==null?void 0:i.name]})]})]}),e.jsx("div",{className:"text-center",children:e.jsxs(K,{size:"lg",className:"text-white shadow-lg hover:shadow-xl transition-shadow px-8",style:{backgroundColor:u},onClick:()=>{H.from("recruit_videos").update({cta_clicked_at:new Date().toISOString()}).eq("id",o.id).then(()=>{})},children:[e.jsx(hn,{className:"h-5 w-5 mr-2"})," Schedule a Conversation"]})})]}),e.jsx("footer",{className:"text-center py-6 text-xs text-muted-foreground",children:"Powered by LevelUp"})]})]})}function SCs(){const t=fr(),s=Qt(),{isAdmin:r}=Ds(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState(null),{data:u,isLoading:p}=mt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:I},error:O}=await H.auth.getUser();if(O)throw O;if(!I)return[];const{data:q,error:U}=await H.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(U)throw U;return q}}),f=Lt({mutationFn:async I=>{const{data:{user:O},error:q}=await H.auth.getUser();if(q)throw q;if(!O)throw new Error("Not authenticated");const{error:U}=await H.from("social_accounts").delete().eq("id",I).eq("user_id",O.id);if(U)throw U},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),me.success("Account disconnected successfully")},onError:()=>{me.error("Failed to disconnect account")}}),g=async()=>{a(!0);try{const{data:I,error:O}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(O)throw O;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Meta OAuth error:",I),me.error("Failed to start connection. Please try again."),a(!1)}},b=async()=>{a(!0);try{const{data:I,error:O}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(O)throw O;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(I){console.error("LinkedIn OAuth error:",I),me.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:I,error:O}=await H.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(O)throw O;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(I){console.error("Google OAuth error:",I),me.error("Failed to start Google connection. Please try again."),a(!1)}},j=(u==null?void 0:u.filter(I=>I.platform==="facebook"))||[],w=(u==null?void 0:u.filter(I=>I.platform==="instagram"))||[],N=(u==null?void 0:u.filter(I=>I.platform==="linkedin"))||[],S=(u==null?void 0:u.filter(I=>I.platform==="google_business"))||[],M=((u==null?void 0:u.length)||0)>0,L=async(I,O)=>{l(I),c(null);try{const{data:q,error:U}=await H.functions.invoke("meta-api-test",{body:{testType:"all",accountId:I}});if(U)throw U;c(q.results||[]),me.success(q.summary||"API tests completed")}catch(q){console.error("Meta API test error:",q),me.error("Failed to run API tests")}finally{l(null)}};return e.jsx(Ms,{title:"Social Connections",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-pink-500 via-purple-500 to-blue-500 p-6 md:p-8 text-white",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsxs(st,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(pn,{className:"h-3 w-3 mr-1"}),"Post directly from Social Swag"]})}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold mb-2",children:"Connect Your Social Accounts"}),e.jsx("p",{className:"text-white/90 max-w-xl",children:"Link your Facebook Pages and Instagram Business accounts to post content directly from Social Swag with one click."})]})]}),e.jsxs(K,{variant:"ghost",onClick:()=>t("/social-swag-2"),className:"gap-2",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-amber-100 dark:bg-amber-900/30 p-4 mb-4",children:e.jsx(un,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(st,{variant:"secondary",className:"mb-3 bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Social Connections Coming Soon!"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"We're putting the finishing touches on this feature. Soon you'll be able to connect your social accounts and post directly from Social Swag with one click."})]})}),r&&e.jsxs(e.Fragment,{children:[M&&e.jsx(Ee,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Oe,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(xi,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-green-800 dark:text-green-200",children:"You're all set!"}),e.jsx("p",{className:"text-sm text-green-600 dark:text-green-400",children:"You can now post directly to your connected accounts from Social Swag."})]})]})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-3",children:e.jsx(Su,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Facebook"}),e.jsx(gr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Go,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsx("div",{className:"space-y-3",children:j.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Su,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:I.page_name||I.platform_username||"Facebook Page"}),e.jsx(st,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect Facebook?"}),e.jsx(sc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>f.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),e.jsxs(K,{onClick:g,disabled:n,className:"w-full gap-2",variant:j.length>0?"outline":"default",children:[n?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),j.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-gradient-to-br from-purple-500/10 via-pink-500/10 to-orange-500/10 p-3",children:e.jsx(Mu,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Instagram"}),e.jsx(gr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Go,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsx("div",{className:"space-y-3",children:w.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",I.platform_username||"Instagram Account"]}),e.jsx(st,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect Instagram?"}),e.jsx(sc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>f.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),e.jsxs(K,{onClick:g,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),w.length>0?"Connect Another Account":"Connect Instagram"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-600/10 p-3",children:e.jsx(Mp,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"LinkedIn"}),e.jsx(gr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Go,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):N.length>0?e.jsx("div",{className:"space-y-3",children:N.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Mp,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:I.platform_username||"LinkedIn Account"}),e.jsx(st,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect LinkedIn?"}),e.jsx(sc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>f.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(K,{onClick:b,disabled:n,className:"w-full gap-2",variant:N.length>0?"outline":"default",children:[n?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),N.length>0?"Reconnect LinkedIn":"Connect LinkedIn"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Share content directly to your LinkedIn profile"})]})]}),e.jsxs(Ee,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(st,{variant:"secondary",className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"})}),r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(st,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-red-500/10 p-3",children:e.jsx(ma,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Google Business"}),e.jsx(gr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Go,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?e.jsx("div",{className:"space-y-3",children:S.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(ma,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:I.page_name||I.platform_username||"Google Business"}),e.jsx(st,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(kc,{children:[e.jsx(Cm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Disconnect Google Business?"}),e.jsx(sc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>f.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:r?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),e.jsxs(K,{onClick:r?_:void 0,disabled:!r||n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?e.jsx(Go,{className:"h-4 w-4 animate-spin"}):e.jsx($s,{className:"h-4 w-4"}),S.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(j.length>0||w.length>0)&&e.jsxs(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-amber-500/10 p-3",children:e.jsx(B_,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(gr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Click "Run Tests" on an account to trigger API calls for: ',e.jsx("strong",{children:"public_profile"}),", ",e.jsx("strong",{children:"pages_show_list"}),", ",e.jsx("strong",{children:"pages_read_engagement"}),", ",e.jsx("strong",{children:"instagram_basic"}),", ",e.jsx("strong",{children:"pages_manage_posts"}),", and ",e.jsx("strong",{children:"instagram_content_publish"}),"."]}),e.jsxs("div",{className:"space-y-3",children:[j.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Su,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:I.page_name||"Facebook Page"})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>L(I.id),disabled:o===I.id,children:o===I.id?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${I.id}`)),w.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Mu,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",I.platform_username||"Instagram"]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>L(I.id),disabled:o===I.id,children:o===I.id?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${I.id}`))]}),i&&i.length>0&&e.jsxs("div",{className:"mt-4 rounded-lg border bg-background p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Test Results"}),e.jsx("div",{className:"space-y-2",children:i.map((I,O)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[I.status==="success"?e.jsx(sa,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):I.status==="pending"?e.jsx(ws,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(vc,{className:"h-4 w-4 text-red-600 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs bg-muted px-1 rounded",children:I.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:I.details})]})]},O))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Note: Facebook posts are auto-deleted. Instagram posts will remain and should be manually deleted. Allow up to 24 hours for Meta to register the API calls."})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"How it works"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"1"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Connect your accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link your Facebook, Instagram, or LinkedIn account"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"2"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Browse Social Swag"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Find the perfect image and caption for your post"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Post with one click"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Click "Create Post" to share directly to your accounts'})]})]})]})})]})]})]})})}function CCs(){const[t]=Cc(),s=fr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing your connection...");return k.useEffect(()=>{(async()=>{var f;const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:g,error:b}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(b)throw b;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||0} account(s)!`),me.success("Social accounts connected successfully!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect accounts"),me.error("Failed to connect: "+(g instanceof Error?g.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function MCs(){const[t]=Cc(),s=fr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your Google Business Profile...");return k.useEffect(()=>{(async()=>{const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:f,error:g}=await H.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(g)throw g;if(f!=null&&f.success)n("success"),o(f.message||"Successfully connected Google Business Profile!"),me.success("Google Business Profile connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Google OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Google Business Profile"),me.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(vc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function TCs(){const[t]=Cc(),s=fr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your LinkedIn account...");return k.useEffect(()=>{(async()=>{var f;const i=t.get("code"),c=t.get("state"),u=t.get("error"),p=t.get("error_description");if(u){console.error("LinkedIn OAuth error:",u,p),n("error"),o(p||"Failed to connect LinkedIn account"),me.error(p||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:g,error:b}=await H.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:c,callbackPath:"/social-connections/linkedin-callback"}});if(b)throw b;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||1} LinkedIn account`),me.success("LinkedIn connected successfully!");else throw new Error((g==null?void 0:g.error)||"Failed to connect LinkedIn account")}catch(g){console.error("LinkedIn callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect LinkedIn account"),me.error("Failed to connect LinkedIn")}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 rounded-full bg-blue-600/10 p-4 w-fit",children:[r==="loading"&&e.jsx(ws,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(xi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(vc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Rt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Mp,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function ACs(){const t=fr(),[s,r]=k.useState(null),{data:n,isLoading:a}=Alt(s||void 0,!0),{data:o,isLoading:l}=hCe(!0),{cartItems:i}=_ue(),c=i.reduce((p,f)=>p+f.quantity,0),u=p=>{t(`/marketplace/${p.id}`)};return a||l?e.jsx(Ms,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[1,2,3].map(p=>e.jsx(ys,{className:"h-10 w-24 flex-shrink-0"},p))}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:[1,2,3,4].map(p=>e.jsx(ys,{className:"h-72 w-full"},p))})]})}):e.jsx(Ms,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Marketplace"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Shop exclusive products for LevelUp members"})]}),e.jsxs(K,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(vp,{className:"h-4 w-4 mr-2"}),"Cart",c>0&&e.jsx(st,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:c})]})]}),o&&o.length>0&&e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[e.jsx(K,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(p=>e.jsx(K,{variant:s===p.id?"default":"outline",size:"sm",onClick:()=>r(p.id),children:p.name},p.id))]}),n&&n.length>0?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(p=>{var f;return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>u(p),children:[e.jsxs("div",{className:"aspect-square bg-muted relative",children:[p.images&&p.images.length>0?e.jsx("img",{src:((f=p.images.find(g=>g.is_primary))==null?void 0:f.image_url)||p.images[0].image_url,alt:p.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Ml,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(st,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:p.name}),p.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:p.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-lg",children:["$",Number(p.base_price).toFixed(2)]}),p.variants&&p.variants.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.variants.length," options"]})]})]})]},p.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ml,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No products available yet."})]})]})})}const mct=k.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));mct.displayName="Breadcrumb";const pct=k.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:It("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));pct.displayName="BreadcrumbList";const Oie=k.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:It("inline-flex items-center gap-1.5",t),...s}));Oie.displayName="BreadcrumbItem";const mwe=k.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?h2e:"a";return e.jsx(a,{ref:n,className:It("transition-colors hover:text-foreground",s),...r})});mwe.displayName="BreadcrumbLink";const fct=k.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:It("font-normal text-foreground",t),...s}));fct.displayName="BreadcrumbPage";const pwe=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:It("[&>svg]:size-3.5",s),...r,children:t??e.jsx(da,{})});pwe.displayName="BreadcrumbSeparator";function ECs(){var ee,X;const{productId:t}=yo(),s=fr(),{data:r,isLoading:n}=$ks(t||""),{addToCart:a,cartItems:o}=_ue(),[l,i]=k.useState(null),[c,u]=k.useState(1),[p,f]=k.useState(0),[g,b]=k.useState(null),[_,j]=k.useState(!1),[w,N]=k.useState(!1),S=(ee=r==null?void 0:r.variants)==null?void 0:ee.find(ie=>ie.id===l),M=((X=r==null?void 0:r.variants)==null?void 0:X.filter(ie=>ie.is_active))||[],L=Number((r==null?void 0:r.base_price)||0),I=S?Number(S.price_adjustment):0,O=L+I,q=Number((r==null?void 0:r.shipping_fee)||0),U=o.reduce((ie,re)=>ie+re.quantity,0),B=async ie=>{if(!ie.target.files||ie.target.files.length===0)return;j(!0);const re=ie.target.files[0],oe=re.name.split(".").pop(),ce=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${oe}`;try{const{error:ge}=await H.storage.from("marketplace").upload(ce,re);if(ge)throw ge;const{data:{publicUrl:ye}}=H.storage.from("marketplace").getPublicUrl(ce);b(ye),me.success("Artwork uploaded successfully")}catch(ge){me.error("Failed to upload artwork: "+ge.message)}finally{j(!1)}},V=()=>{if(r){if(M.length>0&&!l){me.error("Please select an option");return}a(r,S||void 0,c,g||void 0),N(!0),me.success("Added to cart!"),setTimeout(()=>N(!1),2e3)}},Y=()=>{r!=null&&r.images&&f(ie=>(ie+1)%r.images.length)},Q=()=>{r!=null&&r.images&&f(ie=>(ie-1+r.images.length)%r.images.length)};return n?e.jsx(Ms,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(ys,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"h-8 w-3/4"}),e.jsx(ys,{className:"h-6 w-1/4"}),e.jsx(ys,{className:"h-24 w-full"}),e.jsx(ys,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Ms,{title:r.name,children:[e.jsx(mct,{className:"mb-6",children:e.jsxs(pct,{children:[e.jsx(Oie,{children:e.jsx(mwe,{asChild:!0,children:e.jsx(Pi,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(pwe,{}),e.jsx(Oie,{children:e.jsx(mwe,{asChild:!0,children:e.jsx(Pi,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(pwe,{}),e.jsx(Oie,{children:e.jsx(fct,{children:r.name})})]})}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative aspect-square bg-muted rounded-lg overflow-hidden flex items-center justify-center",children:r.images&&r.images.length>0?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:r.images[p].image_url,alt:r.name,className:"max-w-full max-h-full object-contain"}),r.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:Q,children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:Y,children:e.jsx(da,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Ml,{className:"h-24 w-24 text-muted-foreground"})})}),r.images&&r.images.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:r.images.map((ie,re)=>e.jsx("button",{onClick:()=>f(re),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${re===p?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:ie.image_url,alt:"",className:"w-full h-full object-cover"})},ie.id))}),r.video&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:"Product Video"}),e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:r.video.video_url,className:"w-full h-full rounded-lg",allowFullScreen:!0})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[r.category&&e.jsx(st,{variant:"secondary",className:"mb-2",children:r.category.name}),e.jsx("h1",{className:"text-3xl font-bold mb-2",children:r.name}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-3xl font-bold",children:["$",O.toFixed(2)]}),q>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",q.toFixed(2)," shipping"]})]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})}),M.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(ie=>e.jsxs(K,{variant:l===ie.id?"default":"outline",onClick:()=>i(ie.id),children:[ie.name,Number(ie.price_adjustment)!==0&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",Number(ie.price_adjustment)>0?"+":"","$",Number(ie.price_adjustment).toFixed(2),")"]})]},ie.id))})]}),r.allow_artwork_upload&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Upload Your Artwork (Optional)"}),g?e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:g,alt:"Your artwork",className:"h-24 w-auto rounded-lg border"}),e.jsx(K,{variant:"ghost",size:"sm",className:"absolute -top-2 -right-2",onClick:()=>b(null),children:"×"})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6",children:[e.jsx("input",{type:"file",accept:"image/*,.pdf,.ai,.eps",onChange:B,className:"hidden",id:"artwork-upload",disabled:_}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(li,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:_?"Uploading...":"Click to upload artwork"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Supported: JPG, PNG, PDF, AI, EPS"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(ie=>Math.max(1,ie-1)),children:"-"}),e.jsx(ze,{type:"number",value:c,onChange:ie=>u(Math.max(1,parseInt(ie.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(ie=>ie+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(K,{size:"lg",className:"flex-1",onClick:V,disabled:w,children:w?e.jsxs(e.Fragment,{children:[e.jsx(va,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(vp,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(K,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(vp,{className:"h-5 w-5"}),U>0&&e.jsx(st,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:U})]})]}),r.requires_proof_approval&&e.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-lg",children:"📋 This product requires proof approval before production. You'll receive a proof to review after your order is placed."})]})]})]}):e.jsx(Ms,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ml,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Product not found"}),e.jsx(K,{onClick:()=>s("/marketplace"),children:"Back to Marketplace"})]})})}function PCs(){const t=fr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:c}=_ue(),[u,p]=k.useState(!1),[f,g]=k.useState(""),b=async()=>{if(s.length===0){me.error("Your cart is empty");return}p(!0);try{const{data:_,error:j}=await H.functions.invoke("marketplace-checkout",{body:{items:s.map(w=>{var N;return{product_id:w.product.id,variant_id:((N=w.variant)==null?void 0:N.id)||null,quantity:w.quantity,artwork_url:w.artworkUrl||null}}),notes:f.trim()||null}});if(j)throw j;if(_!=null&&_.url)c(),window.open(_.url,"_blank");else throw new Error("No checkout URL received")}catch(_){me.error("Checkout failed: "+_.message)}finally{p(!1)}};return s.length===0?e.jsx(Ms,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(y0,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your cart is empty"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Add some products to get started!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ms,{title:"Shopping Cart",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[s.map(_=>{var j,w;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:_.product.images&&_.product.images.length>0?e.jsx("img",{src:((j=_.product.images.find(N=>N.is_primary))==null?void 0:j.image_url)||_.product.images[0].image_url,alt:_.product.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(y0,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold line-clamp-1",children:_.product.name}),_.variant&&e.jsx("p",{className:"text-sm text-muted-foreground",children:_.variant.name}),e.jsxs("p",{className:"font-medium mt-1",children:["$",a(_).toFixed(2),Number(_.product.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:["+ $",Number(_.product.shipping_fee).toFixed(2)," shipping"]})]}),_.artworkUrl&&e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Artwork uploaded ✓"})})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return r(_.product.id,(N=_.variant)==null?void 0:N.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return n(_.product.id,(N=_.variant)==null?void 0:N.id,_.quantity-1)},disabled:_.quantity<=1,children:e.jsx(f0,{className:"h-3 w-3"})}),e.jsx(ze,{type:"number",value:_.quantity,onChange:N=>{var S;return n(_.product.id,(S=_.variant)==null?void 0:S.id,parseInt(N.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return n(_.product.id,(N=_.variant)==null?void 0:N.id,_.quantity+1)},children:e.jsx($s,{className:"h-3 w-3"})})]})]})]})})},`${_.product.id}-${((w=_.variant)==null?void 0:w.id)||"base"}`)}),e.jsx(K,{variant:"ghost",className:"text-destructive",onClick:c,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((_,j)=>_+j.quantity,0)," items)"]}),e.jsxs("span",{children:["$",o().toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",l().toFixed(2)]})]}),e.jsx(rl,{}),e.jsxs("div",{className:"flex justify-between font-bold text-lg",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",i().toFixed(2)]})]}),e.jsx(rl,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Er,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:f,onChange:_=>g(_.target.value),rows:3,className:"resize-none"})]}),e.jsx(K,{className:"w-full",size:"lg",onClick:b,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(Qa,{className:"h-5 w-5 ml-2"})]})}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Secure checkout powered by Stripe"})]})]})})]})})}function ICs(){const t=fr(),{data:s,isLoading:r}=Qks();return r?e.jsx(Ms,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(ys,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Ms,{title:"My Orders",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ml,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No orders yet"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Start shopping to see your orders here!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ms,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:s.map(n=>{var a,o,l;return e.jsx(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:n.order_number}),e.jsx("span",{className:"text-muted-foreground text-sm ml-2",children:ms(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(st,{className:uCe[n.status],children:uT[n.status]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex -space-x-2",children:[(a=n.items)==null?void 0:a.slice(0,3).map((i,c)=>e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",style:{zIndex:3-c},children:[i.quantity,"×"]},i.id)),n.items&&n.items.length>3&&e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",children:["+",n.items.length-3]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:((o=n.items)==null?void 0:o.length)===1?n.items[0].product_name:`${(l=n.items)==null?void 0:l.length} items`}),e.jsxs("p",{className:"font-semibold",children:["$",Number(n.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.tracking_url&&e.jsxs(K,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(tn,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(da,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const Bze=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function LCs({currentStatus:t,statusHistory:s}){const r=Bze.indexOf(t);return e.jsx("div",{className:"space-y-3",children:Bze.map((n,a)=>{const o=s==null?void 0:s.find(u=>u.status===n),l=ar;return e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center ${l?"bg-green-500 text-white":i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:l?e.jsx(sa,{className:"h-4 w-4"}):i?e.jsx(un,{className:"h-4 w-4"}):e.jsx("span",{className:"text-xs",children:a+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`font-medium ${c?"text-muted-foreground":""}`,children:uT[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ms(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function DCs(){var N;const{orderId:t}=yo(),s=fr(),{data:r,isLoading:n,refetch:a}=Jks(t||""),o=s4s(),l=r4s(),[i,c]=k.useState(!1),[u,p]=k.useState(null),[f,g]=k.useState(""),[b,_]=k.useState(null),j=async S=>{_(S);try{await o.mutateAsync({orderId:t,itemId:S}),me.success("Proof approved!"),a()}catch{me.error("Failed to approve proof")}finally{_(null)}},w=async()=>{if(u){_(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),me.success("Revision requested"),c(!1),g(""),p(null),a()}catch{me.error("Failed to request revision")}finally{_(null)}}};return n?e.jsx(Ms,{title:"Order Details",children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-48 w-full"})]}),e.jsx(ys,{className:"h-96 w-full"})]})}):r?e.jsxs(Ms,{title:`Order ${r.order_number}`,children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"Order Status"}),e.jsx(st,{className:uCe[r.status],children:uT[r.status]})]}),e.jsx(Oe,{children:e.jsx(LCs,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Items"})}),e.jsx(Oe,{className:"space-y-4",children:(N=r.items)==null?void 0:N.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",S.quantity," × $",Number(S.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(S.unit_price)*S.quantity).toFixed(2)]})]}),S.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(z_,{className:"h-4 w-4"}),"View Artwork",e.jsx(tn,{className:"h-3 w-3"})]})]}),S.proof_url&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),e.jsxs("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(z_,{className:"h-4 w-4"}),"View Proof",e.jsx(tn,{className:"h-3 w-3"})]}),S.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{size:"sm",onClick:()=>j(S.id),disabled:b===S.id,children:[b===S.id?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(sh,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{p(S.id),c(!0)},disabled:b===S.id,children:[e.jsx(IL,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),S.proof_status==="approved"&&e.jsxs(st,{className:"bg-green-100 text-green-800",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),S.proof_status==="rejected"&&S.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(st,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.proof_notes})]})]})]},S.id))})]}),r.shipping_name&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(DL,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-medium",children:r.shipping_name}),e.jsxs("p",{className:"text-muted-foreground",children:[r.shipping_address,e.jsx("br",{}),r.shipping_city,", ",r.shipping_state," ",r.shipping_zip]}),r.tracking_number&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracking Number:"}),e.jsx("p",{className:"font-mono font-medium",children:r.tracking_number}),r.tracking_url&&e.jsxs(K,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(tn,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ms(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(rl,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(r.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(r.shipping_total).toFixed(2)]})]})]}),e.jsx(rl,{}),e.jsxs("div",{className:"flex justify-between font-bold text-lg",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(r.total).toFixed(2)]})]}),r.notes&&e.jsxs(e.Fragment,{children:[e.jsx(rl,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Order Notes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.notes})]})]})]})]})})]}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Request Changes"}),e.jsx(Gr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Er,{placeholder:"Describe the changes needed...",value:f,onChange:S=>g(S.target.value),rows:4}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{onClick:w,disabled:!f.trim()||b!==null,children:[b?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Ms,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ml,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Order not found"}),e.jsx(K,{onClick:()=>s("/marketplace/orders"),children:"View All Orders"})]})})}function OCs(){const t=fr(),[s]=Cc();return s.get("session_id"),k.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Ms,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-8 pb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(sa,{className:"h-8 w-8 text-green-600"})}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Thank You for Your Order!"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Your order has been confirmed and is being processed. You'll receive an email confirmation shortly."}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 mb-6 text-left",children:[e.jsxs("h3",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ml,{className:"h-4 w-4"}),"What happens next?"]}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("li",{children:"• We'll review your order and prepare it for production"}),e.jsx("li",{children:"• If your order requires a proof, you'll receive it for approval"}),e.jsx("li",{children:"• Once approved, we'll begin production and ship when ready"}),e.jsx("li",{children:"• You'll receive tracking info when your order ships"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{className:"flex-1",onClick:()=>t("/marketplace/orders"),children:["View My Orders",e.jsx(Qa,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function RCs(){const{user:t}=Ds(),[s,r]=k.useState("store"),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(!1),[u,p]=k.useState(5),[f,g]=k.useState(""),[b,_]=k.useState(!1),[j,w]=k.useState(!1),[N,S]=k.useState(""),[M,L]=k.useState(null),[I,O]=k.useState(!1),{hasSubmittedReview:q,submitReview:U,markPostedToGoogle:B}=RYe(),{data:V}=Plt(),{data:Y,isLoading:Q}=Elt(),{data:ee,isLoading:X}=d4s(n),{data:ie,isLoading:re}=u4s(t==null?void 0:t.id),{data:oe=0}=m4s(t==null?void 0:t.id),ce=p4s(),ge=new Set((ie==null?void 0:ie.map(Ie=>Ie.item_id))||[]),ye=async()=>{if(o)try{const Ie=await ce.mutateAsync(o.id);o.item_type==="reelflow_credits"?me.success(`🎬 ${o.max_quantity} ReelFlow credits added to your balance!`):me.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Ie){me.error(Ie.message||"Failed to purchase item")}},ue=async()=>{if(!f.trim()){me.error("Please write a review");return}_(!0);const Ie=await U(u,f);_(!1),Ie.success?(me.success("Thank you for your review! You earned 25 points!"),S(f),w(!0),g(""),p(5)):me.error(Ie.error||"Failed to submit review")},pe=()=>{navigator.clipboard.writeText(N),me.success("Review copied to clipboard!")},_e=()=>{B(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},$e=()=>{w(!1),c(!1),S("")};return Q||X||re?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-24 w-full"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(Ie=>e.jsx(ys,{className:"h-64"},Ie))})]})}):e.jsxs(Ms,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Reward Store"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Redeem your points for exclusive rewards"})]}),e.jsx(Ee,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Jn,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Spendable Points"}),e.jsx("p",{className:"text-3xl font-bold text-primary",children:oe.toLocaleString()})]})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xo,{className:"h-4 w-4"}),e.jsx("span",{children:"Earn points by attending events"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(eh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(yf,{open:I,onOpenChange:O,children:e.jsxs(Ee,{className:"border-primary/20",children:[e.jsx(vf,{asChild:!0,children:e.jsx(Pt,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(xo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-base",children:"How to Earn Points"}),e.jsx(gr,{children:"See all the ways you can earn spendable points"})]})]}),I?e.jsx(ff,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Eo,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(bf,{children:e.jsx(Oe,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[V==null?void 0:V.filter(Ie=>Ie.is_active).map(Ie=>{const Ce=xe=>{switch(xe){case"event_attendance":return e.jsx(hn,{className:"h-5 w-5"});case"leave_review":return e.jsx(Jn,{className:"h-5 w-5"});case"add_listing":return e.jsx(bn,{className:"h-5 w-5"});case"first_contact":return e.jsx(pr,{className:"h-5 w-5"});case"first_video":return e.jsx(An,{className:"h-5 w-5"});case"first_community_post":return e.jsx(so,{className:"h-5 w-5"});default:return e.jsx(ko,{className:"h-5 w-5"})}};return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50 border",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center text-primary shrink-0",children:Ce(Ie.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Ie.action_name}),Ie.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ie.description})]}),e.jsxs(st,{variant:"secondary",className:"font-bold shrink-0",children:["+",Ie.points]})]},Ie.id)}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/20 flex items-center justify-center text-orange-500 shrink-0",children:e.jsx(eh,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Streak Bonuses"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Attend consecutive weeks for bonus points!"})]}),e.jsx(st,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!q&&e.jsx(Ee,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-yellow-500/20 flex items-center justify-center",children:e.jsx(so,{className:"h-6 w-6 text-yellow-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Earn 25 Free Points!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave a quick review and earn 25 spendable points"})]})]}),e.jsxs(K,{onClick:()=>c(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[e.jsx(Jn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(ba,{value:s,onValueChange:r,children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"store",className:"flex items-center gap-2",children:[e.jsx(y0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(ns,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"h-4 w-4"}),"My Rewards",ie&&ie.length>0&&e.jsx(st,{variant:"secondary",className:"ml-1",children:ie.length})]})]}),e.jsxs(bs,{value:"store",className:"mt-6",children:[Y&&Y.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(K,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),Y.map(Ie=>e.jsxs(K,{variant:n===Ie.id?"default":"outline",size:"sm",onClick:()=>a(Ie.id),children:[Ie.icon&&`${Ie.icon} `,Ie.name]},Ie.id))]}),!ee||ee.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(ko,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No items available"}),e.jsx("p",{className:"text-sm",children:"Check back later for new rewards!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ee.map(Ie=>{const Ce=Ie.item_type==="reelflow_credits",xe=!Ce&&ge.has(Ie.id),we=!Ce&&Ie.max_quantity!==null&&Ie.current_quantity===0,Le=oe>=Ie.points_cost;return e.jsxs(Ee,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${xe?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>L(Ie),children:[Ie.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Ie.preview_image_url,alt:Ie.name,className:"w-full h-full object-cover"}),xe&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(st,{className:"bg-green-500 text-white",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Owned"]})}),we&&!xe&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(st,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(ko,{className:"h-12 w-12 text-muted-foreground/50"}),xe&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(st,{className:"bg-green-500 text-white",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Pt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Rt,{className:"text-lg",children:Ie.name}),e.jsxs(st,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Ie.points_cost]})]}),Ie.category&&e.jsxs(st,{variant:"outline",className:"w-fit",children:[Ie.category.icon&&`${Ie.category.icon} `,Ie.category.name]})]}),e.jsxs(Oe,{children:[e.jsx(gr,{className:"mb-4 line-clamp-2",children:Ie.description||"No description available"}),Ie.max_quantity!==null&&!xe&&!Ce&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Ie.current_quantity," of ",Ie.max_quantity," remaining"]}),Ce&&e.jsxs("p",{className:"text-xs text-violet-600 font-medium mb-3",children:["🎬 Grants ",Ie.max_quantity," ReelFlow credits per purchase"]}),xe?e.jsx(K,{className:"w-full",onClick:tt=>{tt.stopPropagation(),Ie.file_url&&Tye(Ie.file_url,Ie.name)},disabled:!Ie.file_url,children:Ie.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(K,{className:"w-full",onClick:tt=>{tt.stopPropagation(),l(Ie)},disabled:we||!Le,children:we?"Sold Out":Le?e.jsxs(e.Fragment,{children:[e.jsx(y0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Ie.points_cost-oe} more pts`})]})]},Ie.id)})})]}),e.jsx(bs,{value:"my-rewards",className:"mt-6",children:!ie||ie.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Ml,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No rewards yet"}),e.jsx("p",{className:"text-sm",children:"Purchase items from the store to see them here!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ie.map(Ie=>{var Ce,xe,we,Le,tt,Te,pt;return e.jsxs(Ee,{className:"overflow-hidden",children:[(Ce=Ie.item)!=null&&Ce.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Ie.item.preview_image_url,alt:((xe=Ie.item)==null?void 0:xe.name)||"Reward",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"aspect-video bg-muted flex items-center justify-center",children:e.jsx(ko,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Pt,{className:"pb-2",children:[e.jsx(Rt,{className:"text-lg",children:((we=Ie.item)==null?void 0:we.name)||"Unknown Item"}),e.jsxs(gr,{className:"text-xs",children:["Purchased for ",Ie.points_spent," points • ",new Date(Ie.purchased_at).toLocaleDateString()]})]}),e.jsx(Oe,{children:((Le=Ie.item)==null?void 0:Le.item_type)==="reelflow_credits"?e.jsxs(K,{className:"w-full",variant:"outline",disabled:!0,children:[e.jsx(sa,{className:"h-4 w-4 mr-2 text-green-500"}),(tt=Ie.item)==null?void 0:tt.max_quantity," Credits Applied"]}):e.jsx(K,{className:"w-full",onClick:()=>{var fe,qe;(fe=Ie.item)!=null&&fe.file_url&&Tye(Ie.item.file_url,(qe=Ie.item)==null?void 0:qe.name)},disabled:!((Te=Ie.item)!=null&&Te.file_url),children:((pt=Ie.item)==null?void 0:pt.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Ie.id)})})})]})]}),e.jsx(kc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Confirm Purchase"}),e.jsxs(sc,{children:['Are you sure you want to purchase "',o==null?void 0:o.name,'" for ',o==null?void 0:o.points_cost," points?",(o==null?void 0:o.item_type)==="reelflow_credits"&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("br",{}),"🎬 ",e.jsxs("strong",{children:[o==null?void 0:o.max_quantity," ReelFlow credits"]})," will be added to your balance instantly."]}),e.jsx("br",{}),e.jsx("br",{}),"You currently have ",e.jsxs("strong",{children:[oe," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[oe-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:ye,disabled:ce.isPending,children:ce.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(fs,{open:i,onOpenChange:Ie=>{!Ie&&j?$e():c(Ie)},children:e.jsx(ps,{children:j?e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(Gr,{children:"Would you also share your review on Google? It helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your review:"}),e.jsxs("p",{className:"text-sm italic",children:['"',N,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:pe,children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(qn,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:$e,children:"Maybe Later"}),e.jsxs(K,{onClick:_e,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Leave a Review"}),e.jsx(Gr,{children:"Share your experience with LevelUp and earn 25 spendable points!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Rating"}),e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(Ie=>e.jsx("button",{type:"button",onClick:()=>p(Ie),className:"focus:outline-none",children:e.jsx(Jn,{className:`h-8 w-8 transition-colors ${u>=Ie?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Ie))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(Er,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Ie=>g(Ie.target.value),rows:4})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:ue,disabled:b,className:"bg-yellow-600 hover:bg-yellow-700",children:b?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(fs,{open:!!M,onOpenChange:()=>L(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[M==null?void 0:M.name,e.jsxs(st,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),M==null?void 0:M.points_cost]})]}),(M==null?void 0:M.category)&&e.jsxs(st,{variant:"outline",className:"w-fit",children:[M.category.icon&&`${M.category.icon} `,M.category.name]})]}),(M==null?void 0:M.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:M.preview_image_url,alt:M.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(M==null?void 0:M.description)||"No description available"}),(M==null?void 0:M.item_type)==="reelflow_credits"&&e.jsxs("p",{className:"text-sm text-violet-600 font-medium",children:["🎬 Grants ",M==null?void 0:M.max_quantity," ReelFlow credits per purchase"]}),(M==null?void 0:M.item_type)!=="reelflow_credits"&&(M==null?void 0:M.max_quantity)!==null&&!ge.has((M==null?void 0:M.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[M==null?void 0:M.current_quantity," of ",M==null?void 0:M.max_quantity," remaining"]})]}),e.jsx(qn,{children:M&&M.item_type!=="reelflow_credits"&&ge.has(M.id)?e.jsx(K,{className:"w-full",onClick:()=>{M.file_url&&Tye(M.file_url,M.name)},disabled:!M.file_url,children:M.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Access"]})}):M&&e.jsx(K,{className:"w-full",onClick:()=>{L(null),l(M)},disabled:M.item_type!=="reelflow_credits"&&M.max_quantity!==null&&M.current_quantity===0||oe{const{user:t}=Ds(),s=Qt(),r=mt({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await H.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(p)throw p;return u||[]},enabled:!!t}),n=mt({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await H.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(p)throw p;return u||[]},enabled:!!t}),a=Lt({mutationFn:async u=>{const{data:p,error:f}=await H.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Lt({mutationFn:async({id:u,...p})=>{const{data:f,error:g}=await H.from("smart_presentations").update(p).eq("id",u).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Lt({mutationFn:async u=>{const{data:p,error:f}=await H.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation published!")}}),i=Lt({mutationFn:async u=>{const{error:p}=await H.from("smart_presentations").update({status:"archived"}).eq("id",u);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation archived")}}),c=Lt({mutationFn:async u=>{const{error:p}=await H.from("smart_presentation_templates").insert({owner_user_id:t.id,name:u.title+" Template",description:"Created from "+u.title,template_type:"custom",icon:"📄",sections:u.sections,cta_config:{type:u.cta_type,label:u.cta_label},is_system:!1});if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentation-templates"]}),me.success("Saved as template!")}});return{presentations:r.data||[],templates:n.data||[],isLoading:r.isLoading,templatesLoading:n.isLoading,createPresentation:a,updatePresentation:o,publishPresentation:l,archivePresentation:i,saveAsTemplate:c}},FCs=()=>{const t=fr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=xct(),o=i=>i.status==="draft"?e.jsx(st,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(st,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(st,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(st,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const c=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(c),me.success("Link copied!")};return e.jsx(Ms,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-serif font-bold text-foreground",children:"Smart Presentations"})}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create personalized, video-first presentations for your clients"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(ys,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ey,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No presentations yet"}),e.jsx("p",{className:"text-muted-foreground mb-6 max-w-md",children:"Create your first Smart Presentation to impress clients with personalized, video-first content."}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Sn,{className:"h-5 w-5 text-primary"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold truncate",children:i.title}),o(i)]}),e.jsxs("div",{className:"flex items-center gap-x-3 gap-y-0.5 flex-wrap text-sm text-muted-foreground mt-0.5",children:[i.client_name&&e.jsx("span",{children:i.client_name}),e.jsxs("span",{children:["Created ",ms(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ln,{className:"h-3 w-3"})," ",i.view_count," view",i.view_count!==1?"s":""]}),i.cta_clicked_count>0&&e.jsx("span",{className:"text-emerald-600 font-medium",children:"CTA clicked"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap sm:shrink-0",children:[i.status==="published"&&i.share_token&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Ma,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(tn,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Ma,{onClick:()=>a.mutate(i),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Ma,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(kM,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},$ze={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."}]},zCs=[{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 BCs(t){const s=$ze[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries($ze))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return zCs}function $Cs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState("script"),[i,c]=k.useState(0),[u,p]=k.useState(0),{canRecord:f}=Vat(),g=CC(),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,S]=k.useState(!0),[M,L]=k.useState(!1),[I,O]=k.useState(null),q=BCs(t),U=()=>{l("script"),c(0),p(0),_(""),w(!1),S(!0),L(!1),O(null)},B=X=>{!X&&(o==="uploading"||o==="processing")||(a(X),X||U())},V=X=>{O(X),_(q[X].text),w(!1)},Y=()=>{l("record"),S(b.trim().length>0)},Q=()=>{_(""),S(!1),l("record")},ee=k.useCallback(async(X,ie)=>{l("uploading");try{const re=t||"Presentation Video",{videoId:oe,uploadUrl:ce,libraryId:ge}=await xR(re),{apiKey:ye}=await gR(oe),ue=new XMLHttpRequest;ue.upload.onprogress=Ie=>{Ie.lengthComputable&&c(Ie.loaded/Ie.total*100)},await new Promise((Ie,Ce)=>{ue.onload=()=>ue.status>=200&&ue.status<300?Ie():Ce(new Error("Upload failed")),ue.onerror=()=>Ce(new Error("Upload failed")),ue.open("PUT",ce),ue.setRequestHeader("AccessKey",ye),ue.send(X)}),l("processing");let pe=0;const _e=Date.now(),$e=9e4;let Ae=null;for(;pe<4;){if(await new Promise(Ce=>setTimeout(Ce,3e3)),Date.now()-_e>$e){const Ce=X.size/1048576,xe=`https://iframe.mediadelivery.net/embed/${ge}/${oe}?responsive=true`;await g.mutateAsync({bunny_video_id:oe,playback_url:xe,file_size_mb:Ce,title:re,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(xe),me.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Ie=await wA(oe);if(pe=Ie.status,p(Ie.encodeProgress||0),pe===4)Ae={playbackUrl:Ie.directPlayUrl,thumbnailUrl:Ie.thumbnailUrl,previewUrl:Ie.previewUrl||null,duration:Ie.length||ie,fileSizeMb:(Ie.storageSize||X.size)/(1024*1024)};else if(pe===5||pe===6)throw new Error("Video processing failed")}if(!Ae)throw new Error("No video data");await g.mutateAsync({bunny_video_id:oe,contact_id:s||void 0,playback_url:Ae.playbackUrl,thumbnail_url:Ae.thumbnailUrl,preview_url:Ae.previewUrl,duration_seconds:Ae.duration,file_size_mb:Ae.fileSizeMb,title:re,status:"ready",touch_type:"presentation"}),r(Ae.playbackUrl),me.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(re){console.error("Recording upload error:",re),me.error("Failed to process video. Please try again."),l("record")}},[t,s,r,g]);return e.jsxs(fs,{open:n,onOpenChange:B,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(An,{className:"h-3.5 w-3.5"}),"Record"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto !top-[5%] !translate-y-0 sm:!top-[5%] sm:!translate-y-0",children:[e.jsx(_s,{children:e.jsxs(vs,{children:[o==="script"&&`Prepare your script for "${t}"`,o==="record"&&`Record video for "${t}"`,o==="uploading"&&"Uploading...",o==="processing"&&"Processing...",o==="done"&&"Done!"]})}),o==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a starter script below, edit it to make it yours, or skip and speak freely."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starter Scripts"}),e.jsx("div",{className:"grid gap-2",children:q.map((X,ie)=>e.jsxs("button",{onClick:()=>V(ie),className:It("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",I===ie?"border-primary bg-primary/5 ring-1 ring-primary":"border-border"),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Sn,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:X.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:X.text})]},ie))})]}),b&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!j&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:"h-7 text-xs gap-1",children:[e.jsx(Ra,{className:"h-3 w-3"}),"Edit"]})]}),j?e.jsx(Er,{value:b,onChange:X=>_(X.target.value),rows:5,placeholder:"Type your script here...",className:"text-sm"}):e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-sm text-foreground leading-relaxed",children:b})]}),!b&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Or Write Your Own"}),e.jsx(Er,{value:b,onChange:X=>{_(X.target.value),O(null)},rows:4,placeholder:"Type your own script here...",className:"text-sm"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:Q,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{onClick:Y,disabled:!1,children:b.trim()?"Continue with Script":"Continue Without Script"})]})]}),!f&&o==="record"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[e.jsx(Ku,{className:"h-10 w-10 text-destructive"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You've reached your video storage limit. Delete some videos to free up space."})]}):o==="record"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Record up to 60 seconds. Saved to your library & auto-attached."}),b.trim()&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>S(!N),className:"h-7 text-xs gap-1",children:[N?e.jsx(kp,{className:"h-3 w-3"}):e.jsx(Ln,{className:"h-3 w-3"}),N?"Hide Script":"Show Script"]})]}),e.jsx(yme,{maxDurationSeconds:60,onRecordingComplete:ee,onRecordingStateChange:L,onError:X=>me.error(X),teleprompterContent:b.trim()?e.jsx(olt,{text:b,isVisible:N,onToggleVisibility:()=>S(!N),isRecording:M,startCountdown:!1}):void 0}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l("script"),className:"text-xs text-muted-foreground",children:"← Back to script"})]}):o==="uploading"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ws,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Bi,{value:i,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Uploading... ",Math.round(i),"%"]})]})]}):o==="processing"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ws,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Bi,{value:u,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Processing... ",Math.round(u),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"This usually takes less than a minute"})]})]}):o==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(xi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Video attached!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved to your video library"})]}):null]})]})}function qCs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState("idle"),[u,p]=k.useState(0),f=k.useRef(null),g=CC(),{data:b}=Whe(),_=(b==null?void 0:b.total_storage_mb)||0,w=((b==null?void 0:b.max_storage_mb)||1024)-_,N=()=>{l(null),c("idle"),p(0)},S=q=>{!q&&i!=="idle"&&i!=="done"||(a(q),q||N())},M=q=>{var V;const U=(V=q.target.files)==null?void 0:V[0];if(!U)return;if(!U.type.startsWith("video/")){me.error("Please select a video file");return}const B=U.size/(1024*1024);if(B>500){me.error("Video file must be less than 500MB");return}if(B>w){me.error(`Not enough storage. You have ${w.toFixed(1)} MB remaining.`);return}l(U)},L=k.useCallback(async()=>{if(o){c("creating"),p(0);try{const q=t||o.name,{data:U,error:B}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:q,isAgentVideo:!0}});if(B)throw new Error(B.message);const{videoId:V,libraryId:Y}=U;c("uploading");const{data:Q,error:ee}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:V,isAgentVideo:!0}});if(ee)throw new Error(ee.message);await new Promise((re,oe)=>{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?re():oe(new Error(`Upload failed (${ce.status})`))),ce.addEventListener("error",()=>oe(new Error("Upload failed"))),ce.open("PUT",Q.uploadUrl),ce.setRequestHeader("AccessKey",Q.apiKey),ce.send(o)}),c("processing");const X=o.size/(1024*1024),ie=`https://iframe.mediadelivery.net/embed/${Y}/${V}`;await g.mutateAsync({bunny_video_id:V,playback_url:ie,file_size_mb:X,title:q,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(ie),c("done"),me.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch(q){console.error("Upload error:",q),me.error(q instanceof Error?q.message:"Failed to upload video"),c("idle")}}},[o,t,s,r,g]),I=()=>{switch(i){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${u}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},O=i!=="idle"&&i!=="done";return e.jsxs(fs,{open:n,onOpenChange:S,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(li,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsxs(vs,{children:['Upload Video for "',t,'"']})}),e.jsxs("div",{className:"space-y-4 py-2",children:[o?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(An,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(o.size/(1024*1024)).toFixed(1)," MB"]})]}),!O&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var q;return(q=f.current)==null?void 0:q.click()},children:[e.jsx(li,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:f,type:"file",accept:"video/*",className:"hidden",onChange:M,disabled:O}),O&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:I()})]}),e.jsx(Bi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),disabled:O,children:"Cancel"}),e.jsx(K,{onClick:L,disabled:!o||O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const qze=[{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"}],Uze=()=>{const t=fr(),{id:s}=yo(),{user:r}=Ds(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=xct(),{isGmailConnected:c,gmailEmail:u}=Gx(),[p,f]=k.useState(!1),[g,b]=k.useState("client"),[_,j]=k.useState(!1),[w,N]=k.useState(""),[S,M]=k.useState([]),[L,I]=k.useState(!1),[O,q]=k.useState(null),[U,B]=k.useState(!1),[V,Y]=k.useState(""),[Q,ee]=k.useState(""),[X,ie]=k.useState(""),[re,oe]=k.useState("buyer"),[ce,ge]=k.useState(""),[ye,ue]=k.useState(null),[pe,_e]=k.useState(""),[$e,Ae]=k.useState([]),[Ie,Ce]=k.useState("schedule_call"),[xe,we]=k.useState("Schedule a Call"),[Le,tt]=k.useState(""),[Te,pt]=k.useState(""),[fe,qe]=k.useState(null),[at,et]=k.useState(s||null),[Me,rt]=k.useState(null),[He,ct]=k.useState(!1),Ue=async(xt,Es)=>{if(!r)return;const ur=5*1024*1024;if(xt.size>ur){me.error("Image must be under 5MB");return}if(!xt.type.startsWith("image/")){me.error("Please upload an image file");return}qe(Es);try{const Mr=xt.name.split(".").pop()||"jpg",Lr=`${r.id}/${Date.now()}.${Mr}`,{error:fn}=await H.storage.from("listing-photos").upload(Lr,xt);if(fn)throw fn;const{data:{publicUrl:ki}}=H.storage.from("listing-photos").getPublicUrl(Lr);Dt(Es,{image_url:ki}),me.success("Image uploaded")}catch{me.error("Failed to upload image")}finally{qe(null)}};k.useEffect(()=>{s&&Ze(s)},[s]);const Ze=async xt=>{const{data:Es,error:ur}=await H.from("smart_presentations").select("*").eq("id",xt).single();if(ur||!Es)return;const Mr=Es;if(j(!0),_e(Mr.title),Y(Mr.client_name||""),ge(Mr.property_address||""),Ae(Mr.sections||[]),Ce(Mr.cta_type||"schedule_call"),we(Mr.cta_label||"Schedule a Call"),tt(Mr.cta_url||""),pt(Mr.heading||""),rt(Mr.share_token),ct(Mr.status==="published"),et(Mr.id),b("builder"),Mr.contact_id){const{data:Lr}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Mr.contact_id).maybeSingle();Lr&&(q(Lr),ee(Lr.email||""),ie(Lr.phone||""))}};k.useEffect(()=>{if(!r||w.length<1){M([]);return}const xt=setTimeout(async()=>{I(!0);const{data:Es}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${w}%,last_name.ilike.%${w}%,email.ilike.%${w}%`).limit(10);M(Es||[]),I(!1)},300);return()=>clearTimeout(xt)},[w,r]);const Qe=xt=>{q(xt),Y(`${xt.first_name} ${xt.last_name||""}`.trim()),ee(xt.email||""),ie(xt.phone||""),B(!1)},We=async()=>{if(!V.trim()){me.error("Client name is required");return}const xt=V.trim().split(" "),Es=xt[0],ur=xt.slice(1).join(" ")||null,{data:Mr,error:Lr}=await H.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:Es,last_name:ur,email:Q||null,phone:X||null,lead_source:"Smart Presentation"}).select().single();if(Lr){me.error("Failed to create client");return}q(Mr),me.success("Client created & saved to Agent OS"),b("template")},Je=xt=>{ue(xt);const Es=(xt.sections||[]).map(ur=>({...ur,is_visible:!0,video_url:"",text:""}));if(Ae(Es),_e(xt.name+(V?` for ${V}`:"")),xt.cta_config){const ur=xt.cta_config;Ce(ur.type||"schedule_call"),we(ur.label||"Schedule a Call")}b("builder")},it=()=>{Ae([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),_e(V?`Presentation for ${V}`:"New Presentation"),b("builder")},Dt=(xt,Es)=>{Ae(ur=>ur.map((Mr,Lr)=>Lr===xt?{...Mr,...Es}:Mr))},Vt=xt=>{Dt(xt,{is_visible:!$e[xt].is_visible})},hs=()=>{Ae(xt=>[...xt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Ts=xt=>{Ae(Es=>Es.filter((ur,Mr)=>Mr!==xt))},Cs=async()=>{if(!pe.trim()){me.error("Title is required");return}try{if(at){const xt=await l.mutateAsync({id:at,title:pe,sections:$e,client_name:V,property_address:ce||null,cta_type:Ie,cta_label:xe,cta_url:Le||null,heading:Te||null});me.success("Saved")}else{const xt=await o.mutateAsync({title:pe,contact_id:(O==null?void 0:O.id)||void 0,client_name:V,property_address:ce||void 0,template_id:(ye==null?void 0:ye.id)||void 0,sections:$e,cta_type:Ie,cta_label:xe,cta_url:Le||void 0,heading:Te||void 0});et(xt.id),rt(xt.share_token),me.success("Presentation created!")}}catch(xt){console.error("Failed to save presentation:",xt);const Es=(xt==null?void 0:xt.message)||(xt==null?void 0:xt.toString())||"Unknown error";me.error(`Failed to save: ${Es}`)}},cs=async()=>{try{await Cs();const xt=at;if(xt){const Es=await i.mutateAsync(xt);rt(Es.share_token),ct(!0),b("share")}}catch(xt){console.error("Failed to publish presentation:",xt),me.error(`Failed to publish: ${(xt==null?void 0:xt.message)||"Unknown error"}`)}},er=Me?`https://presentations.relevelup.com/${Me}`:"";return e.jsx(Ms,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(Ja,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:_?"Edit Presentation":"Create Smart Presentation"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[g==="client"&&"Who is this presentation for?",g==="template"&&"Choose a starting template",g==="builder"&&"Customize your presentation",g==="share"&&"Share with your client"]})]})]}),!_&&e.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((xt,Es)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:It("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",g===xt?"bg-primary text-primary-foreground":Es<["client","template","builder","share"].indexOf(g)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Es<["client","template","builder","share"].indexOf(g)?e.jsx(va,{className:"h-4 w-4"}):Es+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:xt}),Es<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},xt))}),g==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{q(null),Y(""),ee(""),ie(""),B(!1),b("template")},className:"w-full group flex items-center justify-between gap-4 rounded-xl border border-dashed border-primary/30 bg-primary/5 hover:bg-primary/10 transition-all p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Bn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Skip — Use as Lead Gen Tool"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No specific client. Share broadly to capture new leads."})]})]}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors shrink-0"})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:w,onChange:xt=>N(xt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[L&&e.jsx(ys,{className:"h-12 w-full"}),S.map(xt=>e.jsxs("button",{onClick:()=>Qe(xt),className:It("w-full text-left p-3 rounded-lg border transition-colors",(O==null?void 0:O.id)===xt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[xt.first_name," ",xt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xt.email||xt.phone||"No contact info"})]},xt.id)),!w&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),w&&S.length===0&&!L&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),O&&e.jsxs(K,{onClick:()=>b("template"),className:"w-full gap-2",children:["Continue with ",O.first_name,e.jsx(Qa,{className:"h-4 w-4"})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Tl,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(be,{className:"text-xs",children:"Name *"}),e.jsx(ze,{value:V,onChange:xt=>{Y(xt.target.value),B(!0),q(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Email"}),e.jsx(ze,{value:Q,onChange:xt=>ee(xt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Phone"}),e.jsx(ze,{value:X,onChange:xt=>ie(xt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Client Type"}),e.jsxs(Ks,{value:re,onValueChange:oe,children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"}),e.jsx(Mt,{value:"recruit",children:"Recruit"}),e.jsx(Mt,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Property Address"}),e.jsx(ze,{value:ce,onChange:xt=>ge(xt.target.value),placeholder:"Optional"})]})]}),U&&V&&e.jsxs(K,{onClick:We,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(Qa,{className:"h-4 w-4"})]})]})]})]})]}),g==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ba,{defaultValue:"system",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"mine",children:"My Core Templates"}),e.jsx(ns,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(ns,{value:"blank",children:"+ Start Blank"})]}),e.jsx(bs,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(xt=>e.jsx(ys,{className:"h-32"},xt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(xt=>!xt.is_system).length===0?e.jsx("p",{className:"text-muted-foreground col-span-2 text-center py-8",children:"You haven't saved any templates yet. Create a presentation and save it as a template!"}):n.filter(xt=>!xt.is_system).map(xt=>e.jsx(Vze,{template:xt,onSelect:Je},xt.id))})}),e.jsx(bs,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(xt=>xt.is_system).map(xt=>e.jsx(Vze,{template:xt,onSelect:Je},xt.id))})}),e.jsx(bs,{value:"blank",className:"mt-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),e.jsx(K,{onClick:it,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{variant:"outline",onClick:()=>b("client"),className:"gap-2",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back"]})]}),g==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Presentation Title"}),e.jsx(ze,{value:pe,onChange:xt=>_e(xt.target.value)})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Page Heading"}),e.jsx(ze,{value:Te,onChange:xt=>pt(xt.target.value),placeholder:V?`Welcome, ${V}!`:"e.g. Welcome! or Your Custom Listing Plan"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:['The main heading visitors see. Leave blank for "Welcome, ',"",'!"']})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Client Name"}),e.jsx(ze,{value:V,onChange:xt=>Y(xt.target.value)})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:ce,onChange:xt=>ge(xt.target.value),placeholder:"Optional"})]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sections"}),e.jsx(K,{variant:"outline",size:"sm",onClick:hs,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:$e.map((xt,Es)=>e.jsx(Ee,{className:It(!xt.is_visible&&"opacity-50"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 pt-1",children:[e.jsx(Cu,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:xt.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ze,{value:xt.title,onChange:ur=>Dt(Es,{title:ur.target.value}),className:"font-semibold border-none p-0 h-auto text-base focus-visible:ring-0 bg-transparent"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Vt(Es),children:xt.is_visible?e.jsx(Ln,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ts(Es),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]}),e.jsx(ze,{value:xt.description||"",onChange:ur=>Dt(Es,{description:ur.target.value}),placeholder:"Section description...",className:"text-sm"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs",children:"Video URL"}),e.jsx(ze,{value:xt.video_url||"",onChange:ur=>Dt(Es,{video_url:ur.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx($Cs,{sectionTitle:xt.title,contactId:O==null?void 0:O.id,onVideoReady:ur=>Dt(Es,{video_url:ur})}),e.jsx(qCs,{sectionTitle:xt.title,contactId:O==null?void 0:O.id,onVideoReady:ur=>Dt(Es,{video_url:ur})}),e.jsx(lCe,{userId:r==null?void 0:r.id,onSelect:ur=>Dt(Es,{video_url:ur})})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),xt.image_url?e.jsxs("div",{className:"relative mt-1 rounded-lg overflow-hidden border border-border bg-muted/30 group",children:[e.jsx("img",{src:xt.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Dt(Es,{image_url:""}),children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]}):e.jsxs("label",{className:"mt-1 flex items-center gap-2 cursor-pointer rounded-lg border border-dashed border-border hover:border-primary/50 p-3 transition-colors",children:[fe===Es?e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(o1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:fe===Es?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:fe===Es,onChange:ur=>{var Lr;const Mr=(Lr=ur.target.files)==null?void 0:Lr[0];Mr&&Ue(Mr,Es),ur.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Text (optional)"}),e.jsx(py,{content:xt.text||"",onChange:ur=>Dt(Es,{text:ur}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Es))})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Call to Action"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"CTA Type"}),e.jsxs(Ks,{value:Ie,onValueChange:xt=>{Ce(xt);const Es=qze.find(ur=>ur.value===xt);Es&&we(Es.label)},children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:qze.map(xt=>e.jsx(Mt,{value:xt.value,children:xt.label},xt.value))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Button Label"}),e.jsx(ze,{value:xe,onChange:xt=>we(xt.target.value)})]}),e.jsxs("div",{children:[e.jsxs(be,{children:["Link URL ",e.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),e.jsx(ze,{value:Le,onChange:xt=>tt(xt.target.value),placeholder:"https://calendly.com/..."}),!Le&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Without a URL, clients will see a contact form — their info gets added to your contacts and you'll receive an email notification."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[!_&&e.jsxs(K,{variant:"outline",onClick:()=>b("template"),className:"gap-2",children:[e.jsx(Ja,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:Cs,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:cs,disabled:i.isPending,className:"gap-2",children:[e.jsx(Bn,{className:"h-4 w-4"}),He?"Update & Reshare":"Publish & Share"]})]})]})]}),g==="share"&&Me&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mb-4",children:e.jsx(va,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your Presentation is Live!"}),e.jsxs("p",{className:"text-muted-foreground mb-6 max-w-md",children:["Share this link with ",V||"your client",". You'll be notified when they view it."]}),e.jsxs("div",{className:"flex items-center gap-2 w-full max-w-lg",children:[e.jsx(ze,{value:er,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(er),me.success("Link copied!")},children:e.jsx(gi,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{const xt=`Hi ${V||""}! I put together something for you — check it out: ${er}`;navigator.clipboard.writeText(xt),me.success("Message copied!")},children:[e.jsx(so,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{c?f(!0):window.open(`mailto:${Q||""}?subject=${encodeURIComponent(pe)}&body=${encodeURIComponent(`Hi ${(O==null?void 0:O.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${er} Looking forward to connecting!`)}`)},children:[e.jsx(cr,{className:"h-4 w-4"}),"Send Email"]})]}),c&&e.jsx(Uw,{open:p,onOpenChange:f,contact:O?{id:O.id,first_name:O.first_name,last_name:O.last_name,email:Q||O.email||""}:Q?{id:"",first_name:(V==null?void 0:V.split(" ")[0])||"",last_name:(V==null?void 0:V.split(" ").slice(1).join(" "))||"",email:Q}:void 0,defaultSubject:pe,defaultBody:`Hi ${(O==null?void 0:O.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${er} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>b("builder"),children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},Vze=({template:t,onSelect:s})=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Oe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(st,{variant:"outline",className:"text-xs capitalize",children:t.template_type}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(t.sections||[]).length," sections"]})]})]})]}),e.jsx(K,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),UCs=()=>{var j;const{shareToken:t}=yo(),[s,r]=k.useState(null),[n,a]=k.useState(!0),[o,l]=k.useState(0),[i,c]=k.useState(!1);k.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),k.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:w,error:N}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(N||!w){c(!0),a(!1);return}const{data:S}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let M;if(S!=null&&S.brokerage_id){const{data:I}=await H.from("brokerages").select("name").eq("id",S.brokerage_id).single();M=(I==null?void 0:I.name)||void 0}let L=null;if(w.contact_id){const{data:I}=await H.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();L=I}r({...w,owner_name:S==null?void 0:S.name,owner_email:S==null?void 0:S.email,owner_phone:S==null?void 0:S.phone,owner_avatar:S==null?void 0:S.avatar_url,owner_title:(S==null?void 0:S.title)||void 0,brokerage_name:M,contact_name:L?[L.first_name,L.last_name].filter(Boolean).join(" "):void 0,contact_email:(L==null?void 0:L.email)||void 0,contact_phone:(L==null?void 0:L.phone)||void 0}),a(!1);try{await H.rpc("log_presentation_view",{p_presentation_id:w.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await H.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(ys,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const f=s.sections.filter(w=>w.is_visible!==!1),g=f[o],b=w=>{const N=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(N)return`https://www.youtube.com/embed/${N[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const L=w.replace("/play/","/embed/"),I=L.includes("?")?"&":"?";return`${L}${I}responsive=true`}if(w.includes("iframe.mediadelivery.net")){if(w.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const I=w.includes("?")?"&":"?";return`${w}${I}responsive=true`}return""}const S=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const M=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return M?`https://iframe.mediadelivery.net/embed/${M[1]}/${M[2]}?responsive=true`:w},_=!!((j=s.cta_url)!=null&&j.trim());return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})]})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[g!=null&&g.video_url&&b(g.video_url)?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:b(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"})}):g!=null&&g.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:g.image_url,alt:g.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:g==null?void 0:g.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:g==null?void 0:g.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:g==null?void 0:g.description})]}),(g==null?void 0:g.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:g.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:f.map((w,N)=>e.jsx("button",{onClick:()=>l(N),className:It("w-full text-left p-4 rounded-xl border transition-all",o===N?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(N+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:w.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},N))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),_?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(tn,{className:"h-5 w-5 ml-2"})]}):e.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:e.jsx(cGe,{presentationId:s.id,ctaLabel:s.cta_label,agentName:s.owner_name||void 0,prefillName:s.contact_name,prefillEmail:s.contact_email,prefillPhone:s.contact_phone})})]})]}),e.jsx("footer",{className:"border-t border-gray-100 bg-white mt-12 py-6 text-center text-xs text-gray-400",children:"Powered by LevelUp"})]})};function VCs({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=Wkt(t),o=Ykt(),l=Xkt(),i=Qkt(),c=Jkt(),[u,p]=k.useState(""),[f,g]=k.useState("rating"),b=async N=>{r(N),N&&(!n||n.length===0)&&await c.mutateAsync(t)},_=async()=>{if(!u.trim())return;const N=(n==null?void 0:n.reduce((S,M)=>Math.max(S,M.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:f,question_text:u.trim(),sort_order:N+1}),p("")},j=async N=>{await l.mutateAsync({id:N.id,open_house_id:t,is_active:!N.is_active})},w=async N=>{await i.mutateAsync({id:N.id,open_house_id:t})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(be,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(F_,{className:"h-4 w-4"}),"Property Feedback Survey"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show a quick feedback survey after visitors sign in"})]}),e.jsx(qr,{checked:s,onCheckedChange:b})]}),s&&e.jsx("div",{className:"space-y-3 pt-2 border-t border-border",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:n==null?void 0:n.map(N=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(Cu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm truncate",children:N.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:N.question_type.replace("_"," ")})]}),e.jsx(qr,{checked:N.is_active,onCheckedChange:()=>j(N),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>w(N),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]},N.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(ze,{value:u,onChange:N=>p(N.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:N=>N.key==="Enter"&&_()})]}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Hs,{className:"w-28 h-9 text-xs",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"rating",children:"Rating"}),e.jsx(Mt,{value:"open_text",children:"Text"})]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:_,disabled:!u.trim()||o.isPending,className:"h-9",children:e.jsx($s,{className:"h-3.5 w-3.5"})})]})]})})]})}function HCs({open:t,onOpenChange:s,openHouse:r}){const n=uGe(),{user:a}=Ds(),o=k.useRef(null),[l,i]=k.useState(r.auto_forward_to_card??!1),[c,u]=k.useState(r.disclosure_pdf_url??""),[p,f]=k.useState(r.enable_survey??!1),[g,b]=k.useState(!1),[_,j]=k.useState(!1),w=async M=>{var U;const L=(U=M.target.files)==null?void 0:U[0];if(!L||!a)return;if(L.size>20*1024*1024){wn({title:"File must be under 20MB",variant:"destructive"});return}if(L.type!=="application/pdf"){wn({title:"Only PDF files are accepted",variant:"destructive"});return}b(!0);const I=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:O}=await H.storage.from("open-house-photos").upload(I,L,{upsert:!0});if(O){wn({title:"Upload failed",description:O.message,variant:"destructive"}),b(!1);return}const{data:q}=H.storage.from("open-house-photos").getPublicUrl(I);u(q.publicUrl),b(!1),wn({title:"PDF uploaded!"})},N=()=>{u(""),o.current&&(o.current.value="")},S=async()=>{j(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:c||null,enable_survey:p}),wn({title:"Settings saved!"}),s(!1)}catch{wn({title:"Failed to save",variant:"destructive"})}finally{j(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Guest Book Settings"}),e.jsx(Gr,{className:"truncate",children:r.property_address})]}),e.jsxs("div",{className:"space-y-6 pt-2",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Auto-forward to Digital Card"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"After check-in, redirect visitors to your digital business card"})]}),e.jsx(qr,{checked:l,onCheckedChange:i})]})}),!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Seller's Disclosures (PDF)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visitors can view or download this on the thank you screen after check-in"}),e.jsx("input",{ref:o,type:"file",accept:"application/pdf",onChange:w,className:"hidden"}),c?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(Sn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:N,children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var M;return(M=o.current)==null?void 0:M.click()},disabled:g,className:"w-full h-24 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:g?e.jsx(ws,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(VCs,{openHouseId:r.id,enableSurvey:p,onToggleSurvey:f}),e.jsx(K,{onClick:S,disabled:_,className:"w-full",children:_?"Saving...":"Save Settings"})]})]})})}const gct={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function WCs({question:t,responses:s}){const r=s.filter(l=>l.question_id===t.id&&l.rating_value!=null),n=r.length;if(n===0)return null;const a=r.reduce((l,i)=>l+(i.rating_value||0),0)/n,o=[5,4,3,2,1].map(l=>({val:l,count:r.filter(i=>i.rating_value===l).length,pct:Math.round(r.filter(i=>i.rating_value===l).length/n*100)}));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:t.question_text}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.toFixed(1)," avg (",n," responses)"]})]}),e.jsx("div",{className:"space-y-1",children:o.map(l=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-16 text-muted-foreground text-right",children:gct[l.val]}),e.jsx("div",{className:"flex-1 h-4 bg-muted/30 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/70 rounded-full transition-all",style:{width:`${l.pct}%`}})}),e.jsx("span",{className:"w-8 text-muted-foreground",children:l.count})]},l.val))})]})}function GCs({openHouseId:t}){const{data:s,isLoading:r}=Zkt(t),{data:n}=dGe(t),a=k.useMemo(()=>{const f={};return n==null||n.forEach(g=>{f[g.id]=g}),f},[n]);if(r||!s)return null;const{questions:o,responses:l}=s;if(o.length===0)return null;const i=o.filter(f=>f.question_type==="rating"),c=o.filter(f=>f.question_type!=="rating"),u=[...new Set(l.map(f=>f.visitor_id))],p=u.length;return p===0?e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(F_,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(F_,{className:"h-4 w-4"}),"Survey Results",e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:[p," respondent",p!==1?"s":""]})]})}),e.jsx(Oe,{children:e.jsxs(ba,{defaultValue:"summary",children:[e.jsxs(pa,{className:"mb-4",children:[e.jsxs(ns,{value:"summary",className:"text-xs gap-1",children:[e.jsx(No,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(ns,{value:"individual",className:"text-xs gap-1",children:[e.jsx(to,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(bs,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(WCs,{question:f,responses:l},f.id)),c.map(f=>{const g=l.filter(b=>b.question_id===f.id&&b.text_value);return g.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-medium",children:f.question_text}),e.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto",children:g.map(b=>{const _=a[b.visitor_id];return e.jsxs("div",{className:"text-sm p-2 bg-muted/30 rounded-lg",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:[_?`${_.first_name} ${_.last_name||""}`.trim():"Visitor",":"]}),e.jsx("p",{className:"mt-0.5",children:b.text_value})]},b.id)})})]},f.id)})]}),e.jsx(bs,{value:"individual",className:"space-y-4",children:u.map(f=>{const g=a[f],b=l.filter(_=>_.visitor_id===f);return e.jsxs("div",{className:"p-3 rounded-lg border border-border space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:[g?`${g.first_name} ${g.last_name||""}`.trim():"Unknown Visitor",(g==null?void 0:g.email)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:g.email})]}),e.jsx("div",{className:"space-y-1",children:b.map(_=>{const j=o.find(w=>w.id===_.question_id);return j?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:j.question_text}),e.jsx("span",{className:"font-medium",children:_.rating_value!=null?gct[_.rating_value]||_.rating_value:_.text_value})]},_.id):null})})]},f)})})]})})]})}const fwe="guestbook.relevelup.com";function KCs(){const{data:t,isLoading:s}=qkt(),r=Ukt(),n=uGe(),a=Vkt(),[o,l]=k.useState(!1),[i,c]=k.useState(null),{user:u}=Ds(),p=ci(),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(!1),N=k.useRef(null),[S,M]=k.useState({property_address:"",city:"",state:"",zip:"",event_date:ms(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L=U=>{var V;const B=(V=U.target.files)==null?void 0:V[0];if(B){if(B.size>5*1024*1024){wn({title:"Photo must be under 5MB",variant:"destructive"});return}g(B),_(URL.createObjectURL(B))}},I=()=>{g(null),_(null),N.current&&(N.current.value="")},O=async()=>{if(!S.property_address){wn({title:S.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let U;if(f&&u){w(!0);const B=f.name.split(".").pop(),V=`${p}/${Date.now()}.${B}`,{error:Y}=await H.storage.from("open-house-photos").upload(V,f,{upsert:!0});if(Y){wn({title:"Photo upload failed",description:Y.message,variant:"destructive"}),w(!1);return}const{data:Q}=H.storage.from("open-house-photos").getPublicUrl(V);U=Q.publicUrl,w(!1)}await r.mutateAsync({...S,photo_url:U}),l(!1),M({property_address:"",city:"",state:"",zip:"",event_date:ms(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I()},q=U=>{navigator.clipboard.writeText(`https://${fwe}/${U}`),wn({title:"Link copied!"})};return e.jsxs(Ms,{title:"Guest Book",children:[e.jsx(Sc,{children:e.jsx("title",{children:"Guest Book | LevelUp"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold font-serif text-foreground",children:"Guest Book"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"The modern open house sign-in experience"})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"Create Open House"}),e.jsx(Gr,{children:"Set up a new open house sign-in page"})]}),e.jsxs("div",{className:"space-y-4 pt-2 overflow-y-auto flex-1 pr-1",children:[e.jsx("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:e.jsxs("div",{className:"flex gap-1 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>M(U=>({...U,event_type:"property"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S.event_type==="property"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Single Property"}),e.jsx("button",{type:"button",onClick:()=>M(U=>({...U,event_type:"community"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S.event_type==="community"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Community Event"})]})}),e.jsxs("div",{children:[e.jsx(be,{children:S.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(ze,{value:S.property_address,onChange:U=>M(B=>({...B,property_address:U.target.value})),placeholder:S.event_type==="community"?"Spring Festival at Riverside Estates":"123 Main Street"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"City"}),e.jsx(ze,{value:S.city,onChange:U=>M(B=>({...B,city:U.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"State"}),e.jsx(ze,{value:S.state,onChange:U=>M(B=>({...B,state:U.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"ZIP"}),e.jsx(ze,{value:S.zip,onChange:U=>M(B=>({...B,zip:U.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Date"}),e.jsx(ze,{type:"date",value:S.event_date,onChange:U=>M(B=>({...B,event_date:U.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Start Time"}),e.jsx(ze,{type:"time",value:S.start_time,onChange:U=>M(B=>({...B,start_time:U.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"End Time"}),e.jsx(ze,{type:"time",value:S.end_time,onChange:U=>M(B=>({...B,end_time:U.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Welcome Message"}),e.jsx(Er,{value:S.agent_greeting,onChange:U=>M(B=>({...B,agent_greeting:U.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(be,{children:S.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:N,type:"file",accept:"image/*",onChange:L,className:"hidden"}),b?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:b,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:I,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var U;return(U=N.current)==null?void 0:U.click()},className:"mt-1 w-full h-32 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(o1,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",S.event_type==="community"?"cover":"property"," photo"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(K,{onClick:O,disabled:r.isPending||j,className:"w-full",children:j?"Uploading photo...":r.isPending?"Creating...":S.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map(U=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Pt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-48"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 mt-2"})]})},U))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map(U=>e.jsx(ZCs,{openHouse:U,isExpanded:i===U.id,onToggle:()=>c(i===U.id?null:U.id),onCopyLink:()=>q(U.slug||""),onToggleActive:()=>n.mutate({id:U.id,is_active:!U.is_active}),onDelete:()=>a.mutate(U.id)},U.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(u1,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No Open Houses Yet"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm mb-6",children:"Create your first open house to get a beautiful, mobile-friendly sign-in page with a shareable link and QR code."}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function ZCs({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=dGe(s?t.id:void 0),{data:i}=mt({queryKey:["agent-profile-flyer",t.agent_id],queryFn:async()=>{const{data:I,error:O}=await H.from("profiles").select("name, avatar_url, phone, title, brokerages:brokerage_id(name)").eq("id",t.agent_id).single();if(O)throw O;const q=I.brokerages;return{...I,brokerage_name:(q==null?void 0:q.name)||null}},enabled:!!t.agent_id}),[c,u]=k.useState(!1),[p,f]=k.useState(!1),[g,b]=k.useState(!1),_=k.useRef(null),j=`https://${fwe}/${t.slug}`,w=I=>{if(!I)return"";const[O,q]=I.split(":"),U=parseInt(O),B=U>=12?"PM":"AM";return`${U>12?U-12:U||12}:${q} ${B}`},N=()=>{if(!(l!=null&&l.length))return;const I=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],O=l.map(Y=>[Y.first_name,Y.last_name||"",Y.email||"",Y.phone||"",Y.visitor_intent||"",Y.wants_market_updates?"Yes":"No",(Y.message||"").replace(/"/g,'""'),ms(new Date(Y.created_at),"MM/dd/yyyy h:mm a")]),q=[I,...O].map(Y=>Y.map(Q=>`"${Q}"`).join(",")).join(` `),U=new Blob([q],{type:"text/csv"}),B=URL.createObjectURL(U),V=document.createElement("a");V.href=B,V.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,V.click(),URL.revokeObjectURL(B)},S=k.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const O=new XMLSerializer().serializeToString(I),q=document.createElement("canvas");q.width=1024,q.height=1024;const U=q.getContext("2d"),B=new Image;B.onload=()=>{U==null||U.drawImage(B,0,0,1024,1024);const V=document.createElement("a");V.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,V.href=q.toDataURL("image/png"),V.click()},B.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O)))},[t.property_address]),M=k.useCallback(()=>{var Te;if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const O=new XMLSerializer().serializeToString(I),q="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O))),U=ms(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),B=t.start_time?`${w(t.start_time)}${t.end_time?" – "+w(t.end_time):""}`:"",V=[t.city,t.state].filter(Boolean).join(", "),Y=t.agent_greeting||"Welcome! Please sign in below.",Q=!!t.photo_url,ee=!!i,X=Q||ee,ie=Q&&ee,re=ie?"0.35in 0.75in 0.3in":"0.55in 0.75in 0.45in",oe=ie?"28px":"34px",ce=ie?"0.2in 0.75in":X?"0.3in 0.75in":"0.4in 0.75in",ge=X?"0.15in":"0.3in",ye=X?"0.15in":"0.3in",ue=ie?"14px 36px":"22px 44px",pe=ie?"20px":"24px",_e=X?"0.2in":"0.35in",$e=ie?"1.8in":"2.4in",Ae=X?"0.15in":"0.3in",Ie=ie?"140px":X?"160px":"200px",Ce=ie?"16px":"24px",xe=ie?"10px 20px":"16px 28px",we=ie?"44px":"56px",Le="0.15in",tt=window.open("","_blank");tt&&(tt.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${V?`
${V}${t.zip?" "+t.zip:""}
`:""}
Date
${U}
${B?`
Time
${B}
`:""}
${Y}
${i?`
${i.avatar_url?`${i.name}`:`
${((Te=i.name)==null?void 0:Te.charAt(0))||"A"}
`}
Hosted By
${i.name}
${i.title?`
${i.title}
`:""} ${i.brokerage_name?`
${i.brokerage_name}
`:""} ${i.phone?`
${i.phone}
`:""}
`:""} ${t.photo_url?`Property`:""}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),tt.document.close(),setTimeout(()=>{tt.focus(),tt.print()},500))},[t,j,i]),L=async()=>{b(!0);try{const{error:I}=await H.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(I)throw I;wn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(I){wn({title:"Failed to send",description:I.message,variant:"destructive"})}finally{b(!1)}};return e.jsxs(Ee,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-base leading-snug break-words",children:t.property_address}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 flex-wrap",children:[e.jsx(st,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(st,{variant:"outline",className:"shrink-0 gap-1 text-[11px] bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 border-blue-200 dark:border-blue-800",children:[e.jsx(to,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(st,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(ka,{className:"h-3 w-3"}),"Community"]})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0 -mr-2 -mt-1",children:s?e.jsx(ff,{className:"h-4 w-4"}):e.jsx(Eo,{className:"h-4 w-4"})})]}),e.jsxs(gr,{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs",children:[t.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(t.event_date+"T00:00:00"),"MMM d, yyyy")]}),t.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),w(t.start_time),t.end_time?` – ${w(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(pr,{className:"h-3 w-3"}),t.visitor_count," visitors"]})]}),e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 -mx-1 px-1 scrollbar-hide",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.location.href=`/mission-control/guest-book/live/${t.id}`,title:"Go Live",className:"shrink-0 gap-1.5 text-emerald-600 border-emerald-200 hover:bg-emerald-50 dark:text-emerald-400 dark:border-emerald-800 dark:hover:bg-emerald-900/20 h-8 text-xs",children:[e.jsx(h1,{className:"h-3.5 w-3.5"}),"Live"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:n,title:"Copy link",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(gi,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>u(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(u1,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>f(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(Xo,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>window.open(j,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(tn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:a,title:t.is_active?"Deactivate":"Activate",className:"shrink-0 h-8 text-xs",children:t.is_active?e.jsx(kp,{className:"h-3.5 w-3.5"}):e.jsx(Ln,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:o,title:"Delete",className:"shrink-0 h-8 text-xs text-destructive border-destructive/30 hover:bg-destructive/10",children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(Oe,{className:"pt-0",children:[e.jsx(rl,{className:"mb-4"}),e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Share Link"}),e.jsxs("code",{className:"text-xs bg-muted/50 px-2 py-1 rounded block truncate",children:["https://",fwe,"/",t.slug]})]}),l!=null&&l.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:[l.length," Visitor",l.length!==1?"s":""]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:N,className:"h-7 text-xs gap-1",children:[e.jsx(yi,{className:"h-3 w-3"}),"Export CSV"]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/30 text-xs text-muted-foreground",children:[e.jsx("th",{className:"text-left p-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left p-2 font-medium hidden sm:table-cell",children:"Contact"}),e.jsx("th",{className:"text-left p-2 font-medium hidden md:table-cell",children:"Intent"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Time"})]})}),e.jsx("tbody",{children:l.map(I=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[I.first_name,I.last_name?` ${I.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[I.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:I.email}),I.phone&&e.jsx("div",{className:"text-xs",children:I.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:I.visitor_intent&&e.jsx(st,{variant:"outline",className:"text-xs capitalize",children:I.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:ms(new Date(I.created_at),"h:mm a")})]},I.id))})]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No visitors yet. Share the link to start collecting sign-ins!"}),t.enable_survey&&e.jsx("div",{className:"mt-4",children:e.jsx(GCs,{openHouseId:t.id})})]}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{className:"sm:max-w-sm",children:[e.jsxs(_s,{children:[e.jsx(vs,{children:"QR Code"}),e.jsx(Gr,{className:"truncate",children:t.property_address})]}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx("div",{ref:_,className:"bg-white p-4 rounded-xl",children:e.jsx(CR,{value:j,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:j}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:S,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:M,children:[e.jsx(wL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:L,disabled:g,children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),g?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(HCs,{open:p,onOpenChange:f,openHouse:t})]})}function YCs(){const{slug:t}=yo();return t?e.jsx(RZe,{slug:t}):e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Found"}),e.jsx("p",{className:"text-slate-500",children:"No portal slug was provided."})]})})}function yct({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Ds(),l=CC(),i=k.useRef(null),c=k.useRef(null),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState(0),j=async N=>{if(o){p(!0);try{const S=N.name.split(".").pop()||"jpg",M=`${o.id}/card-${Date.now()}.${S}`,{error:L}=await H.storage.from("listing-photos").upload(M,N);if(L)throw L;const{data:{publicUrl:I}}=H.storage.from("listing-photos").getPublicUrl(M);r(I),me.success("Photo uploaded")}catch(S){me.error(S.message||"Failed to upload photo")}finally{p(!1)}}},w=async N=>{if(o){if(N.size>500*1024*1024){me.error("Video must be under 500MB");return}g(!0),_(0);try{const{videoId:S,libraryId:M}=await xR(`Card Video - ${Date.now()}`),{uploadUrl:L,apiKey:I}=await gR(S);await new Promise((U,B)=>{const V=new XMLHttpRequest;V.upload.addEventListener("progress",Y=>{Y.lengthComputable&&_(Math.round(Y.loaded/Y.total*100))}),V.addEventListener("load",()=>{V.status>=200&&V.status<300?U():B(new Error("Upload failed"))}),V.addEventListener("error",()=>B(new Error("Upload failed"))),V.open("PUT",L),V.setRequestHeader("AccessKey",I),V.send(N)});const O=`https://iframe.mediadelivery.net/embed/${M}/${S}`;n(O);const q=parseFloat((N.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:S,playback_url:`https://iframe.mediadelivery.net/play/${M}/${S}`,file_size_mb:q,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),me.success("Video uploaded & added to your library")}catch(S){me.error(S.message||"Failed to upload video")}finally{g(!1),_(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Media (optional)"}),e.jsxs(ba,{defaultValue:"photo",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ns,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(gl,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(ns,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(An,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(bs,{value:"photo",className:"mt-3",children:[t?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:t,alt:"Card photo",className:"w-full h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var N;return(N=i.current)==null?void 0:N.click()},disabled:u,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:u?e.jsx(ws,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Sx,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a photo"})]})}),e.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:N=>{var M;const S=(M=N.target.files)==null?void 0:M[0];S&&j(S),N.target.value=""}})]}),e.jsxs(bs,{value:"video",className:"mt-3",children:[s?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("iframe",{src:`${s}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var N;return(N=c.current)==null?void 0:N.click()},disabled:f,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:f?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(ws,{className:"h-6 w-6 animate-spin"}),e.jsxs("span",{className:"text-xs",children:["Uploading... ",b,"%"]}),e.jsx("div",{className:"w-32 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${b}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(li,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a video (max 500MB)"})]})}),!s&&!f&&e.jsx("div",{className:"mt-2",children:e.jsx(cCe,{contactId:a,onVideoReady:N=>n(N)})}),e.jsx("input",{ref:c,type:"file",accept:"video/*",className:"hidden",onChange:N=>{var M;const S=(M=N.target.files)==null?void 0:M[0];S&&w(S),N.target.value=""}}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1.5 text-center",children:"Videos are also saved to your Video Library"})]})]})]})}const XCs=[{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 QCs({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:XCs.map((s,r)=>e.jsxs(Gs.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:r*.04,duration:.25},onClick:()=>t(s.type),className:`group relative flex flex-col items-start gap-1 p-3.5 rounded-xl border bg-gradient-to-br ${s.gradient} hover:shadow-md hover:scale-[1.02] active:scale-[0.98] transition-all text-left`,children:[e.jsx("span",{className:"text-2xl",children:s.emoji}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:s.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground leading-tight",children:s.description})]},s.type))})}const zE={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 Hze({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Ds(),c=Qt(),[u,p]=k.useState(!1),[f,g]=k.useState("type"),[b,_]=k.useState(""),[j,w]=k.useState(null),[N,S]=k.useState(!1),[M,L]=k.useState("home_anniversary"),[I,O]=k.useState(""),[q,U]=k.useState(""),[B,V]=k.useState(""),[Y,Q]=k.useState(""),[ee,X]=k.useState("elegant"),[ie,re]=k.useState(null),[oe,ce]=k.useState(null),ge=k.useState(!1);!ge[0]&&t&&s&&(ge[1](!0),p(!0),L(s),r&&w(r),n&&O(n),a&&U(a),o&&V(o),g(n?"details":"contact"));const{data:ye}=mt({queryKey:["contacts-for-card",i==null?void 0:i.id,b],queryFn:async()=>{let Le=H.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);b&&(Le=Le.or(`first_name.ilike.%${b}%,last_name.ilike.%${b}%`));const{data:tt,error:Te}=await Le;if(Te)throw Te;return tt},enabled:!!(i!=null&&i.id)&&u}),{data:ue}=mt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:Le,error:tt}=await H.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(tt)throw tt;return Le},enabled:!!(i!=null&&i.id)}),pe=Le=>{w(Le.id),O(`${Le.first_name}${Le.last_name?" "+Le.last_name:""}`),U([Le.address,Le.city,Le.state].filter(Boolean).join(", ")),V(Le.home_anniversary||""),g("details")},_e=Le=>{L(Le),g("contact")},$e=async()=>{var Le;if(!(!i||!ue)){S(!0);try{const tt={owner_user_id:i.id,contact_id:j,card_type:M,template:ee,recipient_name:I,property_address:q||null,home_anniversary_date:B||null,custom_message:Y||null,property_photo_url:ie||null,video_url:oe||null,agent_name:ue.name||"Agent",agent_photo_url:ue.avatar_url,agent_phone:ue.phone,agent_email:ue.email,agent_brokerage:((Le=ue.brokerage)==null?void 0:Le.name)||null},{error:Te}=await H.from("sendable_cards").insert(tt);if(Te)throw Te;me.success("Card created! Copy the link to share it."),c.invalidateQueries({queryKey:["sendable-cards"]}),Ae()}catch(tt){me.error(tt.message||"Failed to create card")}finally{S(!1)}}},Ae=()=>{p(!1),g("type"),L("home_anniversary"),_(""),w(null),O(""),U(""),V(""),Q(""),X("elegant"),re(null),ce(null)},Ie={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"},Ce=zE[M],xe=M==="home_anniversary",we=["home_anniversary","just_listed","just_sold"].includes(M);return e.jsxs(fs,{open:u,onOpenChange:Le=>{Le?p(!0):(Ae(),l==null||l(!1))},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx($s,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:f==="type"?"What type of card?":f==="contact"?`${Ie[M]} — Choose a Contact`:`${Ie[M]} — Customize`})}),f==="type"&&e.jsx(QCs,{onSelect:_e}),f==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>g("type"),children:[e.jsx(Ja,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search contacts...",value:b,onChange:Le=>_(Le.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[ye==null?void 0:ye.map(Le=>e.jsxs("button",{onClick:()=>pe(Le),className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-accent text-left transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(to,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Le.first_name," ",Le.last_name]}),Le.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(bn,{className:"h-3 w-3"}),Le.address]})]}),Le.home_anniversary&&M==="home_anniversary"&&e.jsx("span",{className:"text-[10px] text-emerald-600 bg-emerald-500/10 px-2 py-0.5 rounded-full shrink-0",children:"Anniversary set"})]},Le.id)),(ye==null?void 0:ye.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No contacts found"})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{g("details")},children:"Skip — enter details manually"})})]}),f==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>g("contact"),children:[e.jsx(Ja,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Recipient Name"}),e.jsx(ze,{value:I,onChange:Le=>O(Le.target.value),placeholder:"John & Jane Smith"})]}),we&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:q,onChange:Le=>U(Le.target.value),placeholder:"123 Main St, Austin, TX"})]}),xe&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Home Anniversary Date"}),e.jsx(ze,{type:"date",value:B,onChange:Le=>V(Le.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Personal Message (optional)"}),e.jsx(Er,{value:Y,onChange:Le=>Q(Le.target.value),placeholder:Ce.defaultMessage,rows:3})]}),e.jsx(yct,{photoUrl:ie,videoUrl:oe,onPhotoChange:re,onVideoChange:ce,contactId:j}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:[{key:"elegant",label:"Elegant",gradient:"bg-gradient-to-br from-slate-100 to-blue-100 dark:from-slate-800 dark:to-slate-700"},{key:"bold",label:"Bold",gradient:"bg-gradient-to-br from-violet-500 to-fuchsia-500"},{key:"warm",label:"Warm",gradient:"bg-gradient-to-br from-amber-200 to-orange-300"},{key:"glass",label:"Glass",gradient:"bg-gradient-to-br from-slate-900 via-blue-900/50 to-slate-900 border border-white/10"},{key:"cinematic",label:"Cinema",gradient:"bg-gradient-to-br from-slate-950 via-blue-950 to-slate-950"}].map(({key:Le,label:tt,gradient:Te})=>e.jsxs("button",{onClick:()=>X(Le),className:`p-2 rounded-lg border-2 transition-all text-center ${ee===Le?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${Te}`}),e.jsx("span",{className:"text-[10px] font-medium",children:tt})]},Le))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>g("contact"),className:"flex-1",children:"Back"}),e.jsx(K,{onClick:$e,disabled:!I||N,className:"flex-1 gap-2",children:N?"Creating...":"Create Card"})]})]})]})]})}const JCs={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 e3s({card:t}){const{user:s}=Ds(),{isGmailConnected:r}=Gx(),n=Qt(),[a,o]=k.useState(!1),[l,i]=k.useState("");k.useEffect(()=>{a&&t.contact_id&&!l&&H.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:j})=>{j!=null&&j.email&&i(j.email)})},[a,t.contact_id]);const c={home_anniversary:`🏡 Happy Home Anniversary, ${t.recipient_name}!`,just_listed:`🏠 Just Listed — Check This Out, ${t.recipient_name}!`,just_sold:`🎉 Just Sold! Congrats, ${t.recipient_name}!`,congratulations:`🏆 Congratulations, ${t.recipient_name}!`,birthday:`🎂 Happy Birthday, ${t.recipient_name}!`,holiday:`🎄 Happy Holidays, ${t.recipient_name}!`,thank_you:`💐 Thank You, ${t.recipient_name}!`,thinking_of_you:`💭 Thinking of You, ${t.recipient_name}!`},[u,p]=k.useState(c[t.card_type]||`A Special Card for ${t.recipient_name}!`),[f,g]=k.useState(""),b=`https://cardstudio.relevelup.com/c/${t.share_token}`,_=Lt({mutationFn:async()=>{var M;if(!l)throw new Error("Recipient email is required");const j=`
${f?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:w}=await H.auth.getSession(),N=(M=w==null?void 0:w.session)==null?void 0:M.access_token,S=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({to:l,subject:u,body:j,contactId:t.contact_id||void 0})});if(!S.ok){const L=await S.json();throw new Error(L.error||"Failed to send")}return S.json()},onSuccess:async()=>{await H.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),n.invalidateQueries({queryKey:["sendable-cards"]}),me.success(`Card sent to ${l}!`),o(!1)},onError:j=>{me.error(j.message||"Failed to send email")}});return r?e.jsxs(fs,{open:a,onOpenChange:o,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Bn,{className:"h-3 w-3"})})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"To"}),e.jsx(ze,{type:"email",value:l,onChange:j=>i(j.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Subject"}),e.jsx(ze,{value:u,onChange:j=>p(j.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Personal Note (optional)"}),e.jsx(Er,{value:f,onChange:j=>g(j.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:["The email will include a beautiful button linking to your card at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono text-foreground",children:b})]}),e.jsx(K,{onClick:()=>_.mutate(),disabled:!l||_.isPending,className:"w-full gap-2",children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bn,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs opacity-50 cursor-not-allowed",title:"Connect Gmail in Settings to send cards via email",disabled:!0,children:e.jsx(Bn,{className:"h-3 w-3"})})}function t3s({card:t}){const s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(t.recipient_name),[c,u]=k.useState(t.property_address||""),[p,f]=k.useState(t.home_anniversary_date||""),[g,b]=k.useState(t.custom_message||""),[_,j]=k.useState(t.template),[w,N]=k.useState(t.property_photo_url),[S,M]=k.useState(t.video_url||null),L=O=>{O&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),b(t.custom_message||""),j(t.template),N(t.property_photo_url),M(t.video_url||null)),n(O)},I=async()=>{if(!l.trim()){me.error("Recipient name is required");return}o(!0);try{const{error:O}=await H.from("sendable_cards").update({recipient_name:l.trim(),property_address:c.trim()||null,home_anniversary_date:p||null,custom_message:g.trim()||null,template:_,property_photo_url:w||null,video_url:S||null}).eq("id",t.id);if(O)throw O;s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card updated"),n(!1)}catch(O){me.error(O.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(fs,{open:r,onOpenChange:L,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Ra,{className:"h-3 w-3"})})}),e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(vs,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Recipient Name"}),e.jsx(ze,{value:l,onChange:O=>i(O.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:c,onChange:O=>u(O.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Home Anniversary Date"}),e.jsx(ze,{type:"date",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Personal Message (optional)"}),e.jsx(Er,{value:g,onChange:O=>b(O.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(yct,{photoUrl:w,videoUrl:S,onPhotoChange:N,onVideoChange:M,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(O=>e.jsxs("button",{onClick:()=>j(O),className:`p-3 rounded-lg border-2 transition-all text-center ${_===O?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${O==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":O==="bold"?"bg-gradient-to-br from-violet-500 to-fuchsia-500":"bg-gradient-to-br from-amber-200 to-orange-300"}`}),e.jsx("span",{className:"text-xs font-medium capitalize",children:O})]},O))})]}),e.jsx(K,{onClick:I,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function s3s(){const{user:t}=Ds(),s=Qt(),[r,n]=k.useState(""),[a,o]=Cc(),l=a.get("cardType"),i=a.get("contactId"),c=a.get("name"),u=a.get("address"),p=a.get("date"),f=!!l,{data:g,isLoading:b}=mt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:M,error:L}=await H.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(L)throw L;return M},enabled:!!(t!=null&&t.id)}),_=Lt({mutationFn:async M=>{const{error:L}=await H.from("sendable_cards").delete().eq("id",M);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card deleted")}}),j=M=>{const L=`https://cardstudio.relevelup.com/c/${M}`;navigator.clipboard.writeText(L),me.success("Share link copied!")},w=g==null?void 0:g.filter(M=>{var L;return!r||M.recipient_name.toLowerCase().includes(r.toLowerCase())||((L=M.property_address)==null?void 0:L.toLowerCase().includes(r.toLowerCase()))}),N={elegant:"Elegant",bold:"Bold",warm:"Warm"},S={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(Ms,{title:"Card Studio",children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Card Studio"})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create & send beautiful branded cards to your clients"})]}),e.jsx(Hze,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search cards...",value:r,onChange:M=>n(M.target.value),className:"pl-9"})]}),b?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(M=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},M))}):w!=null&&w.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(M=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-shadow",children:[e.jsxs("div",{className:`aspect-[16/10] flex items-center justify-center relative overflow-hidden ${M.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":M.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:[M.template==="elegant"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"absolute top-0 left-0 w-full h-full opacity-10",children:[e.jsx("div",{className:"absolute top-3 left-3 w-16 h-16 border-t-2 border-l-2 border-primary/40 rounded-tl-lg"}),e.jsx("div",{className:"absolute bottom-3 right-3 w-16 h-16 border-b-2 border-r-2 border-primary/40 rounded-br-lg"})]}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-32 h-32 rounded-full border border-primary/10"})]}),M.template==="bold"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-8 -right-8 w-32 h-32 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute -bottom-6 -left-6 w-24 h-24 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(255,255,255,0.15)_0%,transparent_70%)]"})]}),M.template==="warm"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-4 -left-4 w-28 h-28 rounded-full bg-orange-400/15 blur-md"}),e.jsx("div",{className:"absolute -bottom-6 -right-6 w-32 h-32 rounded-full bg-rose-400/15 blur-md"})]}),e.jsxs("div",{className:"text-center px-4 relative z-10",children:[e.jsx("div",{className:"text-3xl mb-1.5 opacity-80",children:M.card_type==="home_anniversary"?"🏡":M.card_type==="birthday"?"🎂":M.card_type==="just_sold"?"🎉":M.card_type==="just_listed"?"🏠":M.card_type==="thank_you"?"💐":M.card_type==="congratulations"?"🏆":M.card_type==="holiday"?"🎄":M.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${M.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:S[M.card_type]||M.card_type}),e.jsx("p",{className:`font-semibold text-base ${M.template==="bold"?"text-white":"text-foreground"}`,children:M.recipient_name}),M.property_address&&e.jsx("p",{className:`text-xs mt-1 ${M.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:M.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(st,{variant:M.template==="bold"?"outline":"secondary",className:`text-[10px] ${M.template==="bold"?"border-white/30 text-white/80":""}`,children:N[M.template]||M.template})})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Ln,{className:"h-3 w-3"}),M.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Uc(new Date(M.created_at),{addSuffix:!0})})]}),M.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ms(new Date(M.sent_at),"MMM d, yyyy")," via ",M.sent_via]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>j(M.share_token),children:[e.jsx(gi,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(t3s,{card:M}),e.jsx(e3s,{card:M}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${M.share_token}`,"_blank"),children:e.jsx(tn,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>_.mutate(M.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]})]},M.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(cr,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No cards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Create your first digital card to send to a client"}),e.jsx(Hze,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function mI({delay:t,x:s,y:r,size:n}){return e.jsx(Gs.div,{className:"absolute rounded-full bg-slate-300/30 dark:bg-slate-500/20",style:{left:s,top:r,width:n,height:n},animate:{y:[0,-20,0],opacity:[.3,.7,.3],scale:[1,1.2,1]},transition:{duration:4,delay:t,repeat:1/0,ease:"easeInOut"}})}function r3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=zE[s];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-blue-50/30 to-white dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(Gs.div,{className:"absolute -top-20 -right-20 w-72 h-72 rounded-full bg-gradient-to-br from-blue-100/40 to-slate-100/20 blur-3xl",animate:{scale:[1,1.1,1],rotate:[0,5,0]},transition:{duration:8,repeat:1/0,ease:"easeInOut"}}),e.jsx(Gs.div,{className:"absolute -bottom-20 -left-20 w-64 h-64 rounded-full bg-gradient-to-tr from-slate-200/30 to-blue-100/20 blur-3xl",animate:{scale:[1,1.15,1],rotate:[0,-5,0]},transition:{duration:10,repeat:1/0,ease:"easeInOut"}}),e.jsx(mI,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(mI,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(mI,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(mI,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(mI,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(Gs.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,ease:"easeOut"},children:[e.jsxs(Gs.div,{className:"bg-white/80 dark:bg-slate-900/80 backdrop-blur-xl rounded-3xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.1)] overflow-hidden border border-slate-200/60 dark:border-slate-700/50",initial:{scale:.95},animate:{scale:1},transition:{duration:.6,delay:.2},children:[e.jsx("div",{className:"relative h-2 bg-gradient-to-r from-slate-200 via-blue-300 to-slate-200 dark:from-slate-700 dark:via-blue-500 dark:to-slate-700 overflow-hidden",children:e.jsx(Gs.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:3,repeat:1/0,repeatDelay:2,ease:"easeInOut"}})}),e.jsxs("div",{className:"px-8 py-10 text-center",children:[e.jsxs(Gs.div,{className:"mx-auto mb-6 h-20 w-20 rounded-2xl bg-gradient-to-br from-slate-100 to-blue-50 dark:from-slate-800 dark:to-slate-700 flex items-center justify-center shadow-lg relative",initial:{scale:0,rotate:-10},animate:{scale:1,rotate:0},transition:{duration:.5,delay:.4,type:"spring",stiffness:200},children:[e.jsx(Gs.div,{className:"absolute inset-0 rounded-2xl border-2 border-slate-200/50 dark:border-slate-600/50",animate:{scale:[1,1.15,1],opacity:[.5,0,.5]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl",children:b.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(Gs.div,{className:"inline-block mb-4",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:e.jsxs("span",{className:"text-sm font-semibold tracking-[0.25em] uppercase text-blue-400 dark:text-blue-300",children:[a," ",a===1?"Year":"Years"]})}),e.jsx(Gs.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:b.title[0]}),b.title[1]&&e.jsx(Gs.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:b.title[1]}),e.jsxs(Gs.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.5,delay:1},children:[e.jsx("p",{className:"text-xl font-medium text-slate-700 dark:text-slate-200 mb-1",children:r}),n&&e.jsx("p",{className:"text-sm text-slate-400 dark:text-slate-500 mb-6",children:n})]}),e.jsx(Gs.div,{className:"h-px bg-gradient-to-r from-transparent via-slate-300 dark:via-slate-600 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"80%"},transition:{duration:.8,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(Gs.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(Gs.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Gs.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||b.defaultMessage}),e.jsxs(Gs.div,{className:"border-t border-slate-100 dark:border-slate-800 pt-6",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5,delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(Gs.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-slate-200 dark:ring-slate-700 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-full bg-gradient-to-br from-slate-200 to-blue-100 dark:from-slate-700 dark:to-slate-600 flex items-center justify-center shadow-md",children:e.jsx("span",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:l}),p&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[c&&e.jsxs(Gs.a,{href:`tel:${c}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Gs.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Gs.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 Eye({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(Gs.div,{className:`absolute rounded-full blur-2xl ${n}`,style:{left:s,top:r,width:a,height:a},animate:{scale:[1,1.4,1],opacity:[.2,.5,.2]},transition:{duration:5,delay:t,repeat:1/0,ease:"easeInOut"}})}function pI({delay:t,x:s,y:r}){return e.jsx(Gs.div,{className:"absolute text-white/30 text-lg",style:{left:s,top:r},animate:{opacity:[0,1,0],scale:[.5,1,.5],rotate:[0,180,360]},transition:{duration:3,delay:t,repeat:1/0,ease:"easeInOut"},children:"✦"})}const Wze={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 n3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=zE[s],_=Wze[s]||Wze.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-br ${_.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx(Eye,{delay:0,x:"10%",y:"10%",color:_.orbs[0],size:200}),e.jsx(Eye,{delay:1,x:"70%",y:"60%",color:_.orbs[1],size:180}),e.jsx(Eye,{delay:2,x:"50%",y:"20%",color:_.orbs[2],size:150}),e.jsx(pI,{delay:0,x:"20%",y:"25%"}),e.jsx(pI,{delay:.8,x:"75%",y:"15%"}),e.jsx(pI,{delay:1.6,x:"85%",y:"65%"}),e.jsx(pI,{delay:2.4,x:"10%",y:"75%"}),e.jsx(pI,{delay:.4,x:"45%",y:"85%"}),e.jsxs(Gs.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.7,ease:"easeOut"},children:[e.jsxs(Gs.div,{className:"relative rounded-3xl overflow-hidden",initial:{scale:.9},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring",stiffness:150},children:[e.jsx(Gs.div,{className:"absolute -inset-[1px] rounded-3xl bg-gradient-to-r from-violet-500 via-fuchsia-500 to-violet-500 opacity-50",animate:{backgroundPosition:["0% 50%","100% 50%","0% 50%"]},transition:{duration:4,repeat:1/0,ease:"linear"},style:{backgroundSize:"200% 200%"}}),e.jsxs("div",{className:"relative bg-white/5 backdrop-blur-xl border border-white/10 rounded-3xl px-8 py-10 text-center m-[1px]",children:[e.jsxs(Gs.div,{className:"mx-auto mb-6 h-20 w-20 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-2xl shadow-violet-500/40 relative",initial:{scale:0,rotate:-20},animate:{scale:1,rotate:0},transition:{duration:.6,delay:.4,type:"spring",stiffness:200},children:[e.jsx(Gs.div,{className:"absolute inset-0 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500",animate:{scale:[1,1.3,1],opacity:[.6,0,.6]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl relative z-10",children:b.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Gs.div,{className:"inline-flex items-center gap-2 mb-5 px-5 py-2 rounded-full bg-white/10 border border-white/15 backdrop-blur-sm",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:[e.jsx(Gs.span,{className:"text-3xl font-black text-white",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),e.jsx("span",{className:"text-xs font-semibold text-violet-200 uppercase tracking-widest",children:a===1?"Year":"Years"})]}),e.jsx(Gs.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:b.title[0]}),b.title[1]&&e.jsx(Gs.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:b.title[1]}),e.jsx(Gs.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:b.emojis.slice(0,3).join("")}),e.jsxs(Gs.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:"text-xl font-semibold text-white/90 mb-1",children:r}),n&&e.jsxs("p",{className:"text-sm text-violet-300/70 mb-6 flex items-center justify-center gap-1.5",children:[e.jsx(bn,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(Gs.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(Gs.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Gs.div,{className:"bg-white/5 rounded-2xl p-5 border border-white/10 mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsx("p",{className:"text-sm text-violet-100/80 leading-relaxed",children:o||b.defaultMessage})}),e.jsxs(Gs.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(Gs.img,{src:i,alt:l,className:"h-12 w-12 rounded-xl object-cover ring-2 ring-violet-500/40 shadow-lg",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-lg",children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:l}),p&&e.jsx("p",{className:"text-xs text-violet-300/60",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[c&&e.jsxs(Gs.a,{href:`tel:${c}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(Gs.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Gs.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 a3s({emoji:t,delay:s,x:r,duration:n}){return e.jsx(Gs.div,{className:"absolute text-2xl pointer-events-none",style:{left:r,bottom:-20},animate:{y:[0,-600],opacity:[0,1,1,0],x:[0,15,-10,5],rotate:[0,20,-15,10]},transition:{duration:n,delay:s,repeat:1/0,ease:"easeOut"},children:t})}const Gze={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 i3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=zE[s],_=Gze[s]||Gze.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${_.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[b.emojis.map((j,w)=>e.jsx(a3s,{emoji:j,delay:w*1.2,x:`${15+w*14}%`,duration:5+w%3},w)),e.jsx(Gs.div,{className:"absolute top-1/4 left-1/2 -translate-x-1/2 w-96 h-96 bg-gradient-to-r from-amber-200/30 to-rose-200/30 rounded-full blur-[100px]",animate:{scale:[1,1.2,1],opacity:[.3,.5,.3]},transition:{duration:6,repeat:1/0,ease:"easeInOut"}}),e.jsxs(Gs.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.7},children:[e.jsxs(Gs.div,{className:"bg-white rounded-3xl shadow-[0_20px_60px_-15px_rgba(251,146,60,0.2)] overflow-hidden border border-amber-100",initial:{scale:.9},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring",stiffness:150},children:[e.jsxs(Gs.div,{className:`h-28 bg-gradient-to-r ${_.header} relative overflow-hidden`,children:[e.jsx(Gs.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:3,repeat:1/0,repeatDelay:2,ease:"easeInOut"}}),e.jsx(Gs.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:b.emojis[0]}),e.jsx(Gs.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:b.emojis[1]}),e.jsx(Gs.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:b.emojis[2]})]}),e.jsxs("div",{className:"px-8 py-8 text-center -mt-10 relative",children:[e.jsx(Gs.div,{className:"mx-auto mb-4 h-20 w-20 rounded-full bg-white shadow-xl flex items-center justify-center border-4 border-white relative",initial:{scale:0},animate:{scale:1},transition:{delay:.4,type:"spring",stiffness:300},children:e.jsx(Gs.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-3xl",children:b.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(Gs.div,{className:"mb-3",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:.6},children:e.jsxs("span",{className:`inline-flex items-baseline gap-1.5 ${_.accent}`,children:[e.jsx(Gs.span,{className:"text-5xl font-black",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),e.jsx("span",{className:"text-sm font-semibold",children:a===1?"year":"wonderful years"})]})}),e.jsxs(Gs.h1,{className:`text-3xl font-bold ${_.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[b.title.join(" ")," ",b.emojis[4]]}),e.jsxs(Gs.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:`text-lg font-semibold ${_.text} mb-1`,children:r}),n&&e.jsxs("p",{className:`text-sm ${_.text} opacity-70 flex items-center justify-center gap-1 mb-5`,children:[e.jsx(ma,{className:"h-3 w-3"}),n]})]}),f&&e.jsx(Gs.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(Gs.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Gs.div,{className:"bg-gradient-to-br from-amber-50 to-orange-50 rounded-2xl p-5 mb-6 border border-amber-100 shadow-inner",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:`text-sm ${_.text} leading-relaxed italic`,children:['"',o||b.defaultMessage,'"']})}),e.jsxs(Gs.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center gap-3 justify-center",children:[i?e.jsx(Gs.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-amber-200 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${_.header} flex items-center justify-center shadow-md`,children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:`text-sm font-bold ${_.accent}`,children:l}),p&&e.jsx("p",{className:`text-xs ${_.text} opacity-60`,children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[c&&e.jsxs(Gs.a,{href:`tel:${c}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${_.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Gs.a,{href:`mailto:${u}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${_.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Gs.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 n9({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(Gs.div,{className:`absolute rounded-full ${a} blur-3xl`,style:{left:s,top:r,width:n,height:n},animate:{scale:[1,1.3,1],opacity:[.4,.7,.4],x:[0,20,-10,0],y:[0,-15,10,0]},transition:{duration:8,delay:t,repeat:1/0,ease:"easeInOut"}})}function Pye({delay:t,x:s,y:r,size:n}){return e.jsx(Gs.div,{className:"absolute rounded-full border border-white/10",style:{left:s,top:r,width:n,height:n},animate:{scale:[1,1.2,1],opacity:[.1,.3,.1],rotate:[0,180,360]},transition:{duration:12,delay:t,repeat:1/0,ease:"linear"}})}const Kze={home_anniversary:{mesh:["bg-sky-400/40","bg-indigo-500/30","bg-violet-400/25"],accent:"text-sky-200",glow:"shadow-sky-500/20"},birthday:{mesh:["bg-pink-400/40","bg-fuchsia-500/30","bg-purple-400/25"],accent:"text-pink-200",glow:"shadow-pink-500/20"},just_sold:{mesh:["bg-emerald-400/40","bg-teal-500/30","bg-cyan-400/25"],accent:"text-emerald-200",glow:"shadow-emerald-500/20"},just_listed:{mesh:["bg-amber-400/40","bg-orange-500/30","bg-yellow-400/25"],accent:"text-amber-200",glow:"shadow-amber-500/20"},thank_you:{mesh:["bg-rose-400/40","bg-pink-500/30","bg-red-400/25"],accent:"text-rose-200",glow:"shadow-rose-500/20"},congratulations:{mesh:["bg-yellow-400/40","bg-amber-500/30","bg-orange-400/25"],accent:"text-yellow-200",glow:"shadow-yellow-500/20"},holiday:{mesh:["bg-red-400/40","bg-emerald-500/30","bg-green-400/25"],accent:"text-red-200",glow:"shadow-red-500/20"},thinking_of_you:{mesh:["bg-violet-400/40","bg-indigo-500/30","bg-blue-400/25"],accent:"text-violet-200",glow:"shadow-violet-500/20"}};function o3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=zE[s],_=Kze[s]||Kze.home_anniversary;return e.jsxs("div",{className:"min-h-screen bg-slate-950 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsx(n9,{delay:0,x:"5%",y:"10%",size:300,color:_.mesh[0]}),e.jsx(n9,{delay:2,x:"60%",y:"50%",size:250,color:_.mesh[1]}),e.jsx(n9,{delay:4,x:"30%",y:"70%",size:200,color:_.mesh[2]}),e.jsx(n9,{delay:1,x:"80%",y:"15%",size:180,color:_.mesh[0]}),e.jsx(Pye,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(Pye,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(Pye,{delay:6,x:"40%",y:"10%",size:80}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E")`}}),e.jsxs(Gs.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.8,ease:[.16,1,.3,1]},children:[e.jsxs(Gs.div,{className:`relative rounded-[28px] overflow-hidden backdrop-blur-2xl bg-white/[0.06] border border-white/[0.12] shadow-2xl ${_.glow}`,initial:{scale:.92},animate:{scale:1},transition:{duration:.6,delay:.2,type:"spring",stiffness:120},children:[e.jsx("div",{className:"relative h-[2px] bg-gradient-to-r from-transparent via-white/20 to-transparent overflow-hidden",children:e.jsx(Gs.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:4,repeat:1/0,repeatDelay:3,ease:"easeInOut"}})}),e.jsxs("div",{className:"px-8 py-10 text-center",children:[e.jsxs(Gs.div,{className:"mx-auto mb-6 h-24 w-24 rounded-3xl bg-white/[0.08] backdrop-blur-xl border border-white/[0.15] flex items-center justify-center relative",initial:{scale:0,rotate:-15},animate:{scale:1,rotate:0},transition:{duration:.6,delay:.4,type:"spring",stiffness:180},children:[e.jsx(Gs.div,{className:"absolute -inset-1 rounded-3xl border border-white/[0.08]",animate:{scale:[1,1.1,1],opacity:[.3,0,.3]},transition:{duration:3,repeat:1/0,ease:"easeInOut"}}),e.jsx(Gs.span,{className:"text-5xl",animate:{scale:[1,1.08,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:b.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Gs.div,{className:"inline-flex items-center gap-2 mb-5 px-5 py-2 rounded-full bg-white/[0.06] border border-white/[0.1] backdrop-blur-sm",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:[e.jsx(Gs.span,{className:"text-3xl font-black text-white",initial:{opacity:0},animate:{opacity:1},transition:{delay:.8},children:a}),e.jsx("span",{className:`text-[10px] font-bold uppercase tracking-[0.2em] ${_.accent}`,children:a===1?"Year":"Years"})]}),e.jsx(Gs.h1,{className:"text-4xl font-extralight text-white/90 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.7},children:b.title[0]}),b.title[1]&&e.jsx(Gs.h2,{className:"text-4xl font-bold text-white mb-6 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.85},children:b.title[1]}),e.jsxs(Gs.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1},children:[e.jsx("p",{className:"text-xl font-medium text-white/80 mb-1",children:r}),n&&e.jsxs("p",{className:"text-sm text-white/30 mb-6 flex items-center justify-center gap-1.5",children:[e.jsx(ma,{className:"h-3 w-3"})," ",n]})]}),e.jsx(Gs.div,{className:"h-px bg-gradient-to-r from-transparent via-white/15 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"70%"},transition:{duration:1,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(Gs.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(Gs.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Gs.div,{className:"bg-white/[0.04] rounded-2xl p-5 border border-white/[0.08] mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:"text-sm text-white/60 leading-relaxed italic",children:['"',o||b.defaultMessage,'"']})}),e.jsxs(Gs.div,{className:"border-t border-white/[0.06] pt-6",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(Gs.img,{src:i,alt:l,className:"h-12 w-12 rounded-2xl object-cover ring-1 ring-white/10",whileHover:{scale:1.08}}):e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-white/[0.08] border border-white/[0.1] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-white/60",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-white/80",children:l}),p&&e.jsx("p",{className:"text-xs text-white/30",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[c&&e.jsxs(Gs.a,{href:`tel:${c}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Gs.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Gs.p,{className:"text-center text-[10px] text-white/20 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function Iye({delay:t,x:s,angle:r,color:n}){return e.jsx(Gs.div,{className:`absolute h-[400px] w-[1px] ${n} origin-top`,style:{left:s,top:"-10%",transform:`rotate(${r}deg)`},animate:{opacity:[0,.4,0],scaleY:[.5,1,.5]},transition:{duration:6,delay:t,repeat:1/0,ease:"easeInOut"}})}function a9({delay:t,x:s}){return e.jsx(Gs.div,{className:"absolute w-1 h-1 rounded-full bg-amber-400/60",style:{left:s,bottom:"20%"},animate:{y:[0,-200,-400],x:[0,15,-10],opacity:[0,.8,0],scale:[0,1.5,0]},transition:{duration:4,delay:t,repeat:1/0,ease:"easeOut"}})}const Zze={home_anniversary:{gradient:"from-slate-950 via-blue-950 to-slate-950",accent:"from-blue-400 to-cyan-300",stripe:"bg-blue-400/20"},birthday:{gradient:"from-slate-950 via-rose-950 to-slate-950",accent:"from-rose-400 to-pink-300",stripe:"bg-rose-400/20"},just_sold:{gradient:"from-slate-950 via-emerald-950 to-slate-950",accent:"from-emerald-400 to-green-300",stripe:"bg-emerald-400/20"},just_listed:{gradient:"from-slate-950 via-amber-950 to-slate-950",accent:"from-amber-400 to-yellow-300",stripe:"bg-amber-400/20"},thank_you:{gradient:"from-slate-950 via-pink-950 to-slate-950",accent:"from-pink-400 to-rose-300",stripe:"bg-pink-400/20"},congratulations:{gradient:"from-slate-950 via-yellow-950 to-slate-950",accent:"from-yellow-400 to-amber-300",stripe:"bg-yellow-400/20"},holiday:{gradient:"from-slate-950 via-red-950 to-slate-950",accent:"from-red-400 to-green-400",stripe:"bg-red-400/20"},thinking_of_you:{gradient:"from-slate-950 via-purple-950 to-slate-950",accent:"from-purple-400 to-violet-300",stripe:"bg-purple-400/20"}};function l3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,b=zE[s],_=Zze[s]||Zze.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${_.gradient} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,rgba(255,255,255,0.04)_0%,transparent_60%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_bottom,rgba(0,0,0,0.6)_0%,transparent_60%)]"}),e.jsx(Iye,{delay:0,x:"20%",angle:15,color:_.stripe}),e.jsx(Iye,{delay:2,x:"75%",angle:-12,color:_.stripe}),e.jsx(Iye,{delay:4,x:"50%",angle:5,color:_.stripe}),e.jsx(a9,{delay:0,x:"30%"}),e.jsx(a9,{delay:1.5,x:"60%"}),e.jsx(a9,{delay:3,x:"45%"}),e.jsx(a9,{delay:.7,x:"75%"}),e.jsx("div",{className:"absolute inset-0 opacity-[0.015] mix-blend-overlay",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`}}),e.jsxs(Gs.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(Gs.div,{className:"relative overflow-hidden",initial:{y:50},animate:{y:0},transition:{duration:.8,delay:.3,ease:[.16,1,.3,1]},children:e.jsxs("div",{className:"px-8 py-12 text-center",children:[e.jsx(Gs.div,{className:"mx-auto mb-8 relative",initial:{scale:0},animate:{scale:1},transition:{duration:.8,delay:.5,type:"spring",stiffness:100},children:e.jsx(Gs.div,{className:`h-20 w-20 mx-auto rounded-2xl bg-gradient-to-br ${_.accent} flex items-center justify-center shadow-2xl`,animate:{boxShadow:["0 0 40px rgba(255,255,255,0.05)","0 0 80px rgba(255,255,255,0.1)","0 0 40px rgba(255,255,255,0.05)"]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-4xl",children:b.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Gs.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(Gs.span,{className:`text-6xl font-black bg-gradient-to-r ${_.accent} bg-clip-text text-transparent`,initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},transition:{delay:.9,type:"spring"},children:a}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.4em] text-white/30 mt-1",children:a===1?"Year":"Years"})]}),e.jsx("div",{className:"overflow-hidden mb-2",children:e.jsx(Gs.h1,{className:"text-5xl font-thin text-white/90 tracking-wide",initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.8,ease:[.16,1,.3,1]},children:b.title[0]})}),b.title[1]&&e.jsx("div",{className:"overflow-hidden mb-8",children:e.jsx(Gs.h2,{className:`text-5xl font-black bg-gradient-to-r ${_.accent} bg-clip-text text-transparent`,initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.95,ease:[.16,1,.3,1]},children:b.title[1]})}),e.jsxs(Gs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.1,duration:.6},children:[e.jsx("p",{className:"text-lg font-light text-white/70 tracking-wide",children:r}),n&&e.jsxs("p",{className:"text-xs text-white/25 mt-1 flex items-center justify-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(Gs.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(Gs.div,{className:"h-px flex-1 max-w-[60px] bg-gradient-to-r from-transparent to-white/15",initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8},style:{transformOrigin:"right"}}),e.jsx(Gs.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(Gs.div,{className:"h-px flex-1 max-w-[60px] bg-gradient-to-l from-transparent to-white/15",initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8},style:{transformOrigin:"left"}})]}),f&&e.jsxs(Gs.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.3,duration:.6},children:[e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-950/30 to-transparent pointer-events-none"})]}),g&&e.jsx(Gs.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.35,duration:.6},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(Gs.p,{className:"text-sm text-white/40 leading-relaxed max-w-xs mx-auto mb-10 font-light",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.4,duration:.8},children:o||b.defaultMessage}),e.jsxs(Gs.div,{className:"pt-6 border-t border-white/[0.04]",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:1.6,duration:.6},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[i?e.jsx(Gs.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white/10 shadow-xl",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${_.accent} flex items-center justify-center shadow-xl`,children:e.jsx("span",{className:"text-sm font-bold text-slate-900",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-white/70",children:l}),p&&e.jsx("p",{className:"text-[11px] text-white/25",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[c&&e.jsxs(Gs.a,{href:`tel:${c}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${_.accent} text-xs font-semibold text-slate-900 shadow-lg`,whileHover:{scale:1.05,boxShadow:"0 10px 40px rgba(255,255,255,0.15)"},whileTap:{scale:.95},children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Gs.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/60 hover:bg-white/[0.12] transition-colors",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(Gs.p,{className:"text-center text-[10px] text-white/10 mt-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:2.2},children:"Powered by LevelUp"})]})]})}function vct(){const{shareToken:t}=yo(),{data:s,isLoading:r,error:n}=mt({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await H.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(k.useEffect(()=>{t&&H.rpc("log_sendable_card_view",{p_share_token:t}).then(({error:l})=>{l&&console.error("Error tracking view:",l)})},[t]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"animate-pulse space-y-4 text-center",children:[e.jsx("div",{className:"h-8 w-48 bg-muted rounded mx-auto"}),e.jsx("div",{className:"h-4 w-32 bg-muted rounded mx-auto"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Card not found"}),e.jsx("p",{className:"text-muted-foreground",children:"This card may have been removed or the link is invalid."})]})});const a=s.home_anniversary_date?Math.floor((Date.now()-Ol(s.home_anniversary_date).getTime())/(365.25*24*60*60*1e3)):null,o={cardType:s.card_type||"home_anniversary",recipientName:s.recipient_name,propertyAddress:s.property_address,anniversaryYears:a,customMessage:s.custom_message,agentName:s.agent_name,agentPhotoUrl:s.agent_photo_url,agentPhone:s.agent_phone,agentEmail:s.agent_email,agentBrokerage:s.agent_brokerage,propertyPhotoUrl:s.property_photo_url,videoUrl:s.video_url||null};switch(s.template){case"bold":return e.jsx(n3s,{...o});case"warm":return e.jsx(i3s,{...o});case"glass":return e.jsx(o3s,{...o});case"cinematic":return e.jsx(l3s,{...o});case"elegant":default:return e.jsx(r3s,{...o})}}function c3s(){const t=ci();return mt({queryKey:["drip-settings",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("drip_settings").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function d3s(){const t=ci(),s=Qt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n}=await H.from("drip_settings").select("id").eq("user_id",t).maybeSingle();if(n){const{data:a,error:o}=await H.from("drip_settings").update(r).eq("user_id",t).select().single();if(o)throw o;return a}else{const{data:a,error:o}=await H.from("drip_settings").insert({user_id:t,is_globally_enabled:r.is_globally_enabled??!1,append_signature:r.append_signature??!0}).select().single();if(o)throw o;return a}},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-settings"]})}})}function u3s(){const t=fr(),{isGmailConnected:s,gmailEmail:r}=Gx(),{data:n,isLoading:a}=c3s(),o=d3s(),[l,i]=k.useState(!1),[c,u]=k.useState(!0),[p,f]=k.useState(!1);k.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const g=async _=>{if(_&&!s){me.error("Connect your Gmail account first before enabling Smart Drips");return}i(_);try{await o.mutateAsync({is_globally_enabled:_}),me.success(_?"Smart Drips enabled globally":"Smart Drips paused globally")}catch{i(!_),me.error("Failed to update settings")}},b=async _=>{u(_);try{await o.mutateAsync({append_signature:_}),me.success(_?"Signature will be appended to drip emails":"Signature disabled for drip emails")}catch{u(!_),me.error("Failed to update settings")}};return e.jsxs(fs,{open:p,onOpenChange:f,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Xo,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5 text-primary"}),"Smart Drip Settings"]}),e.jsx(Gr,{children:"Configure how your automated drip emails are sent."})]}),e.jsxs("div",{className:"space-y-5 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email Connection"}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${s?"bg-emerald-500/10":"bg-destructive/10"}`,children:e.jsx(cr,{className:`h-4 w-4 ${s?"text-emerald-600":"text-destructive"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s?"Gmail Connected":"Gmail Not Connected"}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]}),s?e.jsxs(st,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(sa,{className:"h-3 w-3"}),"Active"]}):e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{f(!1),t("/mission-control/integrations")},children:[e.jsx(tn,{className:"h-3 w-3"}),"Connect"]})]}),!s&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Smart Drips sends emails from your Gmail account. Connect Gmail to get started."})]}),e.jsx(rl,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${l?"bg-emerald-500/10":"bg-muted"}`,children:e.jsx(_L,{className:`h-4 w-4 ${l?"text-emerald-600":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Enable Smart Drips"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?"Active drips will send when deals move stages":"All drips are paused — nothing will send"})]})]}),e.jsx(qr,{checked:l,onCheckedChange:g,disabled:a||o.isPending})]}),e.jsx(rl,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${c?"bg-primary/10":"bg-muted"}`,children:e.jsx(e0,{className:`h-4 w-4 ${c?"text-primary":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Append Email Signature"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c?"Your signature from Profile settings will be added":"Drip emails will send without a signature"})]})]}),e.jsx(qr,{checked:c,onCheckedChange:b,disabled:a||o.isPending})]}),c&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{f(!1),t("/profile")},children:[e.jsx(e0,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function h3s(){const t=ci();return mt({queryKey:["drip-templates",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("drip_templates").select("*").or(`owner_user_id.eq.${t},is_starter.eq.true`).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function m3s(){const t=ci();return mt({queryKey:["drip-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function p3s(){const t=ci(),s=Qt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("drip_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title||"",subject:r.subject||"",body:r.body||"",video_url:r.video_url||null,channel:r.channel||"email",delay_type:r.delay_type||"instant",delay_minutes:r.delay_minutes||0,is_enabled:!1,deal_type:r.deal_type||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}function f3s(){const t=Qt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("drip_templates").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function x3s(){const t=Qt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("drip_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function g3s(){const t=ci(),s=Qt();return Lt({mutationFn:async({templateId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("drip_templates").select("*").eq("id",r).single();if(o)throw o;const{data:l,error:i}=await H.from("drip_templates").insert({owner_user_id:t,stage_id:n,title:a.title,subject:a.subject,body:a.body,video_url:a.video_url,channel:a.channel,delay_type:a.delay_type,delay_minutes:a.delay_minutes,is_enabled:!1,is_starter:!1,deal_type:a.deal_type}).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}const y3s=[{key:"{{client_first_name}}",label:"Client First Name"},{key:"{{client_last_name}}",label:"Client Last Name"},{key:"{{property_address}}",label:"Property Address"},{key:"{{agent_name}}",label:"Your Name"},{key:"{{agent_phone}}",label:"Your Phone"},{key:"{{close_date}}",label:"Target Close Date"},{key:"{{stage_name}}",label:"Current Stage"},{key:"{{portal_link}}",label:"Portal Link"},{key:"{{review_link}}",label:"Review Link"}];function v3s(){const t=ci(),{data:s,isLoading:r}=h3s(),{data:n,isLoading:a}=m3s(),o=p3s(),l=f3s(),i=x3s(),c=g3s(),[u,p]=k.useState(null),[f,g]=k.useState(null),b=(s==null?void 0:s.filter(I=>!I.is_starter&&I.owner_user_id===t))||[],_=(s==null?void 0:s.filter(I=>I.is_starter))||[],j=I=>b.filter(O=>O.stage_id===I),w=async I=>{try{await l.mutateAsync({id:I.id,is_enabled:!I.is_enabled}),me.success(I.is_enabled?"Drip disabled":"Drip enabled")}catch{me.error("Failed to update")}},N=async I=>{try{const O=n==null?void 0:n.find(q=>q.id===I);await o.mutateAsync({stage_id:I,title:`${(O==null?void 0:O.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),p(I),me.success("Drip template created")}catch{me.error("Failed to create template")}},S=async I=>{try{await i.mutateAsync(I),me.success("Template deleted")}catch{me.error("Failed to delete")}},M=async I=>{if(!n||n.length===0){me.error("No pipeline stages found");return}const O=n[0].id;try{await c.mutateAsync({templateId:I,stageId:O}),me.success("Template copied to your drips!")}catch{me.error("Failed to copy template")}},L=r||a;return e.jsx(Ms,{children:e.jsxs("div",{className:"container max-w-4xl mx-auto py-6 px-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zh,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(st,{variant:"outline",className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 border-amber-500 text-amber-600 bg-amber-500/10",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Automatically send personalized emails when deals move through your pipeline."})]}),e.jsx(u3s,{})]}),e.jsxs("div",{className:"bg-primary/5 border border-primary/15 rounded-xl p-4 mb-6 flex items-start gap-3",children:[e.jsx(hL,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground mb-1",children:"How it works"}),e.jsxs("p",{children:["When a deal moves to a new stage in your pipeline, Smart Drips automatically sends your pre-written email to the client. Nothing sends until you create a template ",e.jsx("strong",{children:"and"})," toggle it on."]})]})]}),e.jsxs(ba,{defaultValue:"my-drips",children:[e.jsxs(pa,{className:"grid grid-cols-2 w-full max-w-xs mb-6",children:[e.jsx(ns,{value:"my-drips",children:"My Drips"}),e.jsxs(ns,{value:"starters",children:["Starter Templates",_.length>0&&e.jsx(st,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:_.length})]})]}),e.jsx(bs,{value:"my-drips",children:L?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(I=>e.jsx(ys,{className:"h-16 w-full rounded-xl"},I))}):!n||n.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(Zh,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create pipeline stages first to set up drip automations."})]}):e.jsxs("div",{className:"space-y-2",children:[n.filter(I=>!I.is_won_stage&&!I.is_lost_stage).map(I=>{const O=j(I.id),q=u===I.id,U=O.some(B=>B.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>p(q?null:I.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:I.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:I.name}),O.length>0&&e.jsxs(st,{variant:"outline",className:`text-[10px] ${U?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[O.length," drip",O.length!==1?"s":"",U&&" · Active"]}),q?e.jsx(Eo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]}),q&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:O.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>N(I.id),disabled:o.isPending,children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[O.map(B=>e.jsx(Yze,{template:B,isEditing:f===B.id,onToggleEdit:()=>g(f===B.id?null:B.id),onToggleEnabled:()=>w(B),onUpdate:V=>l.mutateAsync({id:B.id,...V}),onDelete:()=>S(B.id),userId:t||""},B.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(I.id),children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},I.id)}),n.filter(I=>I.is_won_stage||I.is_lost_stage).length>0&&e.jsxs("div",{className:"pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-medium mb-2 px-1",children:"Closing Stages"}),n.filter(I=>I.is_won_stage||I.is_lost_stage).map(I=>{const O=j(I.id),q=u===I.id,U=O.some(B=>B.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>p(q?null:I.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:I.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:I.name}),O.length>0&&e.jsxs(st,{variant:"outline",className:`text-[10px] ${U?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[O.length," drip",O.length!==1?"s":"",U&&" · Active"]}),q?e.jsx(Eo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]}),q&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:O.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>N(I.id),disabled:o.isPending,children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[O.map(B=>e.jsx(Yze,{template:B,isEditing:f===B.id,onToggleEdit:()=>g(f===B.id?null:B.id),onToggleEnabled:()=>w(B),onUpdate:V=>l.mutateAsync({id:B.id,...V}),onDelete:()=>S(B.id),userId:t||""},B.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(I.id),children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},I.id)})]})]})}),e.jsx(bs,{value:"starters",children:_.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(pn,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Starter Templates Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Admin-created starter templates will appear here. You'll be able to copy them into your own drips."})]}):e.jsx("div",{className:"space-y-3",children:_.map(I=>e.jsx(b3s,{template:I,onCopy:()=>M(I.id),isCopying:c.isPending},I.id))})})]})]})})}function Yze({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,c]=k.useState(t.title),[u,p]=k.useState(t.subject),[f,g]=k.useState(t.body),[b,_]=k.useState(t.video_url||""),[j,w]=k.useState(t.channel),[N,S]=k.useState(t.delay_type),[M,L]=k.useState(t.delay_minutes),[I,O]=k.useState(!1),q=async()=>{O(!0);try{await a({title:i,subject:u,body:f,video_url:b||null,channel:j,delay_type:N,delay_minutes:M}),me.success("Drip saved"),r()}catch{me.error("Failed to save")}finally{O(!1)}},U=B=>{g(V=>V+B)};return e.jsxs("div",{className:"border rounded-lg bg-background overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",role:"button",onClick:r,children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title||"Untitled drip"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.channel==="sms"?e.jsx(so,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(cr,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.delay_type==="instant"?"Sends instantly":`Sends after ${t.delay_minutes>=60?`${Math.round(t.delay_minutes/60)}h`:`${t.delay_minutes}m`}`}),t.video_url&&e.jsx(An,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(qr,{checked:t.is_enabled,onCheckedChange:n})]}),s&&e.jsxs("div",{className:"border-t p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(ze,{value:i,onChange:B=>c(B.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Buyer intro video"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map(B=>e.jsxs("button",{onClick:()=>w(B),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${j===B?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[B==="sms"?e.jsx(so,{className:"h-3 w-3"}):e.jsx(cr,{className:"h-3 w-3"}),B==="sms"?"SMS":"Email"]},B))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs font-medium",children:"Timing"}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("button",{onClick:()=>S("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="instant"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:"Instant"}),e.jsxs("button",{onClick:()=>S("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(un,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),N==="scheduled"&&e.jsxs("div",{children:[e.jsx(be,{className:"text-xs font-medium",children:"Delay"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(ze,{type:"number",min:1,value:M>=60?Math.round(M/60):M,onChange:B=>{const V=parseInt(B.target.value)||0;L(M>=60?V*60:V)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:M<60?M:30},{label:"Hours",mins:M>=60?M:60},{label:"Days",mins:M>=1440?M:1440}].map(B=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${B.label==="Minutes"&&M<60||B.label==="Hours"&&M>=60&&M<1440||B.label==="Days"&&M>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{B.label==="Minutes"?L(30):B.label==="Hours"?L(60):L(1440)},children:B.label},B.label))})]})]}),j==="email"&&e.jsxs("div",{children:[e.jsx(be,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(ze,{value:u,onChange:B=>p(B.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Next steps for your home purchase"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(be,{className:"text-xs font-medium",children:j==="sms"?"Message":"Email Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Insert:"}),e.jsxs("select",{className:"text-[10px] border rounded px-1 py-0.5 bg-background text-muted-foreground",value:"",onChange:B=>{B.target.value&&U(B.target.value),B.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),y3s.map(B=>e.jsx("option",{value:B.key,children:B.label},B.key))]})]})]}),e.jsx("textarea",{value:f,onChange:B=>g(B.target.value),placeholder:j==="sms"?"Hey {{client_first_name}}, great talking with you today! Here's a quick video about what's next...":`Hi {{client_first_name}}, It was great meeting with you! Here's a video about what to expect next...`,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[100px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs font-medium",children:"Attached Video"}),b?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:[e.jsx(An,{className:"h-3 w-3 inline mr-1 text-primary"}),b.length>50?b.slice(0,50)+"...":b]}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive",onClick:()=>_(""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(cCe,{onVideoReady:B=>_(B)}),e.jsx(lCe,{userId:l,onSelect:B=>_(B),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const B=prompt("Paste a YouTube or Loom URL:");B&&_(B)},children:[e.jsx(Bo,{className:"h-3 w-3"})," Paste URL"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:o,children:[e.jsx(Nr,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(K,{size:"sm",className:"text-xs",onClick:q,disabled:I,children:I?"Saving...":"Save Drip"})]})]})]})]})}function b3s({template:t,onCopy:s,isCopying:r}){const[n,a]=k.useState(!1),o=t.body.replace(/<[^>]+>/g,""),l=t.deal_type==="buyer"?"Buyer":t.deal_type==="seller"?"Seller":null,i=t.delay_type==="instant"?"Sends instantly":t.delay_minutes>=1440?`Sends after ${Math.round(t.delay_minutes/1440)} day${Math.round(t.delay_minutes/1440)!==1?"s":""}`:t.delay_minutes>=60?`Sends after ${Math.round(t.delay_minutes/60)} hour${Math.round(t.delay_minutes/60)!==1?"s":""}`:`Sends after ${t.delay_minutes} min`;return e.jsxs("div",{className:"border rounded-xl overflow-hidden transition-all hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-start gap-3 p-4 text-left hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:t.subject}),!n&&e.jsx("p",{className:"text-xs text-muted-foreground/70 line-clamp-1 mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pt-0.5",children:[l&&e.jsx(st,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(so,{className:"h-3 w-3"}):e.jsx(cr,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(Eo,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(da,{className:"h-4 w-4 text-muted-foreground ml-1"})]})]}),n&&e.jsxs("div",{className:"border-t bg-muted/10 p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Subject Line"}),e.jsx("p",{className:"text-sm font-medium",children:t.subject})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Email Body"}),e.jsx("div",{className:"text-sm text-foreground/80 bg-background rounded-lg border p-4 prose prose-sm max-w-none [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-0.5 [&_p]:my-2 [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:t.body}})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(un,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i})]}),e.jsxs(K,{onClick:c=>{c.stopPropagation(),s()},size:"sm",className:"w-full gap-1.5",disabled:r,children:[e.jsx(gi,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const bct=()=>{const t=id();return k.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-100",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),e.jsx("p",{className:"mb-4 text-xl text-gray-600",children:"Oops! Page not found"}),e.jsx("a",{href:"/",className:"text-blue-500 underline hover:text-blue-700",children:"Return to Home"})]})})};function _3s(){return k.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(R2e,{children:[e.jsx(ks,{path:"/c/:shareToken",element:e.jsx(vct,{})}),e.jsx(ks,{path:"*",element:e.jsx(bct,{})})]})}const Lye={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function _ct({slugOverride:t}){const s=yo(),r=t||s.slug,[n,a]=k.useState("types"),[o,l]=k.useState(null),[i,c]=k.useState(null),[u,p]=k.useState(null),[f,g]=k.useState(new Date),[b,_]=k.useState({name:"",email:"",phone:"",message:""}),[j,w]=k.useState(!1),{data:N,isLoading:S}=mt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:X,error:ie}=await H.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(ie)throw ie;return X},enabled:!!r}),{data:M}=mt({queryKey:["public-booking-profile",N==null?void 0:N.user_id],queryFn:async()=>{const{data:X,error:ie}=await H.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",N.user_id).single();if(ie)throw ie;return X},enabled:!!(N!=null&&N.user_id)}),{data:L=[]}=mt({queryKey:["public-booking-types",N==null?void 0:N.user_id],queryFn:async()=>{const{data:X,error:ie}=await H.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",N.user_id).eq("is_active",!0).order("sort_order");if(ie)throw ie;return X},enabled:!!(N!=null&&N.user_id)}),{data:I=[]}=mt({queryKey:["public-availability",N==null?void 0:N.user_id],queryFn:async()=>{const{data:X,error:ie}=await H.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",N.user_id).eq("is_active",!0);if(ie)throw ie;return X},enabled:!!(N!=null&&N.user_id)}),{data:O=[]}=mt({queryKey:["public-blocked-dates",N==null?void 0:N.user_id],queryFn:async()=>{const{data:X,error:ie}=await H.from("agent_blocked_dates").select("blocked_date").eq("user_id",N.user_id);if(ie)throw ie;return X.map(re=>re.blocked_date)},enabled:!!(N!=null&&N.user_id)}),{data:q=[]}=mt({queryKey:["public-existing-bookings",N==null?void 0:N.user_id,i],queryFn:async()=>{if(!i)return[];const X=ms(i,"yyyy-MM-dd"),{data:ie,error:re}=await H.from("bookings").select("start_time, end_time").eq("agent_user_id",N.user_id).eq("booking_date",X).eq("status","confirmed");if(re)throw re;return ie},enabled:!!(N!=null&&N.user_id)&&!!i}),U=k.useMemo(()=>[...new Set(I.map(X=>X.day_of_week))],[I]),B=X=>{const ie=$m(new Date),re=Pl(ie,(N==null?void 0:N.max_advance_days)||30),oe=Pl(ie,0);return VS(X,oe)||US(X,re)||O.includes(ms(X,"yyyy-MM-dd"))?!1:U.includes(X.getDay())},V=k.useMemo(()=>{if(!i||!o||!N)return[];const X=I.filter(ye=>ye.day_of_week===i.getDay()),ie=o.duration_minutes,re=N.buffer_minutes||0,oe=[],ce=new Date,ge=(N.min_notice_hours||2)*60*60*1e3;for(const ye of X){const[ue,pe]=ye.start_time.split(":").map(Number),[_e,$e]=ye.end_time.split(":").map(Number);let Ae=WL(HL(i,ue),pe);const Ie=WL(HL(i,_e),$e);for(;iM(Ae,ie)<=Ie;){const Ce=ms(Ae,"HH:mm"),xe=ms(iM(Ae,ie),"HH:mm");Ae.getTime()-ce.getTime()>=ge&&(q.some(Le=>{const tt=Le.start_time.slice(0,5),Te=Le.end_time.slice(0,5);return Cett})||oe.push(Ce)),Ae=iM(Ae,ie+re)}}return oe},[i,o,I,N,q]),Y=k.useMemo(()=>{const X=f.getFullYear(),ie=f.getMonth(),re=new Date(X,ie,1),oe=new Date(X,ie+1,0),ce=re.getDay(),ge=[];for(let ye=0;ye{if(!(!o||!i||!u||!b.name||!N)){w(!0);try{const X=ms(iM(WL(HL(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:ie}=await H.from("bookings").insert({agent_user_id:N.user_id,booking_type_id:o.id,booking_date:ms(i,"yyyy-MM-dd"),start_time:u,end_time:X,guest_name:b.name,guest_email:b.email||null,guest_phone:b.phone||null,guest_message:b.message||null});if(ie)throw ie;H.functions.invoke("booking-notify",{body:{agentUserId:N.user_id,guestName:b.name,guestEmail:b.email||null,guestPhone:b.phone||null,guestMessage:b.message||null,bookingTypeName:o.name,bookingDate:ms(i,"yyyy-MM-dd"),startTime:u,endTime:X,durationMinutes:o.duration_minutes,meetingLink:N.meeting_link||null}}).catch(re=>console.error("Booking notify error:",re)),a("confirmed")}catch(X){me.error("Failed to book: "+X.message)}finally{w(!1)}}},ee=X=>{const[ie,re]=X.split(":").map(Number),oe=ie>=12?"PM":"AM";return`${ie%12||12}:${re.toString().padStart(2,"0")} ${oe}`};return S?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):N?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8]",children:[e.jsx("div",{className:"h-1.5 bg-gradient-to-r from-[#406E71] via-[#5a9a9d] to-[#2a4c64]"}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 sm:py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden mb-6",children:[e.jsx("div",{className:"relative bg-gradient-to-r from-[#406E71] to-[#2a4c64] px-6 pt-6 pb-12",children:e.jsxs("div",{className:"absolute inset-0 opacity-10",children:[e.jsx("div",{className:"absolute top-2 right-8 w-20 h-20 rounded-full border-2 border-white/30"}),e.jsx("div",{className:"absolute bottom-4 left-12 w-10 h-10 rounded-full border border-white/20"})]})}),e.jsx("div",{className:"relative -mt-10 px-6",children:e.jsxs("div",{className:"flex items-end gap-4",children:[M!=null&&M.avatar_url?e.jsx("img",{src:M.avatar_url,alt:(M==null?void 0:M.name)||"Agent",className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl object-cover border-4 border-white shadow-md"}):e.jsx("div",{className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl bg-gradient-to-br from-[#406E71] to-[#2a4c64] border-4 border-white shadow-md flex items-center justify-center",children:e.jsx(to,{className:"h-10 w-10 text-white"})}),e.jsxs("div",{className:"pb-1.5",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-slate-800 leading-tight",children:(M==null?void 0:M.name)||"Agent"}),(M==null?void 0:M.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:M.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(M==null?void 0:M.phone)&&e.jsxs("a",{href:`tel:${M.phone}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#406E71]/8 hover:bg-[#406E71]/15 text-[#406E71] text-xs font-medium transition-colors",children:[e.jsx(Un,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:M.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(M==null?void 0:M.email)&&e.jsxs("a",{href:`mailto:${M.email}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#2a4c64]/8 hover:bg-[#2a4c64]/15 text-[#2a4c64] text-xs font-medium transition-colors",children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:M.email}),e.jsx("span",{className:"sm:hidden",children:"Email"})]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden",children:e.jsxs("div",{className:"p-5 sm:p-6",children:[n==="types"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800",children:"Select a meeting type"}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Choose the type of meeting you'd like to schedule"})]}),e.jsx("div",{className:"space-y-2.5",children:L.map(X=>e.jsx("button",{onClick:()=>{l(X),a("date")},className:"w-full text-left group",children:e.jsx("div",{className:"relative rounded-xl border border-slate-150 p-4 transition-all duration-200 hover:shadow-md hover:border-[#406E71]/30 hover:-translate-y-0.5 active:translate-y-0",style:{borderLeftWidth:"3px",borderLeftColor:X.color},children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("span",{className:"text-2xl shrink-0 mt-0.5",children:Lye[X.icon]||"📅"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-slate-800 group-hover:text-[#406E71] transition-colors",children:X.name}),X.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:X.description})]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-full bg-slate-100 text-slate-600 text-xs font-medium",children:[e.jsx(un,{className:"h-3 w-3"}),X.duration_minutes,"m"]})]})})},X.id))})]}),n==="date"&&o&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>{a("types"),c(null),p(null)},className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ja,{className:"h-3.5 w-3.5"})," Back to meeting types"]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border",style:{borderColor:o.color+"40",backgroundColor:o.color+"08"},children:[e.jsx("span",{className:"text-xl",children:Lye[o.icon]||"📅"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-semibold text-sm text-slate-800",children:o.name})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 font-medium",children:[e.jsx(un,{className:"h-3 w-3"}),o.duration_minutes," min"]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ms(f,"MMMM yyyy")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>g(new Date(f.getFullYear(),f.getMonth()-1)),children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>g(new Date(f.getFullYear(),f.getMonth()+1)),children:e.jsx(da,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5 text-center",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(X=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:X},X)),Y.map((X,ie)=>{if(!X)return e.jsx("div",{},`pad-${ie}`);const re=B(X),oe=i&&Cl(X,i),ce=Cl(X,new Date);return e.jsx("button",{disabled:!re,onClick:()=>{c(X),p(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${oe?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":re?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${ce&&!oe?"ring-1 ring-[#406E71]/40":""}`,children:X.getDate()},X.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Od,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ms(i,"EEEE, MMMM d")})]}),V.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(un,{className:"h-8 w-8 text-slate-300 mx-auto"}),e.jsx("p",{className:"text-sm text-slate-400",children:"No available times on this day"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Try selecting a different date"})]}):e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2 max-h-52 overflow-y-auto pr-1 custom-scrollbar",children:V.map(X=>{const ie=u===X;return e.jsx("button",{onClick:()=>p(X),className:`px-3 py-2.5 rounded-xl text-sm font-medium transition-all duration-150 ${ie?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-[1.02]":"bg-slate-50 text-slate-700 hover:bg-[#406E71]/10 hover:text-[#406E71] border border-slate-150"}`,children:ee(X)},X)})}),u&&e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg",onClick:()=>a("form"),children:"Continue to Details"})]})]}),n==="form"&&o&&i&&u&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>a("date"),className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ja,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"rounded-xl bg-gradient-to-r from-[#406E71]/5 to-[#2a4c64]/5 border border-[#406E71]/15 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:Lye[o.icon]||"📅"}),e.jsx("p",{className:"font-semibold text-sm text-slate-800",children:o.name})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-slate-600",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Od,{className:"h-3.5 w-3.5 text-[#406E71]"}),ms(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3.5 w-3.5 text-[#406E71]"}),ee(u)," · ",o.duration_minutes," min"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(ze,{value:b.name,onChange:X=>_({...b,name:X.target.value}),placeholder:"Jane Smith",className:"h-11 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(cr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(ze,{type:"email",value:b.email,onChange:X=>_({...b,email:X.target.value}),placeholder:"jane@email.com",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Un,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(ze,{type:"tel",value:b.phone,onChange:X=>_({...b,phone:X.target.value}),placeholder:"(555) 123-4567",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(Er,{value:b.message,onChange:X=>_({...b,message:X.target.value}),placeholder:"Anything you'd like the agent to know ahead of time?",rows:3,className:"rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20 resize-none"})]})]}),e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg disabled:opacity-60",onClick:Q,disabled:!b.name||j,children:j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}),"Booking..."]}):"Confirm Booking"})]}),n==="confirmed"&&e.jsxs("div",{className:"text-center space-y-5 py-6",children:[e.jsxs("div",{className:"relative mx-auto w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-emerald-100 animate-ping opacity-30"}),e.jsx("div",{className:"relative w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-200",children:e.jsx(sa,{className:"h-10 w-10 text-white"})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-800",children:"You're booked!"}),e.jsxs("p",{className:"text-slate-500 mt-1.5",children:[o==null?void 0:o.name," with ",(M==null?void 0:M.name)||"your agent"]})]}),e.jsx("div",{className:"inline-flex items-center gap-3 px-5 py-3 rounded-xl bg-slate-50 border border-slate-100",children:e.jsxs("div",{className:"text-left text-sm",children:[e.jsx("p",{className:"font-semibold text-slate-800",children:i&&ms(i,"EEEE, MMMM d, yyyy")}),e.jsxs("p",{className:"text-slate-500",children:[u&&ee(u)," · ",o==null?void 0:o.duration_minutes," min"]})]})}),e.jsx("p",{className:"text-sm text-slate-400 max-w-xs mx-auto",children:"A confirmation with meeting details will be sent to you shortly."}),((M==null?void 0:M.phone)||(M==null?void 0:M.email))&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider font-semibold",children:"Contact"}),e.jsxs("div",{className:"flex gap-3",children:[(M==null?void 0:M.phone)&&e.jsxs("a",{href:`tel:${M.phone}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#406E71]/10 text-[#406E71] text-xs font-medium hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Call"]}),(M==null?void 0:M.email)&&e.jsxs("a",{href:`mailto:${M.email}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#2a4c64]/10 text-[#2a4c64] text-xs font-medium hover:bg-[#2a4c64]/20 transition-colors",children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]})}),e.jsx("p",{className:"text-center text-[10px] text-slate-300 mt-6 font-medium tracking-wide uppercase",children:"Powered by LevelUp"})]})]}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-sm w-full text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center",children:e.jsx(Od,{className:"h-8 w-8 text-slate-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-slate-700",children:"Page Not Available"}),e.jsx("p",{className:"text-sm text-slate-500",children:"This booking page doesn't exist or is currently inactive."})]})})}function w3s(){const s=id().pathname.slice(1).split("/")[0];return k.useEffect(()=>{document.body.classList.add("booking-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("booking-page"),n.forEach(clearTimeout)}},[]),s?e.jsx(_ct,{slugOverride:s}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground",children:"Visit a specific agent's booking URL to schedule a meeting."})]})})}function j3s(){const s=id().pathname.slice(1);return k.useEffect(()=>{document.body.classList.add("connect-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("connect-page"),n.forEach(clearTimeout)}},[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Connect"}),e.jsx("p",{className:"text-slate-500",children:"Stay connected with your real estate professional."}),e.jsx("p",{className:"text-slate-400 text-sm mt-2",children:"Visit a specific agent link to get started."})]})}):e.jsx($Ye,{slugOverride:s})}function wct({slugOverride:t}){const{slug:s}=yo(),r=t||s,[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,c]=k.useState(0),[u,p]=k.useState(!1),{data:f,isLoading:g}=mt({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:q,error:U}=await H.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(U)throw U;return q},enabled:!!r}),{data:b=[]}=mt({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:q,error:U}=await H.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if(U)throw U;return q},enabled:!!(f!=null&&f.id)});k.useEffect(()=>{f!=null&&f.id&&H.from("landing_pages").update({view_count:(f.view_count||0)+1}).eq("id",f.id).then(()=>{})},[f==null?void 0:f.id]);const _=Lt({mutationFn:async()=>{const q=b.find(X=>X.field_type==="text"&&X.label.toLowerCase().includes("name")),U=b.find(X=>X.field_type==="email"),B=b.find(X=>X.field_type==="phone"),V=q?String(o[q.label]||""):null,Y=U?String(o[U.label]||""):null,Q=B?String(o[B.label]||""):null,{error:ee}=await H.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:V,contact_email:Y,contact_phone:Q,referrer:document.referrer||null,user_agent:navigator.userAgent,utm_source:new URLSearchParams(window.location.search).get("utm_source"),utm_medium:new URLSearchParams(window.location.search).get("utm_medium"),utm_campaign:new URLSearchParams(window.location.search).get("utm_campaign")}]);if(ee)throw ee;H.functions.invoke("landing-page-lead-notify",{body:{page_id:f.id,contact_name:V,contact_email:Y,contact_phone:Q,answers:o}}).catch(X=>console.error("Landing page lead notification error:",X))},onSuccess:()=>a(!0)}),j=q=>{q.preventDefault(),!(b.filter(B=>B.is_required&&!o[B.label]).length>0)&&_.mutate()};if(g)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-gray-400 border-t-transparent"})});if(!f)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-700",children:"Page Not Found"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"This page doesn't exist or is no longer available."})]})});const w=f.primary_color||"#406E71",N=f.accent_color||"#2a4c64",S=f,M=f.page_type==="lead_magnet",L=f.page_type==="just_listed"||f.page_type==="just_sold",I=Array.isArray(S.property_photos)?S.property_photos:[],O=S.lead_magnet_file_url||S.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(sa,{className:"h-16 w-16 mx-auto mb-4",style:{color:w}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:M?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:f.success_message}),M&&O&&e.jsxs("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-6 px-6 py-3 rounded-lg text-white font-semibold transition-transform hover:scale-105",style:{backgroundColor:w},children:[e.jsx(yi,{className:"h-5 w-5"}),"Download ",S.lead_magnet_file_name||"Your File"]}),f.agent_name&&e.jsxs("div",{className:"mt-6 pt-4 border-t",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Contact"}),e.jsx("p",{className:"font-semibold",children:f.agent_name}),f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(Un,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(cr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(L){const q=U=>{const B=parseFloat(U.replace(/[^0-9.]/g,""));return isNaN(B)?U:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(B)};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[u&&I.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",onClick:()=>p(!1),children:[e.jsx("button",{onClick:()=>p(!1),className:"absolute top-4 right-4 text-white/80 hover:text-white z-10",children:e.jsx(Rr,{className:"h-8 w-8"})}),e.jsx("button",{onClick:U=>{U.stopPropagation(),c(B=>B===0?I.length-1:B-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx("img",{src:I[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:U=>U.stopPropagation()}),e.jsx("button",{onClick:U=>{U.stopPropagation(),c(B=>B===I.length-1?0:B+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(da,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 text-white/70 text-sm",children:[i+1," / ",I.length]})]}),I.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:S.property_status==="just_sold"?"#e74c3c":w},children:S.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),I.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{c(0),p(!0)},children:[e.jsx("img",{src:I[0],alt:"Property",className:"w-full h-[50vh] object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/60 text-white px-3 py-1.5 rounded-lg text-sm flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(K_,{className:"h-4 w-4"})," View"]})]}):I.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:I.slice(0,2).map((U,B)=>e.jsx("div",{className:"cursor-pointer group relative",onClick:()=>{c(B),p(!0)},children:e.jsx("img",{src:U,alt:`Property ${B+1}`,className:"w-full h-[45vh] object-cover group-hover:scale-105 transition-transform duration-500"})},B))}):e.jsxs("div",{className:"grid grid-cols-4 gap-2 rounded-2xl overflow-hidden",style:{height:"55vh"},children:[e.jsx("div",{className:"col-span-2 row-span-2 cursor-pointer group relative",onClick:()=>{c(0),p(!0)},children:e.jsx("img",{src:I[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),I.slice(1,5).map((U,B)=>e.jsxs("div",{className:"cursor-pointer group relative",onClick:()=>{c(B+1),p(!0)},children:[e.jsx("img",{src:U,alt:`Property ${B+2}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),B===3&&I.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",I.length-5," more"]})]},B))]}),I.length>2&&e.jsxs("button",{onClick:()=>{c(0),p(!0)},className:"absolute bottom-4 right-8 bg-white shadow-lg hover:shadow-xl text-gray-800 px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-shadow",children:[e.jsx(K_,{className:"h-4 w-4"})," View all ",I.length," photos"]})]}),I.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-8",children:e.jsxs("div",{className:"grid md:grid-cols-5 gap-6",children:[e.jsx("div",{className:"md:col-span-3 space-y-6",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[S.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:w},children:q(S.property_price)}),S.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(ma,{className:"h-5 w-5 shrink-0"})," ",S.property_address]}),e.jsxs("div",{className:"flex gap-6 mb-5 py-4 border-y border-gray-100",children:[S.property_beds&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Im,{className:"h-5 w-5",style:{color:w}})," ",S.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),S.property_baths&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Ju,{className:"h-5 w-5",style:{color:w}})," ",S.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),S.property_sqft&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(g0,{className:"h-5 w-5",style:{color:w}})," ",Number(S.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),S.property_description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:S.property_description})]})]})}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 sticky top-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:w},children:S.property_status==="just_sold"?"Want results like this?":"Interested in this property?"}),e.jsx("p",{className:"text-gray-500 text-sm mb-4",children:"Fill out the form and I'll be in touch!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:f.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Un,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(cr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,className:"space-y-3",children:[b.map(U=>e.jsxs("div",{children:[e.jsxs(be,{className:"text-xs font-medium",children:[U.label,U.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Xze(U,o,l)]},U.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:_.isPending,children:_.isPending?"Submitting...":"Submit"}),_.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext}),M&&S.lead_magnet_file_name&&e.jsxs("div",{className:"mt-6 inline-flex items-center gap-2 bg-white/20 backdrop-blur px-4 py-2 rounded-full text-sm",children:[e.jsx(yi,{className:"h-4 w-4"}),"Free Download: ",S.lead_magnet_file_name]})]})}),e.jsx("div",{className:"max-w-2xl mx-auto px-4 -mt-8",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[M&&e.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"Fill out the form below to get your free download!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-6 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:f.agent_name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Un,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(cr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[b.map(q=>e.jsxs("div",{children:[e.jsxs(be,{className:"text-sm font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Xze(q,o,l)]},q.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:_.isPending,children:_.isPending?"Submitting...":M?"Get My Free Download":"Submit"}),_.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}function Xze(t,s,r,n){const a=s[t.label]||"",o=Array.isArray(t.options)?t.options:[];switch(t.field_type){case"text":case"email":case"phone":return e.jsx(ze,{type:t.field_type==="email"?"email":t.field_type==="phone"?"tel":"text",value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",className:"mt-1"});case"textarea":return e.jsx(Er,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",rows:3,className:"mt-1"});case"select":return e.jsxs(Ks,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Hs,{className:"mt-1",children:e.jsx(Ys,{placeholder:"Select..."})}),e.jsx(Ws,{children:o.map(l=>e.jsx(Mt,{value:l,children:l},l))})]});case"multiselect":return e.jsx("div",{className:"mt-1 space-y-2",children:o.map(l=>{const i=Array.isArray(a)?a:[];return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Oo,{checked:i.includes(l),onCheckedChange:c=>{const u=c?[...i,l]:i.filter(p=>p!==l);r(p=>({...p,[t.label]:u}))}}),e.jsx("span",{className:"text-sm",children:l})]},l)})});case"toggle":return e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(qr,{checked:!!a,onCheckedChange:l=>r(i=>({...i,[t.label]:l?"Yes":"No"}))}),e.jsx("span",{className:"text-sm text-gray-600",children:a?"Yes":"No"})]});default:return e.jsx(ze,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function N3s(){const s=id().pathname.slice(1).split("/")[0];return k.useEffect(()=>{document.body.classList.add("landing-page-public");const r=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("landing-page-public"),n.forEach(clearTimeout)}},[]),s?e.jsx(wct,{slugOverride:s}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"LevelUp Pages"}),e.jsx("p",{className:"text-gray-500",children:"Visit a specific page URL to view content."})]})})}const jct=[{type:"hero",enabled:!0},{type:"featured_listings",enabled:!0},{type:"new_listings",enabled:!1},{type:"open_houses",enabled:!1},{type:"my_listings",enabled:!1},{type:"city_pages",enabled:!1},{type:"featured_areas",enabled:!0},{type:"about",enabled:!0},{type:"testimonials",enabled:!0},{type:"cta_banner",enabled:!0}],sTs={hero:"Hero Section",featured_listings:"Featured Listings",featured_areas:"Featured Areas",about:"About Me",testimonials:"Testimonials",cta_banner:"Call To Action",new_listings:"New Listings Carousel",open_houses:"Open Houses Carousel",my_listings:"My Listings Carousel",city_pages:"City Pages Grid"};function k3s(t){const s=t.theme_config||{};return{themeTier:t.theme_tier||"basic",brandColor:t.brand_color||"#0f172a",accentColor:t.accent_color||"#3b82f6",fontFamily:t.font_family||"Inter",heroImageUrl:t.hero_image_url||null,homepageModules:Array.isArray(t.homepage_modules)&&t.homepage_modules.length?t.homepage_modules:jct,testimonials:Array.isArray(t.testimonials)?t.testimonials:[],featuredListingIds:t.featured_listing_ids||[],searchCities:Array.isArray(s.searchCities)?s.searchCities:[],searchZipCodes:Array.isArray(s.searchZipCodes)?s.searchZipCodes:[],searchCounties:Array.isArray(s.searchCounties)?s.searchCounties:[]}}function S3s(){const s=window.location.hostname.match(/^([^.]+)\.thelocalmove\.com$/i);return s?s[1]:null}function C3s(){const t=S3s(),{data:s,isLoading:r,error:n}=mt({queryKey:["lead-site",t],queryFn:async()=>{var p;if(!t)return null;const{data:a,error:o}=await H.from("lead_sites").select("*").eq("subdomain_slug",t).eq("is_active",!0).maybeSingle();if(o)throw o;if(!a)return null;const{data:l}=await H.from("profiles").select("id, name, avatar_url, email, phone, title, bio").eq("id",a.agent_id).single();let i=null;if(a.show_team_logo)if(a.team_logo_url)i=a.team_logo_url;else{const{data:f}=await H.from("team_members").select("team_id, teams(avatar_url, name)").eq("user_id",a.agent_id).limit(1).maybeSingle();f&&((p=f.teams)!=null&&p.avatar_url)&&(i=f.teams.avatar_url)}const c={id:a.id,agentId:a.agent_id,subdomainSlug:a.subdomain_slug,mlsProviderId:a.mls_provider_id,siteTitle:a.site_title,siteTagline:a.site_tagline,leadRegistrationMode:a.lead_registration_mode||"disabled",registrationTriggerCount:a.registration_trigger_count??1,themeConfig:a.theme_config||{},isActive:a.is_active,brokerageLegalName:a.brokerage_legal_name||null,brokerageLicenseNumber:a.brokerage_license_number||null,agentLicenseNumber:a.agent_license_number||null,mlsDisclaimerText:a.mls_disclaimer_text||null,mlsLogoUrl:a.mls_logo_url||null,equalHousingEnabled:a.equal_housing_enabled??!0,faviconUrl:a.favicon_url||null,ogImageUrl:a.og_image_url||null,showTeamLogo:a.show_team_logo??!1,teamLogoUrl:i,agent:l?{id:l.id,full_name:l.name||"",avatar_url:l.avatar_url,email:l.email,phone:l.phone,title:l.title,bio:l.bio}:void 0},u=k3s(a);return{siteConfig:c,themeConfig:u}},enabled:!!t});return{siteConfig:(s==null?void 0:s.siteConfig)??null,themeConfig:(s==null?void 0:s.themeConfig)??null,isLoading:r,error:n,slug:t}}async function wme(t,s){try{await H.functions.invoke("lead-site-notify",{body:{lead:s,lead_site_id:t}})}catch(r){console.warn("Lead notification failed:",r)}}const Nct=k.createContext(null);function jme(){const t=k.useContext(Nct);if(!t)throw new Error("useLeadSiteAuth must be used within LeadSiteAuthProvider");return t}function M3s({siteConfig:t,children:s}){const[r,n]=k.useState(null),[a,o]=k.useState(null),[l,i]=k.useState(!0);k.useEffect(()=>{const{data:{subscription:f}}=H.auth.onAuthStateChange(async(g,b)=>{const _=(b==null?void 0:b.user)??null;if(n(_),_){const{data:j}=await H.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",_.id).eq("lead_site_id",t.id).maybeSingle();j&&o({...j,email:_.email||""})}else o(null);i(!1)});return H.auth.getSession().then(({data:{session:g}})=>{n((g==null?void 0:g.user)??null),g!=null&&g.user?H.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",g.user.id).eq("lead_site_id",t.id).maybeSingle().then(({data:b})=>{b&&o({...b,email:g.user.email||""}),i(!1)}):i(!1)}),()=>f.unsubscribe()},[t.id]);const c=k.useCallback(async f=>{const g=f.email.toLowerCase().trim(),b=f.phone.replace(/\D/g,""),{data:_,error:j}=await H.auth.signUp({email:g,password:b,options:{data:{full_name:f.name,consumer_site_id:t.id},emailRedirectTo:window.location.origin}});if(j){if(j.message.includes("already registered")){await u(g,b);return}throw j}if(_.user){const{error:w}=await H.from("lead_site_consumer_profiles").insert({user_id:_.user.id,lead_site_id:t.id,name:f.name.trim(),phone:f.phone.trim()});w&&console.warn("Consumer profile insert error:",w);const{error:N}=await H.from("lead_site_leads").insert({lead_site_id:t.id,name:f.name.trim(),email:g,phone:f.phone.trim(),message:"Created account on website",source_page:window.location.pathname,lead_type:"website_registration",metadata:{registered:!0,has_account:!0}});N&&console.error("Lead insert error (CRM sync may not trigger):",N),wme(t.id,{name:f.name.trim(),email:g,phone:f.phone.trim(),lead_type:"website_registration",message:"Created account on website",source_page:window.location.pathname})}},[t.id]),u=k.useCallback(async(f,g)=>{const b=g.replace(/\D/g,""),{error:_}=await H.auth.signInWithPassword({email:f.toLowerCase().trim(),password:b});if(_)throw _},[]),p=k.useCallback(async()=>{await H.auth.signOut(),n(null),o(null)},[]);return e.jsx(Nct.Provider,{value:{user:r,profile:a,isLoading:l,signUp:c,signIn:u,signOut:p},children:s})}function kct({open:t,mode:s,siteConfig:r,onComplete:n,onSkip:a}){var O;const{signUp:o,signIn:l}=jme(),[i,c]=k.useState(!1),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,S]=k.useState(""),M=s==="required",L=((O=r.agent)==null?void 0:O.full_name)||"the agent",I=async q=>{var B;if(q.preventDefault(),S(""),!f.trim()||!b.trim()){S("Email and phone number are required.");return}if(!i&&!u.trim()){S("Name is required.");return}if(b.replace(/\D/g,"").length<7){S("Please enter a valid phone number.");return}w(!0);try{i?await l(f,b):await o({name:u,email:f,phone:b}),n()}catch(V){(B=V==null?void 0:V.message)!=null&&B.includes("Invalid login")?S("Invalid email or phone number. Please try again."):S((V==null?void 0:V.message)||"Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(fs,{open:t,onOpenChange:M?void 0:q=>{q||a()},children:e.jsxs(ps,{className:"sm:max-w-md",onPointerDownOutside:M?q=>q.preventDefault():void 0,onEscapeKeyDown:M?q=>q.preventDefault():void 0,children:[e.jsxs(_s,{children:[e.jsx(vs,{className:"text-xl",children:i?"Welcome Back":M?"Create a Free Account to Continue":"Save Your Search & Get Updates"}),e.jsx(Gr,{children:i?"Sign in with your email and phone number.":`Create a free account to save favorites, get alerts, and connect with ${L}.`})]}),e.jsxs("form",{onSubmit:I,className:"space-y-3 mt-2",children:[!i&&e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:u,onChange:q=>p(q.target.value),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address",value:f,onChange:q=>g(q.target.value),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsxs("div",{children:[e.jsx("input",{type:"tel",required:!0,placeholder:"Phone number",value:b,onChange:q=>_(q.target.value),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:i?"Your phone number is your password":"Your phone number will be used as your password"})]}),N&&e.jsx("p",{className:"text-red-600 text-sm",children:N}),e.jsx("button",{type:"submit",disabled:j,className:"w-full py-2.5 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:j?i?"Signing in...":"Creating account...":i?"Sign In":"Create Account"}),e.jsx("button",{type:"button",onClick:()=>{c(!i),S("")},className:"w-full text-center text-sm text-blue-600 hover:text-blue-700",children:i?"Don't have an account? Sign up":"Already have an account? Sign in"}),!M&&!i&&e.jsx("button",{type:"button",onClick:a,className:"w-full py-2 text-gray-500 text-sm hover:text-gray-700 transition-colors",children:"Skip for now"})]}),e.jsx("p",{className:"text-xs text-gray-400 text-center mt-1",children:"By registering you agree to receive property updates. You can unsubscribe anytime."})]})})}function xCe({siteConfig:t,pagePath:s}){const r=t.agent;if(!r)return null;const n=`https://${t.subdomainSlug}.thelocalmove.com`,a={"@context":"https://schema.org","@type":"RealEstateAgent","@id":`${n}/#agent`,name:r.full_name,url:n,image:r.avatar_url||void 0,email:r.email,telephone:r.phone||void 0,jobTitle:r.title||"Real Estate Agent",description:r.bio||`${r.full_name} is a trusted real estate professional.`,...t.brokerageLegalName&&{worksFor:{"@type":"RealEstateAgent",name:t.brokerageLegalName}}},o={"@context":"https://schema.org","@type":"WebSite","@id":`${n}/#website`,name:t.siteTitle||`${r.full_name} Real Estate`,url:n,publisher:{"@id":`${n}/#agent`},potentialAction:{"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${n}/search?q={search_term_string}`},"query-input":"required name=search_term_string"}};return e.jsxs(Sc,{children:[e.jsx("script",{type:"application/ld+json",children:JSON.stringify(a)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(o)})]})}function gCe({items:t,siteConfig:s}){const r=`https://${s.subdomainSlug}.thelocalmove.com`,n={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:t.map((a,o)=>({"@type":"ListItem",position:o+1,name:a.name,item:`${r}${a.path}`}))};return e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function T3s({listing:t,siteConfig:s}){var a;const r=`https://${s.subdomainSlug}.thelocalmove.com`,n={"@context":"https://schema.org","@type":"SingleFamilyResidence",name:`${t.address}, ${t.city}, ${t.state} ${t.zip}`,url:`${r}/listing/${t.mlsNumber}`,image:((a=t.photos)==null?void 0:a[0])||void 0,numberOfRooms:t.bedrooms,numberOfBathroomsTotal:t.bathrooms,floorSize:t.sqft?{"@type":"QuantitativeValue",value:t.sqft,unitCode:"FTK"}:void 0,address:{"@type":"PostalAddress",streetAddress:t.address,addressLocality:t.city,addressRegion:t.state,postalCode:t.zip},...t.latitude&&t.longitude&&{geo:{"@type":"GeoCoordinates",latitude:t.latitude,longitude:t.longitude}},offers:{"@type":"Offer",price:t.price,priceCurrency:"USD",availability:t.status==="Active"?"https://schema.org/InStock":"https://schema.org/SoldOut"},...t.yearBuilt&&{yearBuilt:t.yearBuilt}};return e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function A3s({faqs:t}){if(!t.length)return null;const s={"@context":"https://schema.org","@type":"FAQPage",mainEntity:t.map(r=>({"@type":"Question",name:r.question,acceptedAnswer:{"@type":"Answer",text:r.answer}}))};return e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})})}function E3s({title:t,description:s,publishedAt:r,imageUrl:n,slug:a,siteConfig:o}){const l=`https://${o.subdomainSlug}.thelocalmove.com`,i=o.agent,c={"@context":"https://schema.org","@type":"Article",headline:t,description:s,url:`${l}/blog/${a}`,datePublished:r,...n&&{image:n},author:i?{"@type":"Person",name:i.full_name,url:l}:void 0,publisher:{"@type":"Organization",name:o.siteTitle||(i==null?void 0:i.full_name)||"Agent",url:l}};return e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(c)})})}const Qze="ls_visitor_geo",P3s=1e3*60*60;function I3s(t){return t==="/"?"home":t==="/search"?"search":t==="/sell"?"sell":t==="/blog"?"blog":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":t==="/dashboard"?"dashboard":"other"}function L3s(t,s){switch(s){case"home":return"Home";case"search":return"Search";case"sell":return"Sell Your Home";case"blog":return"Blog";case"listing":return`Listing ${t.split("/listing/")[1]||""}`;case"city":return t.replace("/homes-for-sale-in-","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");case"dashboard":return"My Dashboard";default:return t}}async function D3s(){try{const t=localStorage.getItem(Qze);if(t){const s=JSON.parse(t);if(Date.now()-s.ts{o.current||(o.current=!0,D3s().then(l=>{a.current=l}))},[]),k.useEffect(()=>{if(!(t!=null&&t.id))return;const l=r.pathname;if(l===n.current)return;n.current=l;const i=I3s(l),c=L3s(l,i),u=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,p=a.current;H.from("lead_site_page_views").insert({lead_site_id:t.id,page_type:i,page_path:l,page_title:c,visitor_fingerprint:u,auth_user_id:s||null,visitor_city:(p==null?void 0:p.city)||null,visitor_region:(p==null?void 0:p.region)||null,visitor_country:(p==null?void 0:p.country)||null,visitor_lat:(p==null?void 0:p.lat)||null,visitor_lng:(p==null?void 0:p.lng)||null}).then(({error:f})=>{f&&console.error("[PageTracking] insert failed:",f.message)})},[r.pathname,t==null?void 0:t.id,s])}const R3s=3e4;function F3s(t,s){const r=id(),n=k.useRef(null),a=k.useRef(null),o=k.useRef(0),l=r.pathname,i=z3s(l),c=B3s(l,i),u=i==="listing"&&l.split("/listing/")[1]||null;k.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;i==="listing"&&(o.current+=1);const p=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,f=async()=>{const{data:g,error:b}=await H.from("lead_site_active_visitors").upsert({lead_site_id:t.id,auth_user_id:s,visitor_fingerprint:p,current_page_path:l,current_page_title:c,current_mls_number:u,last_seen_at:new Date().toISOString(),listing_views_count:o.current},{onConflict:"lead_site_id,coalesce(auth_user_id::text,visitor_fingerprint,'')"}).select("id, notified_agent").single();!b&&g&&(n.current=g.id,o.current>=2&&!g.notified_agent&&H.functions.invoke("lead-site-presence-notify",{body:{visitor_id:g.id,lead_site_id:t.id}}).catch(()=>{}))};return f(),a.current&&clearInterval(a.current),a.current=setInterval(f,R3s),()=>{a.current&&clearInterval(a.current)}},[t==null?void 0:t.id,s,l]),k.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;const p=()=>{n.current&&H.from("lead_site_active_visitors").delete().eq("id",n.current).then(()=>{})};return window.addEventListener("beforeunload",p),()=>window.removeEventListener("beforeunload",p)},[t==null?void 0:t.id,s])}function z3s(t){return t==="/"?"home":t==="/search"?"search":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":"other"}function B3s(t,s){switch(s){case"home":return"Home";case"search":return"Search";case"listing":return`Listing ${t.split("/listing/")[1]||""}`;case"city":return t.replace("/homes-for-sale-in-","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");default:return t}}function $3s({children:t,siteConfig:s}){var Y,Q,ee,X,ie,re,oe,ce,ge;const r=id(),n=fr(),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(!1),[p,f]=k.useState([]),g=k.useRef(null),{user:b,profile:_,signOut:j}=jme();O3s(s,b==null?void 0:b.id),F3s(s,b==null?void 0:b.id);const w=((Y=s.agent)==null?void 0:Y.full_name)||"Agent",N=s.siteTitle||`${w} Real Estate`,S=r.pathname==="/search",M=r.pathname==="/",L=s.leadRegistrationMode!=="disabled";k.useEffect(()=>{(async()=>{const{data:ue}=await H.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order",{ascending:!0});f(ue||[])})()},[s.id]),k.useEffect(()=>{const ye=ue=>{g.current&&!g.current.contains(ue.target)&&u(!1)};return document.addEventListener("mousedown",ye),()=>document.removeEventListener("mousedown",ye)},[]);const I=[{to:"/",label:"Home"},{to:"/search",label:"Search"},{to:"/sell",label:"Sell"},{to:"/blog",label:"Blog"},{to:"/community",label:"Community"},{to:"/about",label:"About"},{to:"/contact",label:"Contact"}],O=M?"bg-transparent text-white":"bg-white/95 backdrop-blur text-gray-900 border-b border-gray-100 shadow-sm",q=s.siteTitle||`${w} - Real Estate`,U=s.siteTagline||`Browse homes and listings with ${w}`,B=s.ogImageUrl||((Q=s.agent)==null?void 0:Q.avatar_url)||"",V=`https://${s.subdomainSlug||""}.thelocalmove.com`;return e.jsxs("div",{className:`flex flex-col ${S?"h-screen overflow-hidden":"min-h-screen"} bg-white`,children:[e.jsx(xCe,{siteConfig:s,pagePath:r.pathname}),e.jsxs(Sc,{children:[e.jsx("title",{children:q}),e.jsx("meta",{name:"description",content:U}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:U}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:V+r.pathname}),B&&e.jsx("meta",{property:"og:image",content:B}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:q}),e.jsx("meta",{name:"twitter:description",content:U}),B&&e.jsx("meta",{name:"twitter:image",content:B}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${V}${r.pathname}`}),s.subdomainSlug==="matthogg"&&e.jsx("script",{src:"https://analytics.ahrefs.com/analytics.js","data-key":"kyFjzruyvE0yTdMokzgCBw",async:!0})]}),e.jsxs("header",{className:`${M?"absolute":"sticky"} top-0 left-0 right-0 z-50 transition-all ${O}`,children:[e.jsx("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between h-20",children:[e.jsxs(Pi,{to:"/",className:"flex items-center gap-3",children:[((ee=s.agent)==null?void 0:ee.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:w,className:"h-10 w-10 rounded-full object-cover ring-2 ring-white/20"}),e.jsx("div",{children:e.jsx("span",{className:"font-bold text-lg leading-none tracking-tight",children:N})})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[I.map(ye=>e.jsx(Pi,{to:ye.to,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname===ye.to?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:ye.label},ye.to)),p.length>0&&e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!c),className:`flex items-center gap-1 px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname.startsWith("/homes-for-sale-in-")?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:["Cities ",e.jsx(Eo,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-52 bg-white rounded-xl shadow-xl border border-gray-100 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-150",children:p.map(ye=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${ye.city_slug}`),u(!1)},className:"w-full text-left px-4 py-2.5 text-sm text-gray-700 hover:bg-gray-50 hover:text-gray-900 transition-colors",children:ye.city_name},ye.city_slug))})]}),b?e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsxs(Pi,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(ni,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:"Saved"})]}),e.jsxs(Pi,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(to,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:((X=_==null?void 0:_.name)==null?void 0:X.split(" ")[0])||"Account"})]})]}):L?e.jsx("button",{onClick:()=>i(!0),className:`ml-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${M?"bg-white/15 text-white hover:bg-white/25":"bg-blue-600 text-white hover:bg-blue-700"}`,children:"Sign In"}):null]}),e.jsx("button",{onClick:()=>o(!a),className:`md:hidden p-2 rounded-lg ${M?"text-white hover:bg-white/10":"text-gray-600 hover:bg-gray-100"}`,children:a?e.jsx(Rr,{className:"h-5 w-5"}):e.jsx(RM,{className:"h-5 w-5"})})]})}),a&&e.jsx("div",{className:`md:hidden border-t ${M?"border-white/10 bg-black/80 backdrop-blur":"border-gray-100 bg-white"}`,children:e.jsxs("div",{className:"px-4 py-3 space-y-1",children:[I.map(ye=>e.jsx(Pi,{to:ye.to,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===ye.to?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ye.label},ye.to)),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`px-3 pt-3 pb-1 text-xs font-semibold uppercase tracking-wider ${M?"text-white/40":"text-gray-400"}`,children:"Cities"}),p.map(ye=>e.jsx(Pi,{to:`/homes-for-sale-in-${ye.city_slug}`,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===`/homes-for-sale-in-${ye.city_slug}`?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ye.city_name},ye.city_slug))]}),b?e.jsxs(e.Fragment,{children:[e.jsx(Pi,{to:"/account",onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"My Account"}),e.jsx("button",{onClick:async()=>{await j(),o(!1)},className:`block w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium ${M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"Sign Out"})]}):L?e.jsx("button",{onClick:()=>{i(!0),o(!1)},className:`block w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium ${M?"text-white/70 hover:bg-white/10":"text-blue-600 hover:bg-blue-50"}`,children:"Sign In / Register"}):null]})})]}),e.jsx("main",{className:"flex-1 min-h-0 flex flex-col",children:t}),!S&&e.jsx("footer",{className:"bg-gray-950 text-gray-400",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-12",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[((ie=s.agent)==null?void 0:ie.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:w,className:"h-16 w-16 rounded-2xl object-cover ring-2 ring-white/10"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-white text-lg tracking-tight",children:w}),e.jsx("p",{className:"text-sm text-gray-500",children:((re=s.agent)==null?void 0:re.title)||"Real Estate Professional"})]})]}),((oe=s.agent)==null?void 0:oe.phone)&&e.jsx("p",{className:"text-sm mt-3",children:e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"hover:text-white transition-colors flex items-center gap-2",children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," ",s.agent.phone]})}),((ce=s.agent)==null?void 0:ce.email)&&e.jsx("p",{className:"text-sm mt-1",children:e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"hover:text-white transition-colors flex items-center gap-2",children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," ",s.agent.email]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-white mb-4 text-sm tracking-wider uppercase",children:"Quick Links"}),e.jsx("ul",{className:"space-y-3 text-sm",children:I.map(ye=>e.jsx("li",{children:e.jsx(Pi,{to:ye.to,className:"hover:text-white transition-colors",children:ye.label})},ye.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-white mb-4 text-sm tracking-wider uppercase",children:"Get In Touch"}),e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed mb-4",children:"Ready to find your dream home? Get in touch today for a personalized consultation."}),e.jsx(Pi,{to:"/contact",className:"inline-block px-5 py-2.5 bg-white text-gray-900 text-sm font-semibold rounded-lg hover:bg-gray-100 transition-colors",children:"Contact Me"})]})]}),e.jsxs("div",{className:"mt-14 pt-6 border-t border-gray-800/50",children:[s.showTeamLogo&&s.teamLogoUrl&&e.jsx("div",{className:"flex items-center justify-center mb-6",children:e.jsx("img",{src:s.teamLogoUrl,alt:"Team",className:"h-12 w-auto object-contain"})}),s.brokerageLegalName&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-gray-500 mb-3",children:[e.jsxs("span",{children:[w," · ",s.brokerageLegalName]}),s.agentLicenseNumber&&e.jsx("span",{children:s.agentLicenseNumber}),s.brokerageLicenseNumber&&e.jsxs("span",{children:["Brokerage #",s.brokerageLicenseNumber]})]}),s.mlsDisclaimerText&&e.jsxs("div",{className:"flex items-start justify-center gap-3 mb-4",children:[s.mlsLogoUrl&&e.jsx("img",{src:s.mlsLogoUrl,alt:"MLS",className:"h-8 w-auto flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-gray-600 leading-relaxed max-w-3xl text-center",children:s.mlsDisclaimerText})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-gray-600",children:[s.equalHousingEnabled&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-5 w-5 text-gray-500",children:e.jsx("path",{d:"M12 2L2 8v2h20V8L12 2zm0 2.5L18.5 8h-13L12 4.5zM4 12v8h4v-6h8v6h4v-8H4zm6 8v-4h4v4h-4z"})}),e.jsx("span",{children:"Equal Housing Opportunity"})]}),e.jsxs("span",{children:["© ",new Date().getFullYear()," ",w,". Powered by LevelUp."]})]})]})]})}),!S&&((ge=s.agent)==null?void 0:ge.avatar_url)&&e.jsx(q3s,{agent:s.agent}),l&&e.jsx(kct,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function q3s({agent:t}){var a;const[s,r]=k.useState(!1),n=fr();return t?e.jsx("div",{className:"fixed bottom-6 right-6 z-40",children:s?e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl border border-gray-200 w-72 overflow-hidden animate-in slide-in-from-bottom-4 fade-in duration-200",children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-12 w-12 rounded-full object-cover ring-2 ring-gray-100"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-gray-900 text-sm",children:t.full_name}),e.jsx("p",{className:"text-xs text-gray-500",children:t.title||"Real Estate Professional"})]})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"Have questions about a property or the area? I'm here to help!"}),e.jsxs("div",{className:"space-y-2",children:[t.phone&&e.jsxs("a",{href:`tel:${t.phone}`,className:"flex items-center gap-2 w-full px-3 py-2 bg-gray-50 hover:bg-gray-100 rounded-xl text-sm text-gray-700 transition-colors",children:[e.jsx(Un,{className:"h-4 w-4 text-gray-400"}),t.phone]}),t.email&&e.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-center gap-2 w-full px-3 py-2 bg-gray-50 hover:bg-gray-100 rounded-xl text-sm text-gray-700 transition-colors",children:[e.jsx(cr,{className:"h-4 w-4 text-gray-400"}),"Email Me"]}),e.jsx("button",{onClick:()=>{r(!1),n("/contact")},className:"w-full px-3 py-2.5 bg-blue-600 hover:bg-blue-700 text-white text-sm font-semibold rounded-xl transition-colors",children:"Send a Message"})]})]}),e.jsx("button",{onClick:()=>r(!1),className:"absolute top-3 right-3 p-1 text-gray-400 hover:text-gray-600 rounded-full hover:bg-gray-100",children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:()=>r(!0),className:"group flex items-center gap-3 bg-white pl-1.5 pr-5 py-1.5 rounded-full shadow-xl border border-gray-200 hover:shadow-2xl transition-all hover:scale-105",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-10 w-10 rounded-full object-cover ring-2 ring-blue-100"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-xs font-bold text-gray-900 leading-none",children:(a=t.full_name)==null?void 0:a.split(" ")[0]}),e.jsx("p",{className:"text-[10px] text-blue-600 font-medium mt-0.5",children:"Chat with me →"})]})]})}):null}const U3s={city:{icon:ma,label:"City"},zip:{icon:$_,label:"ZIP Code"},county:{icon:l1,label:"County"}};function Sct({suggestions:t,cities:s,value:r,onChange:n,onSelect:a,placeholder:o,className:l,inputClassName:i}){const[c,u]=k.useState(!1),p=k.useRef(null),f=t.length>0?t:(s||[]).map(w=>({label:w,type:"city"})),g=r.trim()?f.filter(w=>w.label.toLowerCase().includes(r.toLowerCase())).slice(0,10):f.slice(0,10),b=g.reduce((w,N)=>(w[N.type]||(w[N.type]=[]),w[N.type].push(N),w),{}),_=c&&g.length>0;k.useEffect(()=>{const w=N=>{p.current&&!p.current.contains(N.target)&&u(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const j=["city","zip","county"];return e.jsxs("div",{ref:p,className:`relative ${l||""}`,children:[e.jsx("input",{type:"text",value:r,onChange:w=>{n(w.target.value),u(!0)},onFocus:()=>u(!0),placeholder:o,className:i,autoComplete:"off"}),_&&e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden z-50 max-h-[360px] overflow-y-auto",children:j.map(w=>{const N=b[w];if(!N||N.length===0)return null;const S=U3s[w],M=S.icon;return e.jsxs("div",{children:[e.jsxs("div",{className:"px-4 pt-2.5 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400",children:[S.label,"s"]}),N.map(L=>e.jsxs("button",{type:"button",onMouseDown:I=>{I.preventDefault(),a(L.label),u(!1)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-left text-sm text-gray-800 hover:bg-blue-50 transition-colors",children:[e.jsx(M,{className:"h-4 w-4 text-gray-400 shrink-0"}),e.jsx("span",{className:"font-medium",children:L.label})]},`${w}-${L.label}`))]},w)})})]})}function V3s({siteId:t,accentColor:s}){const r=fr(),{data:n}=mt({queryKey:["public-featured-areas",t],queryFn:async()=>{const{data:o,error:l}=await H.from("lead_site_featured_areas").select("*").eq("lead_site_id",t).eq("is_published",!0).order("sort_order",{ascending:!0});if(l)throw l;return o}});if(!(n!=null&&n.length))return null;const a=o=>{const l=new URLSearchParams;o.search_query&&l.set("q",o.search_query),o.search_county&&l.set("county",o.search_county),r(`/search?${l.toString()}`)};return e.jsx("section",{className:"py-20",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-2 font-medium",children:"Explore"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:"Featured Areas"})]}),e.jsx("div",{className:"space-y-8",children:n.map((o,l)=>e.jsxs(Gs.div,{initial:{opacity:0,y:30},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:l*.1},onClick:()=>a(o),className:"group grid grid-cols-1 lg:grid-cols-2 gap-0 bg-white rounded-3xl overflow-hidden shadow-sm hover:shadow-2xl transition-all duration-500 cursor-pointer border border-gray-100",children:[e.jsxs("div",{className:"relative h-64 lg:h-80 overflow-hidden",children:[e.jsx("img",{src:o.image_url||"https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&q=80",alt:o.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/30 to-transparent"}),o.badge_text&&e.jsx("span",{className:"absolute top-5 left-5 px-4 py-1.5 text-xs font-bold uppercase tracking-wider text-white rounded-full",style:{backgroundColor:s},children:o.badge_text})]}),e.jsxs("div",{className:"flex flex-col justify-center p-8 lg:p-12",children:[o.subtitle&&e.jsx("p",{className:"text-sm font-medium uppercase tracking-wider text-gray-400 mb-2",children:o.subtitle}),e.jsx("h3",{className:"text-2xl lg:text-3xl font-bold text-gray-900 mb-4 group-hover:text-gray-700 transition-colors",children:o.title}),o.description&&e.jsx("p",{className:"text-gray-600 leading-relaxed mb-6 line-clamp-3 lg:line-clamp-none",children:o.description}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-2 px-5 py-2.5 text-sm font-semibold text-white rounded-xl transition-all group-hover:opacity-90",style:{backgroundColor:s},children:[e.jsx(ma,{className:"h-4 w-4"}),"View Properties",e.jsx(Qa,{className:"h-4 w-4 group-hover:translate-x-1 transition-transform"})]})})]})]},o.id))})]})})}function Dye({siteConfig:t,accentColor:s,sectionTitle:r,cities:n,count:a=12,mode:o}){const l=fr(),[i,c]=k.useState([]),[u,p]=k.useState(!0),f=k.useRef(null),[g,b]=k.useState(!1),[_,j]=k.useState(!1);k.useEffect(()=>{(async()=>{var I;try{const O="https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",q={leadSiteId:t.id,pageSize:a};if(n){const B=n.split(",").map(V=>V.trim()).filter(Boolean);B.length>0&&(q.query=B[0],q.filterCities=B)}o==="open_houses"&&(q.openHousesOnly=!0),o==="my_listings"&&(q.agentListings=!0,q.agentId=t.agentId),o==="new_listings"&&(q.sortBy="newest");const U=await fetch(O,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify(q),signal:AbortSignal.timeout(15e3)});if(U.ok){const B=await U.json();c(((I=B.listings)==null?void 0:I.slice(0,a))||[])}}catch{}finally{p(!1)}})()},[t.id,n,a,o,t.agentId]);const w=()=>{const L=f.current;L&&(b(L.scrollLeft>10),j(L.scrollLeft{const L=f.current;if(L)return w(),L.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",w),()=>{L.removeEventListener("scroll",w),window.removeEventListener("resize",w)}},[i]);const N=L=>{const I=f.current;if(!I)return;const O=340;I.scrollBy({left:L==="left"?-O*2:O*2,behavior:"smooth"})},S={new_listings:"New on the Market",open_houses:"Open Houses",my_listings:"My Active Listings"},M={new_listings:"The latest properties just listed",open_houses:"Tour these homes in person",my_listings:"Properties I'm currently representing"};return u?e.jsx("section",{className:"py-16 md:py-20 overflow-hidden",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"h-4 w-20 bg-gray-200 rounded mx-auto mb-3 animate-pulse"}),e.jsx("div",{className:"h-8 w-72 bg-gray-200 rounded mx-auto mb-2 animate-pulse"}),e.jsx("div",{className:"h-4 w-56 bg-gray-200 rounded mx-auto animate-pulse"})]}),e.jsx("div",{className:"flex gap-5",children:[1,2,3,4].map(L=>e.jsxs("div",{className:"min-w-[320px] rounded-2xl overflow-hidden bg-gray-100",children:[e.jsx("div",{className:"h-56 bg-gray-200 animate-pulse"}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("div",{className:"h-5 bg-gray-200 rounded w-24 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-40 animate-pulse"})]})]},L))})]})}):i.length?e.jsx("section",{className:"py-16 md:py-20 overflow-hidden",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6",children:[e.jsxs("div",{className:"flex items-end justify-between mb-10",children:[e.jsxs("div",{children:[e.jsx(Gs.p,{initial:{opacity:0,y:10},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-sm tracking-[0.2em] uppercase font-semibold mb-2",style:{color:s},children:o==="open_houses"?"Open Houses":o==="my_listings"?"My Listings":"Just Listed"}),e.jsx(Gs.h2,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.05},className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:r||S[o]}),e.jsx(Gs.p,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{delay:.1},className:"text-gray-500 mt-1.5",children:M[o]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>N("left"),disabled:!g,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(cl,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>N("right"),disabled:!_,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(da,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative -mx-6",children:[e.jsxs("div",{ref:f,className:"flex gap-5 overflow-x-auto scrollbar-hide px-6 snap-x snap-mandatory",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[i.map((L,I)=>{var O,q,U,B;return e.jsx(Gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:I*.05},onClick:()=>l(`/listing/${L.mlsNumber}`),className:"group min-w-[300px] sm:min-w-[320px] max-w-[340px] flex-shrink-0 snap-start cursor-pointer",children:e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-[0_2px_20px_-4px_rgba(0,0,0,0.08)] hover:shadow-[0_8px_40px_-8px_rgba(0,0,0,0.15)] transition-all duration-500 h-full flex flex-col",children:[e.jsxs("div",{className:"relative h-56 overflow-hidden",children:[e.jsx("img",{src:((O=L.photos)==null?void 0:O[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:L.address,className:"w-full h-full object-cover group-hover:scale-[1.06] transition-transform duration-700 ease-out"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent"}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide uppercase text-white backdrop-blur-md",style:{backgroundColor:`${s}cc`},children:o==="open_houses"?"Open House":L.status||"Active"}),e.jsx("div",{className:"absolute bottom-3 left-3",children:e.jsxs("p",{className:"text-2xl font-bold text-white drop-shadow-lg",children:["$",(q=L.price)==null?void 0:q.toLocaleString()]})}),((U=L.photos)==null?void 0:U.length)>1&&e.jsxs("div",{className:"absolute bottom-3 right-3 px-2.5 py-1 bg-black/40 backdrop-blur-sm rounded-full text-[11px] text-white font-medium",children:[L.photos.length," photos"]})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsx("p",{className:"text-gray-900 font-semibold text-[15px] leading-snug mb-1 truncate",children:L.address}),e.jsxs("p",{className:"text-gray-500 text-sm mb-3 truncate",children:[L.city,", ",L.state," ",L.zip]}),e.jsxs("div",{className:"flex items-center gap-4 mt-auto pt-3 border-t border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Im,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:L.bedrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:L.bathrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(lS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(B=L.sqft)==null?void 0:B.toLocaleString()," sqft"]})]})]})]})]})},L.mlsNumber)}),e.jsx(Gs.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},onClick:()=>l("/search"),className:"min-w-[200px] flex-shrink-0 snap-start cursor-pointer flex items-center justify-center",children:e.jsxs("div",{className:"text-center group",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center mx-auto mb-3 transition-transform group-hover:scale-110",style:{backgroundColor:`${s}15`},children:e.jsx(Qa,{className:"h-6 w-6",style:{color:s}})}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 group-hover:text-gray-900 transition-colors",children:"View All"})]})})]}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-12 bg-gradient-to-l from-white to-transparent pointer-events-none md:hidden"})]})]})}):null}function H3s({siteId:t,accentColor:s,sectionTitle:r}){const n=fr(),[a,o]=k.useState([]),[l,i]=k.useState(!0);if(k.useEffect(()=>{(async()=>{const{data:p}=await H.from("lead_site_city_pages").select("city_name, city_slug, description, hero_image_url").eq("site_id",t).eq("is_published",!0).order("sort_order",{ascending:!0});o(p||[]),i(!1)})()},[t]),l)return e.jsx("section",{className:"py-16 md:py-20",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"h-4 w-20 bg-gray-200 rounded mx-auto mb-3 animate-pulse"}),e.jsx("div",{className:"h-8 w-64 bg-gray-200 rounded mx-auto animate-pulse"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:[1,2,3].map(u=>e.jsx("div",{className:"h-48 bg-gray-100 rounded-2xl animate-pulse"},u))})]})});if(!a.length)return null;const c=["https://images.unsplash.com/photo-1449824913935-59a10b8d2000?w=600&q=75","https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?w=600&q=75","https://images.unsplash.com/photo-1444723121867-7a241cacace9?w=600&q=75","https://images.unsplash.com/photo-1480714378408-67cf0d13bc1b?w=600&q=75","https://images.unsplash.com/photo-1514565131-fce0801e5785?w=600&q=75","https://images.unsplash.com/photo-1519999482648-25049ddd37b1?w=600&q=75"];return e.jsx("section",{className:"py-16 md:py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs(Gs.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.2em] uppercase font-semibold mb-3",style:{color:s},children:"Explore Areas"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:r||"Browse by City"}),e.jsx("p",{className:"text-gray-500 mt-2 max-w-xl mx-auto",children:"Discover homes in the communities we serve"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:a.map((u,p)=>e.jsxs(Gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:p*.06},onClick:()=>n(`/homes-for-sale-in-${u.city_slug}`),className:"group relative h-52 rounded-2xl overflow-hidden cursor-pointer shadow-sm hover:shadow-xl transition-all duration-500",children:[e.jsx("img",{src:u.hero_image_url||c[p%c.length],alt:`Homes in ${u.city_name}`,className:"absolute inset-0 w-full h-full object-cover group-hover:scale-110 transition-transform duration-700 ease-out",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-5 flex items-end justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-bold text-xl tracking-tight mb-1",children:u.city_name}),u.description&&e.jsxs("p",{className:"text-white/70 text-sm line-clamp-1 max-w-[240px]",children:[u.description.split(` `)[0].slice(0,80),"..."]})]}),e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-white/20 backdrop-blur-sm group-hover:bg-white/30 transition-colors flex-shrink-0",children:e.jsx(Qa,{className:"h-5 w-5 text-white"})})]})]},u.city_slug))})]})})}function W3s({siteConfig:t,themeConfig:s}){var p;const r=fr(),[n,a]=k.useState(""),o=((p=t.agent)==null?void 0:p.full_name)||"Your Agent",l=(s==null?void 0:s.homepageModules)??jct,i=(s==null?void 0:s.brandColor)||"#0f172a",c=(s==null?void 0:s.accentColor)||"#3b82f6",u=f=>{f.preventDefault(),n.trim()&&r(`/search?q=${encodeURIComponent(n.trim())}`)};return e.jsx("div",{children:l.map((f,g)=>{if(!f.enabled)return null;const b=f.config||{};switch(f.type){case"hero":return e.jsx(K3s,{agentName:o,tagline:b.headline||t.siteTagline,subtitle:b.subtitle,heroImageUrl:s==null?void 0:s.heroImageUrl,brandColor:i,accentColor:c,searchQuery:n,setSearchQuery:a,onSearch:u,searchPlaceholder:b.searchPlaceholder,themeConfig:s},g);case"featured_listings":return e.jsx(Z3s,{siteConfig:t,accentColor:c,sectionTitle:b.sectionTitle,count:b.count},g);case"featured_areas":return e.jsx(V3s,{siteId:t.id,accentColor:c},g);case"about":return e.jsx(Y3s,{siteConfig:t,accentColor:c,config:b},g);case"testimonials":return e.jsx(X3s,{testimonials:b.testimonials||(s==null?void 0:s.testimonials)||[],brandColor:i,sectionTitle:b.sectionTitle},g);case"cta_banner":return e.jsx(Q3s,{agentName:o,accentColor:c,brandColor:i,config:b},g);case"new_listings":return e.jsx(Dye,{siteConfig:t,accentColor:c,mode:"new_listings",sectionTitle:b.sectionTitle,cities:b.cities,count:b.count},g);case"open_houses":return e.jsx(Dye,{siteConfig:t,accentColor:c,mode:"open_houses",sectionTitle:b.sectionTitle,cities:b.cities,count:b.count},g);case"my_listings":return e.jsx(Dye,{siteConfig:t,accentColor:c,mode:"my_listings",sectionTitle:b.sectionTitle,count:b.count},g);case"city_pages":return e.jsx(H3s,{siteId:t.id,accentColor:c,sectionTitle:b.sectionTitle},g);default:return null}})})}function G3s(t){if(!t)return[];const s=[];return(t.searchCities||[]).forEach(r=>s.push({label:r,type:"city"})),(t.searchZipCodes||[]).forEach(r=>s.push({label:r,type:"zip"})),(t.searchCounties||[]).forEach(r=>s.push({label:r,type:"county"})),s}function K3s({agentName:t,tagline:s,subtitle:r,heroImageUrl:n,brandColor:a,accentColor:o,searchQuery:l,setSearchQuery:i,onSearch:c,searchPlaceholder:u,themeConfig:p}){const f=fr(),g=n||"https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?w=1920&q=80";return e.jsxs("section",{className:"relative min-h-[85vh] flex items-center justify-center overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:g,alt:"",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/60 via-black/40 to-black/70"})]}),e.jsxs("div",{className:"relative z-10 max-w-4xl mx-auto px-6 text-center",children:[e.jsx(Gs.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6},className:"text-white/70 text-sm tracking-[0.3em] uppercase mb-4 font-medium",children:"Welcome"}),e.jsx(Gs.h1,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.7,delay:.1},className:"text-4xl sm:text-5xl md:text-6xl lg:text-7xl font-bold text-white leading-[1.1] tracking-tight mb-6",children:s||`Find Your Perfect Home with ${t}`}),e.jsx(Gs.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.2},className:"text-white/70 text-lg md:text-xl max-w-2xl mx-auto mb-10",children:r||"Expert guidance. Local knowledge. Personalized service."}),e.jsx(Gs.form,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.35},onSubmit:c,className:"max-w-2xl mx-auto",children:e.jsxs("div",{className:"flex bg-white/10 backdrop-blur-md border border-white/20 rounded-2xl p-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-white/50 z-10"}),(()=>{const b=G3s(p);return b.length>0?e.jsx(Sct,{suggestions:b,value:l,onChange:i,onSelect:_=>{i(_),f(`/search?q=${encodeURIComponent(_)}`)},placeholder:u||"Search by city, zip, county, or address...",className:"flex-1",inputClassName:"w-full pl-12 pr-4 py-4 bg-transparent text-white placeholder:text-white/40 focus:outline-none text-lg"}):e.jsx("input",{type:"text",value:l,onChange:_=>i(_.target.value),placeholder:u||"Search by city, zip, county, or address...",className:"w-full pl-12 pr-4 py-4 bg-transparent text-white placeholder:text-white/40 focus:outline-none text-lg"})})()]}),e.jsx("button",{type:"submit",className:"px-8 py-4 rounded-xl font-semibold text-white transition-all hover:opacity-90",style:{backgroundColor:o},children:"Search"})]})}),e.jsx(Gs.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,delay:.5},className:"flex flex-wrap gap-3 justify-center mt-8",children:["Browse All Listings","Get In Touch"].map((b,_)=>e.jsx("button",{onClick:()=>f(_===0?"/search":"/contact"),className:"px-5 py-2.5 text-sm text-white/80 border border-white/20 rounded-full hover:bg-white/10 hover:text-white transition-all",children:b},b))})]})]})}function Z3s({siteConfig:t,accentColor:s,sectionTitle:r,count:n}){const a=fr(),[o,l]=k.useState([]),[i,c]=k.useState(!0);return k.useEffect(()=>{(async()=>{var p;try{const g=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({siteId:t.id,params:{pageSize:n||6,page:1}})});if(g.ok){const b=await g.json();l(((p=b.listings)==null?void 0:p.slice(0,6))||[])}}catch{}finally{c(!1)}})()},[t.id]),i?e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded w-64 mx-auto mb-3 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-96 mx-auto animate-pulse"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[1,2,3].map(u=>e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"h-64 bg-gray-200 animate-pulse"}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("div",{className:"h-5 bg-gray-200 rounded w-24 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-48 animate-pulse"})]})]},u))})]})}):o.length?e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-2 font-medium",children:"Properties"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:r||"Featured Listings"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:o.map(u=>{var p,f,g;return e.jsxs(Gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5},onClick:()=>a(`/listing/${u.mlsNumber}`),className:"group bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-xl transition-all duration-300 cursor-pointer",children:[e.jsxs("div",{className:"relative h-64 overflow-hidden",children:[e.jsx("img",{src:((p=u.photos)==null?void 0:p[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:u.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 bg-white/90 backdrop-blur rounded-full text-xs font-semibold text-gray-900",children:u.status})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("p",{className:"text-2xl font-bold text-gray-900 mb-1",children:["$",(f=u.price)==null?void 0:f.toLocaleString()]}),e.jsxs("p",{className:"text-gray-500 text-sm mb-3 truncate",children:[u.address,", ",u.city]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-400",children:[e.jsxs("span",{children:[u.bedrooms," Beds"]}),e.jsx("span",{className:"w-1 h-1 bg-gray-300 rounded-full"}),e.jsxs("span",{children:[u.bathrooms," Baths"]}),e.jsx("span",{className:"w-1 h-1 bg-gray-300 rounded-full"}),e.jsxs("span",{children:[(g=u.sqft)==null?void 0:g.toLocaleString()," Sqft"]})]})]})]},u.mlsNumber)})}),e.jsx("div",{className:"text-center mt-10",children:e.jsxs("button",{onClick:()=>a("/search"),className:"inline-flex items-center gap-2 px-6 py-3 text-sm font-semibold rounded-full border border-gray-300 text-gray-700 hover:bg-gray-100 transition-colors",children:["View All Properties ",e.jsx(Qa,{className:"h-4 w-4"})]})})]})}):null}function Y3s({siteConfig:t,accentColor:s,config:r}){const n=fr(),a=t.agent;return a?e.jsx("section",{className:"py-20",children:e.jsx("div",{className:"max-w-7xl mx-auto px-6",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16 items-center",children:[a.avatar_url&&e.jsx(Gs.div,{initial:{opacity:0,x:-30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6},children:e.jsx("img",{src:a.avatar_url,alt:a.full_name,className:"w-full max-w-md mx-auto rounded-3xl object-cover shadow-2xl aspect-[3/4]"})}),e.jsxs(Gs.div,{initial:{opacity:0,x:30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6},children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-3 font-medium",children:(r==null?void 0:r.sectionTitle)||"About"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight mb-2",children:(r==null?void 0:r.headline)||a.full_name}),e.jsx("p",{className:"text-gray-400 font-medium mb-6",children:(r==null?void 0:r.customTitle)||a.title||"Real Estate Professional"}),e.jsx("p",{className:"text-gray-600 leading-relaxed text-lg mb-8",children:(()=>{const o=(r==null?void 0:r.customBio)||a.bio;return o?o.substring(0,400)+(o.length>400?"...":""):"Dedicated to providing exceptional real estate service with deep local market expertise."})()}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{onClick:()=>n("/contact"),className:"px-6 py-3 text-white font-semibold rounded-xl transition-all hover:opacity-90",style:{backgroundColor:s},children:"Get In Touch"}),e.jsx("button",{onClick:()=>n("/about"),className:"px-6 py-3 border border-gray-300 text-gray-700 font-semibold rounded-xl hover:bg-gray-50 transition-colors",children:"Read More"})]})]})]})})}):null}function X3s({testimonials:t,brandColor:s,sectionTitle:r}){const[n,a]=k.useState(0),o=t.length?t:[{name:"Happy Client",quote:"An amazing experience from start to finish. Truly a trusted advisor who goes above and beyond.",role:"Buyer"},{name:"Satisfied Seller",quote:"Professional, knowledgeable, and always available. Made the selling process smooth and stress-free.",role:"Seller"},{name:"First-Time Buyer",quote:"Guided us through every step with patience and expertise. Could not have asked for a better agent.",role:"Buyer"}];return o.length?e.jsx("section",{className:"py-20 text-white",style:{backgroundColor:s},children:e.jsxs("div",{className:"max-w-4xl mx-auto px-6 text-center",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-white/50 mb-3 font-medium",children:"Testimonials"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight mb-12",children:r||"What Clients Say"}),e.jsxs("div",{className:"relative",children:[e.jsx(H_,{className:"h-10 w-10 text-white/20 mx-auto mb-6"}),e.jsxs(Gs.blockquote,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-xl md:text-2xl font-light leading-relaxed text-white/90 mb-8 italic",children:['"',o[n].quote,'"']},n),e.jsx("p",{className:"font-semibold text-lg",children:o[n].name}),o[n].role&&e.jsx("p",{className:"text-white/50 text-sm mt-1",children:o[n].role})]}),o.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mt-10",children:[e.jsx("button",{onClick:()=>a((n-1+o.length)%o.length),className:"p-2 rounded-full border border-white/20 hover:bg-white/10 transition-colors",children:e.jsx(cl,{className:"h-5 w-5"})}),e.jsx("div",{className:"flex gap-2",children:o.map((l,i)=>e.jsx("button",{onClick:()=>a(i),className:`w-2 h-2 rounded-full transition-all ${i===n?"bg-white w-6":"bg-white/30"}`},i))}),e.jsx("button",{onClick:()=>a((n+1)%o.length),className:"p-2 rounded-full border border-white/20 hover:bg-white/10 transition-colors",children:e.jsx(da,{className:"h-5 w-5"})})]})]})}):null}function Q3s({agentName:t,accentColor:s,brandColor:r,config:n}){const a=fr();return e.jsx("section",{className:"py-20",children:e.jsx("div",{className:"max-w-5xl mx-auto px-6",children:e.jsxs("div",{className:"rounded-3xl p-12 md:p-16 text-white text-center",style:{backgroundColor:r},children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight mb-4",children:(n==null?void 0:n.headline)||"Ready to Make Your Move?"}),e.jsx("p",{className:"text-white/70 text-lg max-w-2xl mx-auto mb-8",children:(n==null?void 0:n.subtitle)||"Whether you're buying, selling, or just exploring — let's connect and find the right path for you."}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsx("button",{onClick:()=>a("/search"),className:"px-8 py-4 text-white font-semibold rounded-xl transition-all hover:opacity-90",style:{backgroundColor:s},children:(n==null?void 0:n.primaryButtonText)||"Browse Listings"}),e.jsx("button",{onClick:()=>a("/contact"),className:"px-8 py-4 bg-white/10 border border-white/25 font-semibold rounded-xl hover:bg-white/20 transition-colors",children:(n==null?void 0:n.secondaryButtonText)||`Contact ${t}`})]})]})})})}const J3s=t=>t>=1e6?`$${(t/1e6).toFixed(1)}M`:t>=1e3?`$${Math.round(t/1e3)}K`:`$${t}`,i9=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){const s=Number.parseFloat(t);return Number.isFinite(s)?s:null}return null},e5s=t=>[t.address,t.city,t.state,t.zip].filter(Boolean).join(", ");function Cct({listings:t,onListingClick:s,hoveredMlsNumber:r}){const n=k.useRef(null),a=k.useRef(null),o=k.useRef(new Map),l=k.useRef(null),i=k.useRef(new Map),[c,u]=k.useState(null),[p,f]=k.useState({});k.useEffect(()=>{(async()=>{const{data:j}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();j!=null&&j.value&&u(j.value)})()},[]),k.useEffect(()=>{if(!(!n.current||!c||a.current))return Ao.accessToken=c,a.current=new Ao.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",zoom:4,center:[-98.5795,39.8283]}),a.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var _;(_=a.current)==null||_.remove(),a.current=null}},[c]);const g=k.useMemo(()=>t.map(_=>{var N,S;const j=i9(_.latitude)??((N=p[_.mlsNumber])==null?void 0:N.lat)??null,w=i9(_.longitude)??((S=p[_.mlsNumber])==null?void 0:S.lng)??null;return j===null||w===null?null:{listing:_,latitude:j,longitude:w}}).filter(_=>_!==null),[t,p]);k.useEffect(()=>{if(!c||t.length===0)return;const _=t.filter(N=>!(i9(N.latitude)!==null&&i9(N.longitude)!==null)&&!i.current.has(N.mlsNumber));if(_.length===0)return;let j=!1;return(async()=>{const N=await Promise.all(_.map(async M=>{var I,O;const L=e5s(M);if(!L)return{mlsNumber:M.mlsNumber,coords:null};try{const q=await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(L)}.json?access_token=${encodeURIComponent(c)}&limit=1&country=US&types=address,place,postcode`);if(!q.ok)return{mlsNumber:M.mlsNumber,coords:null};const U=await q.json(),[B,V]=((O=(I=U==null?void 0:U.features)==null?void 0:I[0])==null?void 0:O.center)??[];return!Number.isFinite(V)||!Number.isFinite(B)?{mlsNumber:M.mlsNumber,coords:null}:{mlsNumber:M.mlsNumber,coords:{lat:V,lng:B}}}catch{return{mlsNumber:M.mlsNumber,coords:null}}}));if(j)return;const S={};N.forEach(({mlsNumber:M,coords:L})=>{i.current.set(M,L),L&&(S[M]=L)}),Object.keys(S).length>0&&f(M=>({...M,...S}))})(),()=>{j=!0}},[t,c]);const b=k.useCallback(_=>{var N;const j=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_.price),w=(N=_.photos)!=null&&N[0]?``:`
`;return`
${w}
${j}
${_.address}
${_.bedrooms} bd ${_.bathrooms} ba ${_.sqft>0?`${_.sqft.toLocaleString()} sqft`:""}
`},[]);return k.useEffect(()=>{if(!a.current||!c||(o.current.forEach(j=>j.remove()),o.current.clear(),g.length===0))return;const _=new Ao.LngLatBounds;g.forEach(({listing:j,latitude:w,longitude:N})=>{const S=document.createElement("div");S.style.cssText="cursor: pointer;";const M=document.createElement("div");M.className="lead-site-map-pill",M.setAttribute("data-mls",j.mlsNumber),M.innerHTML=`${J3s(j.price)}`,M.style.cssText=` background: white; border: 2px solid #2563eb; border-radius: 20px; padding: 2px 8px; font-size: 12px; font-weight: 700; color: #1e3a5f; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.15); white-space: nowrap; transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease; font-family: system-ui, -apple-system, sans-serif; pointer-events: auto; `,M.addEventListener("mouseenter",()=>{M.style.background="#2563eb",M.style.color="white",M.style.transform="scale(1.1)"}),M.addEventListener("mouseleave",()=>{r!==j.mlsNumber&&(M.style.background="white",M.style.color="#1e3a5f",M.style.transform="scale(1)")}),S.appendChild(M);const L=new Ao.Marker({element:S,anchor:"bottom"}).setLngLat([N,w]).addTo(a.current);S.addEventListener("click",I=>{var q;I.stopPropagation(),(q=l.current)==null||q.remove();const O=new Ao.Popup({offset:25,closeButton:!0,maxWidth:"240px",className:"lead-site-map-popup"}).setLngLat([N,w]).setHTML(b(j)).addTo(a.current);setTimeout(()=>{const U=O.getElement(),B=U==null?void 0:U.querySelector("[data-mls]");B&&(B.addEventListener("click",()=>{s(j.mlsNumber)}),B.style.cursor="pointer")},50),l.current=O}),o.current.set(j.mlsNumber,L),_.extend([N,w])});try{_.isEmpty()||a.current.fitBounds(_,{padding:60,maxZoom:14})}catch{}},[g,c,b,s]),k.useEffect(()=>{o.current.forEach((_,j)=>{const w=_.getElement().querySelector(".lead-site-map-pill");w&&(j===r?(w.style.background="#2563eb",w.style.color="white",w.style.transform="scale(1.15)",w.style.zIndex="10"):(w.style.background="white",w.style.color="#1e3a5f",w.style.transform="scale(1)",w.style.zIndex="1"))})},[r]),c?e.jsx("div",{ref:n,className:"w-full h-full"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-100 text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(t5s,{className:"h-10 w-10 mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Map not configured"})]})})}function t5s({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"}),e.jsx("circle",{cx:"12",cy:"10",r:"3"})]})}const s5s=50;function r5s({siteConfig:t}){var ue;const s=t.themeConfig||{},r=[...(s.searchCities||[]).map(pe=>({label:pe,type:"city"})),...(s.searchZipCodes||[]).map(pe=>({label:pe,type:"zip"})),...(s.searchCounties||[]).map(pe=>({label:pe,type:"county"}))],n=fr(),[a,o]=Cc(),[l,i]=k.useState(!1),[c,u]=k.useState("list"),[p,f]=k.useState(null),g=a.get("q")||"",b=a.get("county")||"",_=a.get("minPrice")||"",j=a.get("maxPrice")||"",w=a.get("beds")||"",N=a.get("baths")||"",S=a.get("propertyType")||"",M=a.get("minSqft")||"",L=a.get("maxSqft")||"",[I,O]=k.useState(g),[q,U]=k.useState(!0),{data:B,isLoading:V,fetchNextPage:Y,hasNextPage:Q,isFetchingNextPage:ee}=lUe({queryKey:["lead-site-search",t.id,g,b,_,j,w,N,S,M,L,q],queryFn:async({pageParam:pe=1})=>{const{data:_e,error:$e}=await H.functions.invoke("lead-site-search",{body:{leadSiteId:t.id,query:g||void 0,county:b||void 0,minPrice:_?parseInt(_):void 0,maxPrice:j?parseInt(j):void 0,minBeds:w?parseInt(w):void 0,minBaths:N?parseInt(N):void 0,propertyType:S||void 0,minSqft:M?parseInt(M):void 0,maxSqft:L?parseInt(L):void 0,limit:s5s,page:pe}});if($e)throw $e;return _e},getNextPageParam:(pe,_e)=>{if(_e.reduce((Ae,Ie)=>Ae+Ie.listings.length,0)pe.listings))??[],ie=((ue=B==null?void 0:B.pages[0])==null?void 0:ue.total)??0,re=k.useCallback(pe=>{pe.preventDefault();const _e=new URLSearchParams;I&&_e.set("q",I),b&&_e.set("county",b),_&&_e.set("minPrice",_),j&&_e.set("maxPrice",j),w&&_e.set("beds",w),N&&_e.set("baths",N),S&&_e.set("propertyType",S),M&&_e.set("minSqft",M),L&&_e.set("maxSqft",L),o(_e),U(!0)},[I,b,_,j,w,N,S,M,L,o]),oe=k.useCallback((pe,_e)=>{const $e=new URLSearchParams(a);_e?$e.set(pe,_e):$e.delete(pe),o($e),U(!0)},[a,o]),ce=pe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(pe),ge=k.useCallback(pe=>{n(`/listing/${pe}`)},[n]),ye=X.length>0;return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"bg-white border-b border-gray-200 z-40 shrink-0",children:e.jsxs("div",{className:"px-4 sm:px-6 py-3",children:[e.jsxs("form",{onSubmit:re,className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 z-10"}),r.length>0?e.jsx(Sct,{suggestions:r,value:I,onChange:O,onSelect:pe=>{O(pe);const _e=new URLSearchParams(a);_e.set("q",pe),o(_e),U(!0)},placeholder:"City, zip, county, or address...",inputClassName:"w-full pl-10 pr-4 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}):e.jsx("input",{type:"text",value:I,onChange:pe=>O(pe.target.value),placeholder:"City, zip, county, or address...",className:"w-full pl-10 pr-4 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),e.jsx("button",{type:"submit",className:"px-5 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors",children:"Search"}),e.jsx("button",{type:"button",onClick:()=>i(!l),className:`px-3 py-2.5 border rounded-lg text-sm transition-colors ${l?"bg-blue-50 border-blue-300 text-blue-700":"border-gray-300 text-gray-600 hover:bg-gray-50"}`,children:e.jsx(W_,{className:"h-4 w-4"})})]}),l&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3 pb-1",children:[e.jsx("input",{value:b,onChange:pe=>oe("county",pe.target.value),placeholder:"County",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm min-w-[140px]"}),e.jsxs("select",{value:w,onChange:pe=>oe("beds",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Beds"}),e.jsx("option",{value:"1",children:"1+"}),e.jsx("option",{value:"2",children:"2+"}),e.jsx("option",{value:"3",children:"3+"}),e.jsx("option",{value:"4",children:"4+"}),e.jsx("option",{value:"5",children:"5+"})]}),e.jsxs("select",{value:N,onChange:pe=>oe("baths",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Baths"}),e.jsx("option",{value:"1",children:"1+"}),e.jsx("option",{value:"2",children:"2+"}),e.jsx("option",{value:"3",children:"3+"}),e.jsx("option",{value:"4",children:"4+"})]}),e.jsxs("select",{value:S,onChange:pe=>oe("propertyType",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm min-w-[160px]",children:[e.jsx("option",{value:"",children:"Property Type"}),e.jsx("option",{value:"Residential",children:"Residential"}),e.jsx("option",{value:"Condo",children:"Condo"}),e.jsx("option",{value:"Townhouse",children:"Townhouse"}),e.jsx("option",{value:"Multi",children:"Multi-Family"}),e.jsx("option",{value:"Land",children:"Land"}),e.jsx("option",{value:"Farm",children:"Farm"}),e.jsx("option",{value:"Commercial",children:"Commercial"})]}),e.jsxs("select",{value:_,onChange:pe=>oe("minPrice",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Min Price"}),e.jsx("option",{value:"100000",children:"$100k"}),e.jsx("option",{value:"200000",children:"$200k"}),e.jsx("option",{value:"300000",children:"$300k"}),e.jsx("option",{value:"500000",children:"$500k"}),e.jsx("option",{value:"750000",children:"$750k"}),e.jsx("option",{value:"1000000",children:"$1M"})]}),e.jsxs("select",{value:j,onChange:pe=>oe("maxPrice",pe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Max Price"}),e.jsx("option",{value:"200000",children:"$200k"}),e.jsx("option",{value:"300000",children:"$300k"}),e.jsx("option",{value:"500000",children:"$500k"}),e.jsx("option",{value:"750000",children:"$750k"}),e.jsx("option",{value:"1000000",children:"$1M"}),e.jsx("option",{value:"2000000",children:"$2M"})]}),e.jsx("input",{type:"number",value:M,onChange:pe=>oe("minSqft",pe.target.value),placeholder:"Min sqft",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm w-[120px]"}),e.jsx("input",{type:"number",value:L,onChange:pe=>oe("maxSqft",pe.target.value),placeholder:"Max sqft",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm w-[120px]"})]}),ye&&e.jsxs("div",{className:"flex lg:hidden mt-2 gap-1",children:[e.jsxs("button",{onClick:()=>u("list"),className:`flex-1 flex items-center justify-center gap-1.5 py-2 text-xs font-medium rounded-lg transition-colors ${c==="list"?"bg-blue-600 text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Mh,{className:"h-3.5 w-3.5"})," List"]}),e.jsxs("button",{onClick:()=>u("map"),className:`flex-1 flex items-center justify-center gap-1.5 py-2 text-xs font-medium rounded-lg transition-colors ${c==="map"?"bg-blue-600 text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(l1,{className:"h-3.5 w-3.5"})," Map"]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:q?V?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500",children:"Searching listings..."})]})}):ye?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:` w-full lg:w-[65%] overflow-y-auto border-r border-gray-200 bg-gray-50 shrink-0 ${c==="map"?"hidden lg:block":"block"} `,children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 bg-white flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-gray-700 font-semibold",children:[g?`${g} Real Estate`:"All Listings"," · ",ie," listing",ie!==1?"s":""," found"]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Showing ",X.length," of ",ie]})]}),e.jsx("div",{className:"p-3 grid grid-cols-1 sm:grid-cols-2 gap-3",children:X.map(pe=>{var _e;return e.jsxs("button",{onClick:()=>n(`/listing/${pe.mlsNumber}`),onMouseEnter:()=>f(pe.mlsNumber),onMouseLeave:()=>f(null),className:`w-full bg-white rounded-xl border overflow-hidden hover:shadow-lg transition-all text-left group flex flex-col ${p===pe.mlsNumber?"border-blue-400 shadow-lg ring-1 ring-blue-200":"border-gray-200"}`,children:[e.jsxs("div",{className:"relative w-full aspect-[4/3] bg-gray-200 overflow-hidden",children:[(_e=pe.photos)!=null&&_e[0]?e.jsx("img",{src:pe.photos[0],alt:pe.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",onError:$e=>{const Ae=$e.target;Ae.style.display="none"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-400",children:e.jsx(ma,{className:"h-8 w-8"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:"px-2 py-0.5 bg-white/90 backdrop-blur text-[11px] font-semibold rounded text-gray-700",children:pe.status})}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3",children:[e.jsx("p",{className:"text-xl font-bold text-white drop-shadow-md",children:ce(pe.price)}),e.jsxs("p",{className:"text-xs text-white/90 mt-0.5 truncate drop-shadow-sm",children:[pe.address,", ",pe.city,", ",pe.state]})]})]}),e.jsxs("div",{className:"px-3 py-2.5 flex items-center gap-4 text-xs text-gray-600 border-t border-gray-100",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Im,{className:"h-3.5 w-3.5"})," ",pe.bedrooms," bd"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"})," ",pe.bathrooms," ba"]}),pe.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(g0,{className:"h-3.5 w-3.5"})," ",pe.sqft.toLocaleString()," sqft"]})]})]},pe.mlsNumber)})}),Q&&e.jsx("div",{className:"flex justify-center py-6",children:e.jsx("button",{onClick:()=>Y(),disabled:ee,className:"px-6 py-3 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50 flex items-center gap-2",children:ee?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Loading more..."]}):`Load More Listings (${X.length} of ${ie})`})})]}),e.jsx("div",{className:` lg:w-[35%] min-w-0 ${c==="list"?"hidden lg:block":"block w-full"} `,children:e.jsx(Cct,{listings:X,onListingClick:ge,hoveredMlsNumber:p})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Rr,{className:"h-12 w-12 text-gray-300 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-700 mb-2",children:"No Results"}),e.jsx("p",{className:"text-gray-500",children:"Try a different search term or adjust your filters."})]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(cn,{className:"h-12 w-12 text-gray-300 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-700 mb-2",children:"Search for Properties"}),e.jsx("p",{className:"text-gray-500",children:"Enter a city, zip code, county, or address — or click Search to browse all listings."})]})})})]})}const Oye="ls_visitor_";function n5s(t,s){const[r,n]=k.useState(0),[a,o]=k.useState(!1),[l,i]=k.useState(!1),c=t==null?void 0:t.id,u=(t==null?void 0:t.leadRegistrationMode)??"disabled",p=(t==null?void 0:t.registrationTriggerCount)??1;k.useEffect(()=>{if(!c)return;const j=parseInt(localStorage.getItem(`${Oye}views_${c}`)||"0",10);n(j)},[c]);const f=k.useCallback((j,w,N)=>{if(!c||u==="disabled")return;const S=r+1;n(S),localStorage.setItem(`${Oye}views_${c}`,String(S)),H.from("lead_site_property_views").insert({lead_site_id:c,mls_number:j,auth_user_id:w||null,visitor_fingerprint:localStorage.getItem(`${Oye}fp_${c}`)||null,property_address:(N==null?void 0:N.propertyAddress)||null,photo_url:(N==null?void 0:N.photoUrl)||null}).then(),!s&&!l&&S>=p&&o(!0)},[c,u,r,s,l,p]);k.useEffect(()=>{s&&a&&o(!1)},[s,a]);const g=k.useCallback(()=>{o(!1),i(!0)},[]),b=k.useCallback(()=>{o(!1)},[]),_=u==="required"&&!s&&r>=p;return{viewCount:r,showRegistration:a,isGated:_,mode:u,recordView:f,dismissRegistration:g,completeRegistration:b,setShowRegistration:o}}function a5s({photos:t}){const[s,r]=k.useState(!1),[n,a]=k.useState(0);if(!t||t.length===0)return null;const o=c=>{a(c),r(!0)},l=()=>a(c=>(c+1)%t.length),i=()=>a(c=>(c-1+t.length)%t.length);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-1.5 rounded-xl overflow-hidden",children:[e.jsx("div",{className:"md:col-span-2 md:row-span-2 aspect-[4/3] cursor-pointer relative overflow-hidden",onClick:()=>o(0),children:e.jsx("img",{src:t[0],alt:"",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})}),t.slice(1,5).map((c,u)=>e.jsxs("div",{className:"aspect-[4/3] cursor-pointer relative overflow-hidden hidden md:block",onClick:()=>o(u+1),children:[e.jsx("img",{src:c,alt:"",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),u===3&&t.length>5&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("span",{className:"text-white text-lg font-semibold",children:["+",t.length-5," more"]})})]},u))]}),t.length>1&&e.jsxs("button",{onClick:()=>o(0),className:"absolute bottom-3 right-3 flex items-center gap-1.5 px-3 py-1.5 bg-white/90 backdrop-blur-sm text-gray-800 text-sm font-medium rounded-lg shadow hover:bg-white transition-colors",children:[e.jsx(aL,{className:"h-4 w-4"}),"View all ",t.length," photos"]})]}),s&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 text-white",children:[e.jsxs("span",{className:"text-sm font-medium",children:[n+1," / ",t.length]}),e.jsx("button",{onClick:()=>r(!1),className:"p-2 hover:bg-white/10 rounded-full transition-colors",children:e.jsx(Rr,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex-1 flex items-center justify-center px-4 relative min-h-0",children:[e.jsx("img",{src:t[n],alt:"",className:"max-w-full max-h-full object-contain"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"absolute left-2 top-1/2 -translate-y-1/2 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors",children:e.jsx(cl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:l,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors",children:e.jsx(da,{className:"h-6 w-6"})})]})]}),e.jsx("div",{className:"px-4 py-3 overflow-x-auto",children:e.jsx("div",{className:"flex gap-2 justify-center",children:t.map((c,u)=>e.jsx("button",{onClick:()=>a(u),className:`w-16 h-12 rounded overflow-hidden shrink-0 border-2 transition-all ${u===n?"border-white opacity-100":"border-transparent opacity-50 hover:opacity-75"}`,children:e.jsx("img",{src:c,alt:"",className:"w-full h-full object-cover"})},u))})})]})]})}function i5s({listing:t}){var n,a;const s=[];t.lotSize&&s.push({label:"Lot Size",value:t.lotSize,icon:e.jsx(f1,{className:"h-4 w-4"})}),t.garageSpaces&&s.push({label:"Garage",value:`${t.garageSpaces} spaces`,icon:e.jsx(CM,{className:"h-4 w-4"})}),t.stories&&s.push({label:"Stories",value:`${t.stories}`,icon:e.jsx(LM,{className:"h-4 w-4"})}),t.heating&&s.push({label:"Heating",value:t.heating,icon:e.jsx(PL,{className:"h-4 w-4"})}),t.cooling&&s.push({label:"Cooling",value:t.cooling,icon:e.jsx(a0,{className:"h-4 w-4"})}),t.fireplace&&s.push({label:"Fireplace",value:"Yes",icon:e.jsx(eh,{className:"h-4 w-4"})}),t.pool&&s.push({label:"Pool",value:t.pool,icon:e.jsx(BL,{className:"h-4 w-4"})}),t.basement&&s.push({label:"Basement",value:t.basement,icon:e.jsx(LM,{className:"h-4 w-4"})}),t.parking&&s.push({label:"Parking",value:t.parking,icon:e.jsx(CM,{className:"h-4 w-4"})});const r=[];if(t.hoaFee){const o=t.hoaFrequency?`/${t.hoaFrequency.toLowerCase()}`:"/mo";r.push({label:"HOA Fee",value:`$${t.hoaFee.toLocaleString()}${o}`})}if(t.taxAmount){const o=t.taxYear?` (${t.taxYear})`:"";r.push({label:"Annual Taxes",value:`$${t.taxAmount.toLocaleString()}${o}`})}if(t.sqft>0&&t.price>0&&r.push({label:"Price / Sq Ft",value:`$${Math.round(t.price/t.sqft).toLocaleString()}`}),t.listDate){const o=Math.floor((Date.now()-new Date(t.listDate).getTime())/864e5);o>=0&&o<9999&&r.push({label:"Days on Market",value:`${o}`})}return s.length===0&&r.length===0?null:e.jsxs("div",{className:"space-y-6",children:[r.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Financial Details"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:r.map(o=>e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:o.label}),e.jsxs("p",{className:"font-semibold text-gray-900 flex items-center gap-1",children:[e.jsx(ac,{className:"h-3.5 w-3.5 text-gray-400"}),o.value.replace("$","")]})]},o.label))})]}),s.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Property Details"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-3",children:s.map(o=>e.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-gray-100",children:[e.jsx("span",{className:"text-gray-400",children:o.icon}),e.jsx("span",{className:"text-sm text-gray-500",children:o.label}),e.jsx("span",{className:"text-sm font-medium text-gray-900 ml-auto",children:o.value})]},o.label))})]}),((n=t.features)==null?void 0:n.length)>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Features"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.features.map((o,l)=>e.jsx("span",{className:"px-2.5 py-1 bg-blue-50 text-blue-700 text-xs rounded-full font-medium",children:o},l))})]}),((a=t.appliances)==null?void 0:a.length)>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Appliances"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.appliances.map((o,l)=>e.jsx("span",{className:"px-2.5 py-1 bg-gray-100 text-gray-700 text-xs rounded-full font-medium",children:o},l))})]})]})}function o5s({latitude:t,longitude:s,address:r}){const n=k.useRef(null),a=k.useRef(null),o=k.useMemo(()=>{const l=Number(t),i=Number(s);return!Number.isFinite(l)||!Number.isFinite(i)?null:{lat:l,lng:i}},[t,s]);return k.useEffect(()=>{if(!n.current||a.current||!o)return;Ao.accessToken="pk.eyJ1IjoibGV2ZWx1cHJlIiwiYSI6ImNtOGZwMGNrYzBjNjIyanF5c2RwNTFhOXMifQ.sTe5rOhf_2nkqgr8Z_0e4Q";const l=new Ao.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",center:[o.lng,o.lat],zoom:14,interactive:!0});return l.addControl(new Ao.NavigationControl({showCompass:!1}),"top-right"),new Ao.Marker({color:"#2563eb"}).setLngLat([o.lng,o.lat]).setPopup(new Ao.Popup({offset:25}).setText(r)).addTo(l),a.current=l,()=>{l.remove(),a.current=null}},[o,r]),o?e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Location"}),e.jsx("div",{ref:n,className:"w-full h-64 rounded-xl overflow-hidden border border-gray-200"})]}):null}function l5s({listPrice:t}){const[s,r]=k.useState(20),[n,a]=k.useState(6.5),[o,l]=k.useState(30),i=k.useMemo(()=>{const f=t*(1-s/100),g=n/100/12,b=o*12;return g===0?f/b:f*g*Math.pow(1+g,b)/(Math.pow(1+g,b)-1)},[t,s,n,o]),c=t*(s/100),u=t-c,p=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f);return e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(QI,{className:"h-5 w-5 text-blue-600"}),e.jsx("h3",{className:"font-semibold text-gray-900",children:"Mortgage Calculator"})]}),e.jsxs("div",{className:"text-center mb-5",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Estimated Monthly Payment"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900",children:p(i)})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-600",children:"Down Payment"}),e.jsxs("span",{className:"font-medium text-gray-900",children:[s,"% (",p(c),")"]})]}),e.jsx("input",{type:"range",min:0,max:50,step:5,value:s,onChange:f=>r(Number(f.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-600",children:"Interest Rate"}),e.jsxs("span",{className:"font-medium text-gray-900",children:[n,"%"]})]}),e.jsx("input",{type:"range",min:2,max:12,step:.25,value:n,onChange:f=>a(Number(f.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-600",children:"Loan Term"}),e.jsxs("span",{className:"font-medium text-gray-900",children:[o," years"]})]}),e.jsx("div",{className:"flex gap-2",children:[15,20,30].map(f=>e.jsxs("button",{onClick:()=>l(f),className:`flex-1 py-1.5 text-sm font-medium rounded-lg border transition-colors ${o===f?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,children:[f," yr"]},f))})]}),e.jsxs("div",{className:"pt-3 border-t border-gray-100 space-y-1.5 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Loan Amount"}),e.jsx("span",{className:"font-medium",children:p(u)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Total Interest"}),e.jsx("span",{className:"font-medium",children:p(i*o*12-u)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Total Cost"}),e.jsx("span",{className:"font-medium",children:p(i*o*12+c)})]})]})]})]})}function c5s({siteConfig:t,currentListing:s}){const r=fr(),{data:n}=mt({queryKey:["similar-listings",t.id,s.mlsNumber],queryFn:async()=>{const{data:o,error:l}=await H.functions.invoke("lead-site-search",{body:{leadSiteId:t.id,query:s.city,minPrice:Math.round(s.price*.75),maxPrice:Math.round(s.price*1.25),minBeds:Math.max(0,s.bedrooms-1),propertyType:s.propertyType||void 0}});if(l)throw l;return((o==null?void 0:o.listings)||[]).filter(c=>c.mlsNumber!==s.mlsNumber).slice(0,6)},enabled:!!s.city});if(!n||n.length===0)return null;const a=o=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(o);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Similar Listings Nearby"}),e.jsxs("button",{onClick:()=>r("/search"),className:"text-sm text-blue-600 hover:text-blue-700 flex items-center gap-0.5",children:["View all ",e.jsx(da,{className:"h-4 w-4"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(o=>{var l;return e.jsxs("div",{onClick:()=>r(`/listing/${o.mlsNumber}`),className:"bg-white border border-gray-200 rounded-xl overflow-hidden cursor-pointer hover:shadow-md transition-shadow group",children:[e.jsx("div",{className:"aspect-[16/10] overflow-hidden",children:(l=o.photos)!=null&&l[0]?e.jsx("img",{src:o.photos[0],alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full bg-gray-100 flex items-center justify-center text-gray-400 text-sm",children:"No photo"})}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"font-bold text-gray-900",children:a(o.price)}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[o.address,", ",o.city]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Im,{className:"h-3.5 w-3.5"})," ",o.bedrooms]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"})," ",o.bathrooms]}),o.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(g0,{className:"h-3.5 w-3.5"})," ",o.sqft.toLocaleString()]})]})]})]},o.mlsNumber)})})]})}function d5s({siteConfig:t}){var L,I,O;const{mlsNumber:s}=yo(),r=fr(),[n,a]=k.useState(!1),[o,l]=k.useState({name:"",email:"",phone:"",message:""}),[i,c]=k.useState(!1),{user:u}=jme(),p=n5s(t,!!u),[f,g]=k.useState(!1);k.useEffect(()=>{!u||!s||H.from("lead_site_saved_listings").select("id").eq("user_id",u.id).eq("lead_site_id",t.id).eq("mls_number",s).maybeSingle().then(({data:q})=>g(!!q))},[u,s,t.id]);const b=async()=>{var q;!u||!s||(f?(await H.from("lead_site_saved_listings").delete().eq("user_id",u.id).eq("lead_site_id",t.id).eq("mls_number",s),g(!1),me.success("Removed from saved")):(await H.from("lead_site_saved_listings").insert({user_id:u.id,lead_site_id:t.id,mls_number:s,property_address:_?`${_.address}, ${_.city}, ${_.state}`:null,photo_url:((q=_==null?void 0:_.photos)==null?void 0:q[0])||null}),g(!0),me.success("Saved to favorites")))},{data:_,isLoading:j,error:w}=mt({queryKey:["lead-site-listing",t.id,s],queryFn:async()=>{const q=new AbortController,U=window.setTimeout(()=>q.abort(),15e3);try{const B=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-listing",{method:"POST",headers:{"Content-Type":"application/json",apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({leadSiteId:t.id,mlsNumber:s}),signal:q.signal}),V=await B.json().catch(()=>null);if(!B.ok)throw console.error("Lead site listing fetch error:",V),new Error((V==null?void 0:V.error)||"Failed to load listing");return console.log("Lead site listing data received:",!!V,V==null?void 0:V.mlsNumber),V}finally{window.clearTimeout(U)}},enabled:!!s});k.useEffect(()=>{var q;s&&t&&_&&p.recordView(s,u==null?void 0:u.id,{propertyAddress:_.address?`${_.address}, ${_.city}, ${_.state}`:void 0,photoUrl:((q=_.photos)==null?void 0:q[0])||void 0})},[s,t==null?void 0:t.id,_==null?void 0:_.address]);const N=async q=>{q.preventDefault(),c(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:o.name,email:o.email,phone:o.phone||null,message:o.message||`Interested in listing ${s}`,source_page:`/listing/${s}`,lead_type:"listing_inquiry",metadata:{mlsNumber:s}}),wme(t.id,{name:o.name,email:o.email,phone:o.phone||null,message:o.message||`Interested in listing ${s}`,lead_type:"listing_inquiry",source_page:`/listing/${s}`,mls_number:s}),me.success("Message sent! The agent will be in touch."),l({name:"",email:"",phone:"",message:""}),a(!1)}catch{me.error("Something went wrong. Please try again.")}finally{c(!1)}},S=async()=>{const q=window.location.href;if(navigator.share)try{await navigator.share({title:(_==null?void 0:_.address)||"Property Listing",url:q})}catch{}else await navigator.clipboard.writeText(q),me.success("Link copied to clipboard")},M=q=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(q);return j?e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent"})}):_?e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 relative",children:[e.jsx(T3s,{listing:_,siteConfig:t}),e.jsx(gCe,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${_.address}, ${_.city}`,path:`/listing/${_.mlsNumber}`}]}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("button",{onClick:()=>r(-1),className:"flex items-center gap-2 text-gray-600 hover:text-gray-900 text-sm",children:[e.jsx(Ja,{className:"h-4 w-4"})," Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-600 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:[e.jsx(wd,{className:"h-4 w-4"})," Share"]}),u&&e.jsxs("button",{onClick:b,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm border rounded-lg transition-colors ${f?"bg-red-50 text-red-600 border-red-200":"text-gray-600 border-gray-200 hover:bg-gray-50"}`,children:[e.jsx(ni,{className:`h-4 w-4 ${f?"fill-current":""}`}),f?"Saved":"Save"]})]})]}),e.jsx(a5s,{photos:_.photos||[]}),e.jsxs("div",{className:p.isGated?"filter blur-sm pointer-events-none select-none":"",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-3xl font-bold text-gray-900",children:M(_.price)}),e.jsxs("p",{className:"text-gray-600 mt-1 flex items-center gap-1",children:[e.jsx(ma,{className:"h-4 w-4"}),_.address,", ",_.city,", ",_.state," ",_.zip]})]}),e.jsx("span",{className:"px-3 py-1 bg-green-100 text-green-800 text-sm font-semibold rounded-full shrink-0",children:_.status})]}),e.jsxs("p",{className:"text-xs text-gray-400",children:["MLS# ",_.mlsNumber]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-6 py-4 border-y border-gray-200",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Im,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.bedrooms}),e.jsx("span",{className:"text-gray-500 text-sm",children:"beds"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ju,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.bathrooms}),e.jsx("span",{className:"text-gray-500 text-sm",children:"baths"})]}),_.sqft>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g0,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.sqft.toLocaleString()}),e.jsx("span",{className:"text-gray-500 text-sm",children:"sqft"})]}),_.yearBuilt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.yearBuilt}),e.jsx("span",{className:"text-gray-500 text-sm",children:"built"})]}),_.propertyType&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-600",children:_.propertyType}),_.propertySubType&&e.jsxs("span",{className:"text-xs text-gray-400",children:["• ",_.propertySubType]})]})]}),_.virtualTourUrl&&e.jsxs("a",{href:_.virtualTourUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-50 text-blue-700 rounded-lg text-sm font-medium hover:bg-blue-100 transition-colors",children:[e.jsx(tn,{className:"h-4 w-4"})," Take a Virtual Tour"]}),_.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 text-sm leading-relaxed whitespace-pre-line",children:_.description})]}),e.jsx(i5s,{listing:_}),_.latitude&&_.longitude&&e.jsx(o5s,{latitude:_.latitude,longitude:_.longitude,address:`${_.address}, ${_.city}`})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-6 sticky top-24",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[((L=t.agent)==null?void 0:L.avatar_url)&&e.jsx("img",{src:t.agent.avatar_url,alt:"",className:"w-12 h-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900",children:(I=t.agent)==null?void 0:I.full_name}),e.jsx("p",{className:"text-sm text-gray-500",children:((O=t.agent)==null?void 0:O.title)||"Real Estate Agent"})]})]}),n?e.jsxs("form",{onSubmit:N,className:"space-y-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:o.name,onChange:q=>l(U=>({...U,name:q.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("input",{type:"email",required:!0,placeholder:"Email",value:o.email,onChange:q=>l(U=>({...U,email:q.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("input",{type:"tel",placeholder:"Phone (optional)",value:o.phone,onChange:q=>l(U=>({...U,phone:q.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("textarea",{placeholder:"Message",value:o.message,onChange:q=>l(U=>({...U,message:q.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 h-20 resize-none"}),e.jsx("button",{type:"submit",disabled:i,className:"w-full py-2.5 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:i?"Sending...":"Send Message"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors",children:"Ask About This Property"}),e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 border border-gray-300 text-gray-700 font-medium rounded-lg hover:bg-gray-50 transition-colors",children:"Schedule a Showing"})]})]}),_.price>0&&e.jsx(l5s,{listPrice:_.price})]})]}),e.jsx("div",{className:"mt-12 mb-6",children:e.jsx(c5s,{siteConfig:t,currentListing:_})})]}),e.jsx(kct,{open:p.showRegistration,mode:p.mode,siteConfig:t,onComplete:p.completeRegistration,onSkip:p.dismissRegistration})]}):e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-20 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:w?"Error loading listing":"Listing not found"}),w&&e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Please try again in a moment."}),e.jsx("button",{onClick:()=>r("/search"),className:"mt-4 text-blue-600 hover:underline",children:"Back to search"})]})}function u5s({siteConfig:t}){const s=fr(),r=t.agent;return e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"text-center mb-12",children:[(r==null?void 0:r.avatar_url)&&e.jsx("img",{src:r.avatar_url,alt:r.full_name,className:"w-32 h-32 rounded-2xl object-cover mx-auto mb-6 shadow-lg"}),e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:(r==null?void 0:r.full_name)||"About"}),e.jsx("p",{className:"text-lg text-gray-500",children:(r==null?void 0:r.title)||"Real Estate Professional"})]}),(r==null?void 0:r.bio)&&e.jsx("div",{className:"prose prose-gray max-w-none mb-12",children:e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:r.bio})}),e.jsxs("div",{className:"bg-blue-50 rounded-2xl p-8 text-center",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:"Ready to get started?"}),e.jsx("p",{className:"text-gray-600 mb-6",children:"Whether you're buying or selling, I'm here to help you every step of the way."}),e.jsxs("div",{className:"flex gap-3 justify-center",children:[e.jsx("button",{onClick:()=>s("/contact"),className:"px-6 py-3 bg-blue-600 text-white font-semibold rounded-lg hover:bg-blue-700 transition-colors",children:"Contact Me"}),e.jsx("button",{onClick:()=>s("/search"),className:"px-6 py-3 border border-gray-300 text-gray-700 font-semibold rounded-lg hover:bg-white transition-colors",children:"Search Listings"})]})]})]})}function h5s({siteConfig:t}){const[s,r]=k.useState({name:"",email:"",phone:"",message:""}),[n,a]=k.useState(!1),o=async i=>{i.preventDefault(),a(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:s.name,email:s.email,phone:s.phone||null,message:s.message,source_page:"/contact",lead_type:"contact"}),wme(t.id,{name:s.name,email:s.email,phone:s.phone||null,message:s.message,lead_type:"contact",source_page:"/contact"}),me.success("Message sent! We'll be in touch soon."),r({name:"",email:"",phone:"",message:""})}catch{me.error("Something went wrong. Please try again.")}finally{a(!1)}},l=t.agent;return e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Get In Touch"}),e.jsx("p",{className:"text-gray-500",children:"Have a question or ready to start your home search? Reach out!"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-12",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[(l==null?void 0:l.avatar_url)&&e.jsx("img",{src:l.avatar_url,alt:"",className:"w-16 h-16 rounded-xl object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg text-gray-900",children:l==null?void 0:l.full_name}),e.jsx("p",{className:"text-gray-500",children:(l==null?void 0:l.title)||"Real Estate Agent"})]})]}),e.jsxs("div",{className:"space-y-4",children:[(l==null?void 0:l.email)&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center",children:e.jsx(cr,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Email"}),e.jsx("a",{href:`mailto:${l.email}`,className:"text-gray-900 hover:text-blue-600",children:l.email})]})]}),(l==null?void 0:l.phone)&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 rounded-lg flex items-center justify-center",children:e.jsx(Un,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Phone"}),e.jsx("a",{href:`tel:${l.phone}`,className:"text-gray-900 hover:text-blue-600",children:l.phone})]})]})]})]}),e.jsxs("form",{onSubmit:o,className:"bg-white border border-gray-200 rounded-xl p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Name *"}),e.jsx("input",{type:"text",required:!0,value:s.name,onChange:i=>r(c=>({...c,name:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email *"}),e.jsx("input",{type:"email",required:!0,value:s.email,onChange:i=>r(c=>({...c,email:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Phone"}),e.jsx("input",{type:"tel",value:s.phone,onChange:i=>r(c=>({...c,phone:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Message *"}),e.jsx("textarea",{required:!0,value:s.message,onChange:i=>r(c=>({...c,message:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 h-28 resize-none",placeholder:"Tell me about what you're looking for..."})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:n?"Sending...":"Send Message"})]})]})]})}function m5s({siteConfig:t}){const s=fr(),{user:r,profile:n,signOut:a}=jme(),[o,l]=k.useState("saved"),[i,c]=k.useState([]),[u,p]=k.useState([]),[f,g]=k.useState({name:"",phone:"",email:""}),[b,_]=k.useState(!1);k.useEffect(()=>{if(!r){s("/");return}j(),n&&g({name:n.name,phone:n.phone||"",email:n.email})},[r,n]);const j=async()=>{if(!r)return;const{data:M}=await H.from("lead_site_saved_listings").select("*").eq("user_id",r.id).eq("lead_site_id",t.id).order("saved_at",{ascending:!1});c(M||[]);const{data:L}=await H.from("lead_site_property_views").select("*").eq("auth_user_id",r.id).eq("lead_site_id",t.id).order("viewed_at",{ascending:!1}).limit(50),I=new Set,O=(L||[]).filter(q=>I.has(q.mls_number)?!1:(I.add(q.mls_number),!0));p(O)},w=async M=>{await H.from("lead_site_saved_listings").delete().eq("user_id",r.id).eq("lead_site_id",t.id).eq("mls_number",M),c(L=>L.filter(I=>I.mls_number!==M)),me.success("Removed from saved")},N=async M=>{M.preventDefault(),_(!0);try{await H.from("lead_site_consumer_profiles").update({name:f.name,phone:f.phone||null}).eq("user_id",r.id).eq("lead_site_id",t.id),me.success("Profile updated")}catch{me.error("Failed to update profile")}finally{_(!1)}};if(!r)return null;const S=[{key:"saved",label:"Saved Listings",icon:ni,count:i.length},{key:"viewed",label:"Recently Viewed",icon:un,count:u.length},{key:"profile",label:"My Profile",icon:to}];return e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"My Account"}),e.jsxs("p",{className:"text-gray-500 text-sm mt-1",children:["Welcome back, ",(n==null?void 0:n.name)||"there","!"]})]}),e.jsxs("button",{onClick:async()=>{await a(),s("/")},className:"flex items-center gap-2 text-sm text-gray-500 hover:text-gray-700 px-3 py-2 rounded-lg hover:bg-gray-100 transition-colors",children:[e.jsx(oS,{className:"h-4 w-4"})," Sign Out"]})]}),e.jsx("div",{className:"flex gap-1 border-b border-gray-200 mb-6",children:S.map(M=>{const L=M.icon;return e.jsxs("button",{onClick:()=>l(M.key),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${o===M.key?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[e.jsx(L,{className:"h-4 w-4"}),M.label,"count"in M&&typeof M.count=="number"&&e.jsx("span",{className:"ml-1 text-xs bg-gray-100 text-gray-600 px-1.5 py-0.5 rounded-full",children:M.count})]},M.key)})}),o==="saved"&&e.jsx("div",{children:i.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(ni,{className:"h-10 w-10 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"No saved listings yet"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"Browse properties and tap the heart to save them."}),e.jsx("button",{onClick:()=>s("/search"),className:"mt-4 px-5 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700",children:"Search Properties"})]}):e.jsx("div",{className:"space-y-3",children:i.map(M=>e.jsxs("div",{className:"flex items-center justify-between p-4 bg-white border border-gray-200 rounded-xl hover:bg-gray-50 transition-colors",children:[e.jsxs("button",{onClick:()=>s(`/listing/${M.mls_number}`),className:"flex items-center gap-3 flex-1 text-left",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-gray-900",children:["MLS# ",M.mls_number]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Saved ",new Date(M.saved_at).toLocaleDateString()]})]}),e.jsx(da,{className:"h-4 w-4 text-gray-400 ml-auto"})]}),e.jsx("button",{onClick:()=>w(M.mls_number),className:"p-2 text-gray-400 hover:text-red-500 ml-2",children:e.jsx(Nr,{className:"h-4 w-4"})})]},M.mls_number))})}),o==="viewed"&&e.jsx("div",{children:u.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(un,{className:"h-10 w-10 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"No recently viewed properties"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"Properties you view will appear here."})]}):e.jsx("div",{className:"space-y-3",children:u.map(M=>e.jsxs("button",{onClick:()=>s(`/listing/${M.mls_number}`),className:"flex items-center justify-between w-full p-4 bg-white border border-gray-200 rounded-xl hover:bg-gray-50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-gray-900",children:["MLS# ",M.mls_number]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Viewed ",new Date(M.viewed_at).toLocaleDateString()]})]}),e.jsx(da,{className:"h-4 w-4 text-gray-400"})]},M.id))})}),o==="profile"&&e.jsx("div",{className:"max-w-md",children:e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Name"}),e.jsx("input",{type:"text",value:f.name,onChange:M=>g(L=>({...L,name:M.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email"}),e.jsx("input",{type:"email",value:f.email,disabled:!0,className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm bg-gray-50 text-gray-500"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Email cannot be changed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Phone"}),e.jsx("input",{type:"tel",value:f.phone,onChange:M=>g(L=>({...L,phone:M.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"This is also used as your password"})]}),e.jsx("button",{type:"submit",disabled:b,className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50",children:b?"Saving...":"Save Changes"})]})})]})}function Jze({siteConfig:t}){var p;const s=fr(),{slug:r}=yo(),[n,a]=k.useState("all"),{data:o,isLoading:l}=mt({queryKey:["public-blog-posts",t.id,n],queryFn:async()=>{let f=H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("published_at",{ascending:!1});n!=="all"&&(f=f.eq("post_type",n));const{data:g,error:b}=await f;if(b)throw b;return g},enabled:!r}),{data:i,isLoading:c}=mt({queryKey:["public-blog-post",t.id,r],queryFn:async()=>{const{data:f,error:g}=await H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("slug",r).eq("is_published",!0).maybeSingle();if(g)throw g;return f},enabled:!!r});if(r)return c?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-gray-900 border-t-transparent"})}):i?e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsx(E3s,{title:i.title,description:i.excerpt||i.title,publishedAt:i.published_at||i.created_at,imageUrl:i.cover_image_url,slug:i.slug,siteConfig:t}),e.jsx(gCe,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Blog",path:"/blog"},{name:i.title,path:`/blog/${i.slug}`}]}),i.cover_image_url&&e.jsxs("div",{className:"h-72 md:h-96 w-full relative",children:[e.jsx("img",{src:i.cover_image_url,alt:i.title,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 to-transparent"})]}),e.jsxs("article",{className:"max-w-3xl mx-auto px-6 py-12",children:[e.jsxs("button",{onClick:()=>s("/blog"),className:"flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-900 mb-6 transition-colors",children:[e.jsx(Ja,{className:"h-4 w-4"})," All Posts"]}),e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`text-xs font-medium px-2.5 py-1 rounded-full ${i.post_type==="neighborhood_guide"?"bg-emerald-50 text-emerald-700":"bg-blue-50 text-blue-700"}`,children:i.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),i.neighborhood&&e.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"})," ",i.neighborhood]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-4",children:i.title}),i.published_at&&e.jsx("p",{className:"text-sm text-gray-400 mb-8",children:new Date(i.published_at).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),e.jsx("div",{className:"prose prose-lg max-w-none prose-headings:text-gray-900 prose-p:text-gray-700 prose-a:text-blue-600",dangerouslySetInnerHTML:{__html:i.content}})]})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Post Not Found"}),e.jsx("button",{onClick:()=>s("/blog"),className:"text-blue-600 hover:underline",children:"← Back to blog"})]})});const u=((p=t.agent)==null?void 0:p.full_name)||"Your Agent";return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"bg-gradient-to-br from-gray-900 to-gray-800 text-white py-20 px-6",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:"Local Insights"}),e.jsxs("p",{className:"text-lg text-gray-300 max-w-2xl mx-auto",children:["Neighborhood guides, market insights, and local expertise from ",u,"."]})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 -mt-6 mb-8",children:e.jsx("div",{className:"bg-white rounded-2xl shadow-lg p-2 flex gap-1",children:[{value:"all",label:"All Posts"},{value:"blog_post",label:"Blog"},{value:"neighborhood_guide",label:"Neighborhoods"}].map(f=>e.jsx("button",{onClick:()=>a(f.value),className:`flex-1 py-2.5 px-4 rounded-xl text-sm font-medium transition-all ${n===f.value?"bg-gray-900 text-white shadow-md":"text-gray-600 hover:bg-gray-100"}`,children:f.label},f.value))})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 pb-20",children:l?e.jsx("div",{className:"text-center py-12",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-gray-900 border-t-transparent mx-auto"})}):o!=null&&o.length?e.jsx("div",{className:"grid gap-6",children:o.map((f,g)=>e.jsx(Gs.article,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:g*.05},onClick:()=>s(`/blog/${f.slug}`),className:"bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-xl transition-all cursor-pointer group border border-gray-100",children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[f.cover_image_url&&e.jsx("div",{className:"sm:w-64 h-48 sm:h-auto flex-shrink-0",children:e.jsx("img",{src:f.cover_image_url,alt:f.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),e.jsxs("div",{className:"flex-1 p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:`text-xs font-medium px-2.5 py-1 rounded-full ${f.post_type==="neighborhood_guide"?"bg-emerald-50 text-emerald-700":"bg-blue-50 text-blue-700"}`,children:f.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),f.neighborhood&&e.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"})," ",f.neighborhood]})]}),e.jsx("h2",{className:"text-xl font-bold text-gray-900 group-hover:text-blue-600 transition-colors mb-2",children:f.title}),f.excerpt&&e.jsx("p",{className:"text-gray-600 text-sm line-clamp-2 mb-3",children:f.excerpt}),f.published_at&&e.jsx("p",{className:"text-xs text-gray-400",children:new Date(f.published_at).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})]})]})},f.id))}):e.jsx("div",{className:"text-center py-20",children:e.jsx("p",{className:"text-gray-400 text-lg",children:"No posts yet. Check back soon!"})})})]})}function p5s({siteConfig:t}){var a;const s=((a=t.agent)==null?void 0:a.full_name)||"Your Agent",{data:r}=mt({queryKey:["public-lead-site-events",t.id],queryFn:async()=>{const{data:o,error:l}=await H.from("lead_site_events").select("*").eq("lead_site_id",t.id).eq("is_published",!0).gte("event_date",new Date().toISOString()).order("event_date",{ascending:!0});if(l)throw l;return o}}),{data:n}=mt({queryKey:["public-lead-site-businesses",t.id],queryFn:async()=>{const{data:o,error:l}=await H.from("lead_site_businesses").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("sort_order",{ascending:!0});if(l)throw l;return o}});return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"bg-gradient-to-br from-gray-900 to-gray-800 text-white py-20 px-6",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:"Community"}),e.jsxs("p",{className:"text-lg text-gray-300 max-w-2xl mx-auto",children:["Local events, favorite spots, and everything that makes this area special — curated by ",s,"."]})]})}),e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-16 space-y-20",children:[r&&r.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-blue-100 flex items-center justify-center",children:e.jsx(hn,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Upcoming Events"}),e.jsx("p",{className:"text-sm text-gray-500",children:"What's happening in the community"})]})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:r.map((o,l)=>e.jsxs(Gs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:l*.05},className:"bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-lg transition-all border border-gray-100 group",children:[o.image_url&&e.jsx("div",{className:"h-40 overflow-hidden",children:e.jsx("img",{src:o.image_url,alt:o.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),e.jsx("div",{className:"p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-blue-50 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-[10px] font-bold text-blue-600 uppercase leading-none",children:ms(new Date(o.event_date),"MMM")}),e.jsx("span",{className:"text-xl font-bold text-blue-600 leading-none mt-0.5",children:ms(new Date(o.event_date),"d")})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-bold text-gray-900 text-lg mb-1",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2 mb-2",children:o.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-gray-500",children:[o.location&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ma,{className:"h-3 w-3"})," ",o.location]}),e.jsx("span",{children:ms(new Date(o.event_date),"h:mm a")})]}),o.external_url&&e.jsxs("a",{href:o.external_url,target:"_blank",rel:"noopener",className:"inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 mt-3 font-medium",children:["Learn More ",e.jsx(tn,{className:"h-3 w-3"})]})]})]})})]},o.id))})]}),n&&n.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-amber-100 flex items-center justify-center",children:e.jsx($M,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-2xl font-bold text-gray-900",children:[s,"'s Local Picks"]}),e.jsx("p",{className:"text-sm text-gray-500",children:"Places I love and recommend in the area"})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:n.map((o,l)=>e.jsxs(Gs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:l*.05},className:"bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-lg transition-all border border-gray-100 group",children:[o.image_url?e.jsx("div",{className:"h-36 overflow-hidden",children:e.jsx("img",{src:o.image_url,alt:o.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}):e.jsx("div",{className:"h-24 bg-gradient-to-br from-amber-50 to-orange-50 flex items-center justify-center",children:e.jsx($M,{className:"h-8 w-8 text-amber-300"})}),e.jsxs("div",{className:"p-4",children:[o.category&&e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-600 mb-1 block",children:o.category}),e.jsx("h3",{className:"font-bold text-gray-900 mb-1",children:o.name}),o.description&&e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2 mb-3",children:o.description}),e.jsx("div",{className:"flex flex-wrap items-center gap-3 text-xs text-gray-500",children:o.address&&e.jsxs("span",{className:"flex items-center gap-1 truncate",children:[e.jsx(ma,{className:"h-3 w-3 flex-shrink-0"})," ",o.address]})}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[o.phone&&e.jsxs("a",{href:`tel:${o.phone}`,className:"text-xs text-blue-600 hover:text-blue-700 flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"})," Call"]}),o.website_url&&e.jsxs("a",{href:o.website_url,target:"_blank",rel:"noopener",className:"text-xs text-blue-600 hover:text-blue-700 flex items-center gap-1",children:[e.jsx(su,{className:"h-3 w-3"})," Website"]})]})]})]},o.id))})]}),(!r||r.length===0)&&(!n||n.length===0)&&e.jsx("div",{className:"text-center py-20",children:e.jsx("p",{className:"text-gray-400 text-lg",children:"Community content coming soon!"})})]})]})}function f5s({siteConfig:t,themeConfig:s}){var Y,Q,ee,X;const r=fr(),[n]=Cc(),a=((Y=t.agent)==null?void 0:Y.full_name)||"Your Agent",o=a.split(" ")[0],l=(s==null?void 0:s.accentColor)||((Q=t.themeConfig)==null?void 0:Q.accentColor)||"#3b82f6",[i,c]=k.useState({name:"",email:"",phone:"",address:"",timeline:"",message:""}),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState(null),[j,w]=k.useState(!0),[N,S]=k.useState("");k.useEffect(()=>{(async()=>{const re=n.get("city");if(re){S(re);return}const{data:oe}=await H.from("lead_site_city_pages").select("city_name").eq("site_id",t.id).eq("is_published",!0).order("sort_order",{ascending:!0}).limit(1);oe!=null&&oe[0]&&S(oe[0].city_name)})()},[t.id,n]),k.useEffect(()=>{if(!N){w(!1);return}(async()=>{w(!0);try{const{data:re,error:oe}=await H.functions.invoke("lead-site-seller-stats",{body:{leadSiteId:t.id,city:N}});!oe&&re&&_(re)}catch(re){console.warn("Failed to load seller stats:",re)}finally{w(!1)}})()},[t.id,N]);const M=async ie=>{ie.preventDefault(),p(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:i.name,email:i.email,phone:i.phone||null,message:i.message||null,source_page:"/sell",lead_type:"seller",metadata:{address:i.address,timeline:i.timeline}}),wme(t.id,{name:i.name,email:i.email,phone:i.phone||null,message:`Seller Lead — ${i.address||"Address not provided"} Timeline: ${i.timeline||"Not specified"} ${i.message||""}`,lead_type:"seller",source_page:"/sell"}),g(!0),me.success("Your request has been submitted!")}catch{me.error("Something went wrong. Please try again.")}finally{p(!1)}},L=ie=>ie>=1e6?`$${(ie/1e6).toFixed(1)}M`:`$${Math.round(ie/1e3)}K`,I=`https://${t.subdomainSlug}.thelocalmove.com`,O=`Sell Your Home | ${a}`,q=`Thinking of selling your home? Get a free market analysis from ${a}. See recent sales, market trends, and what your home could be worth.`,U=(b==null?void 0:b.marketCondition)==="seller"?"It's a Seller's Market":(b==null?void 0:b.marketCondition)==="buyer"?"It's a Buyer's Market":"The Market Is Balanced",B=(b==null?void 0:b.marketCondition)==="seller"?"Demand exceeds supply. Sellers have the advantage with faster sales and stronger offers.":(b==null?void 0:b.marketCondition)==="buyer"?"More inventory than buyers. Pricing strategy and presentation are critical.":"Supply and demand are relatively even. Well-priced homes sell quickly.",V=[{step:"1",title:"Free Home Valuation",desc:"Get a data-driven market analysis of your home's current value."},{step:"2",title:"Strategic Pricing",desc:"Price your home to attract maximum interest and competitive offers."},{step:"3",title:"Professional Marketing",desc:"Professional photos, virtual tours, targeted digital marketing, and MLS exposure."},{step:"4",title:"Showings & Offers",desc:"Coordinate showings, review offers, and negotiate the best terms for you."},{step:"5",title:"Close & Celebrate",desc:"Navigate inspections, appraisals, and closing with expert guidance."}];return e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsxs(Sc,{children:[e.jsx("title",{children:O}),e.jsx("meta",{name:"description",content:q}),e.jsx("meta",{property:"og:title",content:O}),e.jsx("meta",{property:"og:description",content:q}),e.jsx("link",{rel:"canonical",href:`${I}/sell`})]}),e.jsx(xCe,{siteConfig:t,pagePath:"/sell"}),e.jsxs("section",{className:"relative bg-gray-950 text-white overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-20",style:{background:`radial-gradient(ellipse at 30% 40%, ${l}44, transparent 60%), radial-gradient(ellipse at 70% 60%, ${l}22, transparent 50%)`}}),e.jsx("div",{className:"relative max-w-7xl mx-auto px-6 lg:px-8 py-24 md:py-32",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16 items-center",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-medium mb-6",style:{backgroundColor:`${l}20`,color:l},children:[e.jsx(ul,{className:"h-4 w-4"}),(b==null?void 0:b.marketCondition)==="seller"?"Seller's Market":"Free Home Valuation"]}),e.jsxs("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold tracking-tight leading-[1.1] mb-6",children:["What's Your Home ",e.jsx("span",{style:{color:l},children:"Really Worth?"})]}),e.jsxs("p",{className:"text-lg md:text-xl text-gray-400 leading-relaxed mb-8 max-w-lg",children:["Get a complimentary, data-driven market analysis from ",o,". See what homes in your area are actually selling for — not just what they're listed at."]}),e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:l}})," No obligation"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:l}})," Real MLS data"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:l}})," Expert guidance"]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl p-8 shadow-2xl text-gray-900",children:f?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:`${l}15`},children:e.jsx(sa,{className:"h-8 w-8",style:{color:l}})}),e.jsx("h3",{className:"text-xl font-bold mb-2",children:"You're All Set!"}),e.jsxs("p",{className:"text-gray-500 mb-6",children:[o," will review your information and send you a personalized market analysis within 24 hours."]}),e.jsxs("button",{onClick:()=>r("/search"),className:"text-sm font-medium flex items-center gap-1 mx-auto",style:{color:l},children:["Browse current listings ",e.jsx(Qa,{className:"h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-bold mb-1",children:"Get Your Free Home Valuation"}),e.jsxs("p",{className:"text-sm text-gray-500 mb-6",children:[o," will send you a personalized market analysis."]}),e.jsxs("form",{onSubmit:M,className:"space-y-3.5",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your property address *",value:i.address,onChange:ie=>c(re=>({...re,address:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent",style:{"--tw-ring-color":l}}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Full name *",value:i.name,onChange:ie=>c(re=>({...re,name:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent",style:{"--tw-ring-color":l}}),e.jsx("input",{type:"tel",placeholder:"Phone",value:i.phone,onChange:ie=>c(re=>({...re,phone:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent",style:{"--tw-ring-color":l}})]}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address *",value:i.email,onChange:ie=>c(re=>({...re,email:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent",style:{"--tw-ring-color":l}}),e.jsxs("select",{value:i.timeline,onChange:ie=>c(re=>({...re,timeline:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent text-gray-700",style:{"--tw-ring-color":l},children:[e.jsx("option",{value:"",children:"When are you looking to sell?"}),e.jsx("option",{value:"asap",children:"As soon as possible"}),e.jsx("option",{value:"1-3months",children:"1–3 months"}),e.jsx("option",{value:"3-6months",children:"3–6 months"}),e.jsx("option",{value:"6-12months",children:"6–12 months"}),e.jsx("option",{value:"just-curious",children:"Just curious about my value"})]}),e.jsx("textarea",{placeholder:"Anything else you'd like us to know?",value:i.message,onChange:ie=>c(re=>({...re,message:ie.target.value})),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent h-20 resize-none",style:{"--tw-ring-color":l}}),e.jsx("button",{type:"submit",disabled:u,className:"w-full py-3.5 text-white font-semibold rounded-xl transition-all hover:opacity-90 disabled:opacity-50 text-sm",style:{backgroundColor:l},children:u?"Submitting...":"Get My Free Valuation"}),e.jsxs("p",{className:"text-[11px] text-gray-400 text-center",children:["By submitting, you agree to be contacted by ",o," about your property."]})]})]})})]})})]}),b&&!j&&e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-semibold uppercase tracking-wider mb-4 bg-green-100 text-green-700",children:[e.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})," Live MLS Data"]}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:[N," Market Snapshot"]}),e.jsx("p",{className:"text-gray-500 mt-3 max-w-2xl mx-auto",children:"Real-time data from the MLS — see exactly what's happening in your market right now."})]}),e.jsxs("div",{className:"mb-10 rounded-2xl p-6 text-center",style:{backgroundColor:b.marketCondition==="seller"?"#f0fdf4":b.marketCondition==="buyer"?"#fef2f2":"#eff6ff"},children:[e.jsx("h3",{className:"text-xl font-bold mb-1",style:{color:b.marketCondition==="seller"?"#15803d":b.marketCondition==="buyer"?"#b91c1c":"#1d4ed8"},children:U}),e.jsx("p",{className:"text-sm text-gray-600 max-w-xl mx-auto",children:B}),e.jsxs("p",{className:"text-xs text-gray-400 mt-2",children:[b.monthsOfInventory," months of inventory · ",b.activeCount," active · ",b.soldCount," sold (6 mo)"]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 md:gap-6",children:[{icon:ac,label:"Median Sold Price",value:b.medianSoldPrice>0?L(b.medianSoldPrice):"—",color:"#10b981"},{icon:un,label:"Avg Days on Market",value:b.avgDaysOnMarket>0?`${b.avgDaysOnMarket} days`:"—",color:"#f59e0b"},{icon:hS,label:"Sale-to-List Ratio",value:b.listToSaleRatio>0?`${b.listToSaleRatio}%`:"—",color:"#8b5cf6"},{icon:No,label:"Avg Price / Sq Ft",value:b.avgPricePerSqft>0?`$${b.avgPricePerSqft}`:"—",color:"#3b82f6"}].map(ie=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 p-5 text-center shadow-sm",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center mx-auto mb-3",style:{backgroundColor:`${ie.color}12`},children:e.jsx(ie.icon,{className:"h-5 w-5",style:{color:ie.color}})}),e.jsx("p",{className:"text-2xl md:text-3xl font-bold text-gray-900",children:ie.value}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:ie.label})]},ie.label))})]})}),(b==null?void 0:b.recentlySold)&&b.recentlySold.length>0&&e.jsx("section",{className:"py-20",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:"What Sellers Are Getting"}),e.jsxs("p",{className:"text-gray-500 mt-3",children:["Recently sold homes in ",N," — real prices, real results."]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6",children:b.recentlySold.map((ie,re)=>{var oe,ce,ge;return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 overflow-hidden shadow-sm hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"aspect-[16/10] bg-gray-100 relative",children:[(oe=ie.photos)!=null&&oe[0]?e.jsx("img",{src:ie.photos[0],alt:ie.address,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300",children:e.jsx(bn,{className:"h-10 w-10"})}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 bg-red-600 text-white text-xs font-bold rounded-full",children:"SOLD"})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[e.jsxs("p",{className:"text-xl font-bold text-gray-900",children:["$",(ce=ie.soldPrice)==null?void 0:ce.toLocaleString()]}),ie.listPrice>0&&ie.soldPrice>0&&e.jsxs("span",{className:`text-xs font-semibold ${ie.soldPrice>=ie.listPrice?"text-green-600":"text-red-500"}`,children:[ie.soldPrice>=ie.listPrice?"+":"",((ie.soldPrice-ie.listPrice)/ie.listPrice*100).toFixed(1),"%"]})]}),e.jsxs("p",{className:"text-sm text-gray-600 mb-2 flex items-center gap-1",children:[e.jsx(ma,{className:"h-3.5 w-3.5 text-gray-400 flex-shrink-0"}),ie.address,", ",ie.city]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500",children:[e.jsxs("span",{children:[ie.bedrooms," bed"]}),e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{children:[ie.bathrooms," bath"]}),e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{children:[(ge=ie.sqft)==null?void 0:ge.toLocaleString()," sqft"]}),ie.daysOnMarket>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{children:[ie.daysOnMarket," DOM"]})]})]})]})]},ie.mlsNumber||re)})})]})}),e.jsx("section",{className:"py-20 bg-gray-950 text-white",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-14",children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight",children:["How Selling With ",o," Works"]}),e.jsx("p",{className:"text-gray-400 mt-3 max-w-xl mx-auto",children:"A clear, proven process from listing to closing — no surprises."})]}),e.jsx("div",{className:"space-y-0",children:V.map((ie,re)=>e.jsxs("div",{className:"relative flex gap-6 pb-10 last:pb-0",children:[ree.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${l}12`},children:e.jsx(ie.icon,{className:"h-5 w-5",style:{color:l}})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-0.5",children:ie.title}),e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed",children:ie.desc})]})]},ie.title))})]}),e.jsx("div",{className:"flex justify-center",children:(ee=t.agent)!=null&&ee.avatar_url?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:t.agent.avatar_url,alt:a,className:"w-72 h-72 md:w-80 md:h-80 rounded-2xl object-cover shadow-xl"}),e.jsxs("div",{className:"absolute -bottom-4 -right-4 bg-white rounded-xl shadow-lg p-4 border border-gray-100",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:"Your local expert"}),e.jsx("p",{className:"font-bold text-gray-900",children:a}),e.jsx("p",{className:"text-xs text-gray-500",children:((X=t.agent)==null?void 0:X.title)||"REALTOR®"})]})]}):e.jsx("div",{className:"w-72 h-72 rounded-2xl bg-gray-100 flex items-center justify-center",children:e.jsx(bn,{className:"h-16 w-16 text-gray-300"})})})]})})}),e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 lg:px-8",children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900 text-center mb-10 tracking-tight",children:"Frequently Asked Questions"}),e.jsx(x5s,{agentName:o,city:N,accentColor:l})]})}),e.jsx("section",{className:"py-20 bg-gray-950 text-white",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 tracking-tight",children:"Ready to Find Out What Your Home Is Worth?"}),e.jsxs("p",{className:"text-gray-400 mb-8 text-lg",children:["Get your free, no-obligation market analysis from ",o," today."]}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsx("button",{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),className:"px-8 py-3.5 text-white font-semibold rounded-xl transition-colors text-lg",style:{backgroundColor:l},children:"Get My Free Valuation"}),e.jsxs("button",{onClick:()=>r("/contact"),className:"px-8 py-3.5 border border-white/20 text-white hover:bg-white/10 font-semibold rounded-xl transition-colors text-lg",children:["Contact ",o]})]})]})})]})}function x5s({agentName:t,city:s,accentColor:r}){const[n,a]=k.useState(null),o=s||"your area",l=[{q:`How do I know what my home is worth in ${o}?`,a:`${t} provides a complimentary Comparative Market Analysis (CMA) using current MLS data — recent sales, active listings, and market trends in ${o}. This gives you an accurate, data-driven estimate of your home's value.`},{q:"How long does it take to sell a home?",a:`The timeline varies based on market conditions, pricing, and property condition. In ${o}, well-priced homes typically sell within the average days-on-market for the area. ${t} will give you a realistic timeline based on current data.`},{q:"What should I do to prepare my home for sale?",a:`${t} will walk through your home and provide a personalized checklist — from decluttering and minor repairs to staging recommendations. The goal is to maximize your home's appeal without over-investing.`},{q:"How much does it cost to sell a home?",a:"Typical costs include agent commissions, closing costs (1-3% of sale price), and any agreed-upon repairs or concessions. Your net proceeds depend on your sale price, mortgage payoff, and these costs. We'll provide a detailed net sheet upfront."},{q:"Should I make repairs before listing?",a:`It depends on the repair and the market. ${t} will help you identify high-ROI improvements versus things that won't meaningfully impact your sale price. In a strong seller's market, fewer repairs may be needed.`},{q:`What's the best time of year to sell in ${o}?`,a:`While spring and summer tend to see more buyer activity, ${o}'s market has its own patterns. ${t} can show you seasonal trends from MLS data to help you choose the optimal listing window.`}],i={"@context":"https://schema.org","@type":"FAQPage",mainEntity:l.map(c=>({"@type":"Question",name:c.q,acceptedAnswer:{"@type":"Answer",text:c.a}}))};return e.jsxs(e.Fragment,{children:[e.jsx(Sc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(i)})}),e.jsx("div",{className:"space-y-3",children:l.map((c,u)=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(n===u?null:u),className:"w-full flex items-center justify-between px-6 py-4 text-left",children:[e.jsx("span",{className:"font-medium text-gray-900 text-sm pr-4",children:c.q}),e.jsx(da,{className:`h-4 w-4 text-gray-400 flex-shrink-0 transition-transform ${n===u?"rotate-90":""}`})]}),n===u&&e.jsx("div",{className:"px-6 pb-5 text-sm text-gray-600 leading-relaxed border-t border-gray-100 pt-4",children:c.a})]},u))})]})}function g5s(t,s,r){return[{question:`What is the housing market like in ${t}, ${s}?`,answer:`The ${t} real estate market offers a diverse range of properties from single-family homes to condos. Contact ${r} for a personalized market analysis with the latest pricing trends, inventory levels, and neighborhood insights.`},{question:`What are the best neighborhoods in ${t}?`,answer:`${t} has many desirable neighborhoods, each with unique character, school districts, and amenities. ${r} can help you identify the best fit based on your lifestyle, commute, and budget. Explore the community guide for detailed neighborhood profiles.`},{question:`How much does a home cost in ${t}, ${s}?`,answer:`Home prices in ${t} vary by neighborhood, property type, and condition. Browse current listings to see real-time pricing, or reach out to ${r} for a free home valuation if you're considering selling.`},{question:`Is ${t} a good place to buy a home?`,answer:`${t} offers strong community amenities, quality schools, and a growing local economy that make it attractive for homebuyers. ${r} can walk you through market conditions and help you determine if now is the right time to buy.`},{question:`How do I find a real estate agent in ${t}?`,answer:`${r} is a local ${t} real estate expert specializing in buying, selling, and investment properties. With deep knowledge of the area's neighborhoods, pricing trends, and school districts, ${r} provides personalized guidance throughout your real estate journey.`},{question:`What are the property taxes in ${t}, ${s}?`,answer:`Property tax rates in ${t} vary by county and school district. ${r} can provide specific tax information for any property you're interested in, helping you understand the full cost of homeownership in the area.`}]}function y5s({city:t,state:s="",agentName:r,accentColor:n="#3b82f6"}){const a=g5s(t,s,r),[o,l]=k.useState(null);return e.jsxs("section",{className:"py-16 bg-gray-50",children:[e.jsx(A3s,{faqs:a}),e.jsxs("div",{className:"max-w-3xl mx-auto px-6",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-2 font-medium text-center",children:"Common Questions"}),e.jsxs("h2",{className:"text-3xl font-bold text-gray-900 tracking-tight text-center mb-10",children:["Frequently Asked Questions About ",t]}),e.jsx("div",{className:"space-y-3",children:a.map((i,c)=>{const u=o===c;return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden transition-shadow hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>l(u?null:c),className:"w-full flex items-center justify-between px-6 py-5 text-left",children:[e.jsx("span",{className:"font-semibold text-gray-900 pr-4",children:i.question}),u?e.jsx(ff,{className:"h-5 w-5 text-gray-400 flex-shrink-0"}):e.jsx(Eo,{className:"h-5 w-5 text-gray-400 flex-shrink-0"})]}),u&&e.jsx("div",{className:"px-6 pb-5",children:e.jsx("p",{className:"text-gray-600 leading-relaxed",children:i.answer})})]},c)})})]})]})}function v5s({cityName:t,citySlug:s,agentName:r,total:n,medianPrice:a,avgDom:o,accentColor:l,heroImageUrl:i}){const c=fr();return e.jsxs("section",{className:"relative min-h-[480px] flex items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-cover bg-center",style:{backgroundImage:`url(${i||"https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?w=1600&q=80"})`}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/60 via-black/50 to-black/70"}),e.jsxs("div",{className:"relative z-10 max-w-4xl mx-auto px-6 py-20 text-center text-white",children:[e.jsxs("nav",{className:"flex items-center justify-center gap-2 text-sm text-white/60 mb-6",children:[e.jsx(Pi,{to:"/",className:"hover:text-white transition-colors",children:"Home"}),e.jsx("span",{children:"›"}),e.jsx(Pi,{to:"/search",className:"hover:text-white transition-colors",children:"Search"}),e.jsx("span",{children:"›"}),e.jsx("span",{className:"text-white",children:t})]}),e.jsxs(Gs.h1,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-4xl md:text-5xl lg:text-6xl font-bold mb-4 tracking-tight",children:["Homes for Sale in ",t]}),e.jsxs(Gs.p,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:.1},className:"text-lg text-white/80 max-w-2xl mx-auto mb-8",children:["Browse available properties in ",t," with ",r,", your local real estate expert."]}),e.jsxs(Gs.div,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:.2},className:"flex flex-wrap items-center justify-center gap-4 mb-8",children:[n>0&&e.jsxs("div",{className:"px-5 py-2.5 bg-white/10 backdrop-blur-md rounded-full border border-white/20",children:[e.jsx("span",{className:"text-2xl font-bold",children:n.toLocaleString()}),e.jsx("span",{className:"text-sm text-white/70 ml-2",children:"Active Listings"})]}),a&&a>0&&e.jsxs("div",{className:"px-5 py-2.5 bg-white/10 backdrop-blur-md rounded-full border border-white/20",children:[e.jsxs("span",{className:"text-2xl font-bold",children:["$",(a/1e3).toFixed(0),"K"]}),e.jsx("span",{className:"text-sm text-white/70 ml-2",children:"Median Price"})]}),o&&o>0&&e.jsxs("div",{className:"px-5 py-2.5 bg-white/10 backdrop-blur-md rounded-full border border-white/20",children:[e.jsx("span",{className:"text-2xl font-bold",children:Math.round(o)}),e.jsx("span",{className:"text-sm text-white/70 ml-2",children:"Avg Days on Market"})]})]}),e.jsxs(Gs.button,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},onClick:()=>c(`/search?q=${encodeURIComponent(t)}`),className:"inline-flex items-center gap-2 px-7 py-3.5 text-white font-semibold rounded-xl transition-colors text-lg",style:{backgroundColor:l},children:[e.jsx(cn,{className:"h-5 w-5"}),"Search All ",t," Listings"]})]})]})}function b5s({cityName:t,description:s,highlights:r,agentName:n,accentColor:a}){return!s&&r.length===0?null:e.jsx("section",{className:"py-16 md:py-20 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs(Gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase font-semibold mb-3",style:{color:a},children:"Discover the Area"}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:["Why Live in ",t,"?"]})]}),s&&e.jsx(Gs.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.1},className:"max-w-3xl mx-auto mb-14",children:e.jsx("div",{className:"text-gray-600 leading-relaxed text-[17px] space-y-4",children:s.split(` `).map((o,l)=>e.jsx("p",{children:o},l))})}),r.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:r.map((o,l)=>e.jsxs(Gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:l*.06},className:"group bg-gray-50 hover:bg-white rounded-2xl p-6 border border-gray-100 hover:border-gray-200 hover:shadow-lg transition-all duration-300",children:[e.jsx("span",{className:"text-3xl mb-3 block",children:o.icon}),e.jsx("h3",{className:"font-bold text-gray-900 text-lg mb-1.5",children:o.title}),e.jsx("p",{className:"text-gray-500 text-sm leading-relaxed",children:o.text})]},l))})]})})}function _5s({listings:t,cityName:s,accentColor:r}){const n=fr(),a=k.useRef(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),u=()=>{const f=a.current;f&&(l(f.scrollLeft>10),c(f.scrollLeft{const f=a.current;if(f)return u(),f.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),()=>{f.removeEventListener("scroll",u),window.removeEventListener("resize",u)}},[t]);const p=f=>{const g=a.current;g&&g.scrollBy({left:f==="left"?-680:680,behavior:"smooth"})};return t.length?e.jsx("section",{className:"py-16 md:py-20 overflow-hidden bg-white",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6",children:[e.jsxs("div",{className:"flex items-end justify-between mb-10",children:[e.jsxs("div",{children:[e.jsx(Gs.p,{initial:{opacity:0,y:10},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-sm tracking-[0.2em] uppercase font-semibold mb-2",style:{color:r},children:"Featured Properties"}),e.jsxs(Gs.h2,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.05},className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:[s," Listings"]}),e.jsx(Gs.p,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{delay:.1},className:"text-gray-500 mt-1.5",children:"Currently available properties on the market"})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>p("left"),disabled:!o,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(cl,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>p("right"),disabled:!i,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(da,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative -mx-6",children:[e.jsxs("div",{ref:a,className:"flex gap-5 overflow-x-auto scrollbar-hide px-6 snap-x snap-mandatory",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[t.map((f,g)=>{var b,_,j;return e.jsx(Gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:g*.05},onClick:()=>n(`/listing/${f.mlsNumber}`),className:"group min-w-[300px] sm:min-w-[320px] max-w-[340px] flex-shrink-0 snap-start cursor-pointer",children:e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-[0_2px_20px_-4px_rgba(0,0,0,0.08)] hover:shadow-[0_8px_40px_-8px_rgba(0,0,0,0.15)] transition-all duration-500 h-full flex flex-col",children:[e.jsxs("div",{className:"relative h-56 overflow-hidden",children:[e.jsx("img",{src:((b=f.photos)==null?void 0:b[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:`${f.address}, ${f.city}`,className:"w-full h-full object-cover group-hover:scale-[1.06] transition-transform duration-700 ease-out",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent"}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide uppercase text-white backdrop-blur-md",style:{backgroundColor:`${r}cc`},children:f.status||"Active"}),e.jsx("div",{className:"absolute bottom-3 left-3",children:e.jsxs("p",{className:"text-2xl font-bold text-white drop-shadow-lg",children:["$",(_=f.price)==null?void 0:_.toLocaleString()]})})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsx("p",{className:"text-gray-900 font-semibold text-[15px] leading-snug mb-1 truncate",children:f.address}),e.jsxs("p",{className:"text-gray-500 text-sm mb-3 truncate",children:[f.city,", ",f.state," ",f.zip]}),e.jsxs("div",{className:"flex items-center gap-4 mt-auto pt-3 border-t border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Im,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:f.bedrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Ju,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:f.bathrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(lS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(j=f.sqft)==null?void 0:j.toLocaleString()," sqft"]})]})]})]})]})},f.mlsNumber)}),e.jsx(Gs.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},onClick:()=>n(`/search?q=${encodeURIComponent(s)}`),className:"min-w-[200px] flex-shrink-0 snap-start cursor-pointer flex items-center justify-center",children:e.jsxs("div",{className:"text-center group",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center mx-auto mb-3 transition-transform group-hover:scale-110",style:{backgroundColor:`${r}15`},children:e.jsx(Qa,{className:"h-6 w-6",style:{color:r}})}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 group-hover:text-gray-900 transition-colors",children:"View All"})]})})]}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-12 bg-gradient-to-l from-white to-transparent pointer-events-none md:hidden"})]})]})}):null}function w5s({listings:t,cityName:s,accentColor:r}){const n=fr(),[a,o]=k.useState(null);return!t.some(i=>i.latitude&&i.longitude)&&t.length===0?null:e.jsx("section",{className:"py-16 md:py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs(Gs.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-10",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase font-semibold mb-3",style:{color:r},children:"Explore the Map"}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:["Properties in ",s]}),e.jsx("p",{className:"text-gray-500 mt-2",children:"Click any marker to view property details"})]}),e.jsx(Gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.1},className:"rounded-2xl overflow-hidden border border-gray-200 shadow-sm",style:{height:"500px"},children:e.jsx(Cct,{listings:t,onListingClick:i=>n(`/listing/${i}`),hoveredMlsNumber:a})})]})})}function j5s({cityName:t,total:s,medianPrice:r,avgDom:n,pricePerSqft:a,accentColor:o}){if(s===0&&!r)return null;const l=[{icon:bn,label:"Active Listings",value:s>0?s.toLocaleString():"—",sublabel:"Currently on market"},{icon:ac,label:"Median Price",value:r?`$${(r/1e3).toFixed(0)}K`:"—",sublabel:"Active listings"},{icon:un,label:"Avg Days on Market",value:n?Math.round(n).toString():"—",sublabel:"Time to sell"},{icon:ul,label:"Price per Sq Ft",value:a?`$${Math.round(a)}`:"—",sublabel:"Average $/sqft"}];return e.jsx("section",{className:"py-16 md:py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs(Gs.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase font-semibold mb-3",style:{color:o},children:"Market Snapshot"}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:[t," Real Estate at a Glance"]})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-5",children:l.map((i,c)=>{const u=i.icon;return e.jsxs(Gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:c*.08},className:"bg-white rounded-2xl p-6 border border-gray-100 shadow-sm text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-4",style:{backgroundColor:`${o}15`},children:e.jsx(u,{className:"h-6 w-6",style:{color:o}})}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mb-1",children:i.value}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 mb-0.5",children:i.label}),e.jsx("p",{className:"text-xs text-gray-400",children:i.sublabel})]},c)})})]})})}function N5s({cityName:t,agentName:s,accentColor:r}){const n=fr();return e.jsx("section",{className:"py-20 bg-gray-900 text-white",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 text-center",children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-4 tracking-tight",children:["Ready to Find Your Home in ",t,"?"]}),e.jsxs("p",{className:"text-gray-400 mb-10 text-lg leading-relaxed",children:[s," knows ",t," inside and out. Get personalized guidance on the best neighborhoods, pricing, and available properties."]}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsxs("button",{onClick:()=>n("/contact"),className:"px-8 py-3.5 text-white font-semibold rounded-xl transition-colors text-lg",style:{backgroundColor:r},children:["Contact ",s]}),e.jsx("button",{onClick:()=>n(`/search?q=${encodeURIComponent(t)}`),className:"px-8 py-3.5 border border-white/20 text-white hover:bg-white/10 font-semibold rounded-xl transition-colors text-lg",children:"Browse All Listings"})]})]})})}function k5s({siteConfig:t,citySlugOverride:s}){var M;const r=yo(),n=s||r.citySlug;fr();const[a,o]=k.useState([]),[l,i]=k.useState(!0),[c,u]=k.useState(0),[p,f]=k.useState(null),g=k.useMemo(()=>(n||"").split("-").map(L=>L.charAt(0).toUpperCase()+L.slice(1)).join(" "),[n]),b=((M=t.agent)==null?void 0:M.full_name)||"Your Agent",_=t.accentColor||"#3b82f6",j=`https://${t.subdomainSlug}.thelocalmove.com`,w=`Homes for Sale in ${g} | ${b}`,N=`Browse ${g} homes for sale with ${b}. View listings, pricing, photos, and neighborhood info. Your trusted local real estate expert.`;k.useEffect(()=>{n&&(async()=>{const{data:I}=await H.from("lead_site_city_pages").select("description, highlights, hero_image_url").eq("site_id",t.id).eq("city_slug",n||"").eq("is_published",!0).maybeSingle();I&&f({description:I.description,highlights:Array.isArray(I.highlights)?I.highlights:[],hero_image_url:I.hero_image_url})})()},[t.id,n]),k.useEffect(()=>{g&&(async()=>{i(!0);try{const O=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({leadSiteId:t.id,filterCities:[g],limit:1e3,page:1}),signal:AbortSignal.timeout(15e3)});if(O.ok){const q=await O.json();o(q.listings||[]),u(q.total||0)}}catch{}finally{i(!1)}})()},[g,t.id]);const S=k.useMemo(()=>{if(!a.length)return{medianPrice:null,avgDom:null,pricePerSqft:null};const L=a.map(V=>V.price).filter(V=>!!V&&V>0).sort((V,Y)=>V-Y),I=L.length>0?L[Math.floor(L.length/2)]:null,O=a.map(V=>V.dom||V.daysOnMarket).filter(V=>typeof V=="number"&&V>=0),q=O.length>0?O.reduce((V,Y)=>V+Y,0)/O.length:null,U=a.filter(V=>V.price&&V.sqft&&V.sqft>0),B=U.length>0?U.reduce((V,Y)=>V+Y.price/Y.sqft,0)/U.length:null;return{medianPrice:I,avgDom:q,pricePerSqft:B}},[a]);return e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsx(xCe,{siteConfig:t,pagePath:`/homes-for-sale-in-${n}`}),e.jsx(gCe,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${g} Homes`,path:`/homes-for-sale-in-${n}`}]}),e.jsxs(Sc,{children:[e.jsx("title",{children:w}),e.jsx("meta",{name:"description",content:N}),e.jsx("link",{rel:"canonical",href:`${j}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:title",content:w}),e.jsx("meta",{property:"og:description",content:N}),e.jsx("meta",{property:"og:url",content:`${j}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:site_name",content:t.siteTitle||b}),((p==null?void 0:p.hero_image_url)||t.ogImageUrl)&&e.jsx("meta",{property:"og:image",content:(p==null?void 0:p.hero_image_url)||t.ogImageUrl||""}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:w}),e.jsx("meta",{name:"twitter:description",content:N}),((p==null?void 0:p.hero_image_url)||t.ogImageUrl)&&e.jsx("meta",{name:"twitter:image",content:(p==null?void 0:p.hero_image_url)||t.ogImageUrl||""})]}),e.jsx(v5s,{cityName:g,citySlug:n||"",agentName:b,total:c,medianPrice:S.medianPrice,avgDom:S.avgDom,accentColor:_,heroImageUrl:(p==null?void 0:p.hero_image_url)||void 0}),e.jsx(b5s,{cityName:g,description:(p==null?void 0:p.description)||null,highlights:(p==null?void 0:p.highlights)||[],agentName:b,accentColor:_}),e.jsx(j5s,{cityName:g,total:c,medianPrice:S.medianPrice,avgDom:S.avgDom,pricePerSqft:S.pricePerSqft,accentColor:_}),!l&&e.jsx(_5s,{listings:a.slice(0,12),cityName:g,accentColor:_}),!l&&a.length>0&&e.jsx(w5s,{listings:a,cityName:g,accentColor:_}),e.jsx(y5s,{city:g,agentName:b,accentColor:_}),e.jsx(N5s,{cityName:g,agentName:b,accentColor:_})]})}function S5s(){const{siteConfig:t,themeConfig:s,isLoading:r,error:n}=C3s();return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500",children:"Loading..."})]})}):n||!t?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 p-6",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Site Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This lead site is not available or has not been set up yet."})]})}):e.jsx(M3s,{siteConfig:t,children:e.jsx($3s,{siteConfig:t,children:e.jsxs(R2e,{children:[e.jsx(ks,{path:"/",element:e.jsx(W3s,{siteConfig:t,themeConfig:s??void 0})}),e.jsx(ks,{path:"/search",element:e.jsx(r5s,{siteConfig:t})}),e.jsx(ks,{path:"/listing/:mlsNumber",element:e.jsx(d5s,{siteConfig:t})}),e.jsx(ks,{path:"/about",element:e.jsx(u5s,{siteConfig:t})}),e.jsx(ks,{path:"/contact",element:e.jsx(h5s,{siteConfig:t})}),e.jsx(ks,{path:"/account",element:e.jsx(m5s,{siteConfig:t})}),e.jsx(ks,{path:"/blog",element:e.jsx(Jze,{siteConfig:t})}),e.jsx(ks,{path:"/blog/:slug",element:e.jsx(Jze,{siteConfig:t})}),e.jsx(ks,{path:"/sell",element:e.jsx(f5s,{siteConfig:t,themeConfig:s??void 0})}),e.jsx(ks,{path:"/community",element:e.jsx(p5s,{siteConfig:t})}),e.jsx(ks,{path:"/*",element:e.jsx(C5s,{siteConfig:t})})]})})})}function C5s({siteConfig:t}){const r=id().pathname.match(/^\/homes-for-sale-in-(.+)$/);return r?e.jsx(k5s,{siteConfig:t,citySlugOverride:r[1]}):null}const M5s=({team:t,onSelect:s})=>{const{data:r}=mt({queryKey:["team-card-info",t.id],queryFn:async()=>{const{data:n}=await H.from("team_members").select("user_id, role").eq("team_id",t.id),a=(n==null?void 0:n.length)||0,o=n==null?void 0:n.find(i=>i.role==="team_leader");let l=null;if(o){const{data:i}=await H.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(gr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(st,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(pr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Oe,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx($a,{src:r.leaderProfile.avatar_url||""}),e.jsx(kn,{className:"text-xs",children:(r.leaderProfile.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Dm,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),r.leaderProfile.name||"Team Leader"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(th,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"capitalize text-xs",children:t.contact_visibility.replace("_"," ")})]}),t.lead_pond_enabled&&e.jsx(st,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(st,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(st,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},T5s=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Ds(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:c,isLoading:u,createTeam:p,updateTeam:f,deleteTeam:g,addMember:b,removeMember:_,updateMemberRole:j}=_C(i),[w,N]=k.useState(!1),[S,M]=k.useState(null),{data:L}=mt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:q,error:U}=await H.from("brokerages").select("id, name").order("name");if(U)throw U;return q||[]},enabled:s}),{data:I}=mt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:q,error:U}=await H.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(U)throw U;return q||[]},enabled:!!l}),O=async q=>{const U=q.brokerage_id||l||null,B=await p.mutateAsync({name:q.name,brokerage_id:U,description:q.description});if(q.leaderId&&q.leaderId!=="none"&&await b.mutateAsync({team_id:B.id,user_id:q.leaderId,role:"team_leader"}),q.memberIds)for(const V of q.memberIds)await b.mutateAsync({team_id:B.id,user_id:V,role:"team_member"});N(!1)};return!r&&!s?e.jsx(Ms,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:"You need brokerage manager access to manage teams."})]})}):e.jsx(Ms,{title:"Teams",description:"Create and manage teams within your brokerage",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Teams"}),e.jsx("p",{className:"text-muted-foreground",children:"Organize your agents into teams with leaders and shared resources."})]}),e.jsxs(K,{onClick:()=>N(!0),children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(ctt,{open:w,onOpenChange:N,onCreateTeam:O,isCreating:p.isPending,brokerageAgents:I||[],isAdmin:s,allBrokerages:L,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(q=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsx(ys,{className:"h-5 w-32 mb-3"}),e.jsx(ys,{className:"h-4 w-48 mb-4"}),e.jsx(ys,{className:"h-8 w-full"})]})},q))}),!u&&c.length===0&&!S&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first team to organize agents and share resources."}),e.jsxs(K,{onClick:()=>N(!0),children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&c.length>0&&!S&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:c.map(q=>e.jsx(M5s,{team:q,onSelect:()=>M(q)},q.id))}),S&&e.jsx(ltt,{team:S,brokerageAgents:I||[],onBack:()=>M(null),onUpdate:q=>f.mutateAsync({id:S.id,...q}).then(U=>M(U)),onAddMember:(q,U)=>b.mutateAsync({team_id:S.id,user_id:q,role:U}),onRemoveMember:q=>_.mutateAsync({team_id:S.id,member_id:q}),onUpdateRole:(q,U)=>j.mutateAsync({team_id:S.id,member_id:q,role:U}),onDeleteTeam:()=>g.mutate(S.id),isUpdating:f.isPending,isAddingMember:b.isPending})]})})},A5s=()=>{const{data:t,isLoading:s}=$x(),{useTeamMembers:r}=_C(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Ms,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"h-8 w-48"}),e.jsx(ys,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Ms,{title:"My Team",description:"Your team",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Team Yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't been assigned to a team. Ask your brokerage manager to add you."})]})})});const o=t.team;return e.jsx(Ms,{title:"My Team",description:o.name,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:o.name}),e.jsx(st,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Dm,{className:"mr-1 h-3 w-3"})," Leader"]}):"Member"})]}),o.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:o.description})]}),e.jsxs(ba,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(pa,{className:"flex-wrap",children:[e.jsx(ns,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(ns,{value:"contacts",children:[e.jsx(eS,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(ns,{value:"lead-pond",children:[e.jsx(Xg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(ns,{value:"shared-assets",children:[e.jsx(Om,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(bs,{value:"members",className:"space-y-2",children:a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>e.jsx(ys,{className:"h-16 w-full"},l))}):n.map(l=>{var i,c,u,p;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx($a,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(kn,{children:(((c=l.profile)==null?void 0:c.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:((u=l.profile)==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(p=l.profile)==null?void 0:p.email})]}),l.role==="team_leader"?e.jsxs(st,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Dm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(st,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx(bs,{value:"contacts",className:"space-y-4",children:e.jsx(Oke,{})}),o.lead_pond_enabled&&e.jsx(bs,{value:"lead-pond",className:"space-y-4",children:e.jsx(Rke,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(bs,{value:"shared-assets",className:"space-y-4",children:e.jsx(ott,{teamId:t.teamId})})]})]})})};function E5s(){const{user:t}=Ds(),s=Qt(),r=mt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(N)throw N;return w},enabled:!!t}),n=mt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(N)throw N;return w},enabled:!!t}),a=mt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(N)throw N;return w},enabled:!!t}),o=mt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(N)throw N;return w},enabled:!!t}),l=mt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(N)throw N;return w},enabled:!!t}),i=Lt({mutationFn:async()=>{const{data:w,error:N}=await H.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(N)throw N;const S=[{name:"Listing Consultation",description:"Get a comprehensive market analysis and listing strategy for your home",duration_minutes:60,color:"#10B981",icon:"Home",sort_order:0},{name:"Buyer Consultation",description:"Discuss your home search criteria, budget, and buying process",duration_minutes:45,color:"#3B82F6",icon:"Search",sort_order:1},{name:"Home Valuation",description:"Find out what your home is worth in today's market",duration_minutes:30,color:"#F59E0B",icon:"DollarSign",sort_order:2},{name:"General Meeting",description:"Coffee chat, check-in, or quick real estate question",duration_minutes:30,color:"#8B5CF6",icon:"Coffee",sort_order:3}],{error:M}=await H.from("agent_booking_types").insert(S.map(O=>({...O,user_id:t.id})));if(M)throw M;const L=[1,2,3,4,5].map(O=>({user_id:t.id,day_of_week:O,start_time:"09:00",end_time:"17:00"})),{error:I}=await H.from("agent_availability_slots").insert(L);if(I)throw I;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),me.success("Scheduler set up successfully!")},onError:w=>me.error(w.message)}),c=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_booking_settings").update(w).eq("user_id",t.id);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),me.success("Settings updated")},onError:w=>me.error(w.message)}),u=Lt({mutationFn:async w=>{const N={...w,user_id:t.id};if(w.id){const{error:S}=await H.from("agent_booking_types").update(N).eq("id",w.id);if(S)throw S}else{const{error:S}=await H.from("agent_booking_types").insert(N);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type saved")},onError:w=>me.error(w.message)}),p=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_booking_types").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type deleted")},onError:w=>me.error(w.message)}),f=Lt({mutationFn:async w=>{const N={...w,user_id:t.id};if(w.id){const{error:S}=await H.from("agent_availability_slots").update(N).eq("id",w.id);if(S)throw S}else{const{error:S}=await H.from("agent_availability_slots").insert(N);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>me.error(w.message)}),g=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_availability_slots").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>me.error(w.message)}),b=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_blocked_dates").insert({...w,user_id:t.id});if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),me.success("Date blocked")},onError:w=>me.error(w.message)}),_=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_blocked_dates").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:w=>me.error(w.message)}),j=Lt({mutationFn:async({id:w,reason:N})=>{const{error:S}=await H.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:N}).eq("id",w);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),me.success("Booking cancelled")},onError:w=>me.error(w.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:c,upsertBookingType:u,deleteBookingType:p,upsertAvailability:f,deleteAvailability:g,addBlockedDate:b,removeBlockedDate:_,cancelBooking:j}}const e9e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function P5s({types:t,onSave:s,onDelete:r}){const[n,a]=k.useState(null),[o,l]=k.useState(!1),i=()=>{a({name:"",description:"",duration_minutes:30,color:"#3B82F6",icon:"Calendar",is_active:!0,qualification_enabled:!1}),l(!0)},c=p=>{a({...p}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Booking Types"}),e.jsx(gr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(K,{onClick:i,size:"sm",children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No booking types yet. Add one to get started."}):e.jsx("div",{className:"grid gap-3",children:t.map(p=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-lg",style:{backgroundColor:p.color+"20"},children:e9e[p.icon]||"📅"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:p.name}),!p.is_active&&e.jsx(st,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(st,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(xL,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),p.duration_minutes," min",p.description&&e.jsxs("span",{children:["· ",p.description.slice(0,60),p.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(p),children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(p.id),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},p.id))})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsxs(vs,{children:[n!=null&&n.id?"Edit":"New"," Booking Type"]})}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Name"}),e.jsx(ze,{value:n.name||"",onChange:p=>a({...n,name:p.target.value}),placeholder:"e.g. Listing Consultation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{value:n.description||"",onChange:p=>a({...n,description:p.target.value}),placeholder:"Brief description for prospects",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Duration (minutes)"}),e.jsx(ze,{type:"number",min:15,max:180,step:15,value:n.duration_minutes||30,onChange:p=>a({...n,duration_minutes:parseInt(p.target.value)||30})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"h-10 w-10 rounded border cursor-pointer"}),e.jsx(ze,{value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(e9e).map(([p,f])=>e.jsx("button",{onClick:()=>a({...n,icon:p}),className:`w-10 h-10 rounded-lg text-lg flex items-center justify-center border transition-colors ${n.icon===p?"border-primary bg-primary/10":"hover:bg-muted"}`,children:f},p))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Meeting Link Override (optional)"}),e.jsx(ze,{value:n.meeting_link_override||"",onChange:p=>a({...n,meeting_link_override:p.target.value||null}),placeholder:"Use a different link for this type"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(qr,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Active"}),e.jsx(qr,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const t9e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function I5s({slots:t,onSave:s,onDelete:r}){const[n,a]=k.useState(null),[o,l]=k.useState("09:00"),[i,c]=k.useState("17:00"),u=t9e.map((f,g)=>t.filter(b=>b.day_of_week===g)),p=()=>{n!==null&&(s({day_of_week:n,start_time:o,end_time:i,is_active:!0}),a(null),l("09:00"),c("17:00"))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(gr,{children:"Set your available hours for each day"})]}),e.jsx(Oe,{className:"space-y-2",children:t9e.map((f,g)=>{const b=u[g];return e.jsxs("div",{className:"flex items-start gap-3 py-2 border-b last:border-0",children:[e.jsx("div",{className:"w-24 pt-1",children:e.jsx("p",{className:"text-sm font-medium",children:f})}),e.jsxs("div",{className:"flex-1 space-y-1",children:[b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"Unavailable"}):b.map(_=>{var j,w;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=_.start_time)==null?void 0:j.slice(0,5),onBlur:N=>s({id:_.id,start_time:N.target.value})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=_.end_time)==null?void 0:w.slice(0,5),onBlur:N=>s({id:_.id,end_time:N.target.value})}),e.jsx(qr,{checked:_.is_active,onCheckedChange:N=>s({id:_.id,is_active:N})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(_.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},_.id)}),n===g?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",value:o,onChange:_=>l(_.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",value:i,onChange:_=>c(_.target.value)}),e.jsx(K,{size:"sm",className:"h-8",onClick:p,children:"Add"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(g),children:[e.jsx($s,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const L5s={confirmed:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",cancelled:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400",completed:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",no_show:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"};function D5s({bookings:t,onCancel:s}){const r=t.filter(o=>o.status==="confirmed"&&new Date(o.booking_date)>=new Date(new Date().toDateString())),n=t.filter(o=>o.status!=="confirmed"||new Date(o.booking_date){var i,c;return e.jsxs("div",{className:"flex items-start justify-between p-4 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(st,{className:`text-xs ${L5s[o.status]||""}`,children:o.status})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Od,{className:"h-3.5 w-3.5"}),ms(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3.5 w-3.5"}),(i=o.start_time)==null?void 0:i.slice(0,5)," - ",(c=o.end_time)==null?void 0:c.slice(0,5)]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[o.guest_email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cr,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(st,{variant:"outline",className:"text-xs mt-1",children:o.booking_type.name}),o.guest_message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 italic",children:['"',o.guest_message,'"']})]}),l&&o.status==="confirmed"&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx(vc,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Upcoming Bookings"}),e.jsxs(gr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Oe,{children:r.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No upcoming bookings"}):e.jsx("div",{className:"space-y-3",children:r.map(o=>a(o,!0))})})]}),n.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Past & Cancelled"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function O5s({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,c]=k.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),c(""))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(tL,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(gr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(Oe,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(ze,{type:"date",value:o,onChange:p=>l(p.target.value),className:"w-40"}),e.jsx(ze,{placeholder:"Reason (optional)",value:i,onChange:p=>c(p.target.value),className:"flex-1"}),e.jsx(K,{size:"sm",onClick:u,children:"Add"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>a(!1),children:"Cancel"})]}),t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No blocked dates"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(p=>e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full border bg-muted/50 text-sm",children:[e.jsx("span",{children:ms(new Date(p.blocked_date+"T00:00:00"),"MMM d, yyyy")}),p.reason&&e.jsxs("span",{className:"text-muted-foreground",children:["(",p.reason,")"]}),e.jsx("button",{onClick:()=>r(p.id),className:"ml-1 text-muted-foreground hover:text-destructive",children:e.jsx(Rr,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function R5s(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:c,deleteBookingType:u,upsertAvailability:p,deleteAvailability:f,addBlockedDate:g,removeBlockedDate:b,cancelBooking:_}=E5s(),[j,w]=k.useState(""),[N,S]=k.useState(15);j||t!=null&&t.meeting_link;const M=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Ms,{children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):t?e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(Od,{className:"h-6 w-6 text-primary"}),"LevelUp Scheduler"]}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your booking types, availability, and appointments"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(M),me.success("Booking link copied!")},children:[e.jsx(gi,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:M,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(qr,{id:"scheduler-active",checked:t.is_active,onCheckedChange:L=>i.mutate({is_active:L})})]})]})]}),e.jsxs(ba,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"types",children:"Booking Types"}),e.jsx(ns,{value:"availability",children:"Availability"}),e.jsx(ns,{value:"settings",children:"Settings"}),e.jsxs(ns,{value:"bookings",children:["Bookings",a.filter(L=>L.status==="confirmed").length>0&&e.jsx(st,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(L=>L.status==="confirmed").length})]})]}),e.jsx(bs,{value:"types",children:e.jsx(P5s,{types:s,onSave:L=>c.mutate(L),onDelete:L=>u.mutate(L)})}),e.jsx(bs,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(I5s,{slots:r,onSave:L=>p.mutate(L),onDelete:L=>f.mutate(L)}),e.jsx(O5s,{blockedDates:n,onAdd:L=>g.mutate(L),onRemove:L=>b.mutate(L)})]})}),e.jsx(bs,{value:"settings",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ML,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(gr,{children:"Configure your booking page defaults"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Booking Page URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>{M&&(navigator.clipboard.writeText(M),me.success("Copied!"))},children:e.jsx(gi,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"meeting-link",children:[e.jsx(dl,{className:"h-4 w-4 inline mr-1"}),"Default Meeting Link"]}),e.jsx(ze,{id:"meeting-link",placeholder:"https://zoom.us/j/your-personal-link",defaultValue:t.meeting_link||"",onBlur:L=>i.mutate({meeting_link:L.target.value||null})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Zoom personal link, Google Meet, or phone number"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Buffer Between Meetings"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"number",min:0,max:60,defaultValue:t.buffer_minutes,onBlur:L=>i.mutate({buffer_minutes:parseInt(L.target.value)||15})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"min"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Minimum Notice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"number",min:0,max:72,defaultValue:t.min_notice_hours,onBlur:L=>i.mutate({min_notice_hours:parseInt(L.target.value)||2})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Max Advance Booking"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"number",min:1,max:90,defaultValue:t.max_advance_days,onBlur:L=>i.mutate({max_advance_days:parseInt(L.target.value)||30})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]})]})]})]})]})}),e.jsx(bs,{value:"bookings",children:e.jsx(D5s,{bookings:a,onCancel:L=>_.mutate({id:L})})})]})]})}):e.jsx(Ms,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 md:p-8 space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-primary/10 rounded-2xl flex items-center justify-center",children:e.jsx(Od,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground text-lg max-w-md mx-auto",children:"Your own booking page — built for real estate. Prospects book with you, get auto-added to your CRM, and you never miss a lead."})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{icon:"🏠",title:"Listing Consultation",desc:"60 min"},{icon:"🔍",title:"Buyer Consultation",desc:"45 min"},{icon:"💰",title:"Home Valuation",desc:"30 min"},{icon:"☕",title:"General Meeting",desc:"30 min"}].map(L=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx("span",{className:"text-2xl",children:L.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:L.desc})]})]},L.title))}),e.jsx(rl,{}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"✅ Auto-creates CRM contacts from every booking"}),e.jsx("p",{children:"✅ Optional pre-qualification questions per booking type"}),e.jsx("p",{children:"✅ Embeds on your Smart Card — replaces TidyCal"}),e.jsx("p",{children:"✅ Standalone shareable booking page"})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",size:"lg",children:[e.jsx(pn,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const s9e=[{id:"event_registration",label:"Event Registration",description:"Capture RSVPs for open houses, expos, seminars"},{id:"buyer_consultation",label:"Buyer Consultation",description:"Pre-qualify buyers with targeted questions"},{id:"home_valuation",label:"Home Valuation Request",description:`"What's your home worth?" lead capture`},{id:"lead_capture",label:"General Lead Capture",description:"Flexible form for any lead gen purpose"},{id:"lead_magnet",label:"Lead Magnet / Giveaway",description:"Offer a free download (PDF, guide, checklist) in exchange for contact info"},{id:"just_listed",label:"Just Listed",description:"Showcase a new listing with photos & details + contact CTA"},{id:"just_sold",label:"Just Sold",description:'Celebrate a sale & capture "Want results like this?" leads'}];function F5s(){const{user:t}=Ds(),s=ci(),{toast:r}=Ua(),n=fr(),a=Qt(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState(null),[f,g]=k.useState({title:"",description:"",page_type:"lead_capture"}),{data:b=[],isLoading:_}=mt({queryKey:["landing-pages",s],queryFn:async()=>{const{data:S,error:M}=await H.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(M)throw M;return S},enabled:!!s}),j=Lt({mutationFn:async()=>{const S=f.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:M}=await H.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),L=f.page_type==="just_listed"||f.page_type==="just_sold",{data:I,error:O}=await H.from("landing_pages").insert({user_id:s,title:f.title,description:f.description||null,page_type:f.page_type,slug:S,hero_headline:L?f.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":f.page_type==="lead_magnet"?"📥 Free Download":f.title,agent_name:(M==null?void 0:M.name)||null,agent_phone:(M==null?void 0:M.phone)||null,agent_email:(M==null?void 0:M.email)||t.email||null,agent_photo_url:(M==null?void 0:M.avatar_url)||null,property_status:L?f.page_type.replace("just_",""):null}).select().single();if(O)throw O;const q=z5s(f.page_type);if(q.length>0){const{error:U}=await H.from("landing_page_fields").insert(q.map((B,V)=>({...B,page_id:I.id,sort_order:V})));if(U)throw U}return I},onSuccess:S=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),g({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${S.id}`)},onError:S=>r({title:"Error",description:S.message,variant:"destructive"})}),w=Lt({mutationFn:async S=>{const{error:M}=await H.from("landing_pages").delete().eq("id",S);if(M)throw M},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),c(null),r({title:"Landing page deleted"})}}),N=S=>`https://pages.relevelup.com/${S}`;return e.jsxs(Ms,{title:"Landing Pages",children:[e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Landing Pages"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Create branded lead capture pages for events, consultations, and more"})]}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," New Page"]})]}),_?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):b.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(Sn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No landing pages yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1 mb-4",children:"Create your first page to start capturing leads"}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx($s,{className:"h-4 w-4 mr-2"})," Create Landing Page"]})]})}):e.jsx("div",{className:"grid gap-4",children:b.map(S=>{var M;return e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:S.title}),e.jsx(st,{variant:S.is_published?"default":"secondary",className:"text-[10px]",children:S.is_published?"Published":"Draft"}),e.jsx(st,{variant:"outline",className:"text-[10px]",children:((M=s9e.find(L=>L.id===S.page_type))==null?void 0:M.label)||S.page_type})]}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:S.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ln,{className:"h-3 w-3"})," ",S.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"})," ",S.submission_count," submissions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[S.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>p(N(S.slug)),children:e.jsx(u1,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(N(S.slug)),r({title:"Link copied!"})},children:e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:N(S.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(iu,{children:[e.jsx(ou,{asChild:!0,children:e.jsx(K,{size:"sm",variant:"ghost",children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Ma,{onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(Ma,{onClick:()=>c(S.id),className:"text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},S.id)})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(_s,{children:e.jsx(vs,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Page Title"}),e.jsx(ze,{value:f.title,onChange:S=>g(M=>({...M,title:S.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description (optional)"}),e.jsx(Er,{value:f.description,onChange:S=>g(M=>({...M,description:S.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Page Template"}),e.jsxs(Ks,{value:f.page_type,onValueChange:S=>g(M=>({...M,page_type:S})),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:s9e.map(S=>e.jsx(Mt,{value:S.id,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:S.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:S.description})]})},S.id))})]})]})]}),e.jsxs(qn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>j.mutate(),disabled:!f.title.trim()||j.isPending,children:j.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(kc,{open:!!i,onOpenChange:()=>c(null),children:e.jsxs(Ql,{children:[e.jsxs(Jl,{children:[e.jsx(tc,{children:"Delete Landing Page?"}),e.jsx(sc,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(ec,{children:[e.jsx(rc,{children:"Cancel"}),e.jsx(Rl,{onClick:()=>i&&w.mutate(i),children:"Delete"})]})]})}),e.jsx(fs,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsx(_s,{children:e.jsx(vs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(CR,{value:u,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:u}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{u&&(navigator.clipboard.writeText(u),r({title:"URL copied!"}))},children:[e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function z5s(t){const s=[{field_type:"text",label:"Full Name",placeholder:"Your name",is_required:!0},{field_type:"email",label:"Email",placeholder:"your@email.com",is_required:!0},{field_type:"phone",label:"Phone",placeholder:"(555) 123-4567",is_required:!1}];switch(t){case"event_registration":return[...s,{field_type:"select",label:"How did you hear about this event?",options:JSON.stringify(["Social Media","Friend/Referral","Email","Flyer/Sign","Other"]),is_required:!1},{field_type:"textarea",label:"Any questions or special needs?",placeholder:"Let us know...",is_required:!1}];case"buyer_consultation":return[...s,{field_type:"select",label:"Interested in",options:JSON.stringify(["Buying","Selling","Both"]),is_required:!0},{field_type:"select",label:"Timeline",options:JSON.stringify(["0-3 months","3-6 months","6-12 months","Just exploring"]),is_required:!1},{field_type:"toggle",label:"Already working with a Realtor?",is_required:!1},{field_type:"toggle",label:"Do you have property to sell?",is_required:!1},{field_type:"textarea",label:"Anything else we should know?",placeholder:"Tell us about your situation...",is_required:!1}];case"home_valuation":return[...s,{field_type:"text",label:"Property Address",placeholder:"123 Main St, City, State",is_required:!0},{field_type:"select",label:"Reason for Valuation",options:JSON.stringify(["Thinking of selling","Refinancing","Curiosity","Estate planning","Other"]),is_required:!1},{field_type:"select",label:"Timeline to Sell",options:JSON.stringify(["ASAP","1-3 months","3-6 months","6+ months","Not sure"]),is_required:!1}];case"lead_magnet":return[...s,{field_type:"select",label:"Are you currently working with a Realtor?",options:JSON.stringify(["Yes","No","Not yet"]),is_required:!1}];case"just_listed":return[...s,{field_type:"select",label:"I am interested in",options:JSON.stringify(["Scheduling a showing","Getting more details","Similar properties","Selling my home"]),is_required:!0},{field_type:"textarea",label:"Message",placeholder:"Tell me more about this property...",is_required:!1}];case"just_sold":return[...s,{field_type:"select",label:"I am looking to",options:JSON.stringify(["Sell my home","Buy a home","Both","Just curious"]),is_required:!0},{field_type:"text",label:"My Property Address",placeholder:"123 Main St, City, State",is_required:!1}];default:return[...s,{field_type:"textarea",label:"Message",placeholder:"How can we help you?",is_required:!1}]}}const B5s=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"textarea",label:"Long Text"},{value:"select",label:"Dropdown"},{value:"multiselect",label:"Multi-Select"},{value:"toggle",label:"Yes / No Toggle"}];function $5s(){const{pageId:t}=yo(),s=fr(),{user:r}=Ds(),n=ci(),{toast:a}=Ua(),o=Qt(),[l,i]=k.useState(null),[c,u]=k.useState(!1),{data:p,isLoading:f}=mt({queryKey:["landing-page",t],queryFn:async()=>{const{data:re,error:oe}=await H.from("landing_pages").select("*").eq("id",t).single();if(oe)throw oe;return re},enabled:!!t}),{data:g=[],isLoading:b}=mt({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:re,error:oe}=await H.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(oe)throw oe;return re},enabled:!!t}),{data:_=[]}=mt({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:re,error:oe}=await H.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(oe)throw oe;return re},enabled:!!t}),{data:j=[]}=mt({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:re,error:oe}=await H.from("listings").select("id, property_address, city, state, price, bedrooms, bathrooms, square_footage, description, status").eq("agent_id",n).order("created_at",{ascending:!1});if(oe)throw oe;return re},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[w,N]=k.useState({title:"",hero_headline:"",hero_subtext:"",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",agent_name:"",agent_phone:"",agent_email:"",agent_photo_url:null,success_message:"Thank you! We'll be in touch soon.",is_published:!1,description:"",lead_magnet_file_url:null,lead_magnet_file_name:null,lead_magnet_external_url:null,listing_id:null,property_address:"",property_price:"",property_beds:"",property_baths:"",property_sqft:"",property_description:"",property_photos:[],property_status:"just_listed"}),[S,M]=k.useState([]);k.useEffect(()=>{p&&N({title:p.title,hero_headline:p.hero_headline,hero_subtext:p.hero_subtext||"",hero_image_url:p.hero_image_url,logo_url:p.logo_url,primary_color:p.primary_color,accent_color:p.accent_color,agent_name:p.agent_name||"",agent_phone:p.agent_phone||"",agent_email:p.agent_email||"",agent_photo_url:p.agent_photo_url,success_message:p.success_message||"Thank you! We'll be in touch soon.",is_published:p.is_published,description:p.description||"",lead_magnet_file_url:p.lead_magnet_file_url||null,lead_magnet_file_name:p.lead_magnet_file_name||null,lead_magnet_external_url:p.lead_magnet_external_url||null,listing_id:p.listing_id||null,property_address:p.property_address||"",property_price:p.property_price||"",property_beds:p.property_beds||"",property_baths:p.property_baths||"",property_sqft:p.property_sqft||"",property_description:p.property_description||"",property_photos:Array.isArray(p.property_photos)?p.property_photos:[],property_status:p.property_status||"just_listed"})},[p]),k.useEffect(()=>{g.length>0&&M(g.map(re=>({id:re.id,field_type:re.field_type,label:re.label,placeholder:re.placeholder,is_required:re.is_required,options:typeof re.options=="string"?re.options:re.options?JSON.stringify(re.options):null,sort_order:re.sort_order})))},[g]);const L=Lt({mutationFn:async()=>{const{error:re}=await H.from("landing_pages").update({title:w.title,hero_headline:w.hero_headline,hero_subtext:w.hero_subtext||null,hero_image_url:w.hero_image_url,logo_url:w.logo_url,primary_color:w.primary_color,accent_color:w.accent_color,agent_name:w.agent_name||null,agent_phone:w.agent_phone||null,agent_email:w.agent_email||null,agent_photo_url:w.agent_photo_url,success_message:w.success_message,is_published:w.is_published,description:w.description||null,lead_magnet_file_url:w.lead_magnet_file_url,lead_magnet_file_name:w.lead_magnet_file_name,lead_magnet_external_url:w.lead_magnet_external_url,listing_id:w.listing_id,property_address:w.property_address||null,property_price:w.property_price||null,property_beds:w.property_beds||null,property_baths:w.property_baths||null,property_sqft:w.property_sqft||null,property_description:w.property_description||null,property_photos:w.property_photos,property_status:w.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(re)throw re;if(await H.from("landing_page_fields").delete().eq("page_id",t),S.length>0){const{error:oe}=await H.from("landing_page_fields").insert(S.map((ce,ge)=>({page_id:t,field_type:ce.field_type,label:ce.label,placeholder:ce.placeholder||null,is_required:ce.is_required,options:ce.options?JSON.parse(ce.options):null,sort_order:ge})));if(oe)throw oe}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:re=>a({title:"Error",description:re.message,variant:"destructive"})}),I=async(re,oe)=>{const ce=re.name.split(".").pop(),ge=`landing-pages/${r.id}/${oe}-${Date.now()}.${ce}`,{error:ye}=await H.storage.from("recruit-landing").upload(ge,re);if(ye)throw ye;const{data:{publicUrl:ue}}=H.storage.from("recruit-landing").getPublicUrl(ge);return ue},O=async(re,oe)=>{var ge;const ce=(ge=re.target.files)==null?void 0:ge[0];if(ce){i(oe);try{const ye=await I(ce,oe);N(ue=>({...ue,[oe]:ye})),a({title:"Image uploaded!"})}catch(ye){a({title:"Upload failed",description:ye.message,variant:"destructive"})}finally{i(null)}}},q=async re=>{var ce;const oe=(ce=re.target.files)==null?void 0:ce[0];if(oe){i("lead_magnet");try{const ge=await I(oe,"lead-magnet");N(ye=>({...ye,lead_magnet_file_url:ge,lead_magnet_file_name:oe.name})),a({title:"File uploaded!"})}catch(ge){a({title:"Upload failed",description:ge.message,variant:"destructive"})}finally{i(null)}}},U=async re=>{const oe=re.target.files;if(!(!oe||oe.length===0)){i("property_photos");try{const ce=[];for(const ge of Array.from(oe)){const ye=await I(ge,"property-photo");ce.push(ye)}N(ge=>({...ge,property_photos:[...ge.property_photos,...ce]})),a({title:`${ce.length} photo(s) uploaded!`})}catch(ce){a({title:"Upload failed",description:ce.message,variant:"destructive"})}finally{i(null)}}},B=async re=>{const oe=j.find(ge=>ge.id===re);if(!oe)return;const{data:ce}=await H.from("listing_photos").select("photo_url").eq("listing_id",re).order("sort_order");N(ge=>({...ge,listing_id:re,property_address:oe.property_address||`${oe.city}, ${oe.state}`,property_price:oe.price?`$${oe.price.toLocaleString()}`:"",property_beds:oe.bedrooms?String(oe.bedrooms):"",property_baths:oe.bathrooms?String(oe.bathrooms):"",property_sqft:oe.square_footage?oe.square_footage.toLocaleString():"",property_description:oe.description||"",property_photos:(ce==null?void 0:ce.map(ye=>ye.photo_url))||ge.property_photos})),a({title:"Listing data imported!"})},V=()=>{M(re=>[...re,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:re.length}])},Y=(re,oe)=>{M(ce=>ce.map((ge,ye)=>ye===re?{...ge,...oe}:ge))},Q=re=>{M(oe=>oe.filter((ce,ge)=>ge!==re))},ee=p?`https://pages.relevelup.com/${p.slug}`:"",X=(p==null?void 0:p.page_type)==="lead_magnet",ie=(p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold";return f||b?e.jsx(Ms,{title:"Loading...",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):p?e.jsxs(Ms,{title:w.title||"Edit Page",children:[e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/landing-pages"),children:e.jsx(Ja,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:w.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(st,{variant:w.is_published?"default":"secondary",className:"text-[10px]",children:w.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ln,{className:"h-3 w-3"})," ",p.view_count," views"]}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(pr,{className:"h-3 w-3"})," ",_.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[w.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(u1,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(ee),a({title:"Link copied!"})},children:[e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"})," Copy Link"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:ee,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(tn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{onClick:()=>L.mutate(),disabled:L.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),L.isPending?"Saving...":"Save"]})]})]}),e.jsxs(ba,{defaultValue:"design",children:[e.jsxs(pa,{children:[e.jsx(ns,{value:"design",children:"Design"}),X&&e.jsx(ns,{value:"lead_magnet",children:"Lead Magnet"}),ie&&e.jsx(ns,{value:"property",children:"Property Details"}),e.jsxs(ns,{value:"fields",children:["Form Fields (",S.length,")"]}),e.jsxs(ns,{value:"submissions",children:["Submissions (",_.length,")"]}),e.jsx(ns,{value:"settings",children:"Settings"})]}),e.jsxs(bs,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Page Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Page Title (internal)"}),e.jsx(ze,{value:w.title,onChange:re=>N(oe=>({...oe,title:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description (internal)"}),e.jsx(ze,{value:w.description,onChange:re=>N(oe=>({...oe,description:re.target.value}))})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Headline"}),e.jsx(ze,{value:w.hero_headline,onChange:re=>N(oe=>({...oe,hero_headline:re.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Subtext"}),e.jsx(Er,{value:w.hero_subtext,onChange:re=>N(oe=>({...oe,hero_subtext:re.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.hero_image_url&&e.jsx("img",{src:w.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(li,{className:"h-3.5 w-3.5 mr-1"}),l==="hero_image_url"?"Uploading...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:re=>O(re,"hero_image_url")})]}),w.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(re=>({...re,hero_image_url:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Branding"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.logo_url&&e.jsx("img",{src:w.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="logo_url",children:e.jsxs("span",{children:[e.jsx(li,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:re=>O(re,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.agent_photo_url&&e.jsx("img",{src:w.agent_photo_url,alt:"Agent",className:"h-10 w-10 rounded-full object-cover"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="agent_photo_url",children:e.jsxs("span",{children:[e.jsx(li,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:re=>O(re,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.primary_color,onChange:re=>N(oe=>({...oe,primary_color:re.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:w.primary_color,onChange:re=>N(oe=>({...oe,primary_color:re.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.accent_color,onChange:re=>N(oe=>({...oe,accent_color:re.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:w.accent_color,onChange:re=>N(oe=>({...oe,accent_color:re.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Name"}),e.jsx(ze,{value:w.agent_name,onChange:re=>N(oe=>({...oe,agent_name:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Phone"}),e.jsx(ze,{value:w.agent_phone,onChange:re=>N(oe=>({...oe,agent_phone:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Email"}),e.jsx(ze,{value:w.agent_email,onChange:re=>N(oe=>({...oe,agent_email:re.target.value}))})]})]})})]})]}),X&&e.jsx(bs,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(yi,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a file or provide an external URL. Visitors will receive the download link after submitting the form."}),e.jsxs("div",{children:[e.jsx(be,{children:"Upload File (PDF, guide, checklist, etc.)"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.lead_magnet_file_name&&e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(yi,{className:"h-3 w-3"})," ",w.lead_magnet_file_name]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="lead_magnet",children:e.jsxs("span",{children:[e.jsx(li,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:q})]}),w.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(re=>({...re,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"flex-1 border-t"}),e.jsx("span",{children:"OR"}),e.jsx("div",{className:"flex-1 border-t"})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1",children:[e.jsx(dl,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(ze,{value:w.lead_magnet_external_url||"",onChange:re=>N(oe=>({...oe,lead_magnet_external_url:re.target.value||null})),placeholder:"https://drive.google.com/... or https://dropbox.com/...",className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Link to a file on Google Drive, Dropbox, or any URL"})]})]})]})}),ie&&e.jsxs(bs,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(bn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pull property details and photos directly from one of your listings, or enter them manually below."}),e.jsxs(Ks,{value:w.listing_id||"",onValueChange:re=>B(re),children:[e.jsx(Hs,{children:e.jsx(Ys,{placeholder:"Select a listing to import..."})}),e.jsx(Ws,{children:j.map(re=>{var oe;return e.jsxs(Mt,{value:re.id,children:[re.property_address||`${re.city}, ${re.state}`," — $",(oe=re.price)==null?void 0:oe.toLocaleString()]},re.id)})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Property Information"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:w.property_address,onChange:re=>N(oe=>({...oe,property_address:re.target.value})),placeholder:"123 Main St, City, State"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Price"}),e.jsx(ze,{value:w.property_price,onChange:re=>N(oe=>({...oe,property_price:re.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Beds"}),e.jsx(ze,{value:w.property_beds,onChange:re=>N(oe=>({...oe,property_beds:re.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Baths"}),e.jsx(ze,{value:w.property_baths,onChange:re=>N(oe=>({...oe,property_baths:re.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Sq Ft"}),e.jsx(ze,{value:w.property_sqft,onChange:re=>N(oe=>({...oe,property_sqft:re.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Er,{value:w.property_description,onChange:re=>N(oe=>({...oe,property_description:re.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Property Photos"})}),e.jsxs(Oe,{className:"space-y-4",children:[w.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:w.property_photos.map((re,oe)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:re,alt:`Property ${oe+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>N(ce=>({...ce,property_photos:ce.property_photos.filter((ge,ye)=>ye!==oe)})),children:e.jsx(Nr,{className:"h-3 w-3"})})]},oe))}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="property_photos",children:e.jsxs("span",{children:[e.jsx(li,{className:"h-3.5 w-3.5 mr-1"}),l==="property_photos"?"Uploading...":"Add Photos"]})}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:U})]})]})]})]}),e.jsxs(bs,{value:"fields",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the form fields visitors will fill out"}),e.jsxs(K,{size:"sm",onClick:V,children:[e.jsx($s,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),S.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No fields yet. Add fields to build your form."})}):e.jsx("div",{className:"space-y-3",children:S.map((re,oe)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Cu,{className:"h-4 w-4 mt-2 text-muted-foreground cursor-grab"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Field Type"}),e.jsxs(Ks,{value:re.field_type,onValueChange:ce=>Y(oe,{field_type:ce}),children:[e.jsx(Hs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:B5s.map(ce=>e.jsx(Mt,{value:ce.value,children:ce.label},ce.value))})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Label"}),e.jsx(ze,{value:re.label,onChange:ce=>Y(oe,{label:ce.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Placeholder"}),e.jsx(ze,{value:re.placeholder||"",onChange:ce=>Y(oe,{placeholder:ce.target.value}),placeholder:"Optional hint text"})]})]}),(re.field_type==="select"||re.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(ze,{value:re.options?(typeof re.options=="string"?JSON.parse(re.options):re.options).join(", "):"",onChange:ce=>Y(oe,{options:JSON.stringify(ce.target.value.split(",").map(ge=>ge.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:re.is_required,onCheckedChange:ce=>Y(oe,{is_required:ce})}),e.jsx(be,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Q(oe),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},oe))})]}),e.jsx(bs,{value:"submissions",className:"mt-4",children:_.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"No submissions yet. Share your page to start collecting leads!"})}):e.jsx("div",{className:"space-y-3",children:_.map(re=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:re.contact_name||"Anonymous"}),re.synced_to_crm&&e.jsx(st,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[re.contact_email&&e.jsx("span",{className:"mr-3",children:re.contact_email}),re.contact_phone&&e.jsx("span",{children:re.contact_phone})]}),re.answers&&typeof re.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(re.answers).map(([oe,ce])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[oe,":"]})," ",e.jsx("span",{children:String(ce)})]},oe))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(re.created_at).toLocaleDateString()})]})})},re.id))})}),e.jsxs(bs,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Publishing"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx(qr,{checked:w.is_published,onCheckedChange:re=>N(oe=>({...oe,is_published:re}))})]}),w.is_published&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Public URL:"}),e.jsx("code",{className:"text-xs ml-2 break-all",children:ee})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Thank You Message"})}),e.jsx(Oe,{children:e.jsx(Er,{value:w.success_message,onChange:re=>N(oe=>({...oe,success_message:re.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsx(_s,{children:e.jsx(vs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(CR,{value:ee,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:ee})]})]})})]}):e.jsx(Ms,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Page not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/mission-control/landing-pages"),children:"Go back"})]})})}function r9e({value:t}){return t>0?e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600 dark:text-emerald-400",children:[e.jsx(KI,{className:"h-3 w-3"}),t,"%"]}):t<0?e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-red-600 dark:text-red-400",children:[e.jsx(GI,{className:"h-3 w-3"}),Math.abs(t),"%"]}):e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(f0,{className:"h-3 w-3"}),"0%"]})}const q5s={Phone:Un,MessageSquare:so,Mail:cr,Gift:ko,PenTool:U_,Video:An},n9e=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function U5s(){const t=fr(),{contactsWithScores:s,stats:r}=kue(),{data:n}=UO(365),{data:a}=MNe(),{data:o}=qO(),l=kNe(),i=k.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const M=new Date,L=Fc(M),I=cx(M),O=Fc(v4(M,1)),q=cx(v4(M,1)),U=n.filter(Y=>Fg(new Date(Y.completed_at),{start:L,end:I})).length,B=n.filter(Y=>Fg(new Date(Y.completed_at),{start:O,end:q})).length,V=B>0?Math.round((U-B)/B*100):U>0?100:0;return{touchesThisMonth:U,touchesLastMonth:B,touchTrend:V}},[n]),c=k.useMemo(()=>{if(!n)return 0;const M=new Date,L=Fc(M),I=cx(M);return new Set(n.filter(O=>Fg(new Date(O.completed_at),{start:L,end:I})).map(O=>O.contact_id)).size},[n]),u=k.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const M=new Date,L=Fc(M),I=cx(M),O=a.filter(q=>q.close_date&&Fg(Ol(q.close_date),{start:L,end:I}));return{closedThisMonth:O.length,totalGCI:O.reduce((q,U)=>q+(Number(U.commission_amount)||0),0)}},[a]),p=k.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const M=new Date,L=Fc(M),I=Fc(v4(M,1)),O=cx(v4(M,1)),q=s.filter(V=>new Date(V.created_at)>=L).length,U=s.filter(V=>Fg(new Date(V.created_at),{start:I,end:O})).length,B=U>0?Math.round((q-U)/U*100):q>0?100:0;return{newThisMonth:q,newLastMonth:U,trend:B}},[s]),f=k.useMemo(()=>{if(!n||!o)return[];const M=new Date,L=Fc(M),I=cx(M),O=n.filter(B=>Fg(new Date(B.completed_at),{start:L,end:I})),q={};O.forEach(B=>{const V=B.action_type_id;q[V]=(q[V]||0)+1});const U=O.length||1;return o.filter(B=>q[B.id]).map(B=>({id:B.id,name:B.name,icon:B.icon,count:q[B.id]||0,percent:Math.round((q[B.id]||0)/U*100)})).sort((B,V)=>V.count-B.count)},[n,o]),g=k.useMemo(()=>[...s].filter(M=>M.relationshipScore.status==="at-risk"||M.relationshipScore.status==="cooling").sort((M,L)=>{const I=M.relationshipScore.daysSinceTouch??9999;return(L.relationshipScore.daysSinceTouch??9999)-I}).slice(0,5),[s]),b=k.useMemo(()=>{if(!n)return[];const M=new Date,L=Fc(M),I=cx(M),O=new Set(n.filter(q=>Fg(new Date(q.completed_at),{start:L,end:I})).map(q=>q.contact_id));return s.filter(q=>q.relationshipScore.status==="warm"&&O.has(q.id)&&q.relationshipScore.touchCountLast12Months>=2).sort((q,U)=>U.relationshipScore.score-q.relationshipScore.score).slice(0,5)},[s,n]),_=k.useMemo(()=>{if(!n)return{currentStreak:0,longestStreak:0};const M=new Set(n.map(V=>{const Y=new Date(V.completed_at);return`${Y.getFullYear()}-${Y.getMonth()}-${Y.getDate()}`})),L=new Date;L.setHours(0,0,0,0);let I=0,O=new Date(L);for(;M.has(`${O.getFullYear()}-${O.getMonth()}-${O.getDate()}`);)I++,O.setDate(O.getDate()-1);let q=0,U=0;if(Array.from(M).sort().length>0){const V=n.map(Y=>{const Q=new Date(Y.completed_at);return Q.setHours(0,0,0,0),Q.getTime()}).filter((Y,Q,ee)=>ee.indexOf(Y)===Q).sort((Y,Q)=>Y-Q);U=1;for(let Y=1;Y[...s].sort((M,L)=>M.relationshipScore.score-L.relationshipScore.score),[s]),w=j.filter(M=>M.relationshipScore.status==="warm"),N=j.filter(M=>M.relationshipScore.status==="cooling"),S=j.filter(M=>M.relationshipScore.status==="at-risk");return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Relationship Scorecard"}),e.jsxs("p",{className:"text-muted-foreground",children:[ms(new Date,"MMMM yyyy")," — Your monthly relationship health report"]})]}),_.currentStreak>0&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-full bg-orange-500/10 border border-orange-500/20",children:[e.jsx(eh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-orange-600 dark:text-orange-400",children:_.currentStreak}),e.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:"day streak"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ni,{className:"h-4 w-4"}),"Avg Score"]}),e.jsx("div",{className:"text-3xl font-bold",children:r.averageScore}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"out of 100"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(kh,{className:"h-4 w-4"}),"Touches"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:i.touchesThisMonth}),e.jsx(r9e,{value:i.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",i.touchesLastMonth," last month"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(pr,{className:"h-4 w-4"}),"Reached"]}),e.jsx("div",{className:"text-3xl font-bold",children:c}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.total," contacts"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ul,{className:"h-4 w-4"}),"New Contacts"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:p.newThisMonth}),e.jsx(r9e,{value:p.trend})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"added this month"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(zm,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[l.actionsThisWeek," of ",l.weeklyGoal," touches"]}),e.jsxs("span",{className:"text-sm font-medium",children:[Math.round(l.progress),"%"]})]}),e.jsx(Bi,{value:l.progress,className:"h-3"}),l.progress>=100&&e.jsxs("p",{className:"text-xs text-emerald-600 dark:text-emerald-400 mt-2 flex items-center gap-1",children:[e.jsx(xo,{className:"h-3 w-3"}),"Goal reached! 🎉"]}),l.progress<100&&l.progress>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[l.weeklyGoal-l.actionsThisWeek," more to hit your goal"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(eh,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:_.currentStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"}),_.currentStreak>=7&&e.jsx("span",{className:"ml-1",children:"🔥"}),_.currentStreak>=30&&e.jsx("span",{children:"🏆"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Longest Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:_.longestStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"})]})]}),_.currentStreak===0&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 italic",children:"Log a touch today to start your streak!"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(kh,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Oe,{children:f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No touches logged this month yet."}):e.jsx("div",{className:"space-y-2.5",children:f.slice(0,5).map((M,L)=>{const I=q5s[M.icon||""]||kh;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:M.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[M.count," (",M.percent,"%)"]})]}),e.jsx(Bi,{value:M.percent,className:It("h-1.5 bg-muted [&>div]:",n9e[L%n9e.length])})]},M.id)})})})]})]}),g.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-primary",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Un,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(st,{variant:"secondary",children:[g.length," contacts"]})]}),e.jsx(gr,{children:"These relationships need attention the most"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:g.map(M=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${M.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_8,{score:M.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[M.first_name," ",M.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${M.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:L=>{L.stopPropagation(),window.open(`tel:${M.phone}`)},children:e.jsx(Un,{className:"h-4 w-4"})}),M.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:L=>{L.stopPropagation(),window.open(`mailto:${M.email}`)},children:e.jsx(cr,{className:"h-4 w-4"})}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]})]},M.id))})})]}),b.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Nc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(gr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:b.map(M=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-full bg-emerald-500/10 border border-emerald-500/20 cursor-pointer hover:bg-emerald-500/20 transition-colors",onClick:()=>t(`/mission-control/contacts/${M.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[M.first_name," ",M.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:M.relationshipScore.score})]},M.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Warm"}),e.jsx("p",{className:"text-3xl font-bold text-emerald-600 dark:text-emerald-400",children:r.warm})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟢"})})]}),e.jsx(Bi,{value:r.total?r.warm/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-emerald-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-amber-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cooling Off"}),e.jsx("p",{className:"text-3xl font-bold text-amber-600 dark:text-amber-400",children:r.cooling})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟡"})})]}),e.jsx(Bi,{value:r.total?r.cooling/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-amber-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-red-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"At Risk"}),e.jsx("p",{className:"text-3xl font-bold text-red-600 dark:text-red-400",children:r.atRisk})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🔴"})})]}),e.jsx(Bi,{value:r.total?r.atRisk/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-red-500"})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(cL,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deals Closed This Month"}),e.jsx("p",{className:"text-2xl font-bold",children:u.closedThisMonth})]})]}),u.totalGCI>0&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"GCI This Month"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:["$",u.totalGCI.toLocaleString()]})]})]})})}),e.jsxs(ba,{defaultValue:"at-risk",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"at-risk",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),"At Risk (",r.atRisk,")"]}),e.jsxs(ns,{value:"cooling",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"}),"Cooling (",r.cooling,")"]}),e.jsxs(ns,{value:"warm",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),"Warm (",r.warm,")"]})]}),[{key:"at-risk",contacts:S},{key:"cooling",contacts:N},{key:"warm",contacts:w}].map(({key:M,contacts:L})=>e.jsx(bs,{value:M,children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:L.length===0?e.jsx("p",{className:"p-6 text-center text-muted-foreground",children:"No contacts in this category"}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Contact"}),e.jsx(St,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(St,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(St,{children:"Score"}),e.jsx(St,{className:"w-10"})]})}),e.jsx(zn,{children:L.slice(0,20).map(I=>e.jsxs(Ss,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${I.id}`),children:[e.jsxs(dt,{className:"font-medium",children:[I.first_name," ",I.last_name]}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:I.relationshipScore.daysSinceTouch===null?"Never":I.relationshipScore.daysSinceTouch===0?"Today":`${I.relationshipScore.daysSinceTouch}d ago`}),e.jsx(dt,{className:"hidden md:table-cell",children:I.relationshipScore.touchCountLast12Months}),e.jsx(dt,{children:e.jsx(_8,{score:I.relationshipScore,showScore:!0})}),e.jsx(dt,{children:e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})})]},I.id))})]})})})},M))]})]})})}function Mct(){const{user:t}=Ds(),s=Qt(),{data:r,isLoading:n}=mt({queryKey:["contact-intake-page",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:u,error:p}=await H.from("contact_intake_pages").select("*").eq("user_id",t.id).maybeSingle();if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),a=Lt({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:p,error:f}=await H.from("contact_intake_pages").insert({user_id:t.id,slug:u.toLowerCase().replace(/[^a-z0-9-]/g,"-")}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),me.success("Connect page created!")},onError:u=>{var p;(p=u.message)!=null&&p.includes("duplicate")?me.error("That slug is already taken. Try another."):me.error("Failed to create page")}}),o=Lt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page");const{error:p}=await H.from("contact_intake_pages").update({...u,updated_at:new Date().toISOString()}).eq("id",r.id);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),me.success("Page updated!")},onError:()=>me.error("Failed to update page")}),{data:l=[],isLoading:i}=mt({queryKey:["contact-intake-submissions",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:u,error:p}=await H.from("contact_intake_submissions").select("*").eq("agent_user_id",t.id).order("created_at",{ascending:!1}).limit(100);if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),c=Lt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:p,error:f}=await H.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(f)throw f;return`${window.location.origin}/connect/${r.slug}?t=${p.token}`}});return{intakePage:r,isLoading:n,createPage:a,updatePage:o,submissions:l,loadingSubmissions:i,generateUpdateLink:c}}function V5s(){const{user:t}=Ds();return mt({queryKey:["bulk-email-sends",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:s,error:r}=await H.from("bulk_email_sends").select("contact_id, sent_at, subject").eq("user_id",t.id).order("sent_at",{ascending:!1});if(r)throw r;return s}})}function H5s(t,s){if(!t)return null;const r=t.find(n=>n.contact_id===s);return(r==null?void 0:r.sent_at)||null}const LI=[{key:"email",label:"Missing Email",icon:cr,description:"No email — can't send drips or market updates",check:t=>!t.email,color:"text-red-500",fieldKey:"email",fieldType:"email",placeholder:"email@example.com"},{key:"phone",label:"Missing Phone",icon:Un,description:"No phone number — can't call or text",check:t=>!t.phone,color:"text-orange-500",fieldKey:"phone",fieldType:"tel",placeholder:"(555) 123-4567"},{key:"address",label:"Missing Address",icon:ma,description:"No address — can't send postcards or popbys",check:t=>!t.address,color:"text-amber-500",fieldKey:"address",fieldType:"text",placeholder:"123 Main St, City, ST 12345"},{key:"birthday",label:"Missing Birthday",icon:Ch,description:"No birthday — missing a key personal touch",check:t=>!t.birthday,color:"text-purple-500",fieldKey:"birthday",fieldType:"date"},{key:"home_anniversary",label:"Missing Home Anniversary",icon:bn,description:"No home anniversary — missing annual outreach opportunity",check:t=>!t.home_anniversary,color:"text-blue-500",fieldKey:"home_anniversary",fieldType:"date"},{key:"tags",label:"No Tags",icon:Fm,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function G5(t){const s=[!!t.email,!!t.phone,!!t.address,!!t.birthday,!!t.home_anniversary,!!(t.tags&&t.tags.length>0)];return Math.round(s.filter(Boolean).length/s.length*100)}function W5s({contact:t,onClose:s}){const r=wNe(),[n,a]=k.useState({email:t.email||"",phone:t.phone||"",address:t.address||"",birthday:t.birthday||"",home_anniversary:t.home_anniversary||""}),o=async()=>{r.mutate({id:t.id,...n},{onSuccess:()=>s()})},l=LI.filter(i=>i.fieldKey&&i.check(t));return e.jsx(eE,{open:!0,onOpenChange:()=>s(),children:e.jsxs(vC,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(tE,{children:[e.jsxs(sE,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(qZe,{children:["Fill in missing fields to improve this contact's completeness (",G5(t),"%)"]})]}),e.jsxs("div",{className:"space-y-5 mt-6",children:[l.length>0&&e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400 mb-1",children:"Missing Fields"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(i=>{const c=i.icon;return e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(c,{className:"h-3 w-3"}),i.label.replace("Missing ","")]},i.key)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(cr,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(ze,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(c=>({...c,email:i.target.value})),className:It(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(Un,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(ze,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(c=>({...c,phone:i.target.value})),className:It(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(ma,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(ze,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(c=>({...c,address:i.target.value})),className:It(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(Ch,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(ze,{type:"date",value:n.birthday,onChange:i=>a(c=>({...c,birthday:i.target.value})),className:It(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(bn,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(ze,{type:"date",value:n.home_anniversary,onChange:i=>a(c=>({...c,home_anniversary:i.target.value})),className:It(!t.home_anniversary&&"border-amber-500/50")})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{className:"flex-1",onClick:o,disabled:r.isPending,children:[e.jsx(qc,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const Rye="Quick favor — can you update your info? 🙏",a9e=`Hi {{first_name}}, Hope you're doing well! I'm making sure I have the most up-to-date info for all my important contacts. Could you take 30 seconds to update your details? Just click the link below: {{update_link}} It's super quick — and it helps me make sure I'm reaching you at the right place with anything useful (market updates, birthday wishes, you name it 😊). Thanks so much!`;function G5s(){const t=fr(),{data:s,isLoading:r}=Gm(),{data:n}=Vx(),{intakePage:a}=Mct(),{isGmailConnected:o,gmailEmail:l}=Gx(),{data:i}=V5s(),[c,u]=k.useState("blocked"),[p,f]=k.useState("all"),[g,b]=k.useState(null),[_,j]=k.useState(!1),[w,N]=k.useState(!1),[S,M]=k.useState(null),[L,I]=k.useState([]),[O,q]=k.useState(""),[U,B]=k.useState(""),V=k.useMemo(()=>s?p==="all"?s:s.filter(xe=>{var we;return(we=xe.tags)==null?void 0:we.some(Le=>Le.relationship_type_id===p)}):[],[s,p]),Y=k.useMemo(()=>V.filter(xe=>!xe.email&&!xe.phone),[V]),Q=k.useMemo(()=>{if(!V.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const xe={};xe.blocked=Y,LI.forEach(Te=>{xe[Te.key]=V.filter(Te.check)});const we=V.map(G5),Le=V.length>0?Math.round(we.reduce((Te,pt)=>Te+pt,0)/V.length):0,tt=we.filter(Te=>Te===100).length;return{contactsByGap:xe,overallCompleteness:Le,fullyComplete:tt}},[V,Y]),ee=k.useMemo(()=>{if(!s||s.length===0)return null;const xe=Fc(v4(new Date,1)),we=s.filter(pt=>new Date(pt.created_at)pt+fe,0)/we.length),tt=Q.overallCompleteness,Te=tt-Le;return{oldCompleteness:Le,currentCompleteness:tt,diff:Te,oldCount:we.length}},[s,Q.overallCompleteness]),X=V.length,ie=k.useCallback(()=>{var at;const xe=Q.contactsByGap[c];if(!(xe!=null&&xe.length))return;const we=c==="blocked"?"Outreach Blocked":((at=LI.find(et=>et.key===c))==null?void 0:at.label)||c,Le=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],tt=xe.map(et=>[et.first_name,et.last_name||"",et.email||"",et.phone||"",et.address||"",et.birthday||"",et.home_anniversary||"",G5(et).toString()]),Te=[Le.join(","),...tt.map(et=>et.map(Me=>`"${Me.replace(/"/g,'""')}"`).join(","))].join(` `),pt=new Blob([Te],{type:"text/csv"}),fe=URL.createObjectURL(pt),qe=document.createElement("a");qe.href=fe,qe.download=`sphere-gaps-${we.toLowerCase().replace(/\s+/g,"-")}-${ms(new Date,"yyyy-MM-dd")}.csv`,qe.click(),URL.revokeObjectURL(fe),wn({title:`Exported ${xe.length} contacts to CSV`})},[Q.contactsByGap,c]),re=k.useCallback(async xe=>{if(!a)return null;try{const{data:we,error:Le}=await H.from("contact_intake_tokens").insert({contact_id:xe,intake_page_id:a.id}).select("token").single();if(Le)throw Le;return we.token}catch{return null}},[a]),oe=k.useCallback(xe=>a?`https://contacts.relevelup.com/${a.slug}?t=${xe}`:"",[a]),ce=k.useCallback(async xe=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const we=await re(xe);we?(await navigator.clipboard.writeText(oe(we)),me.success("Update link copied!")):me.error("Failed to generate link")},[a,re,oe,t]),ge=k.useCallback(async xe=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!xe.email){me.error("This contact has no email address");return}const we=await re(xe.id);if(!we){me.error("Failed to generate link");return}const Le=oe(we),tt=a9e.replace("{{update_link}}",Le).replace(/\{\{first_name\}\}/g,xe.first_name).replace(/\{\{last_name\}\}/g,xe.last_name||""),Te=Rye.replace(/\{\{first_name\}\}/g,xe.first_name).replace(/\{\{last_name\}\}/g,xe.last_name||"");if(o)M({id:xe.id,first_name:xe.first_name,last_name:xe.last_name,email:xe.email}),I([]),q(Te),B(tt),N(!0);else{const pt=encodeURIComponent(Rye.replace("{{first_name}}",xe.first_name)),fe=encodeURIComponent(tt.replace(/\{\{first_name\}\}/g,xe.first_name));window.location.href=`mailto:${xe.email}?subject=${pt}&body=${fe}`}},[a,re,oe,o,t]),ye=k.useCallback(async xe=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const we=xe.filter(Te=>Te.email);if(!we.length){me.error("No contacts with email addresses in this group");return}const Le=new Set((i||[]).map(Te=>Te.contact_id)),tt=we.filter(Te=>!Le.has(Te.id));if(tt.length===0){me.info(`All ${we.length} contacts with email have already been sent this update request.`);return}if(tt.lengthrt.id),intake_page_id:a.id}});if(pt)throw pt;const fe=typeof Te=="string"?JSON.parse(Te):Te,qe=Array.isArray(fe)?fe:Array.isArray(fe==null?void 0:fe.tokens)?fe.tokens:[],at=new Map(qe.filter(rt=>(rt==null?void 0:rt.contact_id)&&(rt==null?void 0:rt.token)).map(rt=>[rt.contact_id,rt.token]));if(at.size===0&&(await Promise.all(we.map(async He=>({contactId:He.id,token:await re(He.id)})))).forEach(({contactId:He,token:ct})=>{ct&&at.set(He,ct)}),at.size===0){me.error("Failed to generate update links. Please try again.");return}const et=tt.filter(rt=>at.has(rt.id)).map(rt=>({id:rt.id,first_name:rt.first_name,last_name:rt.last_name,email:rt.email,updateLink:oe(at.get(rt.id))})),Me=a9e;M(null),I(et),q(Rye),B(Me),N(!0),me.success(`Ready to email ${et.length} contacts`)}catch{me.error("Failed to generate links")}finally{j(!1)}},[a,o,oe,re,t]),pe=[{key:"blocked",label:"Outreach Blocked",icon:Fv,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...LI].find(xe=>xe.key===c),_e=Q.contactsByGap[c]||[],$e=_e.filter(xe=>xe.email).length,Ae=new Set((i||[]).map(xe=>xe.contact_id)),Ie=_e.filter(xe=>xe.email&&Ae.has(xe.id)).length,Ce=$e-Ie;return e.jsxs(Ms,{children:[e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Sphere Gaps Analyzer"}),e.jsx("p",{className:"text-muted-foreground",children:"Find missing info in your database to maximize your outreach potential"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Ks,{value:p,onValueChange:f,children:[e.jsx(Hs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Filter by tag"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(xe=>e.jsx(Mt,{value:xe.id,children:xe.name},xe.id))]})]})]})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Database Completeness",p!=="all"&&e.jsx("span",{className:"ml-1 text-primary",children:"(filtered)"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("p",{className:"text-4xl font-bold",children:[Q.overallCompleteness,"%"]}),ee&&ee.diff!==0&&p==="all"&&e.jsxs("div",{className:It("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",ee.diff>0?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-red-500/10 text-red-600 dark:text-red-400"),children:[ee.diff>0?"↑":"↓"," ",Math.abs(ee.diff),"% vs older contacts"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Fully Complete"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:[Q.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",X]})]})]})]}),e.jsx(Bi,{value:Q.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:Q.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":Q.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),Y.length>0&&e.jsx(Ee,{className:It("border-l-4 border-l-destructive cursor-pointer transition-all hover:shadow-md",c==="blocked"&&"ring-2 ring-primary"),onClick:()=>u("blocked"),children:e.jsx(Oe,{className:"pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Fv,{className:"h-6 w-6 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Outreach Blocked"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Missing both email AND phone — completely unreachable"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-3xl font-bold text-destructive",children:Y.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"contacts"})]})]})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:LI.map(xe=>{var pt;const we=((pt=Q.contactsByGap[xe.key])==null?void 0:pt.length)||0,Le=X>0?Math.round(we/X*100):0,tt=xe.icon,Te=c===xe.key;return e.jsx(Ee,{className:It("cursor-pointer transition-all hover:shadow-md",Te&&"ring-2 ring-primary"),onClick:()=>u(xe.key),children:e.jsxs(Oe,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(tt,{className:It("h-5 w-5",xe.color)}),e.jsx("span",{className:"text-sm font-medium",children:xe.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:we}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Le,"% of contacts"]})]}),e.jsx(Bi,{value:100-Le,className:"mt-2 h-1.5"})]})},xe.key)})}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg",children:[(pe==null?void 0:pe.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(st,{variant:"secondary",children:[_e.length," contacts"]}),Ie>0&&e.jsxs(st,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(sa,{className:"h-3 w-3"}),Ie," already emailed"]}),_e.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-1.5",children:[e.jsx(yi,{className:"h-3.5 w-3.5"}),"Export"]}),Ce>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>ye(_e),disabled:_,className:"gap-1.5",children:[_?e.jsx(ws,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Bn,{className:"h-3.5 w-3.5"}),"Email ",Ce," Update Links"]})]})]})]}),e.jsx(gr,{children:pe==null?void 0:pe.description})]}),e.jsx(Oe,{className:"p-0",children:_e.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(sa,{className:"h-10 w-10 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:c==="blocked"?"All contacts have at least an email or phone!":"All contacts have this field filled in!"})]}):e.jsxs(Rn,{children:[e.jsx(Fn,{children:e.jsxs(Ss,{children:[e.jsx(St,{children:"Contact"}),e.jsx(St,{className:"hidden md:table-cell",children:"Email"}),e.jsx(St,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(St,{children:"Completeness"}),e.jsx(St,{className:"w-28",children:"Actions"})]})}),e.jsx(zn,{children:_e.map(xe=>{const we=H5s(i,xe.id);return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"cursor-pointer hover:underline",onClick:()=>t(`/mission-control/contacts/${xe.id}`),children:[xe.first_name," ",xe.last_name]}),!xe.email&&!xe.phone&&c!=="blocked"&&e.jsx(st,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),we&&e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(cr,{className:"h-2.5 w-2.5"}),Uc(new Date(we),{addSuffix:!0})]})}),e.jsxs(Xl,{children:["Last bulk emailed ",ms(new Date(we),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:xe.email||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:xe.phone||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bi,{value:G5(xe),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[G5(xe),"%"]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>b(xe),children:e.jsx(Bv,{className:"h-3.5 w-3.5"})})}),e.jsx(Xl,{children:"Quick edit"})]}),(xe.email||xe.phone)&&a&&e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ce(xe.id),children:e.jsx(gi,{className:"h-3.5 w-3.5"})})}),e.jsx(Xl,{children:"Copy update link"})]}),xe.email&&a&&e.jsxs(bc,{children:[e.jsx(_c,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ge(xe),children:e.jsx(cr,{className:"h-3.5 w-3.5"})})}),e.jsx(Xl,{children:"Email update link"})]})]})})]},xe.id)})})]})})]})]}),g&&e.jsx(W5s,{contact:g,onClose:()=>b(null)}),e.jsx(Uw,{open:w,onOpenChange:N,contact:S||void 0,bulkContacts:L.length>0?L:void 0,defaultSubject:O,defaultBody:U,gmailEmail:l})]})}function K5s(){const{user:t}=Ds(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=Mct(),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(!1);k.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),k.useEffect(()=>{if(t!=null&&t.email&&!s){const M=t.email.split("@")[0];c(M.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+$/,""))}},[t,s]);const b=s?`https://contacts.relevelup.com/${s.slug}`:"",_=()=>{navigator.clipboard.writeText(b),me.success("Link copied!")};if(r)return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 flex items-center justify-center",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(dl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Connect Page"}),e.jsx(gr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Your Connect Page URL"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"contacts.relevelup.com/"}),e.jsx(ze,{value:i,onChange:M=>c(M.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"jane-smith",className:"max-w-[200px]"})]})]}),e.jsxs(K,{onClick:()=>n.mutate(i),disabled:!i.trim()||n.isPending,children:[n.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const j=o.filter(M=>!M.is_processed),w=o.filter(M=>M.is_processed),N=j.length,S=(M,L)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[M.first_name," ",M.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[M.email&&e.jsx("span",{children:M.email}),M.phone&&e.jsx("span",{children:M.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M.real_estate_interest&&M.real_estate_interest!=="not_now"&&e.jsx(st,{variant:"outline",className:"text-xs",children:M.real_estate_interest==="buying"?"🏠 Buying":M.real_estate_interest==="selling"?"📋 Selling":M.real_estate_interest==="both"?"🔄 Both":M.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(M.created_at),"MMM d")]}),L&&e.jsx(sa,{className:"h-4 w-4 text-emerald-500"})]})]},M.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(dl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Connect Page"}),e.jsx(gr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx(qr,{id:"active-toggle",checked:s.is_active,onCheckedChange:M=>a.mutate({is_active:M})})]})]})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:b}),e.jsxs(K,{size:"sm",variant:"outline",onClick:_,children:[e.jsx(gi,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:b,target:"_blank",rel:"noopener noreferrer",children:e.jsx(tn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Welcome Message"}),f?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:M=>p(M.target.value),rows:3,className:"w-full px-3 py-2 text-sm border rounded-md bg-background"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:()=>{a.mutate({welcome_message:u}),g(!1)},children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g(!1),children:"Cancel"})]})]}):e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:()=>g(!0),children:s.welcome_message||"Click to set a welcome message..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-base",children:"New Submissions"}),N>0&&e.jsxs(gr,{children:[N," awaiting sync"]})]})]}),N>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:M,error:L}=await H.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(L)throw L;me.success(`Synced ${M.processed} contacts to your CRM!`)}catch{me.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",N," to CRM"]})]})}),e.jsx(Oe,{children:l?e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"}):j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"All caught up! No new submissions to sync."}):e.jsx("div",{className:"space-y-3",children:j.map(M=>S(M,!1))})})]}),w.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(sa,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-base",children:"Synced to CRM"}),e.jsxs(gr,{children:[w.length," contacts already in your database"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[w.slice(0,10).map(M=>S(M,!0)),w.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",w.length-10," more synced contacts"]})]})})]})]})}function Z5s(){return e.jsx(Ms,{children:e.jsxs("div",{className:"max-w-3xl mx-auto py-8 px-4",children:[e.jsx("h1",{className:"text-2xl font-bold mb-6",children:"Connect Page"}),e.jsx(K5s,{})]})})}const Y5s={property_view:{label:"Viewed Listing",icon:Ln,badgeClass:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-700"},new_lead:{label:"New Lead",icon:Tl,badgeClass:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-200 dark:border-emerald-700"},saved_listing:{label:"Saved Listing",icon:ni,badgeClass:"bg-rose-500/10 text-rose-600 dark:text-rose-400 border-rose-200 dark:border-rose-700"}},X5s={home:"🏠",search:"🔍",listing:"🏡",city:"🌆",sell:"💰",blog:"📝",dashboard:"📊",other:"📄"};function Q5s({locations:t}){const s=k.useRef(null),r=k.useRef(null),[n,a]=k.useState(null);return k.useEffect(()=>{H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle().then(({data:o})=>{o!=null&&o.value&&a(o.value)})},[]),k.useEffect(()=>{if(!(!s.current||!n||r.current))return Ao.accessToken=n,r.current=new Ao.Map({container:s.current,style:"mapbox://styles/mapbox/light-v11",zoom:3.5,center:[-98.5795,39.8283],interactive:!0}),r.current.addControl(new Ao.NavigationControl,"top-right"),()=>{var o;(o=r.current)==null||o.remove(),r.current=null}},[n]),k.useEffect(()=>{if(!r.current||!n||t.length===0)return;const o=()=>{if(t.forEach(l=>{if(!Number.isFinite(l.lat)||!Number.isFinite(l.lng))return;const i=Math.min(40,Math.max(16,12+l.visitor_count*3)),c=document.createElement("div");c.style.cssText=` width: ${i}px; height: ${i}px; border-radius: 50%; background: radial-gradient(circle, rgba(64,110,113,0.9), rgba(64,110,113,0.4)); border: 2px solid rgba(64,110,113,0.8); display: flex; align-items: center; justify-content: center; font-size: ${Math.max(9,i*.35)}px; font-weight: 700; color: white; cursor: pointer; transition: transform 0.2s; `,c.textContent=String(l.visitor_count),c.addEventListener("mouseenter",()=>{c.style.transform="scale(1.3)"}),c.addEventListener("mouseleave",()=>{c.style.transform="scale(1)"});const u=document.createElement("div");u.appendChild(c),new Ao.Marker({element:u,anchor:"center"}).setLngLat([l.lng,l.lat]).setPopup(new Ao.Popup({offset:15}).setHTML(`
${l.city}, ${l.region}
${l.visitor_count} visitor${l.visitor_count>1?"s":""}
`)).addTo(r.current)}),t.length>1){const l=new Ao.LngLatBounds;t.forEach(i=>{Number.isFinite(i.lat)&&Number.isFinite(i.lng)&&l.extend([i.lng,i.lat])}),l.isEmpty()||r.current.fitBounds(l,{padding:60,maxZoom:10})}else t.length===1&&r.current.flyTo({center:[t[0].lng,t[0].lat],zoom:8})};r.current.loaded()?o():r.current.on("load",o)},[t,n]),n?e.jsx("div",{ref:s,className:"w-full h-full rounded-xl overflow-hidden"}):e.jsxs("div",{className:"h-full flex items-center justify-center bg-muted/30 rounded-xl text-muted-foreground text-sm",children:[e.jsx(l1,{className:"h-5 w-5 mr-2"})," Map not configured"]})}function Tct(){var I,O,q,U;const{user:t}=Ds(),s=fr(),{isGmailConnected:r,gmailEmail:n}=Gx(),[a,o]=k.useState("all"),[l,i]=k.useState("30"),[c,u]=k.useState(""),[p,f]=k.useState(!1),[g,b]=k.useState(null),{data:_,isLoading:j}=mt({queryKey:["lead-site-activity-full",t==null?void 0:t.id,l],queryFn:async()=>{const{data:B,error:V}=await H.rpc("get_lead_site_activity_full",{_user_id:t.id,_days:parseInt(l)});if(V)throw V;const Y=B;return{...Y,visitor_locations:((Y==null?void 0:Y.visitor_locations)||[]).map(Q=>({...Q,lat:Number(Q.lat),lng:Number(Q.lng),visitor_count:Number(Q.visitor_count??Q.visit_count??0)}))}},enabled:!!t,refetchInterval:6e4}),w=k.useMemo(()=>{if(!(_!=null&&_.activities))return[];let B=_.activities;if(a!=="all"&&(B=B.filter(V=>V.activity_type===a)),c){const V=c.toLowerCase();B=B.filter(Y=>{var Q,ee,X,ie,re;return((Q=Y.visitor_name)==null?void 0:Q.toLowerCase().includes(V))||((ee=Y.visitor_email)==null?void 0:ee.toLowerCase().includes(V))||((X=Y.mls_number)==null?void 0:X.includes(V))||((ie=Y.property_address)==null?void 0:ie.toLowerCase().includes(V))||((re=Y.lead_type)==null?void 0:re.toLowerCase().includes(V))})}return B},[_==null?void 0:_.activities,a,c]),N=_==null?void 0:_.subdomain,S=B=>N?`https://${N}.thelocalmove.com/listing/${B}`:null,M=_==null?void 0:_.stats,L=B=>{if(B.visitor_email)if(r){const V=(B.visitor_name||"").split(" ");b({id:B.contact_id||"",first_name:V[0]||"",last_name:V.slice(1).join(" ")||null,email:B.visitor_email}),f(!0)}else window.location.href=`mailto:${B.visitor_email}`};return!(_!=null&&_.has_site)&&!j?e.jsx(Ms,{title:"Website Activity",description:"Monitor your website lead activity",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(su,{className:"h-16 w-16 text-muted-foreground/30 mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Website Connected"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"Set up your Lead Site to start capturing and tracking visitor activity."})]})}):e.jsxs(Ms,{title:"Website Activity",description:"Monitor and act on your website leads",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/mission-control"),children:e.jsx(Ja,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(su,{className:"h-6 w-6 text-primary"}),"Website Activity"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track, respond, and convert your website visitors"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:["7","30","90"].map(B=>e.jsxs(K,{variant:l===B?"default":"outline",size:"sm",onClick:()=>i(B),children:[B,"d"]},B))})]}),M&&e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Page Views",value:M.total_page_views,sub:M.page_views_7d,icon:Sn,color:"text-violet-600 dark:text-violet-400",bg:"bg-violet-500/10"},{label:"Listing Views",value:M.total_views,sub:M.views_7d,icon:Ln,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-500/10"},{label:"New Leads",value:M.total_leads,sub:M.leads_7d,icon:Tl,color:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/10"},{label:"Saved Listings",value:M.total_saved,sub:M.saved_7d,icon:ni,color:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/10"}].map(B=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:B.label}),e.jsx("p",{className:`text-2xl font-bold ${B.color}`,children:B.value})]}),e.jsx("div",{className:`p-2.5 rounded-xl ${B.bg}`,children:e.jsx(B.icon,{className:`h-5 w-5 ${B.color}`})})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:[e.jsx("span",{className:`font-semibold ${B.color}`,children:B.sub})," in last 7d"]})]})},B.label))}),e.jsxs(ba,{defaultValue:"overview",className:"space-y-4",children:[e.jsxs(pa,{children:[e.jsxs(ns,{value:"overview",className:"gap-1.5",children:[e.jsx(No,{className:"h-4 w-4"})," Overview"]}),e.jsxs(ns,{value:"leads",className:"gap-1.5",children:[e.jsx(Zh,{className:"h-4 w-4"})," Lead Inbox"]}),e.jsxs(ns,{value:"map",className:"gap-1.5",children:[e.jsx(l1,{className:"h-4 w-4"})," Visitor Map"]})]}),e.jsxs(bs,{value:"overview",className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(ul,{className:"h-4 w-4 text-primary"}),"Most Viewed Listings"]})}),e.jsx(Oe,{className:"pt-0",children:!(_!=null&&_.top_listings)||_.top_listings.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(bn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/30"}),"No listing views yet"]}):e.jsx("div",{className:"space-y-1.5",children:_.top_listings.map((B,V)=>{const Y=S(B.mls_number);return e.jsxs("a",{href:Y||"#",target:"_blank",rel:"noopener noreferrer",onClick:Q=>{Y||Q.preventDefault()},className:"group flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[e.jsx("span",{className:"text-sm font-bold text-muted-foreground w-5 text-right",children:V+1}),B.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0",children:e.jsx("img",{src:B.photo_url,alt:"",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(bn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.property_address||`MLS# ${B.mls_number}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Uc(new Date(B.last_viewed),{addSuffix:!0})})]}),e.jsxs(st,{variant:"secondary",className:"shrink-0 text-xs",children:[B.view_count," view",B.view_count!==1?"s":""]}),Y&&e.jsx(tn,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},B.mls_number)})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4 text-primary"}),"Most Visited Pages"]})}),e.jsx(Oe,{className:"pt-0",children:!(_!=null&&_.top_pages)||_.top_pages.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(Sn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/30"}),"No page views yet"]}):e.jsx("div",{className:"space-y-1.5",children:_.top_pages.map((B,V)=>e.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[e.jsx("span",{className:"text-sm font-bold text-muted-foreground w-5 text-right",children:V+1}),e.jsx("span",{className:"text-lg w-8 text-center",children:X5s[B.page_type]||"📄"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.page_title||B.page_path}),e.jsx("p",{className:"text-xs text-muted-foreground",children:B.page_path})]}),e.jsx(st,{variant:"secondary",className:"shrink-0 text-xs capitalize",children:B.page_type}),e.jsx(st,{variant:"outline",className:"shrink-0 text-xs",children:B.view_count})]},`${B.page_type}-${B.page_path}`))})})]})]}),(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(ma,{className:"h-4 w-4 text-primary"}),"Where Visitors Are Browsing From"]})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:_.visitor_locations.slice(0,9).map(B=>e.jsxs("div",{className:"flex items-center gap-2.5 p-2.5 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ma,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[B.city,", ",B.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:B.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:B.visitor_count})]},`${B.city}-${B.region}`))})})]})]}),e.jsxs(bs,{value:"leads",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, address...",value:c,onChange:B=>u(B.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex gap-2",children:[{key:"all",label:"All",count:((I=_==null?void 0:_.activities)==null?void 0:I.length)||0},{key:"new_lead",label:"Leads",count:((O=_==null?void 0:_.activities)==null?void 0:O.filter(B=>B.activity_type==="new_lead").length)||0},{key:"property_view",label:"Views",count:((q=_==null?void 0:_.activities)==null?void 0:q.filter(B=>B.activity_type==="property_view").length)||0},{key:"saved_listing",label:"Saved",count:((U=_==null?void 0:_.activities)==null?void 0:U.filter(B=>B.activity_type==="saved_listing").length)||0}].map(B=>e.jsxs(K,{variant:a===B.key?"default":"outline",size:"sm",onClick:()=>o(B.key),className:"gap-1.5",children:[B.label,e.jsx(st,{variant:"secondary",className:"text-[10px] h-4 px-1 rounded-full",children:B.count})]},B.key))})]}),j?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(B=>e.jsx("div",{className:"h-20 rounded-xl bg-muted animate-pulse"},B))}):w.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(kh,{className:"h-10 w-10 text-muted-foreground/30 mx-auto mb-3"}),e.jsx("p",{className:"font-medium",children:"No activity found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c?"Try adjusting your search.":"Website engagement will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:w.map((B,V)=>{const Y=Y5s[B.activity_type],Q=Y.icon,ee=Uc(new Date(B.occurred_at),{addSuffix:!0}),X=B.visitor_name&&B.visitor_name!=="Site Visitor";return e.jsx(Ee,{className:`transition-all hover:shadow-md ${B.activity_type==="new_lead"?"border-l-4 border-l-emerald-500":B.activity_type==="saved_listing"?"border-l-4 border-l-rose-500":"border-l-4 border-l-blue-500"}`,children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[B.photo_url?e.jsx("a",{href:B.mls_number&&S(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"shrink-0 rounded-lg overflow-hidden w-12 h-12 bg-muted",children:e.jsx("img",{src:B.photo_url,alt:B.property_address||"Property",className:"w-full h-full object-cover"})}):e.jsx("div",{className:`p-2 rounded-lg shrink-0 ${B.activity_type==="new_lead"?"bg-emerald-500/10":B.activity_type==="saved_listing"?"bg-rose-500/10":"bg-blue-500/10"}`,children:e.jsx(Q,{className:`h-4 w-4 ${B.activity_type==="new_lead"?"text-emerald-500":B.activity_type==="saved_listing"?"text-rose-500":"text-blue-500"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[X?e.jsx("button",{className:"font-semibold text-sm text-primary hover:underline text-left truncate",onClick:()=>{B.contact_id&&s(`/mission-control/contacts/${B.contact_id}`)},children:B.visitor_name}):e.jsx("span",{className:"font-medium text-sm text-muted-foreground",children:B.visitor_name||"Site Visitor"}),e.jsx(st,{variant:"outline",className:`text-[10px] shrink-0 ${Y.badgeClass}`,children:Y.label}),B.lead_type&&e.jsx(st,{variant:"secondary",className:"text-[10px] capitalize",children:B.lead_type.replace(/_/g," ")})]}),B.property_address&&B.mls_number&&e.jsxs("a",{href:S(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-0.5 text-xs font-medium text-foreground hover:text-primary transition-colors truncate",children:[e.jsx(ma,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:B.property_address}),e.jsx(tn,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ee]}),B.mls_number&&!B.property_address&&e.jsxs("a",{href:S(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"hover:text-primary transition-colors",children:["MLS# ",B.mls_number]})]}),B.message&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5 line-clamp-2 italic",children:['"',B.message,'"']})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[B.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:r?"Compose via Gmail":"Send Email",onClick:()=>L(B),children:e.jsx(cr,{className:"h-4 w-4"})}),B.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Call",onClick:()=>window.location.href=`tel:${B.visitor_phone}`,children:e.jsx(Un,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Text",onClick:()=>window.location.href=`sms:${B.visitor_phone}`,children:e.jsx(so,{className:"h-4 w-4"})})]}),B.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",title:"View Contact",onClick:()=>s(`/mission-control/contacts/${B.contact_id}`),children:e.jsx(da,{className:"h-4 w-4"})})]})]})})},`${B.activity_type}-${B.occurred_at}-${V}`)})})]}),e.jsxs(bs,{value:"map",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(l1,{className:"h-4 w-4 text-primary"}),"Visitor Locations",(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(st,{variant:"secondary",className:"text-xs ml-2",children:[_.visitor_locations.reduce((B,V)=>B+V.visitor_count,0)," visitors from ",_.visitor_locations.length," cities"]})]})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"h-[450px] rounded-xl overflow-hidden border",children:e.jsx(Q5s,{locations:(_==null?void 0:_.visitor_locations)||[]})})})]}),(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-base",children:"Location Breakdown"})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:_.visitor_locations.map(B=>e.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ma,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[B.city,", ",B.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:B.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:B.visitor_count})]},`${B.city}-${B.region}`))})})]})]})]})]}),r&&g&&e.jsx(Uw,{open:p,onOpenChange:f,contact:g,gmailEmail:n})]})}const J5s=Object.freeze(Object.defineProperty({__proto__:null,default:Tct},Symbol.toStringTag,{value:"Module"})),eMs=k.lazy(()=>Al(()=>import("./MobileAgentApp-CsUrBAKi.js"),[])),tMs=k.lazy(()=>Al(()=>import("./PostcardManager-6m0AWMVD.js"),__vite__mapDeps([0,1]))),sMs=k.lazy(()=>Al(()=>import("./HomeReelManager-BI8siG1z.js"),[])),rMs=k.lazy(()=>Al(()=>import("./AdminCredits-BHupZ-_u.js"),[])),nMs=k.lazy(()=>Al(()=>import("./DirectMail-YxgdM4xP.js").then(t=>t.D),__vite__mapDeps([2,1]))),aMs=k.lazy(()=>Al(()=>import("./InnerCirclePopbyMap-BA6f9HKS.js"),[])),iMs=k.lazy(()=>Al(()=>import("./LiveVisitorFeed-CDfpvIRs.js"),[])),oMs=k.lazy(()=>Al(()=>import("./LeadSites-DqwQw8Dm.js"),[])),i9e=k.lazy(()=>Al(()=>import("./LeadSiteEditor-CyZCffYh.js"),[])),lMs=k.lazy(()=>Al(()=>import("./AdminMlsFeeds-RTjJlrh3.js"),[])),cMs=k.lazy(()=>Al(()=>import("./AdminLeadSiteAnalytics-CWMRGbTS.js"),[])),dMs=k.lazy(()=>Al(()=>import("./MLSListings-Bam-Ji52.js"),[])),uMs=k.lazy(()=>Al(()=>import("./MLSListingDetail-Cv-GyVsr.js"),[])),hMs=k.lazy(()=>Al(()=>import("./MarketReportPage-Cnc8dhol.js"),[]));k.lazy(()=>Al(()=>Promise.resolve().then(()=>J5s),void 0));const mMs=k.lazy(()=>Al(()=>import("./EmailCampaigns-DCbCXD3P.js"),[])),pMs=k.lazy(()=>Al(()=>import("./EmailCampaignComposer-D7O3zh4Q.js"),__vite__mapDeps([3,4]))),fMs=k.lazy(()=>Al(()=>import("./EmailCampaignDetail-DYaSDo8T.js"),[])),xMs=k.lazy(()=>Al(()=>import("./SharedCampaignTemplates-DFvpYHux.js"),__vite__mapDeps([5,6,4]))),gMs=k.lazy(()=>Al(()=>import("./AgentTemplates-DAciBLrC.js"),__vite__mapDeps([7,6,4]))),o9e=k.lazy(()=>Al(()=>import("./TheLocalMoveHome-I5C9Vnf2.js"),[])),yMs=new svt({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:5*60*1e3}}}),vMs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},bMs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},_Ms=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},wMs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},jMs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},NMs=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},kMs=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},SMs=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},CMs=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},Act=()=>{const t=window.location.hostname;return t==="thelocalmove.com"||t==="www.thelocalmove.com"},MMs=()=>window.location.hostname.endsWith(".thelocalmove.com")&&!Act(),TMs=()=>e.jsx(ovt,{client:yMs,children:e.jsx(kUe,{children:e.jsxs(B1,{children:[e.jsx(wgt,{}),e.jsx(eyt,{}),e.jsx(y1t,{children:e.jsx(_wt,{children:e.jsx(wwt,{children:e.jsxs(Nwt,{children:[e.jsx(jwt,{}),e.jsx(sNt,{}),e.jsx(yNt,{}),NMs()?e.jsx(_3s,{}):bMs()?e.jsx(Rkt,{}):vMs()?e.jsx(akt,{}):_Ms()?e.jsx(Bkt,{}):wMs()?e.jsx(SEt,{}):jMs()?e.jsx(UEt,{}):kMs()?e.jsx(w3s,{}):SMs()?e.jsx(j3s,{}):CMs()?e.jsx(N3s,{}):Act()?e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(o9e,{})}):MMs()?e.jsx(S5s,{}):e.jsxs(R2e,{children:[e.jsx(ks,{path:"/",element:e.jsx(QEt,{})}),e.jsx(ks,{path:"/the-local-move",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(o9e,{})})}),e.jsx(ks,{path:"/privacy-policy",element:e.jsx(JEt,{})}),e.jsx(ks,{path:"/terms-of-service",element:e.jsx(e6t,{})}),e.jsx(ks,{path:"/data-deletion",element:e.jsx(t6t,{})}),e.jsx(ks,{path:"/public/listings",element:e.jsx(sGe,{})}),e.jsx(ks,{path:"/public/listing/:slugOrId",element:e.jsx($It,{})}),e.jsx(ks,{path:"/card/:slug",element:e.jsx(qIt,{})}),e.jsx(ks,{path:"/join-brokerage/:slug",element:e.jsx(jCs,{})}),e.jsx(ks,{path:"/recruit-video/:shareToken",element:e.jsx(kCs,{})}),e.jsx(ks,{path:"/connect/:slug",element:e.jsx($Ye,{})}),e.jsx(ks,{path:"/auth",element:e.jsx(r6t,{})}),e.jsx(ks,{path:"/subscription-success",element:e.jsx(n6t,{})}),e.jsx(ks,{path:"/subscription",element:e.jsx(nr,{children:e.jsx(YPt,{})})}),e.jsxs(ks,{path:"/share/video",element:e.jsx(RIt,{}),children:[e.jsx(ks,{path:":shareToken",element:e.jsx(gIe,{})}),e.jsx(ks,{path:":shareToken/r/:recipientToken",element:e.jsx(gIe,{})})]}),e.jsx(ks,{path:"/p/:shareToken",element:e.jsx(UCs,{})}),e.jsx(ks,{path:"/portal/:slug",element:e.jsx(YCs,{})}),e.jsx(ks,{path:"/og/video/:token",element:e.jsx(FIt,{})}),e.jsx(ks,{path:"/setup-brokerage",element:e.jsx(nr,{children:e.jsx(XPt,{})})}),e.jsx(ks,{path:"/claim-account",element:e.jsx(pIe,{})}),e.jsx(ks,{path:"/claim",element:e.jsx(pIe,{})}),e.jsx(ks,{path:"/join",element:e.jsx(QPt,{})}),e.jsx(ks,{path:"/trial",element:e.jsx(cIt,{})}),e.jsx(ks,{path:"/trial/success",element:e.jsx(dIt,{})}),e.jsx(ks,{path:"/dashboard",element:e.jsx(nr,{children:e.jsx(c8t,{})})}),e.jsx(ks,{path:"/profile",element:e.jsx(nr,{children:e.jsx(GBt,{})})}),e.jsx(ks,{path:"/apps",element:e.jsx(nr,{children:e.jsx(o$t,{})})}),e.jsx(ks,{path:"/admin",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(WUt,{})})}),e.jsx(ks,{path:"/admin/apps",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(ZUt,{})})}),e.jsx(ks,{path:"/admin/members",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(rVt,{})})}),e.jsx(ks,{path:"/admin/invite-codes",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(nVt,{})})}),e.jsx(ks,{path:"/admin/events",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(dVt,{})})}),e.jsx(ks,{path:"/events",element:e.jsx(nr,{children:e.jsx(r$t,{})})}),e.jsx(ks,{path:"/events/:eventId",element:e.jsx(nr,{children:e.jsx(a$t,{})})}),e.jsx(ks,{path:"/templates",element:e.jsx(nr,{children:e.jsx(l$t,{})})}),e.jsx(ks,{path:"/templates/:templateId",element:e.jsx(nr,{children:e.jsx(h$t,{})})}),e.jsx(ks,{path:"/admin/templates",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(hVt,{})})}),e.jsx(ks,{path:"/academy",element:e.jsx(nr,{children:e.jsx(m$t,{})})}),e.jsx(ks,{path:"/academy/:videoId",element:e.jsx(nr,{children:e.jsx(f$t,{})})}),e.jsx(ks,{path:"/admin/academy",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(pVt,{})})}),e.jsx(ks,{path:"/toolbox",element:e.jsx(nr,{children:e.jsx(x$t,{})})}),e.jsx(ks,{path:"/toolbox/:kitId",element:e.jsx(nr,{children:e.jsx(g$t,{})})}),e.jsx(ks,{path:"/admin/toolbox",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(fVt,{})})}),e.jsx(ks,{path:"/social-swag",element:e.jsx(nr,{children:e.jsx(y$t,{})})}),e.jsx(ks,{path:"/social-swag-2",element:e.jsx(nr,{children:e.jsx(xUt,{})})}),e.jsx(ks,{path:"/social-swag/:swagId",element:e.jsx(nr,{children:e.jsx(gUt,{})})}),e.jsx(ks,{path:"/social-connections",element:e.jsx(nr,{children:e.jsx(SCs,{})})}),e.jsx(ks,{path:"/social-connections/callback",element:e.jsx(nr,{children:e.jsx(CCs,{})})}),e.jsx(ks,{path:"/social-connections/linkedin-callback",element:e.jsx(nr,{children:e.jsx(TCs,{})})}),e.jsx(ks,{path:"/social-connections/google-callback",element:e.jsx(nr,{children:e.jsx(MCs,{})})}),e.jsx(ks,{path:"/admin/social-swag",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(xVt,{})})}),e.jsx(ks,{path:"/admin/social-swag-2",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(JHt,{})})}),e.jsx(ks,{path:"/community",element:e.jsx(nr,{children:e.jsx(OUt,{})})}),e.jsx(ks,{path:"/support",element:e.jsx(nr,{children:e.jsx(RUt,{})})}),e.jsx(ks,{path:"/admin/community",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(eWt,{})})}),e.jsx(ks,{path:"/admin/support-tickets",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(qvs,{})})}),e.jsx(ks,{path:"/admin/email-templates",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Vvs,{})})}),e.jsx(ks,{path:"/admin/agent-email-templates",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Hvs,{})})}),e.jsx(ks,{path:"/admin/analytics",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(zvs,{})})}),e.jsx(ks,{path:"/admin/brokerage-resources",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Bvs,{})})}),e.jsx(ks,{path:"/admin/dashboard-management",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx($vs,{})})}),e.jsx(ks,{path:"/brokerage/dashboard",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx(r1s,{})})}),e.jsx(ks,{path:"/brokerage/teams",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx(T5s,{})})}),e.jsx(ks,{path:"/brokerage/recruiting",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx(K4s,{})})}),e.jsx(ks,{path:"/my-team",element:e.jsx(nr,{children:e.jsx(A5s,{})})}),e.jsx(ks,{path:"/my-brokerage",element:e.jsx(nr,{children:e.jsx(c1s,{})})}),e.jsx(ks,{path:"/brokerage-content",element:e.jsx(nr,{children:e.jsx(f1s,{})})}),e.jsx(ks,{path:"/brokerage-content/:contentId",element:e.jsx(nr,{children:e.jsx(b1s,{})})}),e.jsx(ks,{path:"/brokerage-resources",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx(UUt,{})})}),e.jsx(ks,{path:"/brokerage-resources/:resourceId",element:e.jsx(nr,{requireBrokerageManager:!0,children:e.jsx(VUt,{})})}),e.jsx(ks,{path:"/newsletters",element:e.jsx(nr,{children:e.jsx(_1s,{})})}),e.jsx(ks,{path:"/newsletters/:id",element:e.jsx(nr,{children:e.jsx(j1s,{})})}),e.jsx(ks,{path:"/wishlist",element:e.jsx(nr,{children:e.jsx(S1s,{})})}),e.jsx(ks,{path:"/wishlist/:itemId",element:e.jsx(nr,{children:e.jsx(C1s,{})})}),e.jsx(ks,{path:"/admin/wishlist",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(M1s,{})})}),e.jsx(ks,{path:"/admin/levelup-brief",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(T1s,{})})}),e.jsx(ks,{path:"/admin/newsletters",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k1s,{})})}),e.jsx(ks,{path:"/admin/additional-services",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(A1s,{})})}),e.jsx(ks,{path:"/admin/discounts",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(E1s,{})})}),e.jsx(ks,{path:"/admin/subscriptions",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(P1s,{})})}),e.jsx(ks,{path:"/admin/referrals",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(I1s,{})})}),e.jsx(ks,{path:"/admin/prospector",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(E4s,{})})}),e.jsx(ks,{path:"/admin/recruiting",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(G4s,{})})}),e.jsx(ks,{path:"/admin/beta/social-post-generator",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(ZSs,{})})}),e.jsx(ks,{path:"/admin/credits",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(rMs,{})})})}),e.jsx(ks,{path:"/admin/beta/postcard-manager",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(tMs,{})})})}),e.jsx(ks,{path:"/admin/beta/homereel",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(sMs,{})})})}),e.jsx(ks,{path:"/admin/lms",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(cCs,{})})}),e.jsx(ks,{path:"/admin/lms/stats",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(pCs,{})})}),e.jsx(ks,{path:"/admin/lms/:courseId",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(dCs,{})})}),e.jsx(ks,{path:"/levelup-u",element:e.jsx(nr,{children:e.jsx(fCs,{})})}),e.jsx(ks,{path:"/levelup-u/:courseId",element:e.jsx(nr,{children:e.jsx(gCs,{})})}),e.jsx(ks,{path:"/admin/brokerage-content-activity",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Z4s,{})})}),e.jsx(ks,{path:"/admin/onboarding-checklist",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(D1s,{})})}),e.jsx(ks,{path:"/admin/marketplace",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(l4s,{})})}),e.jsx(ks,{path:"/admin/agent-points",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Pks,{})})}),e.jsx(ks,{path:"/admin/reward-store",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(j4s,{})})}),e.jsx(ks,{path:"/admin/integrations",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k4s,{})})}),e.jsx(ks,{path:"/admin/integrations/callback",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(A4s,{})})}),e.jsx(ks,{path:"/admin/email-campaigns",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(mMs,{})})})}),e.jsx(ks,{path:"/admin/email-campaigns/templates",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(xMs,{})})})}),e.jsx(ks,{path:"/email-campaigns/templates",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(gMs,{})})})}),e.jsx(ks,{path:"/admin/email-campaigns/new",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(pMs,{})})})}),e.jsx(ks,{path:"/admin/email-campaigns/:id",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(fMs,{})})})}),e.jsx(ks,{path:"/reward-store",element:e.jsx(nr,{children:e.jsx(RCs,{})})}),e.jsx(ks,{path:"/additional-services",element:e.jsx(nr,{children:e.jsx(W1s,{})})}),e.jsx(ks,{path:"/additional-services/:serviceId",element:e.jsx(nr,{children:e.jsx(G1s,{})})}),e.jsx(ks,{path:"/ai-toolkit",element:e.jsx(nr,{children:e.jsx(K1s,{})})}),e.jsx(ks,{path:"/mission-control",element:e.jsx(nr,{children:e.jsx(mbs,{})})}),e.jsx(ks,{path:"/mission-control/contacts",element:e.jsx(nr,{children:e.jsx(Xbs,{})})}),e.jsx(ks,{path:"/mission-control/contacts/:contactId",element:e.jsx(nr,{children:e.jsx(k_s,{})})}),e.jsx(ks,{path:"/mission-control/plans",element:e.jsx(nr,{children:e.jsx(S_s,{})})}),e.jsx(ks,{path:"/mission-control/popbys",element:e.jsx(nr,{children:e.jsx(T_s,{})})}),e.jsx(ks,{path:"/mission-control/popbys/map",element:e.jsx(nr,{children:e.jsx(aMs,{})})}),e.jsx(ks,{path:"/admin/notification-settings",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(C4s,{})})}),e.jsx(ks,{path:"/admin/agent-os",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(R1s,{})})}),e.jsx(ks,{path:"/mission-control/listings",element:e.jsx(nr,{children:e.jsx(J_s,{})})}),e.jsx(ks,{path:"/mission-control/listings/new",element:e.jsx(nr,{children:e.jsx(i7e,{})})}),e.jsx(ks,{path:"/mission-control/listings/:listingId",element:e.jsx(nr,{children:e.jsx(pws,{})})}),e.jsx(ks,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(nr,{children:e.jsx(i7e,{})})}),e.jsx(ks,{path:"/admin/listing-exchange",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Sks,{})})}),e.jsx(ks,{path:"/mission-control/pipeline",element:e.jsx(nr,{children:e.jsx(INs,{})})}),e.jsx(ks,{path:"/mission-control/tasks",element:e.jsx(nr,{children:e.jsx(UNs,{})})}),e.jsx(ks,{path:"/mission-control/my-card",element:e.jsx(nr,{children:e.jsx(cks,{})})}),e.jsx(ks,{path:"/mission-control/integrations",element:e.jsx(nr,{children:e.jsx(vks,{})})}),e.jsx(ks,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(nr,{children:e.jsx(bks,{})})}),e.jsx(ks,{path:"/mission-control/integrations/canva/callback",element:e.jsx(_ks,{})}),e.jsx(ks,{path:"/mission-control/integrations/meta/callback",element:e.jsx(nr,{children:e.jsx(wks,{})})}),e.jsx(ks,{path:"/mission-control/scorecard",element:e.jsx(nr,{children:e.jsx(U_s,{})})}),e.jsx(ks,{path:"/admin/scorecard",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Nks,{})})}),e.jsx(ks,{path:"/admin/scorecard/:userId",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(vze,{})})}),e.jsx(ks,{path:"/mission-control/scorecard/:userId",element:e.jsx(nr,{children:e.jsx(vze,{})})}),e.jsx(ks,{path:"/mission-control/relationship-scorecard",element:e.jsx(nr,{children:e.jsx(U5s,{})})}),e.jsx(ks,{path:"/mission-control/sphere-gaps",element:e.jsx(nr,{children:e.jsx(G5s,{})})}),e.jsx(ks,{path:"/mission-control/website-activity",element:e.jsx(nr,{children:e.jsx(Tct,{})})}),e.jsx(ks,{path:"/mission-control/connect-page",element:e.jsx(nr,{children:e.jsx(Z5s,{})})}),e.jsx(ks,{path:"/admin/membership-reviews",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Cks,{})})}),e.jsx(ks,{path:"/admin/weekly-digest",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Aks,{})})}),e.jsx(ks,{path:"/mission-control/video/record",element:e.jsx(nr,{children:e.jsx(gjs,{})})}),e.jsx(ks,{path:"/mission-control/video-library",element:e.jsx(nr,{children:e.jsx(Pjs,{})})}),e.jsx(ks,{path:"/marketplace",element:e.jsx(nr,{children:e.jsx(ACs,{})})}),e.jsx(ks,{path:"/marketplace/:productId",element:e.jsx(nr,{children:e.jsx(ECs,{})})}),e.jsx(ks,{path:"/marketplace/cart",element:e.jsx(nr,{children:e.jsx(PCs,{})})}),e.jsx(ks,{path:"/marketplace/orders",element:e.jsx(nr,{children:e.jsx(ICs,{})})}),e.jsx(ks,{path:"/marketplace/orders/:orderId",element:e.jsx(nr,{children:e.jsx(DCs,{})})}),e.jsx(ks,{path:"/marketplace/success",element:e.jsx(nr,{children:e.jsx(OCs,{})})}),e.jsx(ks,{path:"/admin/agent-cards",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(Iks,{})})}),e.jsx(ks,{path:"/admin/presentation-analytics",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(M4s,{})})}),e.jsx(ks,{path:"/admin/guest-book-analytics",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(T4s,{})})}),e.jsx(ks,{path:"/mission-control/smart-drips",element:e.jsx(nr,{children:e.jsx(v3s,{})})}),e.jsx(ks,{path:"/mission-control/direct-mail",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(nMs,{})})})}),e.jsx(ks,{path:"/mission-control/presentations",element:e.jsx(nr,{children:e.jsx(FCs,{})})}),e.jsx(ks,{path:"/mission-control/presentations/new",element:e.jsx(nr,{children:e.jsx(Uze,{})})}),e.jsx(ks,{path:"/mission-control/presentations/:id",element:e.jsx(nr,{children:e.jsx(Uze,{})})}),e.jsx(ks,{path:"/mission-control/guest-book",element:e.jsx(nr,{children:e.jsx(KCs,{})})}),e.jsx(ks,{path:"/mission-control/guest-book/live/:id",element:e.jsx(nr,{children:e.jsx(iMs,{})})}),e.jsx(ks,{path:"/guestbook/:slug",element:e.jsx(OGe,{})}),e.jsx(ks,{path:"/mission-control/card-studio",element:e.jsx(nr,{children:e.jsx(s3s,{})})}),e.jsx(ks,{path:"/mission-control/scheduler",element:e.jsx(nr,{children:e.jsx(R5s,{})})}),e.jsx(ks,{path:"/c/:shareToken",element:e.jsx(vct,{})}),e.jsx(ks,{path:"/book/:slug",element:e.jsx(_ct,{})}),e.jsx(ks,{path:"/page/:slug",element:e.jsx(wct,{})}),e.jsx(ks,{path:"/mission-control/landing-pages",element:e.jsx(nr,{children:e.jsx(F5s,{})})}),e.jsx(ks,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(nr,{children:e.jsx($5s,{})})}),e.jsx(ks,{path:"/my-website/:siteId/edit",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(i9e,{})})})}),e.jsx(ks,{path:"/my-website/mls-listings",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(dMs,{})})})}),e.jsx(ks,{path:"/my-website/mls-listings/:mlsId",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(uMs,{})})})}),e.jsx(ks,{path:"/my-website/market-report",element:e.jsx(nr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(hMs,{})})})}),e.jsx(ks,{path:"/admin/lead-sites",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(oMs,{})})})}),e.jsx(ks,{path:"/admin/lead-sites/:siteId/edit",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(i9e,{})})})}),e.jsx(ks,{path:"/admin/mls-feeds",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(lMs,{})})})}),e.jsx(ks,{path:"/admin/lead-site-analytics",element:e.jsx(nr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(cMs,{})})})}),e.jsx(ks,{path:"/m/*",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(eMs,{})})}),e.jsx(ks,{path:"*",element:e.jsx(bct,{})})]}),")"]})})})})]})})}),Jp=window.location.hostname,AMs=Jp.includes("lovable.app")||Jp.includes("lovableproject.com"),EMs=(()=>{try{return window.self!==window.top}catch{return!0}})(),PMs=Jp.startsWith("cards.")||Jp.startsWith("cardstudio.")||Jp.startsWith("listings.")||Jp.startsWith("presentations.")||Jp.startsWith("guestbook.")||Jp.startsWith("clients.")||Jp.startsWith("booking.")||Jp.startsWith("contacts.")||Jp.startsWith("pages.")||Jp.endsWith(".thelocalmove.com")&&!Jp.startsWith("dashboard.");var y9e;AMs||EMs||PMs?((y9e=navigator.serviceWorker)==null||y9e.getRegistrations().then(t=>{t.forEach(s=>s.unregister())}),"caches"in window&&caches.keys().then(t=>t.forEach(s=>caches.delete(s)))):"serviceWorker"in navigator&&Al(async()=>{const{registerSW:t}=await import("./virtual_pwa-register-_cmvyXDE.js");return{registerSW:t}},[]).then(({registerSW:t})=>{t({onNeedRefresh(){},onOfflineReady(){}})});P$e(document.getElementById("root")).render(e.jsx(TMs,{}));export{yo as $,$s as A,Ja as B,No as C,Gh as D,Ln as E,Ra as F,ma as G,bn as H,cY as I,hn as J,LAe as K,ni as L,so as M,rxe as N,c1t as O,Un as P,Hhe as Q,Rbs as R,Xo as S,Fm as T,pr as U,qat as V,Bbs as W,Rr as X,lSe as Y,va as Z,Al as _,fr as a,qc as a$,Gx as a0,Lt as a1,su as a2,Bn as a3,Uw as a4,ul as a5,W_ as a6,ws as a7,Im as a8,Ju as a9,Fn as aA,Ss as aB,St as aC,zn as aD,dt as aE,st as aF,qr as aG,fs as aH,ps as aI,_s as aJ,vs as aK,be as aL,ze as aM,Ks as aN,Hs as aO,Ys as aP,Ws as aQ,Mt as aR,qn as aS,UMs as aT,ms as aU,ko as aV,Er as aW,gl as aX,Jne as aY,G4 as aZ,ka as a_,lS as aa,wd as ab,CM as ac,LM as ad,eh as ae,a0 as af,Xg as ag,cl as ah,tn as ai,Lm as aj,oS as ak,R2e as al,ks as am,Ee as an,Pt as ao,Rt as ap,ac as aq,gr as ar,Oe as as,ba as at,pa as au,ns as av,Ml as aw,bs as ax,K as ay,Rn as az,Ds as b,B1 as b$,gi as b0,Nr as b1,Ms as b2,aS as b3,qi as b4,li as b5,pn as b6,B_ as b7,eJ as b8,Rm as b9,rR as bA,Yke as bB,JS as bC,Cu as bD,bc as bE,_c as bF,s1 as bG,Xl as bH,Gte as bI,$o as bJ,qo as bK,Ro as bL,Gi as bM,rL as bN,sa as bO,kl as bP,KQ as bQ,qQ as bR,YI as bS,oh as bT,tV as bU,Sn as bV,IM as bW,zL as bX,Mx as bY,Gr as bZ,Hj as b_,nl as ba,Cae as bb,Kg as bc,qv as bd,Bi as be,yi as bf,DM as bg,Go as bh,gu as bi,An as bj,v0 as bk,dS as bl,f0 as bm,VPt as bn,Nn as bo,$a as bp,kn as bq,qke as br,Ule as bs,Fse as bt,Gke as bu,Uke as bv,Zke as bw,JMs as bx,hV as by,Hke as bz,It as c,lR as c$,DL as c0,Ku as c1,wL as c2,Oo as c3,wn as c4,$mt as c5,Po as c6,ht as c7,wbs as c8,_bs as c9,Wh as cA,jct as cB,zv as cC,Dm as cD,ic as cE,Tl as cF,n1 as cG,Ah as cH,Jn as cI,sTs as cJ,Sp as cK,nL as cL,kx as cM,bd as cN,nSe as cO,kp as cP,u1 as cQ,rl as cR,Su as cS,Xne as cT,CR as cU,Qa as cV,Om as cW,wf as cX,iT as cY,wat as cZ,V0 as c_,Nbs as ca,Ao as cb,hX as cc,nJ as cd,xi as ce,VMs as cf,dGe as cg,HMs as ch,WMs as ci,GMs as cj,h1 as ck,jZe as cl,dl as cm,Gs as cn,G_ as co,eE as cp,vC as cq,tE as cr,sE as cs,wre as ct,Cx as cu,_L as cv,Aee as cw,$M as cx,IQ as cy,ku as cz,Cc as d,hp as d0,_at as d1,iC as d2,oC as d3,L1 as d4,wh as d5,ZI as d6,Q4 as d7,g0 as d8,Bv as d9,zm as dA,vj as dB,F_ as dC,nS as dD,XI as dE,QW as dF,Ree as dG,Zh as dH,Gv as dI,Kre as da,X4 as db,ake as dc,oke as dd,h9t as de,Nat as df,vke as dg,gke as dh,yke as di,Y4 as dj,sS as dk,EM as dl,PM as dm,Mh as dn,p0 as dp,W4 as dq,K4 as dr,Bo as ds,xS as dt,mS as du,rke as dv,Ua as dw,Sc as dx,th as dy,eS as dz,mt as e,cn as f,rE as g,lbs as h,da as i,e as j,cr as k,Qt as l,OPt as m,Uc as n,to as o,un as p,wue as q,k as r,H as s,Vx as t,id as u,nE as v,yp as w,ff as x,Eo as y,me as z};